Class EntityServer

All Implemented Interfaces:
is.codion.common.rmi.server.Server<AbstractRemoteEntityConnection,EntityServerAdmin>, Serializable, Remote

public class EntityServer extends is.codion.common.rmi.server.AbstractServer<AbstractRemoteEntityConnection,EntityServerAdmin>
A remote server class, responsible for handling requests for AbstractRemoteEntityConnections.
See Also:
  • Constructor Details

    • EntityServer

      public EntityServer(EntityServerConfiguration configuration) throws RemoteException
      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 exception
      RuntimeException - 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

      public final EntityServerAdmin serverAdmin(is.codion.common.user.User user) throws is.codion.common.rmi.server.exception.ServerAuthenticationException
      Parameters:
      user - the server admin user
      Returns:
      the administration interface for this server
      Throws:
      is.codion.common.rmi.server.exception.ServerAuthenticationException - in case authentication fails
      IllegalStateException - in case no server admin instance is available
    • serverLoad

      public final int serverLoad()
    • connect

      protected final AbstractRemoteEntityConnection connect(is.codion.common.rmi.server.RemoteClient remoteClient) throws RemoteException, is.codion.common.rmi.server.exception.LoginException
      Specified by:
      connect in class is.codion.common.rmi.server.AbstractServer<AbstractRemoteEntityConnection,EntityServerAdmin>
      Throws:
      RemoteException
      is.codion.common.rmi.server.exception.LoginException
    • disconnect

      protected final void disconnect(AbstractRemoteEntityConnection connection) throws RemoteException
      Specified by:
      disconnect in class is.codion.common.rmi.server.AbstractServer<AbstractRemoteEntityConnection,EntityServerAdmin>
      Throws:
      RemoteException
    • createRemoteConnection

      protected AbstractRemoteEntityConnection createRemoteConnection(is.codion.common.db.database.Database database, is.codion.common.rmi.server.RemoteClient remoteClient, int port, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory) throws RemoteException, is.codion.common.db.exception.DatabaseException
      Creates the remote connection provided by this server
      Parameters:
      database - the underlying database
      remoteClient - the client requesting the connection
      port - the port to use when exporting this remote connection
      clientSocketFactory - the client socket factory, null for default
      serverSocketFactory - the server socket factory, null for default
      Returns:
      a remote connection
      Throws:
      RemoteException - in case of an exception
      is.codion.common.db.exception.DatabaseException - 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<is.codion.common.rmi.server.AbstractServer.ClientConnection<AbstractRemoteEntityConnection>> connections) throws RemoteException
      Specified by:
      maintainConnections in class is.codion.common.rmi.server.AbstractServer<AbstractRemoteEntityConnection,EntityServerAdmin>
      Throws:
      RemoteException
    • startServer

      public static EntityServer startServer() throws RemoteException
      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

      public static void main(String[] arguments) throws RemoteException, is.codion.common.rmi.server.exception.ServerAuthenticationException
      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 export
      is.codion.common.rmi.server.exception.ServerAuthenticationException - in case of missing or incorrect admin user information