Package ch.autumo.beetroot.server
Class BaseServer
java.lang.Object
ch.autumo.beetroot.server.BaseServer
- Direct Known Subclasses:
BeetRootServer
Base server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classHelp class for shell script. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Stringprotected static Stringprotected static final org.slf4j.Loggerprotected Stringprotected ServerSocketFactoryDefault or SSL.protected booleanprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidOverwrite to do something after starting the server.protected abstract voidOverwrite to do something after stopping the server.protected abstract booleanOverwrite to do something before starting the server.protected abstract voidOverwrite to do something before stopping the server.protected voidcustomOperation(String operation, String[] params) Custom operation has been defined when starting the server, we possibly want to do something else.protected booleanInternal delete method if no file-storage has been configuredprotected DownloadInternal find-file method if no file-storage has been configuredGet argument help text.protected static StringGet root path of this server.Get server name.protected ThreadOS shutdown hook.protected String[]Return a list of valid custom operationsprotected voidinitializeLogging(String logCfgFile) Initialize logging.protected booleanprintHealthStatus(boolean hasNoIssues) Prints out the health status of this server.processServerCommand(ServerCommand command) This method is called when a server command has been received.protected voidsendServerCommand(ServerCommand command) You can send local server commands to be send to the running server for possible custom operations.protected voidStart server and web server if configured.protected voidStop server and web server if configured.protected StringInternal file-store method if no file-storage has been configured
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
serverSocketFactory
Default or SSL. -
startFileServer
protected boolean startFileServer -
startWebServer
protected boolean startWebServer -
name
-
ansiServerName
-
ansiErrServerName
-
-
Constructor Details
-
BaseServer
Create a base server.- Parameters:
params- start or stop
-
-
Method Details
-
initializeLogging
Initialize logging. Can be overwritten.- Parameters:
logCfgFile- logging config file
-
getHelpText
Get argument help text.- Returns:
- argument help text
-
getServerName
Get server name.- Returns:
- server name
-
getRootPath
Get root path of this server.- Returns:
- root path
-
startServer
protected void startServer()Start server and web server if configured. -
stopServer
protected void stopServer()Stop server and web server if configured. -
delete
Internal delete method if no file-storage has been configured. -> Must be overwritten if this internal module is used.- Parameters:
uniqueFileId- unique file IDdomain- domain or null- Returns:
- true if at least one (of all versions) has been found and deleted
- Throws:
Exception- exception
-
findFile
Internal find-file method if no file-storage has been configured. -> Must be overwritten if this internal module is used.- Parameters:
uniqueFileId- unique file IDdomain- domain or null- Returns:
- Download for the server to queue
- Throws:
Exception- exception
-
store
Internal file-store method if no file-storage has been configured. -> Must be overwritten if this internal module is used.- Parameters:
file- filename- file nameuser- user or nulldomain- domain or null (default)- Returns:
- unique file ID
- Throws:
Exception- exception
-
getShutDownHook
OS shutdown hook. Don't overwrite this, unless you know exactly what you are doing. This implementation calls all methods necessary to properly stop the server.- Returns:
- thread for runtime shutdown hook.
-
sendServerCommand
You can send local server commands to be send to the running server for possible custom operations. You might want to force them over sockets, seeServerCommand.forceSockets().- Parameters:
command- server command
-
getValidCustomOperations
Return a list of valid custom operations- Returns:
- custom operations possible
-
customOperation
Custom operation has been defined when starting the server, we possibly want to do something else. Overwrite if needed. Of you overwrite, you have to implementcustomOperation(String, String[])!- Parameters:
operation- the operation = params[0], 1st argument of all program argumentsparams- all program arguments
-
processServerCommand
This method is called when a server command has been received. At this point security checks have been made. Usually mustn't be overwritten, because configured module/component dispatchers do the work beside internal commands.- Parameters:
command- received server command- Returns:
- client answer
-
beforeStart
protected abstract boolean beforeStart()Overwrite to do something before starting the server. Handle exceptions by your own!- Returns:
- true id server should be started, otherwise false; e.g. a pre-condition is not met
-
afterStart
protected abstract void afterStart()Overwrite to do something after starting the server. Handle exceptions by your own! -
beforeStop
protected abstract void beforeStop()Overwrite to do something before stopping the server. Handle exceptions by your own! -
afterStop
protected abstract void afterStop()Overwrite to do something after stopping the server. Handle exceptions by your own! -
printHealthStatus
protected boolean printHealthStatus(boolean hasNoIssues) Prints out the health status of this server. Overwrite if necessary.- Parameters:
hasNoIssues- any pre-existing issues for the overall state; false if there are issues!- Returns:
- overall state, true if good
-