|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--net.agmodel.utilBean.ServerBean
An invisible abstract bean for managing RMI (direct) and HTTP (indirect) connections to a server or broker.
The bean connects using RMI, and if RMI is blocked then to a wrapper servlet using HTTP.
Note that the bean will only attempt a direct connection if setRMIHost() has been called,
and will only attempt an indirect connecion if setHTTPHost() has been called.
The connection (and disconnection) process runs in a separate thread which is initiated when setLive(true) is called.
Listening applications are notified when the connection has been established.
To use the bean, applications or applets must implement ServerBeanListener, and register themselves as listeners using #addServerBeanListener(ServerBeanListener)
The basic sequence of using this kind of bean is:
1. Create the bean
2. Set the RMIHost and HTTPHost details (ParameterManager is useful for this)
3. Register your application/applet as a ServerBeanListener
4. Start the connection process with setLive(true)
Your application will be notified when the connection has been established, and can then use the bean.
5. When the application has finished using the bean (typically at shutdown), please
call setLive(false) which will cause the bean to disconnect.
This helps the server to promptly free-up resources associated with the connection.
| Nested Class Summary | |
class |
ServerBean.ConnectThreadEJBHTTP
|
class |
ServerBean.ConnectThreadHTTP
|
class |
ServerBean.ConnectThreadRMIHTTP
|
| Field Summary | |
protected ServiceHTTP |
serverHTTP
|
protected Remote |
serverRMI
|
protected String |
sessionID
|
| Constructor Summary | |
ServerBean()
Creates a "dead" ServerBean object ready to be parameterized with details of the host server. |
|
| Method Summary | |
void |
addServiceBeanListener(ServiceBeanListener l)
Register a listener to be notified when a connection to the server has been established. |
protected abstract Remote |
createEJB(Object obj)
|
protected abstract void |
disconnect()
If the services is a Server, then connects and returns a sessionID. |
void |
finalize()
Forces the bean to disconnect immediately. |
protected void |
fireServiceBeanEvent(ServiceBeanEvent evt)
|
String |
getClientInfo()
|
String |
getHTTPHost()
|
String |
getHTTPHostParamName()
The preferred name of an applet parameter to hold the host address of the HTTP wrapper servlet associated with this bean. |
protected abstract ServerHTTP |
getHTTPObject()
|
int |
getHTTPPort()
|
String |
getHTTPPortParamName()
The preferred name for an applet parameter to hold the port number of the HTTP wrapper servlet associated with this bean. |
String |
getLanguage()
|
protected abstract void |
getRMIConnection()
If the services is an RMIServer, then connects and returns a sessionID. |
String |
getRMIHost()
|
String |
getRMIHostParamName()
The preferred name of an applet parameter to hold the host address of the RMI server associated with this bean. |
abstract String |
getRMIName()
Return the name the server registers itself by in RMIRegistry. |
protected abstract Thread |
getServiceFinderThread()
Returns a thread object which can find a reference to the service, and in the case of Servers establish a connection to the broker, through whichever mechanisms are available. |
protected abstract boolean |
isEJB()
|
boolean |
isLive()
|
protected abstract boolean |
isStateful()
|
void |
removeServiceBeanListener(ServiceBeanListener l)
|
void |
setClientInfo(String clientInfo)
Sets the information passed by the bean to the server when a connection is established. |
void |
setHTTPHost(String host)
Sets the IP address or host name of the machine that the bean will try to find a wrapper servlet running on. |
void |
setHTTPPort(int port)
Sets port number that the bean will try to find a wrapper servlet running on. |
void |
setLanguage(String language)
Sets the national language that this user would like to use when receiving information like database names. |
void |
setLive(boolean makeLive)
Initiates either connection to (true) or disconnection from (false) the server. |
void |
setRMIHost(String host)
Sets the IP address or host name of the machine that the bean will try to find the RMI server running on. |
protected void |
setUpBean()
|
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected transient volatile Remote serverRMI
protected transient volatile ServiceHTTP serverHTTP
protected transient volatile String sessionID
| Constructor Detail |
public ServerBean()
| Method Detail |
protected abstract ServerHTTP getHTTPObject()
throws GeneralException
GeneralExceptionpublic String getRMIHostParamName()
public String getHTTPHostParamName()
public String getHTTPPortParamName()
protected void setUpBean()
protected void fireServiceBeanEvent(ServiceBeanEvent evt)
public void addServiceBeanListener(ServiceBeanListener l)
l - the listener to be notifiedpublic void removeServiceBeanListener(ServiceBeanListener l)
public String getRMIHost()
public String getHTTPHost()
public void setRMIHost(String host)
host - eg ume.narc.affrc.go.jpsetHTTPHost(String)public abstract String getRMIName()
public void setHTTPHost(String host)
host - a computer which is running the corresponding wrapper servlet in a container like Tomcat eg www.agmodel.netsetRMIHost(String)public void setHTTPPort(int port)
port - a port on the computer which is running the wrapper servlet eg 8080 for accessing Tomcat directly, or 80 if accessing via a web server.setHTTPHost(String)public int getHTTPPort()
public void setClientInfo(String clientInfo)
clientInfo - something to identify this client application, and perhaps user.public String getClientInfo()
public void setLanguage(String language)
language - an ISO 2 letter language identifier like "en", "ja", "zn", "ko".public String getLanguage()
public boolean isLive()
protected abstract Thread getServiceFinderThread()
protected abstract void getRMIConnection()
throws GeneralException,
RemoteException
GeneralException
RemoteException
protected abstract void disconnect()
throws Exception
Exceptionprotected abstract boolean isStateful()
protected abstract boolean isEJB()
protected abstract Remote createEJB(Object obj)
throws Exception
Exceptionpublic void setLive(boolean makeLive)
makeLive - true-allow the connection thread to start, false-allow the disconnection thread to startpublic void finalize()
finalize in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||