The client: EJClient

EJClient is a TCP/IP based network client, which which is exclusively capable to communicate with a EJServer.

EJClient offers support for:

  • synchronous as well as asynchronous Requests
  • encapsulation of requests within the HTTP/1.0 protocol
  • selective compression (if enabled in EJServer too)
  • dynamic remote-classloading
  • persistent as well as non-persistent connections (persistent connections only if enabled in EJServer too)
  • adjustable connection timeout setting
  • multiple strategies for the process of (de-)serialization
In addition EJClient is serializable itself and can be put into containers of the type HTTPSession.

Creating an instance of EJClient

A client is an instance of de.netseeker.ejoe.EJClient . The instance must be created by using one of the offered constructors:
  • EJClient()
    Creates a new instance of EJClient, pre-configured with the settings out of the file "ejoe.properties", which has to be able on the classpath.
  • EJClient(Properties properties)
    Creates a new instance of EJClient, pre-configured with the passed settings. This constructor can be used, if the settings for EJClient were already read from another configuration file...
  • EJClient(String pathToConfigFile)
    Creates a new instance of EJClient, pre-configured with the settings out of the given file.
  • EJClient(String host, int port)
    Creates a new instance of EJClient, which is able to communicate with the EJServer listening to "host:port".
  • EJClient(String host, int port, SerializeAdapter adapter)
    Creates a new instance of EJClient, which is able to communicate with the EJServer listening to "host:port". EJClient will use the passed SerializeAdapter.
  • EJClient(String host, int port, SerializeAdapter adapter, boolean isPersistent, boolean isHttp, boolean useCompression)
    Creates a new instance of EJClient, which is able to communicate with the EJServer listening to "host:port". EJClient will use the passed SerializeAdapter. If "isPersistent" was set to true, EJClient will use a persitent connection to the corresponding EJServer. If "isHttp" was set to true, EJClient will encapsulate requests within HTTP-Post-Requests. If "useCompression" was set to true, EJClient will use GZIP-compression to compact request data.

Executing requests

EJOE just uses objects for requests and responses. EJOE does not force to use a special protocol or container for requests. Just send any object your serverside business logic is able to process. Requests are processed by the method
execute(Object request)
. The request object can be any object of a non-primitive type and has to fulfill possibly requirements of the chossen SerializeAdapter. Errors during communication between client and server will be thrown as java.io.IOException, error during the serverside processing of a request will be thrown as java.rmi.RemoteException.
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? 
	} 
	...
}