java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
is.codion.common.rmi.server.AbstractServer<AbstractRemoteEntityConnection,EntityServerAdmin>
is.codion.framework.server.EntityServer
- All Implemented Interfaces:
Server<AbstractRemoteEntityConnection,
,EntityServerAdmin> Serializable
,Remote
A remote server class, responsible for handling requests for AbstractRemoteEntityConnections.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class is.codion.common.rmi.server.AbstractServer
AbstractServer.ClientConnection<T>
Nested classes/interfaces inherited from interface is.codion.common.rmi.server.Server
Server.Locator
-
Field Summary
Fields inherited from class java.rmi.server.RemoteObject
ref
Fields inherited from interface is.codion.common.rmi.server.Server
CLIENT_HOST
-
Constructor Summary
ConstructorDescriptionEntityServer
(EntityServerConfiguration configuration) Constructs a new EntityServer and binds it to a registry on the port found in the configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected final AbstractRemoteEntityConnection
connect
(RemoteClient remoteClient) Establishes the actual client connection.protected AbstractRemoteEntityConnection
createRemoteConnection
(Database database, RemoteClient remoteClient, int port, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory) Creates the remote connection provided by this serverprotected final void
disconnect
(AbstractRemoteEntityConnection connection) Disconnects the given connection.static void
If no arguments are supplied a new EntityServer is started.protected final void
maintainConnections
(Collection<AbstractServer.ClientConnection<AbstractRemoteEntityConnection>> connections) Maintains the given connections, that is, disconnects inactive or invalid connections, if required.final EntityServerAdmin
serverAdmin
(User user) Returns the admin interface used to administer this serverfinal int
static EntityServer
Starts the server, using the configuration from system properties.static EntityServer
startServer
(EntityServerConfiguration configuration) Starts the server.Methods inherited from class is.codion.common.rmi.server.AbstractServer
addAuthenticator, addShutdownListener, auxiliaryServers, clients, connect, connection, connectionCount, connections, connectionsAvailable, disconnect, getAdmin, getConnectionLimit, getMaintenanceInterval, logShutdownAndReturn, registry, serverInformation, setAdmin, setConnectionLimit, setMaintenanceInterval, shutdown, validateUserCredentials
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
-
EntityServer
Constructs a new EntityServer and binds it to a registry on the port found in the configuration.- Parameters:
configuration
- the server configuration- Throws:
RemoteException
- in case of a remote exceptionRuntimeException
- in case the domain model classes are not found on the classpath or if the jdbc driver class is not found or in case of an exception while constructing the initial pooled connections
-
-
Method Details
-
serverAdmin
Description copied from interface:Server
Returns the admin interface used to administer this server- Parameters:
user
- the server admin user- Returns:
- the administration interface for this server
- Throws:
ServerAuthenticationException
- in case authentication failsIllegalStateException
- in case no server admin instance is available
-
serverLoad
public final int serverLoad()- Returns:
- the server load as number of service requests per second
-
connect
protected final AbstractRemoteEntityConnection connect(RemoteClient remoteClient) throws RemoteException, LoginException Description copied from class:AbstractServer
Establishes the actual client connection.- Specified by:
connect
in classAbstractServer<AbstractRemoteEntityConnection,
EntityServerAdmin> - Parameters:
remoteClient
- the remote client- Returns:
- a connection for the given client
- Throws:
RemoteException
- in case of an exceptionLoginException
- in case of an error during the login
-
disconnect
Description copied from class:AbstractServer
Disconnects the given connection.- Specified by:
disconnect
in classAbstractServer<AbstractRemoteEntityConnection,
EntityServerAdmin> - Parameters:
connection
- the connection to disconnect- Throws:
RemoteException
- in case of an exception
-
createRemoteConnection
protected AbstractRemoteEntityConnection createRemoteConnection(Database database, RemoteClient remoteClient, int port, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory) throws RemoteException Creates the remote connection provided by this server- Parameters:
database
- the underlying databaseremoteClient
- the client requesting the connectionport
- the port to use when exporting this remote connectionclientSocketFactory
- the client socket factory, null for defaultserverSocketFactory
- the server socket factory, null for default- Returns:
- a remote connection
- Throws:
RemoteException
- in case of an exceptionDatabaseException
- in case a database connection can not be established, for example if a wrong username or password is provided
-
maintainConnections
protected final void maintainConnections(Collection<AbstractServer.ClientConnection<AbstractRemoteEntityConnection>> connections) throws RemoteException Description copied from class:AbstractServer
Maintains the given connections, that is, disconnects inactive or invalid connections, if required.- Specified by:
maintainConnections
in classAbstractServer<AbstractRemoteEntityConnection,
EntityServerAdmin> - Parameters:
connections
- all current connections- Throws:
RemoteException
- in case of an exception
-
startServer
Starts the server, using the configuration from system properties.- Returns:
- the server instance
- Throws:
RemoteException
- in case of an exception
-
startServer
public static EntityServer startServer(EntityServerConfiguration configuration) throws RemoteException Starts the server.- Parameters:
configuration
- the configuration- Returns:
- the server instance
- Throws:
RemoteException
- in case of an exception
-
main
If no arguments are supplied a new EntityServer is started.- Parameters:
arguments
- 'shutdown' (case-insensitive) causes a running server to be shut down, otherwise a server is started- Throws:
RemoteException
- in case of a remote exception during service exportServerAuthenticationException
- in case of missing or incorrect admin user information
-