Java DCE Developer Guide
|
|
Java Interfaces1.The interface used for 'Java class for DCE node' is infinity.common.action.GAction.java, and its content is as follows: package infinity.common.action; import infinity.common.server.*; import infinity.common.*; import infinity.client.*; import infinity.server.*; /** * This interface is used to be an action interface. * An action class is used with the scheduler, which execute the perform() of each * action according to the predefined schedule. * To implement this interface, please notice that the constructor must * be a constructor without any parameter, or it will encounter instantiationException * in the instantiation stage. * To compile the action class, the classpath should include the 'infinity.jar' file. * By default, there is no main() method in this class, however, it can be added to * its subclass if you want to run it alone as an application. */ public interface GAction { /** To get the action name. The action name is a brief description about this action. @return The default return value can be "undefined". */ public String getActionName(); /** for status or statistics or anything could be csv or anything */ public String getInfo(); /** To get the version of the action class. @return The default return value can be "undefined". */ public String getVersion(); /** To get the version date of the action class. @return The default return value can be "undefined". */ public String getVersionDate(); /** * This method usually called by the system's scheduler. * If the subclass is intended to be a thread, can use these codes: * t=new Thread(this); * t.start(); * when override this method. * If this method wants to share Weber, Net,and Connection with the command() * method, can use these codes: * this.dceClient=dceClient; this.dceServer=dceServer; this.c=c; * when override this method. * @param mode0 A original type of this command, produced by system. * If a user calls this method directly, can set this to 0. * @param modeNow A current type of this command, produced by system. * If a user calls this method directly, can set this to 0. * @param commandid An id of this command, produced by system. * If a user calls this method directly, can set this to null. * @param filler A string used by system. * If a user calls this method directly, can set this to null. * @param w The client object, produced by system. * If a user calls this method directly, can set this to null. * @param gs The server object, produced by system. * If a user calls this method directly, can set this to null. * @param parameters An array that represents the parameters for this perform. * @param c The connection to the server, produced by system. * If a user calls this method directly, can set this to null. * @param scheduleItemId The id of the schedule item. This used when need to record the perform result or to control the schedule item, * for example, a schedule item has a perform count limit or time limit. */ public boolean perform(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String parameters[],infinity.common.server.Connection c); /** * This method usually called by using the client command. * If this method wants to share dceClient, dceServer,and Connection with the perform() * method, can use these codes: * this.dceClient=dceClient; this.dceServer=dceServer; this.c=c; * when override this method. * @param mode0 A original type of this command, produced by system. * If a user calls this method directly, can set this to 0. * @param modeNow A current type of this command, produced by system. * If a user calls this method directly, can set this to 0. * @param mode A type of this command, produced by system. * If a user calls this method directly, can set this to null. * @param commandid An id of this command, produced by system. * If a user calls this method directly, can set this to null. * @param filler A string used by system. * If a user calls this method directly, can set this to null. * @param w The client object, produced by system. * If a user calls this method directly, can set this to null. * @param gs The server object, produced by system. * If a user calls this method directly, can set this to null. * @param cmd The command string represents the parameters of the command, * each parameter separated by space, for example, "john 232 good day". * when override this method, use * StringTokenizer st=new StringTokenizer(cmd," "); to parse the command. * @param c The connection to the server, produced by system. * If a user calls this method directly, can set this to null. */ public boolean command(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String cmd,infinity.common.server.Connection c);// /** * This method usually called for object processing. * If the subclass is intended to be a thread, can use these codes: * t=new Thread(this); * t.start(); * when override this method. * If this method wants to share Weber, Net,and Connection with the command() * method, can use these codes: * this.dceClient=dceClient; this.dceServer=dceServer; this.c=c; * when override this method. * @param mode0 A original type of this command, produced by system. * If a user calls this method directly, can set this to 0. * @param modeNow A current type of this command, produced by system. * If a user calls this method directly, can set this to 0. * @param commandid An id of this command, produced by system. * If a user calls this method directly, can set this to null. * @param filler A string used by system. * If a user calls this method directly, can set this to null. * @param w The client object, produced by system. * If a user calls this method directly, can set this to null. * @param gs The server object, produced by system. * If a user calls this method directly, can set this to null. * @param parameters An array that represents the parameters for this perform. * @param obj An Object as a parameter for this perform. * @param c The connection to the server, produced by system. If a user calls this method directly, can set this to null. */ public boolean commandObj(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread sot); public boolean commandObj2(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread2 sot); public boolean commandObj3(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread3 sot); /** * The parameter definition of this is the same as command(). * The difference between command() and msg() is that msg() can be called without authorized code. */ public boolean msg(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String cmd,infinity.common.server.Connection c);// /** * The parameter definition of this method is the same as commandObj(). * The difference between commandObj() and msgObj() is that msgObj() can be called without authorized code. */ public boolean msgObj(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread sot); public boolean msgObj2(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread2 sot); public boolean msgObj3(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread3 sot); /** * This method will be called where the grid status changed. * For example, this method will be called when one node in or one node out.. */ public void gridChanged(Weber dceClient, Net dceServer,int from); /** * To stop the running thread 't'. * Subclass don't have to override this method, this method can be called directly. */ public void killThread(); /** * To check if the thread t is sleeping or not. * @return If this thread (if the subclass also implement Runable interface) is sleeping, return true. */ public boolean isSleep(); /** * To check if the thread is null or not. * @return If this thread (if the subclass also implement Runable interface) is null, return true. */ public boolean isNull(); /** * To check if the thread 't' is alive or not. * A thread is alive if it has been started and has not yet died. * @return If the thread 't' is alive, return true. */ public boolean isAlive(); /** * To get the status of this action class. * @return The status of this action class, including the action name, version, * version date, Thread 't' status, and so on. */ public String getStatus();/ /** * To get the usage help of this class. * @return The help of this action. Default is an empty string. */ public String getHelp(); /** To get the output format of the action. @return 1, if the output is in html format. 0, if not in html format. The defautl return value is "0". */ public String getHtmlOutput(); /** To get the html title, this can be put as the headline of the html-result, @return The default return value can be null or "undefined". */ public String getHtmlTitle(); /** To get the Style for the html result. The value format is "<style>.....</style>". @return The default return value can be "". */ public String getStyle(); /** To get the javascript for the html result. The value is the text between "<script><!--" and "--></script>". @return The default return value can be "". */ public String getJScript(); /** To get the html result. @return The default return value can be "". */ public String getHtmlResult(); /** To get the menu title for hyperlink. @return The default return value can be "undefined". */ public String getMenuTitle(); /** #.dceClient.ap.onExit() should not been put within this method, or will cause infinite loop error. Because dceClient.ap.onExit() will call this method, So one should call dceClient.ap.onExit() only outside this method. #.window closing() should not call this method, window closing() show call dceClient.ap.onExit(). #.System.exit() should not put within this method, because dceClient.ap.onExit() will execute System.exit(). */ public void onExit(int type); /** * @param apId, is id of this class. * @param status, 2=already is updated version. 3=new version found. * @param version, updated version value. */ public void informVersion(String apId,int status,String version); } Code example: package ci_demo; import infinity.common.Obj; public class DCEHello implements GAction { public String getActionName(){return "demo01";} public String getInfo(){return "":} public String getVersion() {return "1.0";} public String getVersionDate(){return '20260903";} public boolean perform(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String parameters[],infinity.common.server.Connection c){ System.out.println("Hello world!"); dceClient.sendToOne("performcommand DCEHello Hello world!", dceClient.getGNS(38)); dceClient.sendToAll("performcommand DCEHello Hello world!"); Obj obj=new Obj("performactionobject DCEHello","Hello world!"); dceClient.sendObjToOne(obj, dceClient.getGNS(38)); dceClient.sendObjToAll(obj); return true; } public boolean command(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String cmd,infinity.common.server.Connection c){ return true; } public boolean commandObj(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread sot){ return true; } public boolean commandObj2(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread2 sot){ return true; } public boolean commandObj3(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread3 sot){ return true; } public boolean msg(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String cmd,infinity.common.server.Connection c){ return true; } public boolean msgObj(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread sot){ return true; } public boolean msgObj2(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread2 sot){ retrun true; } public boolean msgObj3(int mode0,int modeNow,String originalId,Weber dceClient,Net dceServer,String parameters[],Obj obj,infinity.common.server.ServerObjectThread3 sot){ return true; } public void gridChanged(Weber dceClient, Net dceServer,int from){} public void killThread(){} public boolean isSleep(){ return false; } public boolean isNull(){return false; } public boolean isAlive(){return true; } public String getStatus(){return ""; } public String getHelp(){return "";} public String getHtmlOutput(return "0"; ) public String getHtmlTitle(){teturn "demo01";} public String getStyle(){return ""; } public String getJScript(){return ""; } public String getHtmlResult(){return ""; }; public String getMenuTitle(){return "";} public void onExit(int type){} public void informVersion(String apId,int status,String version){} } Usage example: ![]() This will call the perform(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String parameters[],infinity.common.server.Connection c) method in GAction.java. |
|
.DCE Client Object1.Java class infinity.client.Weber as DCE client object 2.Usage example (method perform() within GAction class): public boolean perform(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String parameters[],infinity.common.server.Connection c){ dceClient.sendToOne("performcommand DCEHello Hello world!", dceClient.getGNS(38)); dceClient.sendToAll("performcommand DCEHello Hello world!"); Obj obj=new Obj("performactionobject DCEHello","Hello world!"); dceClient.sendObjToOne(obj, dceClient.getGNS(38)); dceClient.sendObjToAll(obj); String myID=dceClient.getGNS(1); String gns[]=dceClient.getGNS(); return true; } 3.Parameters used in DCE client object: String gns[] definitions: gns[0]=system starttime (value in long)) gns[1]=my id gns[2]=dce server version gns[3]=dce client version gns[4]=undefined gns[5]=undefined gns[6]=my ip gns[7]=my port gns[8]=undefined gns[9]=undefined gns[10]=computer name gns[11]=group name gns[12]=the server objport that I connect to gns[13] ~ gns[26] = undefined gns[27]=nick name in group as a member gns[28]=connection limit gns[29]=undefined gns[30]=the server ip that I connect to gns[31]=the server port that I connect to gns[32] ~ gns[37] = undefined gns[38]=the server id that I connect to gns[39]=my objectport2 gns[40]=the server objectport2 that I connect to gns[41]=my objectport3 gns[42]=the server objectport3 that I connect to gns[43]=undefined gns[44]=top server id gns[45]=top server ip gns[46]=top server port |
|
.DCE Server Object1.Java class infinity.server.Net as DCE server object 2.Usage example (method perform() within GAction class): public boolean perform(int mode0,int modeNow,String originalId,String scheduleItemId,Weber dceClient,Net dceServer,String parameters[],infinity.common.server.Connection c){ String cmdcode="code234"; String pid=dceClient.getPid(cmdcode); infinity.common.server.Connection connections[]=dceServer.getConnections(pid); for(int i=0;i<connections.length;i++){ String cgns[]=connections[i].getCGNS(); String connectionID=cgns[0]; String computername=cgns[1]; System.out.println("Connection "+i+": id="+connectionID+", computername="+computername); } return true; } 3.Parameters used in each connection of DCE server object: String cgns[] definitions: cgns[0]=id cgns[1]=computername cgns[2] ~ [6] = undefined cgns[7]=ip cgns[8]=port cgns[9]=undefined cgns[10]=undefined cgns[11]=nick name cgns[12] ~ [15] = undefined cgns[16]=group name |
|
| Any other questions, please contact us. |