|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.application.Server
public abstract class Server
Base class for all servers and applications developed by project OpenSubsystems. TODO: Improve: At present moment this server is tightly integrated with Jetty HTTP server mainly because it is easily embeddble. Once there is a need to support multiple servers, it can be abstracted through an intermediate interface with multiple imlementations. That's the main reason why is this class not derived from the Jetty server class but it is using it instead. The lifecycle of the server is Constructor, init(), start(). The derived classes should just declare their own main method, construct the derived Server object and call startServer on it: ExampleServer srvServer; srvServer = new ExampleServer(); startServer(srvServer); The web applications which should be run on the server should be configured by overriding addWebApplications method.
| Field Summary | |
|---|---|
protected boolean |
m_bStarted
This flag is true if the server is started. |
protected org.mortbay.http.HttpServer |
m_hsServer
Web container used by this server. |
protected int |
m_iWebServerPort
Port where this web server should start. |
protected static int |
s_iMaxServerStartRetry
How many try we will try to restart the server if specified port cannot be used as initialized from configuration file. |
static java.lang.String |
SERVER_START_RETRYCOUNT
Name of the property specifying how many times we should try to restart the embedded web server if it cannot be started at the port specified by oss.webserver.port. |
static int |
SERVER_START_RETRYCOUNT_DEFAULT
How many try we will try to restart the server if specified port cannot be used. |
| Constructor Summary | |
|---|---|
Server(ProductInfo product)
Create new instance of the server. |
|
| Method Summary | |
|---|---|
protected abstract void |
addWebApplications(org.mortbay.http.HttpServer hsServer)
Install web applications which should be run on the server. |
protected static int |
generateNewWebPort(int iOldPort)
Generate new port number where to start the server if the old one failed. |
int |
getWebServerPort()
Get the web server port. |
void |
init()
Initialize the server. |
protected void |
initContext(java.lang.String strURLPrefix,
org.mortbay.jetty.servlet.WebApplicationContext wacContext)
Initialize context (URL subtree) starting with given prefix. |
boolean |
isStarted()
Test if the server is started. |
void |
setWebServerPort(int iWebServerPort)
Set the web server port. |
void |
start()
Start the server. |
protected static void |
startServer(Server srvServer)
Start specified server. |
void |
stop()
Stop the server. |
protected static void |
stopServer(Server srvServer)
Stop specified server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SERVER_START_RETRYCOUNT
s_iMaxServerStartRetry,
SERVER_START_RETRYCOUNT_DEFAULT,
Constant Field Valuespublic static final int SERVER_START_RETRYCOUNT_DEFAULT
SERVER_START_RETRYCOUNT,
s_iMaxServerStartRetry,
Constant Field Valuesprotected int m_iWebServerPort
protected org.mortbay.http.HttpServer m_hsServer
protected boolean m_bStarted
protected static int s_iMaxServerStartRetry
SERVER_START_RETRYCOUNT,
SERVER_START_RETRYCOUNT_DEFAULT,
s_iMaxServerStartRetry| Constructor Detail |
|---|
public Server(ProductInfo product)
product - - information about product which is running this server,
this way we will force every application to create and
publish this information in uniform way| Method Detail |
|---|
public int getWebServerPort()
public void setWebServerPort(int iWebServerPort)
iWebServerPort - - new web server port
public void init()
throws OSSException,
java.io.IOException
OSSException - - if there was an error starting persistance store
java.io.IOException - - if there was an error accessing database properties
public void start()
throws org.mortbay.util.MultiException,
OSSException
org.mortbay.util.MultiException - - if there was an error starting the server
OSSException - - if there was an error starting the serverpublic boolean isStarted()
public void stop()
throws OSSException,
java.lang.InterruptedException
OSSException - - if there was en error stopping persistance store
java.lang.InterruptedException - - if the server was stopped
protected static void startServer(Server srvServer)
throws OSSException
srvServer - - server to start
OSSException - - problem starting server
OSSException - - problem initializing the server
protected static void stopServer(Server srvServer)
throws OSSException
srvServer - - server to stop
OSSException - - problem stopping serverprotected static int generateNewWebPort(int iOldPort)
iOldPort - - old port number which cannot be used
protected abstract void addWebApplications(org.mortbay.http.HttpServer hsServer)
hsServer - - HTTP server to install the applications to
protected void initContext(java.lang.String strURLPrefix,
org.mortbay.jetty.servlet.WebApplicationContext wacContext)
strURLPrefix - - URL prefix which all requests to resources
in this context will have.wacContext - - context to setup
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||