Package helma.main
Class Server
- java.lang.Object
-
- helma.main.Server
-
- All Implemented Interfaces:
java.lang.Runnable
public class Server extends java.lang.Object implements java.lang.Runnable
Helma server main class.
-
-
Constructor Summary
Constructors Constructor Description Server(ServerConfig config)
Constructs a new Server instance with an array of command line options.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkAppManager()
Make sure this server has an ApplicationManager (e.g.static void
checkJavaVersion()
check if we are running on a Java 2 VM - otherwise exit with an error messagestatic void
checkRunning(ServerConfig config)
Check wheter a server is already running on any of the given ports - otherwise exit with an error messageApplication
getApplication(java.lang.String name)
Get an Application by namejava.lang.Object[]
getApplications()
Get an Iterator over the applications currently running on this Server.java.lang.String[]
getApplicationsOption()
Get the explicit list of apps if started with -a optionjava.io.File
getAppsHome()
ResourceProperties
getAppsProperties(java.lang.String appName)
Return the apps.properties entries for a given applicationstatic ServerConfig
getConfig(java.lang.String[] args)
parse the command line arguments, read a given server.properties file and check the values given for server portsjava.io.File
getDbHome()
ResourceProperties
getDbProperties()
Return the server-wide db.propertiesjava.util.Vector
getExtensions()
java.io.File
getHopHome()
Get the Home directory of this server.org.apache.commons.logging.Log
getLogger()
Get a logger to use for output in this server.ResourceProperties
getProperties()
Return the server.properties for this serverjava.lang.String
getProperty(java.lang.String key)
static Server
getServer()
Get the main Server instance.static org.apache.xmlrpc.WebServer
getXmlRpcServer()
Get the Server's XML-RPC web server.static void
guessConfig(ServerConfig config)
get main property file from home dir or vice versa, depending on what we havevoid
init()
initialize the serverstatic Server
loadServer(java.lang.String[] args)
Entry point used by launcher.jar to load a server instancestatic void
main(java.lang.String[] args)
Static main entry point.static void
parseArgs(ServerConfig config, java.lang.String[] args)
parse argument list from command line and store values in given ServerConfig objectstatic void
printUsageError()
print the usage hintsstatic void
printUsageError(java.lang.String msg)
print the usage hints and prefix them with a message.void
run()
The main method of the Server.void
shutdown()
void
start()
void
startApplication(java.lang.String name)
void
stop()
void
stopApplication(java.lang.String name)
-
-
-
Field Detail
-
version
public static final java.lang.String version
- See Also:
- Constant Field Values
-
hopHome
protected java.io.File hopHome
-
starttime
public final long starttime
-
paranoid
public boolean paranoid
-
jetty
protected JettyServer jetty
-
xmlrpc
protected org.apache.xmlrpc.WebServer xmlrpc
-
-
Constructor Detail
-
Server
public Server(ServerConfig config)
Constructs a new Server instance with an array of command line options. TODO make this a singleton- Parameters:
config
- the configuration
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
Static main entry point.- Parameters:
args
- the command line arguments- Throws:
java.io.IOException
-
loadServer
public static Server loadServer(java.lang.String[] args)
Entry point used by launcher.jar to load a server instance- Parameters:
args
- the command line arguments- Returns:
- the server instance
-
checkJavaVersion
public static void checkJavaVersion()
check if we are running on a Java 2 VM - otherwise exit with an error message
-
getConfig
public static ServerConfig getConfig(java.lang.String[] args) throws java.lang.Exception
parse the command line arguments, read a given server.properties file and check the values given for server ports- Returns:
- ServerConfig if successfull
- Throws:
java.lang.Exception
- on any configuration error
-
parseArgs
public static void parseArgs(ServerConfig config, java.lang.String[] args) throws java.lang.Exception
parse argument list from command line and store values in given ServerConfig object- Throws:
java.lang.Exception
- when argument can't be parsed into an InetAddrPort or invalid token is given.
-
guessConfig
public static void guessConfig(ServerConfig config) throws java.lang.Exception
get main property file from home dir or vice versa, depending on what we have- Throws:
java.lang.Exception
-
printUsageError
public static void printUsageError(java.lang.String msg)
print the usage hints and prefix them with a message.
-
printUsageError
public static void printUsageError()
print the usage hints
-
checkRunning
public static void checkRunning(ServerConfig config)
Check wheter a server is already running on any of the given ports - otherwise exit with an error message
-
init
public void init() throws java.io.IOException
initialize the server- Throws:
java.io.IOException
-
start
public void start()
-
stop
public void stop()
-
shutdown
public void shutdown()
-
run
public void run()
The main method of the Server. Basically, we set up Applications and than periodically check for changes in the apps.properties file, shutting down apps or starting new ones.- Specified by:
run
in interfacejava.lang.Runnable
-
checkAppManager
public void checkAppManager()
Make sure this server has an ApplicationManager (e.g. used when accessed from CommandlineRunner)
-
getApplications
public java.lang.Object[] getApplications()
Get an Iterator over the applications currently running on this Server.
-
getApplication
public Application getApplication(java.lang.String name)
Get an Application by name
-
getLogger
public org.apache.commons.logging.Log getLogger()
Get a logger to use for output in this server.
-
getHopHome
public java.io.File getHopHome()
Get the Home directory of this server.
-
getApplicationsOption
public java.lang.String[] getApplicationsOption()
Get the explicit list of apps if started with -a option- Returns:
-
getServer
public static Server getServer()
Get the main Server instance.
-
getXmlRpcServer
public static org.apache.xmlrpc.WebServer getXmlRpcServer()
Get the Server's XML-RPC web server.
-
getProperty
public java.lang.String getProperty(java.lang.String key)
- Parameters:
key
- ...- Returns:
- ...
-
getProperties
public ResourceProperties getProperties()
Return the server.properties for this server- Returns:
- the server.properties
-
getDbProperties
public ResourceProperties getDbProperties()
Return the server-wide db.properties- Returns:
- the server-wide db.properties
-
getAppsProperties
public ResourceProperties getAppsProperties(java.lang.String appName)
Return the apps.properties entries for a given application- Parameters:
appName
- the app name- Returns:
- the apps.properties subproperties for the given app
-
getAppsHome
public java.io.File getAppsHome()
- Returns:
- ...
-
getDbHome
public java.io.File getDbHome()
- Returns:
- ...
-
getExtensions
public java.util.Vector getExtensions()
- Returns:
- ...
-
startApplication
public void startApplication(java.lang.String name)
- Parameters:
name
- ...
-
stopApplication
public void stopApplication(java.lang.String name)
- Parameters:
name
- ...
-
-