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
refFields inherited from interface is.codion.common.rmi.server.Server
CLIENT_HOST -
Constructor Summary
ConstructorsConstructorDescriptionEntityServer(EntityServerConfiguration configuration) Constructs a new EntityServer and binds it to a registry on the port found in the configuration. -
Method Summary
Modifier and TypeMethodDescriptionfinal EntityServerAdminReturns the admin interface used to administer this serverprotected final AbstractRemoteEntityConnectionconnect(RemoteClient remoteClient) Establishes the actual client connection.protected AbstractRemoteEntityConnectioncreateRemoteConnection(Database database, RemoteClient remoteClient, int port, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory) Creates the remote connection provided by this serverprotected final voiddisconnect(AbstractRemoteEntityConnection connection) Disconnects the given connection.static voidIf no arguments are supplied a new EntityServer is started.protected final voidmaintainConnections(Collection<AbstractServer.ClientConnection<AbstractRemoteEntityConnection>> connections) Maintains the given connections, that is, disconnects inactive or invalid connections, if required.static EntityServerStarts the server, using the configuration from system properties.static EntityServerstartServer(EntityServerConfiguration configuration) Starts the server.Methods inherited from class is.codion.common.rmi.server.AbstractServer
addAuthenticator, addShutdownListener, auxiliaryServers, connect, connection, connectionCount, connections, connectionsAvailable, disconnect, getAdmin, getConnectionLimit, getMaintenanceInterval, information, logShutdownAndReturn, registry, setAdmin, setConnectionLimit, setMaintenanceInterval, shutdown, validateUserCredentialsMethods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObjectMethods 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
-
admin
Description copied from interface:ServerReturns 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
-
connect
protected final AbstractRemoteEntityConnection connect(RemoteClient remoteClient) throws RemoteException, LoginException Description copied from class:AbstractServerEstablishes the actual client connection.- Specified by:
connectin 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:AbstractServerDisconnects the given connection.- Specified by:
disconnectin 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:AbstractServerMaintains the given connections, that is, disconnects inactive or invalid connections, if required.- Specified by:
maintainConnectionsin 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
-