Package com.iizix.server
Interface IServer
- All Superinterfaces:
IAppLoader
- All Known Implementing Classes:
JakartaEEServer
,JettyRunConfiguration
,RuntimeBuilderServer
,ServerShell
,StandardServer
The interface to the Server instance, whether running in a JakartaEE Application Server or stand-alone using another web server and/or WebSocket implementation.
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Error enum used when validating an App ID with locale support.static enum
States of the server.Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum valid length of an App ID in characters = 64.Method Summary
Modifier and TypeMethodDescriptionboolean
addDisposeListener
(IServerDisposeListener listener) Adds a server dispose.addEndPointListener
(IEndPointListener listener) Adds a listener of end point create/dispose and retrieves the list of current end points.boolean
addModule
(IServerModule<?> module) Adds a server module for processing.boolean
dispose()
Disposes of the server, e.g.Gets the default mail sender.Gets an array of all end points.getMailSender
(String name) Gets the default mail sender.Gets the web server root directory.Gets the Server Properties.getState()
Gets the state of the server.The transaction processor coordinator.void
Called to load the application.void
onEndPointDisposed
(IEndPoint endPoint) Called when an end point is disposed of.void
Processes server start-up asynchronously.registerApplication
(String id, AppDefinition app) Registers an application with an ID available in the server.boolean
registerRequestPrinter
(String target, IWebServerRequestPrinter processor) Registers a new request printer.boolean
removeDisposeListener
(IServerDisposeListener listener) Removes a server dispose listener.boolean
removeEndPointListener
(IEndPointListener listener) Adds a listener of end point create/dispose and retrieves the list of current end points.boolean
removeModule
(IServerModule<?> module) Removes a server module for processing.void
Starts the server synchronously.boolean
unregisterRequestPrinter
(String target, IWebServerRequestPrinter processor) Unregister a previously registered request printer.static IServer.InvalidAppID
validateAppID
(String id) Checks an App ID for validity.Methods inherited from interface com.iizix.server.IAppLoader
getExecutorService, getPropertyManager, loadFile, loadFile, loadPlugins
Field Details
MAX_VALID_APP_ID_LENGTH
static final int MAX_VALID_APP_ID_LENGTHThe maximum valid length of an App ID in characters = 64.- See Also:
Method Details
validateAppID
Checks an App ID for validity.Valid App ID's are the characters A-Z, a-z, 0-9, and the characters
._
, where the first character must be A-Z or a-z. App ID's are case sensitive. The maximum length of an App ID is 64 characters.- Parameters:
id
- The application ID.- Returns:
- The
IServer.InvalidAppID
instance of the error, ornull
for valid.
addDisposeListener
Adds a server dispose. Calling this method multiple times with the same listener will have no effect (but to return false).- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeDisposeListener
Removes a server dispose listener.- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
startServer
Starts the server synchronously.- Throws:
Throwable
- for start-up errors.
onStartServer
Processes server start-up asynchronously.- Throws:
Throwable
- for start-up errors.
loadApplications
Called to load the application.- Throws:
Throwable
- for start-up errors.
registerApplication
AppDefinition registerApplication(String id, AppDefinition app) throws ServerApplicationSetupException Registers an application with an ID available in the server.- 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.
dispose
boolean dispose()Disposes of the server, e.g. at shut-down. This dispose call will wait until the server has shut-down successfully.- Returns:
- true for success, false if already disposed of or stopping/disposing.
getState
IServer.State getState()Gets the state of the server.- Returns:
- The server state: STARTING, STARTED, STOPPING or STOPPED.
getServerProperties
ServerProps getServerProperties()Gets the Server Properties.getDefaultMailSender
MailSender getDefaultMailSender() throws NotFoundException, AddressException, NoSuchProviderException, IOExceptionGets the default mail sender.- 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
MailSender getMailSender(String name) throws NotFoundException, AddressException, NoSuchProviderException, IOException Gets the default mail sender.- 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.
addModule
Adds a server module for processing. The module can have an end point constructor that is added during initialization.- Parameters:
module
- The server module.- Returns:
- true for success, false if already added.
removeModule
Removes a server module for processing. This will unregister a potential end point constructor and dispose of the module.- Parameters:
module
- The server module.- Returns:
- true for success, false if already removed.
getEndPointsInstances
IEndPoint[] getEndPointsInstances()Gets an array of all end points. Avoid this method as it causes unnecessary garbage collection, use getEndPointsCollection instead.- Returns:
- an array of EndPoint instances.
onEndPointDisposed
Called when an end point is disposed of.addEndPointListener
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 callinggetEndPointInstances()
.- Parameters:
listener
- The end point listener.- Returns:
- An array of EndPoint instances.
removeEndPointListener
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 callinggetEndPointInstances()
.- Parameters:
listener
- The end point listener.- Returns:
- true for success, false if not added as listener.
getTXPCoordinator
ITXPCoordinator getTXPCoordinator()The transaction processor coordinator.getRootDirectory
String getRootDirectory()Gets the web server root directory.- Returns:
- The directory, or null if web server is not started.
registerRequestPrinter
Registers a new request printer.- 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
Unregister a previously registered request printer.- 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.