java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
org.tentackle.dbms.rmi.RemoteServerObject
org.tentackle.dbms.rmi.RemoteDbConnectionImpl
- All Implemented Interfaces:
Serializable
,Remote
,RemoteDbConnection
public abstract class RemoteDbConnectionImpl
extends RemoteServerObject
implements RemoteDbConnection
Server side RMI-connection implementation.
Overview of what happens in a Tentackle RMI application rmiServer:
- client gets a reference to a RemoteDbConnection
- client invokes login() on the connection and gets a reference to a RemoteDbSession.
- each session runs in its own thread (rmiServer and client) and the rmiServer session gets its own Db.
- all further client requests work through the session object and the remote delegates created within the session
- the client invokes logout() to close the session and Db.
- in case the client terminates abnormally (without invoking logout()) a timeout runs logout() via its cleanable.
- Author:
- harald
- See Also:
-
Field Summary
Fields inherited from class java.rmi.server.RemoteObject
ref
-
Constructor Summary
ConstructorDescriptionRemoteDbConnectionImpl
(RmiServer rmiServer, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) Creates a connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkClientVersion
(String clientVersion) Checks the client's version.abstract RemoteDbSession
createSession
(SessionInfo clientInfo) Creates the session.
Needs to be implemented by the application.int
exportRemoteObject
(Remote remoteObject, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) Exports the given remote object.Gets the RMI-server.Gets the application-specific version of the server.login
(SessionInfo clientInfo) Login to remote RMI-server.void
unexportRemoteObject
(Remote remoteObject) Un-exports the given remote object.Methods inherited from class org.tentackle.dbms.rmi.RemoteServerObject
getRMICsf, getRMIPort, getRMISsf
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
-
Constructor Details
-
RemoteDbConnectionImpl
public RemoteDbConnectionImpl(RmiServer rmiServer, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException Creates a connection.- Parameters:
rmiServer
- the RMI-serverport
- the tcp-port, 0 = system defaultcsf
- the client socket factory, null = system defaultssf
- the rmiServer socket factory, null = system default- Throws:
RemoteException
- if failed to export object- See Also:
-
-
Method Details
-
getRmiServer
Gets the RMI-server.- Returns:
- the RMI server
-
checkClientVersion
Checks the client's version.The default implementation does nothing. It is invoked only for remote connections.
Throws
VersionIncompatibleException
if versions are not compatible.- Parameters:
clientVersion
- the client version
-
createSession
Creates the session.
Needs to be implemented by the application.- Parameters:
clientInfo
- the client info (login info)- Returns:
- the created session
- Throws:
RemoteException
- if creation failed
-
exportRemoteObject
public int exportRemoteObject(Remote remoteObject, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException Exports the given remote object.Notice that the delegate must not extend
UnicastRemoteObject
!- Parameters:
remoteObject
- the object to exportport
- the port to export the object on, 0 if autocsf
- the client-side socket factory for making calls to the remote object, null if system defaultssf
- the rmiServer-side socket factory for receiving remote calls, null if system default- Returns:
- the effective port, 0 if system default
- Throws:
RemoteException
- if export failed
-
unexportRemoteObject
Un-exports the given remote object.- Parameters:
remoteObject
- the object to un-export- Throws:
RemoteException
- if the remote object is not currently exported
-
getServerVersion
Description copied from interface:RemoteDbConnection
Gets the application-specific version of the server.- Specified by:
getServerVersion
in interfaceRemoteDbConnection
- Returns:
- the server version
- Throws:
RemoteException
- if failed
-
login
Description copied from interface:RemoteDbConnection
Login to remote RMI-server.- Specified by:
login
in interfaceRemoteDbConnection
- Parameters:
clientInfo
- the session information- Returns:
- the session
- Throws:
RemoteException
- if some error, for example wrong password- See Also:
-