public class MessageMediator extends java.lang.Thread implements BusDef, PublishSubscribeDef
Modifier and Type | Field and Description |
---|---|
protected ESB |
esb
The parent ESB server
|
protected MessageStore |
messageStore
Communication IDs to identify the calling components and replies
for stored method results.
|
protected MonitorServer |
monitorServer
To monitor the server resource allocation
|
protected PasswordHandler |
passwordHandler
The parent password handler
|
protected PublishSubscribeDef |
pubSub
The publish-subscribe facility for registering and notifying about service work.
|
Constructor and Description |
---|
MessageMediator(ESB theESB,
PasswordHandler thePasswordHandler,
MessageStore theMessageStore)
Create a new instance of MessageMediator.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelMessage(java.lang.String ticket)
Remove the message with the specified ticket number from the queue.
|
protected org.licas_xml.abs.Element |
executeServerService(java.lang.String serviceType,
MethodInfo methodInfo)
Execute a method on the server or a type of service owned by the server.
|
org.licas_xml.abs.Element |
executeServiceType(java.lang.String serviceType,
MethodInfo methodInfo)
Execute a synchronous method on a service type known by the server and probably stored locally.
|
void |
executeServiceTypeAsync(java.lang.String serviceType,
MethodInfo methodInfo)
Execute an asynchronous method on the server, or a service type owned by the server.
|
java.util.ArrayList<java.lang.String> |
getServiceNames()
Get a list of current services on the server that allow ptp comm.
|
java.util.ArrayList<java.lang.String> |
getServiceTypeNames(java.lang.String serviceType)
Get a list of current services on the server for a service type that allow subscribe comm.
|
java.lang.Object |
messageBus(MethodInfo methodInfo)
Execute a call on the system message bus.
|
boolean |
messageToBus(MessageInfo ro)
Add the message to the message bus queue for subsequent processing.
|
boolean |
publish(WorkInfo workInfo)
Publish to do work.
|
void |
run()
Run the thread loop to process the message bus queue.
|
boolean |
subscribe(WorkInfo workInfo)
Subscribe for a service.
|
void |
unpublish(KeywordInfo keyInfo,
org.licas_xml.abs.Element serviceURI)
Un-publish to do work.
|
void |
unsubscribe(KeywordInfo keyInfo,
org.licas_xml.abs.Element clientURI)
Un-subscribe for a service.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected MonitorServer monitorServer
protected PublishSubscribeDef pubSub
protected MessageStore messageStore
protected PasswordHandler passwordHandler
protected ESB esb
public MessageMediator(ESB theESB, PasswordHandler thePasswordHandler, MessageStore theMessageStore)
theESB
- the parent ESB server.thePasswordHandler
- the parent password handler.theMessageStore
- the message store.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public boolean messageToBus(MessageInfo ro)
ro
- the request object to add.public void cancelMessage(java.lang.String ticket)
ticket
- unique ticket number, equivalent to a communication ID.public java.util.ArrayList<java.lang.String> getServiceNames() throws LicasException
LicasException
- licas error.public java.util.ArrayList<java.lang.String> getServiceTypeNames(java.lang.String serviceType) throws LicasException
serviceType
- the service type to check for.LicasException
- licas error.public java.lang.Object messageBus(MethodInfo methodInfo) throws java.lang.Exception
messageBus
in interface BusDef
methodInfo
- the method call description with all of the required information.java.lang.Exception
- any error.public void executeServiceTypeAsync(java.lang.String serviceType, MethodInfo methodInfo) throws java.lang.Exception
executeServerService
to invoke the methodInfo
spec.
The asynchronous call does not return a value, thereby freeing the client sooner.
After executing the method, it instead saves any reply to a messageStore
under the
methodInfo
's communicationID
.
This method forces a return type of Element
on the method it invokes or void
return type.
If that is not correct the method to invoke will not be found.serviceType
- the service type on the server.methodInfo
- this is the actual method call as it would be invoked from
any place. It requires the correct method name and parameter list.java.lang.Exception
- any error.public org.licas_xml.abs.Element executeServiceType(java.lang.String serviceType, MethodInfo methodInfo) throws java.lang.Exception
executeServerService
to invoke the parameter methodInfo
spec.
This method forces a return type of Element
on the method it invokes.
If that is not correct the method to invoke will not be found.serviceType
- the service type on the server.methodInfo
- this is the actual method description as it would be invoked from
any place. It requires the correct method name and parameter list. It is not
restricted to the two query types, but the further programming might be required
to add other ones. The invoked method is assumed to return XML elements only.java.lang.Exception
- any error.protected org.licas_xml.abs.Element executeServerService(java.lang.String serviceType, MethodInfo methodInfo) throws java.lang.Exception
serviceType
- the service type on the server.methodInfo
- this is the actual method call as it would be made from
a remote server. It requires the correct method name and parameter list.
The service itself is replaced by a direct reference to one of the specified
type, if one exists. The method is assumed to return XML elements only.java.lang.Exception
- any error.public boolean subscribe(WorkInfo workInfo) throws java.lang.Exception
subscribe
in interface PublishSubscribeDef
workInfo
- new client details. It must include the keyword list and the method
to reply with.
getClientURI()
is empty, then the request is ignored. It must also contain
a parameter list of size 1, that is either an Object
or a WorkInfo
object, as that is what will be sent as a reply.java.lang.Exception
- any error.public void unsubscribe(KeywordInfo keyInfo, org.licas_xml.abs.Element clientURI) throws java.lang.Exception
unsubscribe
in interface PublishSubscribeDef
keyInfo
- list of descriptive keywords to uniquely identify the service.clientURI
- the client URI defines the request client.java.lang.Exception
- any error.public boolean publish(WorkInfo workInfo) throws java.lang.Exception
publish
in interface PublishSubscribeDef
workInfo
- full work details, including an optional contract. The method
description must include the client URI as this is what identifies the request.
If getClientURI()
is empty, then the request is ignored.java.lang.Exception
- any error.public void unpublish(KeywordInfo keyInfo, org.licas_xml.abs.Element serviceURI) throws java.lang.Exception
unpublish
in interface PublishSubscribeDef
keyInfo
- list of descriptive keywords to uniquely identify the work.serviceURI
- the client URI defines the request service.java.lang.Exception
- any error.