public class PublishSubscribe extends java.lang.Object implements PublishSubscribeDef
MethodInfo
description and a KeywordInfo
list of keywords.
The method description must include a client URI or it will be rejected. This uniquely
defines the service or client. The keyword lists may not overlap for any one client
or service. They may not share any keywords, but the topic names can be shared.Constructor and Description |
---|
PublishSubscribe()
Create a new instance of PublishSubscribe
|
Modifier and Type | Method and Description |
---|---|
protected void |
addToRegister(java.lang.String address,
WorkInfo workInfo,
java.util.HashMap<java.lang.String,java.util.ArrayList<WorkInfo>> register)
Add the request to do work.
|
protected WorkInfo |
getWorkInfo(java.lang.String address,
KeywordInfo keyInfo,
java.util.HashMap<java.lang.String,java.util.ArrayList<WorkInfo>> register)
If a work description is already saved under the service address and keyword list then
return it, otherwise return null.
|
static MethodInfo |
methodForPublish(org.licas_xml.abs.Element serverUri,
java.lang.String serverPassword,
KeywordInfo keywords,
MethodInfo replyMethod,
PasswordHandler pHandler)
Create and return the full method list for publishing a service's information.
|
static MethodInfo |
methodForSubscribe(org.licas_xml.abs.Element serverUri,
java.lang.String serverPassword,
KeywordInfo keywords,
MethodInfo replyMethod,
PasswordHandler pHandler)
Create and return the full method list for subscribing to a service's information.
|
boolean |
publish(WorkInfo workInfo)
Publish to do work.
|
protected void |
removeFromRegister(java.lang.String address,
KeywordInfo keyInfo,
java.util.HashMap<java.lang.String,java.util.ArrayList<WorkInfo>> register)
Add the request to do work.
|
boolean |
subscribe(WorkInfo workInfo)
Subscribe for a service.
|
void |
unpublish(KeywordInfo keyInfo,
org.licas_xml.abs.Element clientURI)
Un-publish to do work.
|
void |
unsubscribe(KeywordInfo keyInfo,
org.licas_xml.abs.Element clientURI)
Un-subscribe for a service.
|
public PublishSubscribe()
public boolean subscribe(WorkInfo workInfo) throws java.lang.Exception
WorkInfo
details. An immediate check is done to
determine if matching work is available.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.Object
or
a WorkInfo
object, as that is what will be sent as a reply.void
(asynchronous call).
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 clientURI) throws java.lang.Exception
unpublish
in interface PublishSubscribeDef
keyInfo
- list of descriptive keywords to uniquely identify the work.clientURI
- the client URI defines the request service.java.lang.Exception
- any error.protected void addToRegister(java.lang.String address, WorkInfo workInfo, java.util.HashMap<java.lang.String,java.util.ArrayList<WorkInfo>> register)
address
- unique address for the client.workInfo
- the work request.register
- the register to add to.protected void removeFromRegister(java.lang.String address, KeywordInfo keyInfo, java.util.HashMap<java.lang.String,java.util.ArrayList<WorkInfo>> register) throws java.lang.Exception
address
- unique address for the client.keyInfo
- keywords list to identify the work description.register
- the register to add to.java.lang.Exception
- any error.protected WorkInfo getWorkInfo(java.lang.String address, KeywordInfo keyInfo, java.util.HashMap<java.lang.String,java.util.ArrayList<WorkInfo>> register) throws java.lang.Exception
address
- unique address for the client/service.keyInfo
- list of keywords. None must be present in a currently saved
work request by the same service.register
- the register to check.java.lang.Exception
- any error.public static MethodInfo methodForPublish(org.licas_xml.abs.Element serverUri, java.lang.String serverPassword, KeywordInfo keywords, MethodInfo replyMethod, PasswordHandler pHandler) throws java.lang.Exception
serverUri
- address for the server to call.serverPassword
- the server password.keywords
- list of keywords to represent the published information.replyMethod
- callback method by the server after publshing.pHandler
- the service password handler.MethodInfo
object to make a server publish invocation with.java.lang.Exception
- any error.public static MethodInfo methodForSubscribe(org.licas_xml.abs.Element serverUri, java.lang.String serverPassword, KeywordInfo keywords, MethodInfo replyMethod, PasswordHandler pHandler) throws java.lang.Exception
serverUri
- address for the server to call.serverPassword
- the server password.keywords
- list of keywords to represent the published information.replyMethod
- callback method by the server, to send the published data to.pHandler
- the service password handler.MethodInfo
object to make a server subscribe invocation with.java.lang.Exception
- any error.