import de.netseeker.ejoe.EJClient;
import de.netseeker.ejoe.handler.
RemotingRequest;
...
{
EJClient ejClient = new EJClient( "192.168.1.21", 80 );
List result = null;
try
{
RemotingRequest request = new RemotingRequest( "com.who.AddressManagement",
"listAddressesByName", new Object[]{ "Mustermann" } );
result = (List)ejClient.execute(request );
}
catch(RemoteException re)
{
//EJServer did return an Error
}
catch(IOException e)
{
//connection or serialization issues maybe?
}
...
}
|
####################################################################### # This is the default configuration for remote reflection in EJOE. # EJOE handles received reflection requests by clients VERY restrictive: # Only packages/classes which are listed in this file # can be used for remote reflection. # To overwrite the reflection settings, provide a customized # ejoe-reflection-conf.properties on the classpath. ########################################################################## de.netseeker.ejoe.test.*
|
package.path.*
也可以通过指定明确的类路径来明确限制要执行的类:
package.path.MyClass
package de.netseeker.ejoe.handler; /** * Simple interface defining the entry point for all server handlers. * Server handlers are the working horses which the caller must implement. * Server handlers take the transported input objects send by the client * application and return none, one or more return values. * * @author netseeker aka Michael Manske * @since 0.3.0 */ public interface ServerHandler { /** * Handles a client request * * @param obj The input object transported by EJOE * @return null or a valid return value. If you want return custom datatypes, * eg. Your own beans and do not want (or not be able) to deploy the classes of * these datatypes on the client, you can turn on EJOEs remote classloading feature. */ public Object handle( Object obj ) throws Exception; }
|
import de.netseeker.ejoe.EJServer; ... { EJServer server = new EJServer( ... ); //expected server load? //available hardware resources? //how many read/process-threads are required? server.setMaxReadProcessors( number of read/process-threads ); //how many write-threads are required? server.setMaxWriteProcessors( number of write-threads ); //start the server server.start(); ... }
|
EJClient()—利用默认的“ejoe.properties”配置文件。
EJClient(Properties properties)
EJClient(String pathToConfigFile)
EJClient(String host, int port)
EJClient(String host, int port, SerializeAdapter adapter)
EJClient(String host, int port, SerializeAdapter adapter, boolean isPersistent, boolean isHttp, boolean useCompression)------
其监听端口是“host:port”,使用指定的系列化适配器,
如果isPersistent=true,那么EJClient将使用持久连接到相应的EJServer.
如果isHttp=true,那么EJClient将使用HTTP请求协议来封装requests
如果useCompression=true,EJClient将使用GZIP格式来压缩请求的数据
import de.netseeker.ejoe.EJClient; ... { Integer myIntegerRequest = new Integer(1); String myStringRequest = "Hallo EJServer"; Map myMapRequest = new HashMap(); SomeBean myBeanRequest = new SomeBean(); ... EClient client = new EJClient(...); try { client.execute( myIntegerRequest); client.execute( myStringRequest ); client.execute( myMapRequest ); client.execute( myBeanRequest ); ... } catch(RemoteException re) { //EJServer did return an Error } catch(IOException e) { //connection or serialization issues maybe? } ... }
|