Quando si impiega l'operatore Richiama Java, utilizzare le linee guida seguenti per l'implementazione del codice Java:
Per ulteriori informazioni su sintassi e i comandi BeanShell, visitare il sito seguente: http://www.beanshell.org/
L'interprete BeanShell implementa solo "final" (e ignora gli altri modificatori).
Attualmente solo "synchronized" viene implementato. L'interprete BeanShell ignora gli altri modificatori.
// Import the classes that you want to use
import ca.tech.pam.MyAccount;
// Note: no need to import StringBuffer and Date because they are part of the
// automatically imported packages
// import java.lang.StringBuffer;
// import java.util.Date;
// Note: the jar that contains the ca.tech.pam.MyAccount class
// must be in the list of External Jars of the operator or the module;
// but java lang and java util are in rt.jar, which is automatically put in the classpath
MyAccount acct = new MyAccount(newDate(),100);
// Use the public methods of the MyAccount object
acct.addFunds(34);
acct.subFunds(10);
// Define your own method
String getStatement(MyAccount acc) {
StringBuffer strBuff = new StringBuffer("Account Balance: " + acc.getBalance());
Date dt = new Date(System.currentTimeMillis());
strBuff.append(" on date: " + dt);
return strBuff.toString();
}
// Use the method you defined
// also print the statement using the 'logger' object that you
// setup in the 'Logger' page of the operator
logger.info(getStatement(acct));
Nota: per eseguire questa istruzione, impostare il logger su True e fornire il nome del file di log. In caso contrario, durante l'esecuzione si verifica un errore.
Al termine dell'esecuzione, il messaggio del log contiene:
Account Balance: 124. on date: Wed Jul 13 12:53:37 EDT 2011
(Il messaggio include la data e l'orario di esecuzione corretti.)
|
Copyright © 2013 CA.
Tutti i diritti riservati.
|
|