|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--galaxy.server.Server
This is the base class for all Galaxy servers implemented in Java. It implements the basic message loop, logging, and the symbolic invocation of the dispatch function defined in the received frame.
You can add a ServerListener
to receive notification of Server
events.
MainServer
,
ServerListener
Field Summary | |
protected MainServer |
mainServer
Reference to the MainServer that started this server. |
Constructor Summary | |
Server(MainServer mainServer,
java.net.Socket socket)
Creates a new server. |
|
Server(MainServer mainServer,
java.net.Socket socket,
java.lang.String sessionId,
java.lang.String name)
Deprecated. As of Galaxy Communicator 3.0. Use Server(MainServer, Socket) constructor. |
Method Summary | |
protected void |
addContinuationData(int serverTidx,
ContinuationData data)
Stores continuation data associated with a server token index. |
void |
addServerListener(ServerListener listener)
|
void |
addServiceType(java.lang.String serviceType)
Adds a service type to this server's lists of supported service types if it is not already in the list. |
protected void |
addSignature(Signature sig)
Adds new signature information for this server. |
protected void |
cleanup()
This cleanup method is called when this server is preparing to stop. |
protected void |
deleteServerProperties(java.lang.String[] keys)
Deletes the specified server properties. |
protected GFrame |
dispatchFrame(GFrame frame)
Deprecated. As of Galaxy Communicator 3.0. Use Environment.dispatchFrame. |
protected GVector |
encodeSignatures()
Encodes this server's signature information in a GVector . |
protected GFrame |
evaluateHubFrame(GFrame frame)
Evaluates the Hub frame. |
protected ContinuationData |
getContinuationData(int serverTidx)
Gets the continuation data associated with a server token index. |
Environment |
getCopyOfCurrentEnvironment()
Returns a copy of this server's current execution environment. |
Environment |
getCurrentEnvironment()
Returns this server current execution environment. |
java.lang.String |
getHostAddress()
Gets the host address for this server's local host. |
int |
getHubContactPolicy()
Gets the Hub contact policy (used if this server is a Hub client). |
java.net.InetAddress |
getIPAddress()
Gets the internet address information for this server's local host. |
MainServer |
getMainServer()
Returns the reference to the MainServer that started this
server. |
GFrame |
getServerProperties()
Gets this server's properties. |
GVector |
getServiceTypes()
Gets the service types supported by this server. |
java.lang.String |
getSessionId()
Gets the session id. |
protected Signature |
getSignature(java.lang.String op)
Gets the signature information associated with an operation on this server's interface |
boolean |
getValidate()
Gets the value of the method signature validation flag. |
void |
init()
Called before server starts. |
boolean |
isRunning()
Indicates if this server's thread is marked as running or stopped. |
void |
log(java.lang.String msg)
|
protected void |
logAndSendError(java.lang.String msg)
Logs an error message locally (if enabled) and sends it to the Hub. |
protected void |
logAndSendError(java.lang.String msg,
int errno)
|
void |
logError(java.lang.String msg)
|
void |
logError(java.lang.String msg,
java.lang.Exception ex)
|
void |
logFatalError(java.lang.String msg)
|
void |
logFatalError(java.lang.String msg,
java.lang.Exception ex)
|
void |
logWarning(java.lang.String msg)
|
protected void |
register(DataOutBroker broker)
Deprecated. As of Galaxy Communicator 3.0. Use registerOutBroker. |
protected void |
registerOutBroker(DataOutBroker broker)
Registers an outgoing broker that was started by this server. |
void |
removeServerListener(ServerListener listener)
|
void |
run()
This implements the basic message loop. |
void |
serverOpReinitialize(GFrame frame)
Subclasses of Server typically override this method in
order to provide custom reinitialization. |
void |
setHubContactPolicy(int hubContactPolicy)
Sets the Hub contact policy (used if this server is a Hub client). |
protected void |
setServerProperties(GFrame props)
Sets the specified server properties. |
void |
setValidate(boolean validate)
Sets the method signature validation flag. |
void |
stop()
Marks this server's thread as being stopped. |
protected boolean |
unregister(DataOutBroker broker)
Deprecated. As of Galaxy Communicator 3.0. Use unregisterOutBroker. |
protected boolean |
unregisterOutBroker(DataOutBroker broker)
Unregisters an outgoing broker that was started by this server. |
protected boolean |
wasHubContactPolicyModified()
Tests if this server's Hub contact policy has been modified since the the server was created. |
void |
writeDestroyMessage()
Deprecated. As of Galaxy Communicator 3.0. Use Environment.destroyToken. |
void |
writeErrorMessage(ErrorMessage msg)
Deprecated. As of Galaxy Communicator 3.0. Use Environment.error. |
void |
writeFrame(GFrame frame)
Deprecated. As of Galaxy Communicator 3.0. Use Environment.writeFrame. |
void |
writeMessage(GalaxyMessage msg)
Deprecated. As of Galaxy Communicator 3.0. Use Environment methods (error, destroyToken, reply, writeFrame). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected MainServer mainServer
MainServer
that started this server.Constructor Detail |
public Server(MainServer mainServer, java.net.Socket socket) throws java.io.IOException
mainServer
- the MainServer
that created this serversocket
- the socket connection to the Hubpublic Server(MainServer mainServer, java.net.Socket socket, java.lang.String sessionId, java.lang.String name) throws java.io.IOException
Method Detail |
public void init() throws java.lang.Exception
public void setValidate(boolean validate)
validate
- true if validation should be done, false otherwisepublic boolean getValidate()
public java.net.InetAddress getIPAddress()
public java.lang.String getHostAddress()
public Environment getCurrentEnvironment()
public Environment getCopyOfCurrentEnvironment()
public MainServer getMainServer()
MainServer
that started this
server.MainServer
public GFrame getServerProperties()
protected void setServerProperties(GFrame props)
props
- the properties to setprotected void deleteServerProperties(java.lang.String[] keys)
keys
- the keys of the properties to deletepublic void addServiceType(java.lang.String serviceType)
serviceType
- the service type to addpublic GVector getServiceTypes()
public void setHubContactPolicy(int hubContactPolicy)
hubContactPolicy
- the policyprotected boolean wasHubContactPolicyModified()
public int getHubContactPolicy()
public java.lang.String getSessionId()
protected void register(DataOutBroker broker)
protected void registerOutBroker(DataOutBroker broker)
broker
- the brokerprotected boolean unregister(DataOutBroker broker)
protected boolean unregisterOutBroker(DataOutBroker broker)
broker
- the brokerpublic void stop()
public boolean isRunning()
protected void cleanup()
Server
cleanup will still take place.public void run()
run
in interface java.lang.Runnable
evaluateHubFrame(galaxy.lang.GFrame)
protected ContinuationData getContinuationData(int serverTidx)
serverTidx
- the server token index associated with the
continuationprotected void addContinuationData(int serverTidx, ContinuationData data)
serverTidx
- the server token index associated with the
continuationdata
- the continuation dataprotected void addSignature(Signature sig)
sig
- the signature informationprotected Signature getSignature(java.lang.String op)
op
- the name of the operationprotected GVector encodeSignatures()
GVector
.protected GFrame evaluateHubFrame(GFrame frame)
op_name
property
is extracted from the frame and the method name formed by prepending
serverOp
when it is called.
For example, if serverOp
is explode
, then the
method serverOpExplode
will be called.public void serverOpReinitialize(GFrame frame)
Server
typically override this method in
order to provide custom reinitialization.protected GFrame dispatchFrame(GFrame frame) throws DispatchError
frame
- the frame to dispatchpublic void writeFrame(GFrame frame)
frame
- the frame to sendpublic void writeMessage(GalaxyMessage msg)
public void writeErrorMessage(ErrorMessage msg)
public void writeDestroyMessage()
public void addServerListener(ServerListener listener)
public void removeServerListener(ServerListener listener)
public void log(java.lang.String msg)
public void logWarning(java.lang.String msg)
public void logError(java.lang.String msg)
public void logError(java.lang.String msg, java.lang.Exception ex)
public void logFatalError(java.lang.String msg)
public void logFatalError(java.lang.String msg, java.lang.Exception ex)
protected void logAndSendError(java.lang.String msg)
msg
- the description of the errorprotected void logAndSendError(java.lang.String msg, int errno) throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |