|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.symcomp.scscp.C3PO
public abstract class C3PO
A class to encapsulate an SCSCP-Server. To set up an SCSCP server that can compute mathematical expressions that are given in OpenMath form, the SCSCP-protocol needs to be implemented. This class takes care of all the protocol stuff. To set up an SCSCP server this class needs to be subclassed and the methods
compute,getServiceName, andgetServiceVersion Whilst the latter are self-explanatory, the compute method does the actual
work. Here, some call to an CAS/a Library or something similar should be inserted which
ought to translate the incomin OpenMath-xml string to another OpenMath-xml string.
| Field Summary | |
|---|---|
protected java.io.BufferedReader |
inn
|
protected static java.lang.Integer |
loglevel
|
protected java.io.PrintWriter |
out
|
protected java.lang.String |
scscpVersion
|
protected java.lang.String |
serviceId
|
protected java.lang.Integer |
state
|
protected java.util.LinkedList<java.lang.String> |
waitingComputations
|
| Constructor Summary | |
|---|---|
C3PO()
|
|
C3PO(java.lang.String serviceId,
java.io.PrintWriter out,
java.io.BufferedReader inn)
Construct a C3PO-instance that reads its iputs from inn and writes its
results to out. |
|
| Method Summary | |
|---|---|
static boolean |
announceRendevouz(int port,
java.lang.String name,
java.lang.String description)
Used to announce the existence of this Server to the world |
static void |
breed(java.lang.Class clazz,
int port)
Does exactly the same as spawn but the listening on port
port is not done in a seperate thread, so that breed
blocks. |
protected void |
cleanup()
The "destructor" that is called when communication is done, for any reason. |
abstract java.lang.String |
compute(java.lang.String input)
Public method that does the actual computation. |
java.lang.String |
getServiceDescription()
Returns the description of the SCSCP-server. |
java.lang.String |
getServiceName()
Returns the name of the SCSCP-server. |
java.lang.String |
getServiceVersion()
Returns the version of the SCSCP-server. |
protected static void |
log(java.lang.Integer l,
java.lang.String msg)
just for logging, quick hack, to be replaced by something better. |
protected static void |
logStackTrace(java.lang.Integer l,
java.lang.Exception e)
just for logging, quick hack, to be replaced by something better. |
protected void |
receivedInfo(java.lang.String s)
Method that is called when scscp info is received; simply prints a message. |
protected void |
receivedTerminateRequest(java.lang.String callID)
Method that is called when a terminate request is received; simply prints a message |
protected void |
receivedTerminateRequestInternal(java.lang.String callID)
Method that is called when a terminate request is received; simply prints a message |
void |
run()
The run-loop which is called for a session. |
static void |
setLoglevel(java.lang.Integer l)
for logging, 0 is no output, 5 is a lot. |
static void |
spawn(java.lang.Class clazz,
int port)
Listens on Port port, then for each incoming connection, it
instantiates Class clazz and starts it run-loop in a new thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.Integer state
protected java.lang.String scscpVersion
protected java.io.PrintWriter out
protected java.io.BufferedReader inn
protected java.lang.String serviceId
protected java.util.LinkedList<java.lang.String> waitingComputations
protected static java.lang.Integer loglevel
| Constructor Detail |
|---|
public C3PO(java.lang.String serviceId,
java.io.PrintWriter out,
java.io.BufferedReader inn)
inn and writes its
results to out.
serviceId - the name of the SCSCP Serverout - the PrintWriter to which the SCSCP Server prints its output.inn - the BufferedReader from which the SCSCP Server reads its input.public C3PO()
| Method Detail |
|---|
public static void breed(java.lang.Class clazz,
int port)
throws java.lang.Exception
spawn but the listening on port
port is not done in a seperate thread, so that breed
blocks.
clazz - the actual class whiss shall be instantiatedport - the port on which the server shall listen
java.lang.Exception
public static void spawn(java.lang.Class clazz,
int port)
throws java.lang.Exception
port, then for each incoming connection, it
instantiates Class clazz and starts it run-loop in a new thread.
spawn immediately returns, internally instanziating
ScscspSpawner and starting it th a new thread.
clazz - the actual class whiss shall be instantiatedport - the port on which the server shall listen
java.lang.Exceptionpublic void run()
run in interface java.lang.Runnableprotected void cleanup()
public abstract java.lang.String compute(java.lang.String input)
This method needs to be overridden in any subclass.
input - a String that contains an OpenMath-xml string
protected void receivedTerminateRequest(java.lang.String callID)
This method may be overridden in a subclass.
callID - the callID of the call that could be terminatedprotected void receivedTerminateRequestInternal(java.lang.String callID)
This method may be overridden in a subclass, but one needs to call super.receivedTerminateRequestInternal if that's done.
callID - the callID of the call that could be terminatedprotected void receivedInfo(java.lang.String s)
This method may be overridden in a subclass.
s - the string of info receivedpublic java.lang.String getServiceName()
This string is needed for the <?scscp ?>-hello-message. The value must be set via the ScscspServerInfo Annotation
public java.lang.String getServiceVersion()
This string is needed for the <?scscp ?>-hello-message. The value must be set via the ScscspServerInfo Annotation
public java.lang.String getServiceDescription()
public static boolean announceRendevouz(int port,
java.lang.String name,
java.lang.String description)
port - The Port on which the server runsname - the name of the serverdescription - some description
public static void setLoglevel(java.lang.Integer l)
protected static void log(java.lang.Integer l,
java.lang.String msg)
protected static void logStackTrace(java.lang.Integer l,
java.lang.Exception e)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||