Class ServerShell

java.lang.Object
com.iizix.server.ServerShell
All Implemented Interfaces:
IWebServiceEngine, WebSocketAcceptor, IAdditonalInformation<UserInfoHistoryEntry>, IPushNotificationService, IAppLoader, IServer, IKStringInfoProviderHolder
Direct Known Subclasses:
JakartaEEServer, JettyRunConfiguration

The Server Shell.
Author:
Christopher Mindus
  • Field Details

  • Constructor Details

  • Method Details

    • updateWebServerRoot

      public static void updateWebServerRoot(File dirHint)
      Update the web server root for the license system. This method is not intended to be called, it is done only by the IIZI framework.
      Parameters:
      dirHint - The directory hint might be non-null. If so, that one should be used.
    • setWSFileProviderEngine

      public static void setWSFileProviderEngine(WSFileProviderEngine engine)
      Assigns the web server file provider engine. This method is not intended to be called, it is done only by the IIZI framework.
      Parameters:
      engine - The engine.
      Throws:
      IllegalStateException - In case the engine is already set by the framework.
    • getInstance

      public static ServerShell getInstance()
      Gets the instance of the main server. If the server never has been started, it will be started before returning the instance.
      Returns:
      null if it is stopped.
    • getInstance

      protected static ServerShell getInstance(Class<? extends ServerShell> server)
      Gets the instance of the main server. If the server never has been started, it will be started before returning the instance.
      Returns:
      null if it is stopped.
    • _getState

      public static IServer.State _getState()
      Gets the state of the server.
      Returns:
      The server state: STARTING, STARTED, STOPPING or STOPPED.
    • _unregisterApplication

      public static void _unregisterApplication(String jndiName, Object injector)
      Unregisters an application with the server.
      Parameters:
      jndiName - The full JNDI name of the application.
      injector - The instance of the application injector.
      Throws:
      NullPointerException - If the server has not been started.
    • _registerApplication

      public static void _registerApplication(String jndiName, Object injector)
      Registers an application with the server.
      Parameters:
      jndiName - The full JNDI name of the application.
      injector - The instance of the application injector.
      Throws:
      NullPointerException - If the server has not been started.
    • registerRegionLocationServiceProviders

      public static void registerRegionLocationServiceProviders(ServerSettings settings, boolean isTestMode)
      Registers the Region Location Service Providers.

      The local IP2Location provider is registered first when the server setting ServerSettings.IP2LOCATION_ENABLED is on, which makes it the default provider: its lookups stay on the server. The web providers GeoPlugin, IPStack and IPWhoIs follow in test mode or when ServerSettings.GEO_WEB_PROVIDERS is on; a lookup through one of them sends the client's IP address to that web service. In production this method is called by IP2LocationModule.onServerReady(IServer) only when one of the two settings is on.

      Parameters:
      settings - The settings.
      isTestMode - Flag for test mode.
      Throws:
      IllegalStateException - For invalid server states.
    • shutdownRegionLocationServiceProviders

      public static void shutdownRegionLocationServiceProviders()
      Shuts down the Region Location Service Providers.

      This method is used for testing and not by the server.

      Throws:
      IllegalStateException - For invalid state.
    • getURNFactory

      public static URNFactory getURNFactory()
      Gets the instance to URNFactory initialized for the Server-side dependencies that the com.iizix.urn.getInstance() cannot resolve. However, you do not need to worry, the iiziGo Designer as well as the iiziServer handles this automatically, so it doesn't matter as an app implementor if you call com.iizix.urn.getInstance() or com.iizix.server.getURNFactory().
    • getAllAppAliases

      public Map<String,String> getAllAppAliases()
      Gets the unmodifiable map of all application aliases: the command line's and the registered applications' (CC-FIX-APP-DEFINITIONS).
      Returns:
      The map of 'alias' as keys and 'appID' as values.
    • forgetAppAliases

      protected final void forgetAppAliases(Set<String> aliases)
      Forgets the aliases of a command-line application definition the configuration file overrides (CC-FIX-APP-DEFINITIONS, M-4: the file wins, the command line's aliases with it).
      Parameters:
      aliases - The aliases to forget.
    • getCurrentDirectory

      public File getCurrentDirectory()
      Gets the server current directory.
      Returns:
      The current directory (canonical form).
    • getStartTime

      public final long getStartTime()
      Gets the server's start time (not the creation time).
      Returns:
      The start time in milliseconds since the Epoch, zero if not yet started.
    • getExecutorService

      public final ExecutorService getExecutorService()
      Gets the Server ExecutorService: the file upload module's verifier and the mail sender run on it. ServerShell's own method since CC-FIX-VTHREAD-SMALLS (VF-D-2): the app loader interface no longer asks its implementations for an executor, and nothing of the loading runs on this one.
      Returns:
      A server executor service appropriate to the number of threads capable of the CPU or any number of virtual threads possible in the executor service.
    • getServerThreadGroup

      public final VirtualThreadGroup getServerThreadGroup()
      Gets the ThreadGroup for the server.
      Returns:
      The IIZI server platform thread group, not a virtual thread group, null if not yet retrieved or created.
    • getState

      public final IServer.State getState()
      Gets the server state.
      Specified by:
      getState in interface IServer
      Returns:
      The server state: STARTING, STARTED, STOPPING or STOPPED.
    • getActiveUserSessions

      public final ActiveUserSessions getActiveUserSessions()
      The active user sessions.
      Returns:
      The instance controlling the active user sessions, null if server hasn't been started.
    • getWebEngineStats

      public final WebEngineStats getWebEngineStats()
      Gets the counts of the web engines the client sessions of this server arrived on: how many run an engine that no longer receives security updates, now and since the server started, per status and per application, platform and version (CC-WEBENGINE-SERVER). The counts are in memory and start at zero with the server; the server log holds the history.
      Returns:
      The counts, never null. Take a WebEngineStats.snapshot() to read them.
    • loadPluginsAndConfig

      protected final void loadPluginsAndConfig() throws Throwable
      Performs initial setup, loading plugins and the configuration file.
      Throws:
      IOException - For server singleton errors.
      Throwable - For other severe server failures.
    • startServer

      public final void startServer() throws Throwable
      Processes server start-up asynchronously.
      Specified by:
      startServer in interface IServer
      Throws:
      Throwable - for startup errors.
    • getServerLogger

      public ServerLogger getServerLogger()
      Gets the server logger instance.
    • flushStartupLog

      protected void flushStartupLog()
      Flushes a potential start-up logging to console for exceptions causing server not to initialize the logging system.
    • registerRequestPrinter

      public boolean registerRequestPrinter(String target, IWebServerRequestPrinter processor)
      Registers a new request printer.
      Specified by:
      registerRequestPrinter in interface IServer
      Parameters:
      target - The target URL, always starting with "/" and doesn't contain the query.
      processor - The print processor.
      Returns:
      true if added successfully, false if the print processor already exists or the server is not started yet.
    • unregisterRequestPrinter

      public boolean unregisterRequestPrinter(String target, IWebServerRequestPrinter processor)
      Unregister a previously registered request printer.
      Specified by:
      unregisterRequestPrinter in interface IServer
      Parameters:
      target - The target URL, always starting with "/" and doesn't contain the query.
      processor - The print processor.
      Returns:
      true if removed successfully, false if the print processor does not exist or doesn't match, or the server is not yet started.
    • getExternalWebServerBaseURL

      @Deprecated(since="Java17") public String getExternalWebServerBaseURL()
      Deprecated.
      Attempts to get the default external host address from the current thread's context.

      Note: the SessionInfo instance will be attempted to be retrieved from the current thread and used for the external server address, including protocol (http:// or https://). Note that if the iiziServer is behind a proxy that handles SSL, the protocol returned here would be "http://" if not configured properly in the server configuration.

      Returns:
      The external host address, including protocol (http:// or https://) and potentially a port as (:8080), or null if it cannot be established. The string never ends with a '/'.
    • getEmailVerificationURL

      public String getEmailVerificationURL(BasicUserInfo bui, String email, String externalWebServerBaseURL)
      Gets a verification URL for an email address. This URL is used to send a mail to the email in question with the link using this URL. When the user clicks on the link, the email gets verified in the database and all logging is handled by the server.

      Note: if the parameter externalHostAddress is null, the SessionInfo instance will be attempted to be retrieved from the current thread and used for the external server address, including protocol (http:// or https://). Note that if the iiziServer is behind a proxy that handles SSL, the protocol returned here would be "http://" if not configured properly in the server configuration.

      If the SessionInfo cannot be located, the server's external URL configuration is used.

      Parameters:
      bui - The basic user information.
      email - The email in question.
      externalWebServerBaseURL - The external base URL for the web server, e.g. "https://lic.mindus.co", use null for default. The default address is retrieved using getExternalWebServerBaseURL().
      Returns:
      The URL, or null if the external host address cannot be created.

      PLEASE NOTE THAT IF THE DOMAIN NAME FAILS TO BE RETRIEVED, THE "url" DOES NOT CONTAIN THAT INFORMATION. It will then just be a path such as "/iizi-email-verification?...".

      The return URL is null if the link cannot be sealed with the server key (ServerSecurityManager). If this is the case, an error message is logged prior to returning. The link is valid for EmailVerificationLink.VALIDITY_MS milliseconds.

    • getServerConfigFile

      public final File getServerConfigFile()
      Gets the Server Config File.
      Returns:
      The config file used to start the server with.
    • loadServerConfig

      protected final void loadServerConfig() throws IOException, PropException
      Loads or reloads the server config and starts the WSFile provider engine. This call can only be done by the framework and is not intended to be called.
      Throws:
      IOException - For load failure.
      PropException - For property errors.
    • getServerProperties

      public final ServerProps getServerProperties()
      Gets the Server Properties.
      Specified by:
      getServerProperties in interface IServer
    • getServerSettings

      public ServerSettings getServerSettings()
      Gets the container for server settings.
    • getHubDefinition

      public HubDefinition getHubDefinition()
      Gets the hub definition in force on this server (HUB-DESIGN.md 4.2, B-7b): loaded from the file the system property iizi.hub.definition or the environment variable IIZI_HUB_DEFINITION names at the first call, and watched for changes; standalone when none is configured. The hub module and the member client both read it here.
      Specified by:
      getHubDefinition in interface IServer
      Returns:
      The definition, never null.
    • getHubClusterKey

      public HubClusterKey getHubClusterKey()
      Gets the interim cluster key the definition names (HUB-DESIGN.md 2.2, ruled H-8): loaded at the first call from the file [hub] key names, resolved against the definition file's directory when relative, under the permission rule of PUSH-CREDENTIALS.md section 8.
      Specified by:
      getHubClusterKey in interface IServer
      Returns:
      The key, or null when standalone, when the definition names none, or when the file is refused (SEVERE, once).
    • getHubMemberClient

      public HubMemberClient getHubMemberClient()
      Gets the member client of the hub (HUB-DESIGN.md 3.1).
      Returns:
      The client, or null while standalone or before the server worker started.
    • isOriginAllowedForCORS

      public boolean isOriginAllowedForCORS(String origin, String requestHost)
      Tells whether a cross-origin page may read this server's responses (CC-FIX-SB-CORS, IIZI-JETTY-CORS-CREDENTIALS-ANY-ORIGIN): the WebSocket Origin allow-list of HUB-DESIGN.md 3.6 decides, the $allowedOrigins setting included, and a development server grants the loopback origins as well. CORSFilter asks through IExternalBrowserPages.isOriginAllowed, for an http(s) origin that is neither an iiziRun WebView origin nor the host the request came to.
      Parameters:
      origin - The request's Origin header field.
      requestHost - The host the request came to, may be null.
      Returns:
      true to grant the origin, false to refuse it.
    • configureSessionMgr

      public void configureSessionMgr()
      Configures the client session manager with the settings for idle timeout, dormant time and heartbeat interval.
    • saveServerConfig

      public boolean saveServerConfig() throws IOException
      Saves the Server Properties if required, creating a backup file of the previous configuration as "filename-DD MMM YYYY hh:mm:ss.SSS.iiziServer".
      Returns:
      true for successful save, false for no change.
      Throws:
      IOException - For load failure.
    • getDefaultMailSender

      Gets the default mail sender.
      Specified by:
      getDefaultMailSender in interface IServer
      Returns:
      The default mail sender.
      Throws:
      NotFoundException - If the mail sender is not found.
      IOException - If the mail queue directory does not exist.
      NoSuchProviderException - If the "smtp" or "smtps" providers do not exist!
      AddressException - If the default sender failed to parse.
    • getMailSender

      Gets the default mail sender.
      Specified by:
      getMailSender in interface IServer
      Parameters:
      name - The mail sender name, null for default or the first one found if no default is configured.
      Returns:
      The default mail sender.
      Throws:
      NotFoundException - If the mail sender is not found.
      IOException - If the mail queue directory does not exist.
      NoSuchProviderException - If the "smtp" or "smtps" providers do not exist!
      AddressException - If the default sender failed to parse.
    • loadApplications

      public abstract void loadApplications() throws Throwable
      Called to load the applications.
      Specified by:
      loadApplications in interface IServer
      Throws:
      Throwable - for start-up errors.
    • registerApplication

      public final AppDefinition registerApplication(String id, AppDefinition app) throws ServerApplicationSetupException
      Registers an application with an ID available in the server.
      Specified by:
      registerApplication in interface IServer
      Parameters:
      id - The ID of the application.
      app - The application.
      Returns:
      The previous overwritten application, or null for a new application.
      Throws:
      ServerApplicationSetupException - In case a plug-in fail to initialize.
    • unregisterApplication

      public final boolean unregisterApplication(AppDefinition app)
      Unregisters one application, the inverse of registerApplication(String,AppDefinition) (CC-FIX-APP-DEFINITIONS-FOLLOWUPS, UI-D-5 (b)): the definition leaves the server's applications when it is still the one registered under its ID, every alias of it that still names that ID leaves the alias table, and the plug-ins are informed as for the unload of all applications. An alias of a removed application therefore resolves to nothing at once, without a restart. Nothing is disposed of here: the caller disposes of the application's factory and of the definition first, as unregisterApplications does.
      Parameters:
      app - The definition to unregister.
      Returns:
      true when the definition was the registered one and is unregistered, false when another definition (or none) is registered under its ID: then nothing is changed.
    • getApplication

      public final AppFactory getApplication(String id)
      Gets an application that has been registered with an ID. The table of appID aliases is checked.
      Parameters:
      id - The application ID or an alias of the appID.
      Returns:
      The application factory, or null if not registered.
    • getAppDefinition

      public final AppDefinition getAppDefinition(String idOrAlias)
      Gets the definition of an application registered with an ID or an alias, WITHOUT the hot deploy check that getApplication(String) performs (CC-FIX-APP-MODULE-REFERENCES: the Module project reference resolution of a project application looks up the applications it references while one of them may be reloading).
      Parameters:
      idOrAlias - The application ID or an alias of it.
      Returns:
      The definition, or null if no such application is registered.
    • getAppDefinitions

      public final AppDefinition[] getAppDefinitions()
      Gets the definitions of all registered applications (CC-FIX-APP-MODULE-REFERENCES).
      Returns:
      The definitions, in no particular order.
    • getApplications

      public final AppFactory[] getApplications()
      Gets the applications that are loaded and registered. The appIDs are only the non-aliased names.
      Returns:
      The application factories loaded.
    • onApplicationSessionStarted

      public void onApplicationSessionStarted(AppSessionGyro appGyro)
      Called when an application is instantiated and started by a user session.
      Parameters:
      appGyro - The application session.
    • onApplicationSessionStopped

      public void onApplicationSessionStopped(AppSessionGyro appGyro)
      Called when an application is stopped.
      Parameters:
      appGyro - The application session.
    • addDisposeListener

      public boolean addDisposeListener(IServerDisposeListener listener)
      Adds a server dispose. Calling this method multiple times with the same listener will have no effect (but to return false).
      Specified by:
      addDisposeListener in interface IServer
      Parameters:
      listener - The listener to add.
      Returns:
      true if the listener was added, false otherwise.
      Throws:
      NullPointerException - If the listener is null.
    • removeDisposeListener

      public boolean removeDisposeListener(IServerDisposeListener listener)
      Removes a server dispose listener.
      Specified by:
      removeDisposeListener in interface IServer
      Parameters:
      listener - The listener to remove.
      Returns:
      true if listener is successfully removed, false otherwise.
    • onStartServer

      public void onStartServer() throws Throwable
      Called to initialize the server.
      Specified by:
      onStartServer in interface IServer
      Throws:
      Throwable - for start-up errors.
    • getWorker

      protected final Worker getWorker()
      Gets the server worker.
    • dispose

      public final boolean dispose()
      Disposes of the server, e.g. at shut-down. This dispose call will wait until the server has shut-down successfully.

      The JVM exits with the code of the exit request, ServerExit.STOP when there was none (a licence shutdown, an uncaught start-up failure).

      Specified by:
      dispose in interface IServer
      Returns:
      true for success, false if already disposed of or stopping/disposing.
    • dispose

      public final boolean dispose(int code)
      Disposes of the server and exits the JVM with an exit code of the ServerExit contract: what a supervisor reads. This dispose call will wait until the server has shut-down successfully; the ExitWatchdog halts the JVM with the same code should it not end.
      Parameters:
      code - The exit code: ServerExit.STOP, ServerExit.RESTART or ServerExit.UPDATE_RESTART.
      Returns:
      true for success, false if already disposed of or stopping/disposing.
    • onDispose

      protected void onDispose()
      Called prior to disposing. Override to process.
    • onDisposed

      protected void onDisposed()
      Called after disposing. Override to process.
    • setSupervisor

      public static void setSupervisor(ServerShell.Supervisor s)
      Sets the supervisor of the server process, from the start option -supervisor. This method is not intended to be called, it is done only by the launcher.
      Parameters:
      s - The supervisor, null for ServerShell.Supervisor.NONE.
    • getSupervisor

      public static ServerShell.Supervisor getSupervisor()
      Gets the supervisor of the server process.
      Returns:
      The supervisor, ServerShell.Supervisor.NONE when the server was started without one.
    • isSupervised

      public static boolean isSupervised()
      Checks if the server process is supervised, i.e. is relaunched when it exits with ServerExit.RESTART.
      Returns:
      true when a supervisor was named at start.
    • setAllowUnsignedUpdate

      public static void setAllowUnsignedUpdate(boolean on)
      Sets the flag that lets a server built without a code signature install update packages. This method is not intended to be called, it is done only by the launcher.
      Parameters:
      on - The flag.
    • isAllowUnsignedUpdate

      public static boolean isAllowUnsignedUpdate()
      Checks if a server built without a code signature may install update packages.
      Returns:
      The flag of the start option -allowUnsignedUpdate, false by default.
    • getExitCode

      public static int getExitCode()
      Gets the exit code the JVM ends with when the server disposes.
      Returns:
      The code of the exit request, ServerExit.STOP when there was none.
    • getPendingUpdate

      public static File getPendingUpdate()
      Gets the update package an administrator chose.
      Returns:
      The package file, null when no update is pending.
    • setPendingUpdate

      public static void setPendingUpdate(File file)
      Marks an update package as pending: the next "restart and update" installs it. The package is verified by the updater right before it writes, never here.
      Parameters:
      file - The package file, null to clear the pending update.
    • getUpdatesDirectory

      public File getUpdatesDirectory()
      Gets the directory of the update packages, the request and the result: UPDATES_DIRECTORY under the server's current directory.
      Returns:
      The directory (it may not exist).
    • getExitRefusal

      public final ServerShell.ExitRefusal getExitRefusal(int code)
      Gets why an exit request would be refused now: what ServerAdmin shows as a disabled action.
      Parameters:
      code - The exit code: ServerExit.STOP, ServerExit.RESTART or ServerExit.UPDATE_RESTART.
      Returns:
      The refusal, null when the request would be accepted.
      Throws:
      IllegalArgumentException - For a code that cannot be requested.
    • requestExit

      public final ServerShell.ExitRefusal requestExit(int code, String requestedBy)
      Requests an exit of the server process: a stop, a restart, or an update and a restart. An accepted request is logged; a server thread (a platform thread, never a daemon) then waits EXIT_NOTICE_DELAY, so that the reply of the action reaches the administrator's browser, tells every connected client (notifyEndPointsOfExit(int)) and disposes the server with the code. For an update the request file for the updater is written first.
      Parameters:
      code - The exit code: ServerExit.STOP, ServerExit.RESTART or ServerExit.UPDATE_RESTART.
      requestedBy - Who asked, for the log: the administrator and the address.
      Returns:
      The refusal, null when the exit is under way.
      Throws:
      IllegalArgumentException - For a code that cannot be requested.
    • restart

      public final ServerShell.ExitRefusal restart(boolean update, String requestedBy)
      Requests a restart of the server process, with or without an update first.
      Parameters:
      update - true to install the pending update package before the restart.
      requestedBy - Who asked, for the log.
      Returns:
      The refusal, null when the restart is under way.
    • stop

      public final ServerShell.ExitRefusal stop(String requestedBy)
      Requests a stop of the server process: exit code ServerExit.STOP, no relaunch.
      Parameters:
      requestedBy - Who asked, for the log.
      Returns:
      The refusal, null when the stop is under way.
    • notifyEndPointsOfExit

      protected void notifyEndPointsOfExit(int code)
      Tells every connected client that the server exits, right before the dispose: each client end point is closed with
      invalid reference
      GCloseCodes#CC_SERVER_RESTART
      and the text of ServerExitNotice for its kind, Browser or iiziRun. Dormant sessions have no channel and are not told; their clients meet
      invalid reference
      GCloseCodes#CC_DISPOSED
      at their next reconnection. The other end points (the VirtualSpace viewer, the monitor) go down with the server.
      Parameters:
      code - The exit code of the request.
    • getPropertyFactory

      public final PropFactory getPropertyFactory()
      Gets the server property factory.
    • getPropertyManager

      public final PropMgr getPropertyManager()
      Gets the server property manager.
      Specified by:
      getPropertyManager in interface IAppLoader
    • loadFile

      public final PropCnr loadFile(File file) throws IOException, PropException
      Loads a property file.
      Specified by:
      loadFile in interface IAppLoader
      Parameters:
      file - The file to load.
      Returns:
      A Property container.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • loadFile

      public final PropCnr loadFile(String fileName, InputStream inputStream) throws IOException, PropException
      Loads a property file.
      Specified by:
      loadFile in interface IAppLoader
      Parameters:
      fileName - The file name for logging.
      inputStream - The file input stream.
      Returns:
      A Property container.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • saveFile

      public final void saveFile(File file, PropCnr cnr) throws IOException, PropException
      Saves a property file.
      Parameters:
      file - The file to load.
      cnr - The property container to save.
      Throws:
      IOException - For file errors.
      PropException - For property errors.
    • getAccessibleEnvironments

      public boolean getAccessibleEnvironments(HttpServletRequest request, List<ServerConfigEnvProps> envs)
      Gets the environments that are supported for the request. Pass in an empty ArrayList of envs that is filled in.
      Parameters:
      request - The HTTP request.
      envs - The environment list is filled in upon return.
      Returns:
      true if the request is "valid", false if the "host" header doesn't match and that each environment should be interrogated. The return value could be true even if there is no specific environment in envs that matches, but the request is valid.
    • loadPlugins

      public final List<IPluginDescriptor<?>> loadPlugins(String names) throws IOException
      Loads required plug-in's.

      Each plug-in must have a class called "name.server.Descriptor" that implement the interface com.iizix.IPluginDescriptor available.

      The plug-in definition should be found at the "name/schema/properties.xml", but the iiziGo modules have the "iizigo" module instead of "iizix". To figure out translation of names, a class called "name.server.Descriptor" is loaded and should implement the interface

      Specified by:
      loadPlugins in interface IAppLoader
      Parameters:
      names - The plug-in name, e.g. "com.iizigo.db,com.iizigo.term,com.iizigo.ws".
      Returns:
      The list of plug-in descriptors.
      Throws:
      IOException - If a plug-in failed to load.
    • addModule

      public boolean addModule(IServerModule<?> module)
      Adds a server module for processing. The module can have an end point constructor that is added during initialization.
      Specified by:
      addModule in interface IServer
      Parameters:
      module - The server module.
      Returns:
      true for success, false if already added.
    • removeModule

      public boolean removeModule(IServerModule<?> module)
      Removes a server module for processing. This will unregister a potential end point constructor and dispose of the module.
      Specified by:
      removeModule in interface IServer
      Parameters:
      module - The server module.
      Returns:
      true for success, false if already removed.
    • registerEndPointConstructor

      protected final boolean registerEndPointConstructor(IEndPointConstructor<?> epc)
      Registers an end point constructor.
      Parameters:
      epc - The end point constructor.
      Returns:
      true for success, false for failure e.g. epc is null or it is already registered.
    • unregisterEndPointConstructor

      protected final boolean unregisterEndPointConstructor(IEndPointConstructor<?> epc)
      Unregisters an end point constructor.
      Parameters:
      epc - The end point constructor.
      Returns:
      true for success, false for failure.
    • isRequestURIAccepted

      public final Object isRequestURIAccepted(IWebSocketComm comm, String uri, Map<String, List<String>> headerFields)
      Called to check if a request URI can be accepted.
      Specified by:
      isRequestURIAccepted in interface WebSocketAcceptor
      Parameters:
      comm - The WebSocket communication instance.
      uri - The request URI, formatted as e.g. "/something/more.ws?query-params".
      headerFields - HTTP header fields.
      Returns:
      Object an object that is attached to the communications, or null if the URI is not accepted.
    • getHandledContextPaths

      public String[] getHandledContextPaths()
      Gets the list of potential handled context paths for the websocket.
      Specified by:
      getHandledContextPaths in interface WebSocketAcceptor
      Returns:
      The array of possibly handled context path.
    • getEndPointsInstances

      public final IEndPoint[] getEndPointsInstances()
      Gets an array of all end points: a snapshot, built on every call under the lock of the end points. Every end point is an IEndPoint, and not every one extends AbstractEndPoint: a client session (ClientEndPoint) and a VirtualSpace viewer session implement the interface directly, so the array is typed by the interface. An array of the abstract class threw ArrayStoreException as soon as one client was connected, and the exit notice of notifyEndPointsOfExit(int) reached no client (CC-FIX-ENDPOINTS-ARRAY). Avoid this method where a listener does: it allocates on every call.
      Specified by:
      getEndPointsInstances in interface IServer
      Returns:
      An array of IEndPoint instances.
    • onEndPointDisposed

      public final void onEndPointDisposed(IEndPoint endPoint)
      Called when an end point is disposed of.
      Specified by:
      onEndPointDisposed in interface IServer
    • addEndPointListener

      public final IEndPoint[] addEndPointListener(IEndPointListener listener)
      Adds a listener of end point create/dispose and retrieves the list of current end points. Calling this method several times with the same listener does not add a new one, it is similar to calling getEndPointInstances().
      Specified by:
      addEndPointListener in interface IServer
      Parameters:
      listener - The end point listener.
      Returns:
      An array of EndPoint instances.
    • removeEndPointListener

      public final boolean removeEndPointListener(IEndPointListener listener)
      Adds a listener of end point create/dispose and retrieves the list of current end points. Calling this method several times with the same listener does not add a new one, it is similar to calling getEndPointInstances().
      Specified by:
      removeEndPointListener in interface IServer
      Parameters:
      listener - The end point listener.
      Returns:
      true for success, false if not added as listener.
    • getTXPCoordinator

      public final ITXPCoordinator getTXPCoordinator()
      The transaction processor coordinator.
      Specified by:
      getTXPCoordinator in interface IServer
    • getKStringInfoProvider

      public final IKStringInfoProvider getKStringInfoProvider()
      /** Gets the session's IKStringInfoProvider from the ClientSessionGyro threads, and if not found, from the application session gyro threads.
      Specified by:
      getKStringInfoProvider in interface IKStringInfoProviderHolder
      Returns:
      The current client or application session's IKStringInfoProvider instance, or null if not found.
    • registerApplication

      public void registerApplication(String jndiName, Object injector)
      Registers an application with the server.
      Parameters:
      jndiName - The full JNDI name of the application.
      injector - The instance of the application injector.
    • unregisterApplication

      public void unregisterApplication(String jndiName, Object injector)
      Unregisters an application with the server.
      Parameters:
      jndiName - The full JNDI name of the application.
      injector - The instance of the application injector.
    • getHistory

      public final OSSystemInfo.HistoryEntry<UserInfoHistoryEntry>[] getHistory(long start)
      Gets the history entries gathered between a date up to the last available entry. The history entries are gathered at specific interval defined at start of history.
      Parameters:
      start - The start time for the events in milliseconds since the Epoch, or zero for all history entries.
      Returns:
      The entries, possibly empty array.
    • getInfoClass

      public final Class<UserInfoHistoryEntry> getInfoClass()
      Gets the class of the additional information.
      Specified by:
      getInfoClass in interface IAdditonalInformation<UserInfoHistoryEntry>
      Returns:
      The Class for additional information, or null for none.
    • getAdditionalInformation

      public final UserInfoHistoryEntry getAdditionalInformation()
      Allocates a new instance of the additional information to be stored with the history entry. If the getInfoClass() returns null, this method can also return null.
      Specified by:
      getAdditionalInformation in interface IAdditonalInformation<UserInfoHistoryEntry>
      Returns:
      A new instance of additional information, or null for none.
    • isUserLoginEnabled

      public final boolean isUserLoginEnabled()
      Checks if user login is enabled.
      Returns:
      The user login enabled flag.
    • setUserLoginEnabled

      public final void setUserLoginEnabled(boolean on) throws SecurityException
      Sets the user login enabled flag.
      Parameters:
      on - The enabled flag.
      Throws:
      SecurityException - If the caller is not allowed to perform this function.
    • isUserLoginPermittedNow

      public final boolean isUserLoginPermittedNow()
      Verifies if the user login is permitted at the current time.
      Returns:
      The login permission flag.
    • getUserLoginProhibitedIntervals

      public final TimeInterval[] getUserLoginProhibitedIntervals()
      Gets the time intervals when user login is prohibited.
      Returns:
      The array of time intervals.
    • addUserLoginProhibitedInterval

      public final boolean addUserLoginProhibitedInterval(TimeInterval timeInterval) throws SecurityException
      Removes a time interval when user login is prohibited.
      Parameters:
      timeInterval - The time interval.
      Returns:
      Success flag true meaning OK, false means no change, or the interval was already present.
      Throws:
      SecurityException - If the caller is not allowed to perform this function.
    • initializeCompressedFiles

      protected void initializeCompressedFiles() throws IOException
      Initializes and compresses the HTML files and all sources and CSS files loaded from there.
      Throws:
      IOException - For I/O errors.
    • getSourceResolver

      public ISourceResolver getSourceResolver()
      Gets the source file resolver.
      Returns:
      The instance used to resolve file names.
    • getWebServerDirectoryMapper

      public abstract IWebServerDirectoryMapper getWebServerDirectoryMapper()
      Gets the interface for mapping directories to the web server.
      Returns:
      The interface for mapping directories to the web server, of null if not supported or not yet initialized.
    • getFileProviderEngine

      public WSFileProviderEngine getFileProviderEngine()
      Gets the WSFile provider engine.

      The engine is initialized as soon as the server configuration file has been loaded, before any additional processing is done.

      Returns:
      The file provider engine, null if not yet initialized.
    • getWebThumbs

      public WebThumbs getWebThumbs() throws IOException
      Gets the instance of the WebThumbs.
      Returns:
      The singleton (per server instance).
      Throws:
      IOException - For I/O errors when creating the WebThumbs directory for persistent images.
    • getWebLogos

      public WebLogos getWebLogos() throws IOException
      Gets the instance of the WebLogos.
      Returns:
      The singleton (per server instance).
      Throws:
      IOException - For I/O errors when creating the WebLogos directory for persistent images.
    • addFileUploader

      public void addFileUploader(IWSUploaderAcceptor endPoint)
      Adds a new web file loader acceptor for an end point.
      Parameters:
      endPoint - The end point.
      Throws:
      ClassCastException - If the end point is not configurable to receive file uploads.
      IllegalStateException - If the end point is already added.
    • removeFileUploader

      public void removeFileUploader(IWSUploaderAcceptor endPoint)
      Removes a new web file loader acceptor for an end point.
      Parameters:
      endPoint - The end point.
    • getWSUploaderService

      public IWSUploaderService getWSUploaderService()
      Gets the web service file uploader service.
      Returns:
      The instance of the web service file uploader service.
    • doCompressNormalHTML

      public abstract boolean doCompressNormalHTML()
      Flag indicating the normal HTML files needs compression along with CSS minify and JS compression.

      The files are typically: iiziApp.html and iiziVSViewer.html.

      Returns:
      true by default, override to return false (e.g. for internal development).
    • getWebServerCompression

      public abstract IWebServerCompression getWebServerCompression()
      Gets the web server compression interface.
      Returns:
      The instance of the interface implemented by the web server.
    • registerServlet

      public abstract boolean registerServlet(String pathSpec, HttpServlet servlet)
      Registers a servlet at a path specification in the web server's root context.
      Specified by:
      registerServlet in interface IServer
      Parameters:
      pathSpec - The servlet path specification, always starting with "/".
      servlet - The servlet.
      Returns:
      true if registered, false if the path specification is already registered or the web server is not started.
    • unregisterServlet

      public abstract boolean unregisterServlet(String pathSpec, HttpServlet servlet)
      Unregisters a servlet previously registered.
      Specified by:
      unregisterServlet in interface IServer
      Parameters:
      pathSpec - The servlet path specification.
      servlet - The servlet, must be the registered instance.
      Returns:
      true if unregistered, false if the path specification is not registered, the servlet is not the registered one, or the web server is not started.
    • getWebServerMapping

      public File getWebServerMapping(String mappedFile)
      Gets the map of web server mappings for files.
      Parameters:
      mappedFile - The file to map.
      Returns:
      The mapping from String (such as "dojo.root" or "iiziRun.root") to File Returns null if not found.
    • getWebServerDirectoryAlias

      public File getWebServerDirectoryAlias(String alias)
      Gets the alias directory file for the web server.
      Parameters:
      alias - The alias.
      Returns:
      The file that is aliased to the directory. Returns null if not found.
    • getETag

      public String getETag(File file)
      Gets the map of web server mappings for files.
      Parameters:
      file - The file.
      Returns:
      The weak ETag for the resource.mapping from String (such as "dojo.root" or "iiziRun.root") to File Returns null if not found.