Package com.iizix.server
Interface IServer
- All Superinterfaces:
IAppLoader
- All Known Implementing Classes:
JakartaEEServer,JettyRunConfiguration,RuntimeBuilderServer,ServerShell,StandardServer
public interface IServer extends IAppLoader
The interface to the Server instance, whether running in a J2EE Application Server or stand-alone using another web server and/or WebSocket implementation.
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIServer.StateStates of the server.
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddDisposeListener(IServerDisposeListener listener)Adds a server dispose.IEndPoint[]addEndPointListener(IEndPointListener listener)Adds a listener of end point create/dispose and retrieves the list of current end points.booleanaddModule(IServerModule<?> module)Adds a server module for processing.booleandispose()Disposes of the server, e.g.MailSendergetDefaultMailSender()Gets the default mail sender.IEndPoint[]getEndPointsInstances()Gets an array of all end points.MailSendergetMailSender(java.lang.String name)Gets the default mail sender.java.lang.StringgetRootDirectory()Gets the web server root directory.ServerPropsgetServerProperties()Gets the Server Properties.IServer.StategetState()Gets the state of the server.ITXPCoordinatorgetTXPCoordinator()The transaction processor coordinator.voidloadApplications()Called to load the application.voidonEndPointDisposed(IEndPoint endPoint)Called when an end point is disposed of.voidonStartServer()Processes server start-up asynchronously.AppDefinitionregisterApplication(java.lang.String id, AppDefinition app)Registers an application with an ID available in the server.booleanregisterRequestPrinter(java.lang.String target, IWebServerRequestPrinter processor)Registers a new request printer.booleanremoveDisposeListener(IServerDisposeListener listener)Removes a server dispose listener.booleanremoveEndPointListener(IEndPointListener listener)Adds a listener of end point create/dispose and retrieves the list of current end points.booleanremoveModule(IServerModule<?> module)Removes a server module for processing.voidstartServer()Starts the server synchronously.booleanunregisterRequestPrinter(java.lang.String target, IWebServerRequestPrinter processor)Unregister a previously registered request printer.Methods inherited from interface com.iizix.server.IAppLoader
getExecutorService, getPropertyManager, loadFile, loadFile, loadPlugins
Method Detail
addDisposeListener
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).- Parameters:
listener- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
java.lang.NullPointerException- If the listener isnull.
removeDisposeListener
boolean removeDisposeListener(IServerDisposeListener listener)
Removes a server dispose listener.- Parameters:
listener- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
startServer
void startServer() throws java.lang.ThrowableStarts the server synchronously.- Throws:
java.lang.Throwable- for start-up errors.
onStartServer
void onStartServer() throws java.lang.ThrowableProcesses server start-up asynchronously.- Throws:
java.lang.Throwable- for start-up errors.
loadApplications
void loadApplications() throws java.lang.ThrowableCalled to load the application.- Throws:
java.lang.Throwable- for start-up errors.
registerApplication
AppDefinition registerApplication(java.lang.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, java.io.IOException
Gets the default mail sender.- Returns:
- The default mail sender.
- Throws:
NotFoundException- If the mail sender is not found.java.io.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(java.lang.String name) throws NotFoundException, AddressException, NoSuchProviderException, java.io.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.java.io.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
boolean addModule(IServerModule<?> module)
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
boolean removeModule(IServerModule<?> module)
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
void onEndPointDisposed(IEndPoint endPoint)
Called when an end point is disposed of.
addEndPointListener
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 callinggetEndPointInstances().- Parameters:
listener- The end point listener.- Returns:
- An array of EndPoint instances.
removeEndPointListener
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 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
java.lang.String getRootDirectory()
Gets the web server root directory.- Returns:
- The directory, or null if web server is not started.
registerRequestPrinter
boolean registerRequestPrinter(java.lang.String target, IWebServerRequestPrinter processor)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
boolean unregisterRequestPrinter(java.lang.String target, IWebServerRequestPrinter processor)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.