Package helma.main

# Class Server

java.lang.Object
helma.main.Server

All Implemented Interfaces:
  `Runnable`

public class Server extends Object implements Runnable
Helma server main class.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`buildDate`
`static final String`
`commitHash`
`protected File`
`hopHome`
`protected JettyServer`
`jetty`
`boolean`
`paranoid`
`final long`
`starttime`
`static final String`
`version`
`protected org.apache.xmlrpc.WebServer`
`xmlrpc`

## Constructor Summary

Constructors
Constructor
Description
`Server(ServerConfig config)`
Constructs a new Server instance with an array of command line options.

## Method Summary

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 message
`static void`
`checkRunning(ServerConfig config)`
Check wheter a server is already running on any of the given ports - otherwise exit with an error message
`Application`
`getApplication(String name)`
Get an Application by name
`Object[]`
`getApplications()`
Get an Iterator over the applications currently running on this Server.
`String[]`
`getApplicationsOption()`
Get the explicit list of apps if started with -a option
`File`
`getAppsHome()`
`ResourceProperties`
`getAppsProperties(String appName)`
Return the apps.properties entries for a given application
`static ServerConfig`
`getConfig(String[] args)`
parse the command line arguments, read a given server.properties file and check the values given for server ports
`File`
`getDbHome()`
`ResourceProperties`
`getDbProperties()`
Return the server-wide db.properties
`Vector`
`getExtensions()`
`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 server
`String`
`getProperty(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 have
`void`
`init()`
initialize the server
`static Server`
`loadServer(String[] args)`
Entry point used by launcher.jar to load a server instance
`static void`
`main(String[] args)`
Static main entry point.
`static void`
`parseArgs(ServerConfig config, String[] args)`
parse argument list from command line and store values in given ServerConfig object
`static void`
`printUsageError()`
print the usage hints
`static void`
`printUsageError(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(String name)`
`void`
`stop()`
`void`
`stopApplication(String name)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### version

public static final String version

See Also:
  - Constant Field Values

### buildDate

public static final String buildDate

See Also:
  - Constant Field Values

### commitHash

public static final String commitHash

See Also:
  - Constant Field Values

### hopHome

protected File hopHome

### starttime

public final long starttime

### paranoid

public boolean paranoid

### jetty

protected JettyServer jetty

### xmlrpc

protected org.apache.xmlrpc.WebServer xmlrpc

## Constructor Details

### 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 Details

### main

public static void main(String[] args) throws IOException
Static main entry point.

Parameters:
  `args` - the command line arguments
Throws:
  `IOException`

### loadServer

public static Server loadServer(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(String[] args) throws 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:
  `Exception` - on any configuration error

### parseArgs

public static void parseArgs(ServerConfig config, String[] args) throws Exception
parse argument list from command line and store values in given ServerConfig object

Throws:
  `Exception` - when argument can't be parsed into an InetAddrPort or invalid token is given.

### guessConfig

public static void guessConfig(ServerConfig config) throws Exception
get main property file from home dir or vice versa, depending on what we have

Throws:
  `Exception`

### printUsageError

public static void printUsageError(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 IOException
initialize the server

Throws:
  `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 interface `Runnable`

### checkAppManager

public void checkAppManager()
Make sure this server has an ApplicationManager (e.g. used when accessed from CommandlineRunner)

### getApplications

public Object[] getApplications()
Get an Iterator over the applications currently running on this Server.

### getApplication

public Application getApplication(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 File getHopHome()
Get the Home directory of this server.

### getApplicationsOption

public 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 String getProperty(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(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 File getAppsHome()

Returns:
  ...

### getDbHome

public File getDbHome()

Returns:
  ...

### getExtensions

public Vector getExtensions()

Returns:
  ...

### startApplication

public void startApplication(String name)

Parameters:
  `name` - ...

### stopApplication

public void stopApplication(String name)

Parameters:
  `name` - ...