public class MinimalHub extends Object implements PlasticHubListener, org.apache.xmlrpc.XmlRpcHandler
PlasticHub
for a more user-friendly
implementation. This class is provided mainly to make it
as clear as possible what the implementation of a hub involves.PLASTIC_CONFIG_FILENAME, PLASTIC_RMI_PORT_KEY, PLASTIC_VERSION_KEY, PLASTIC_XMLRPC_URL_KEY
Constructor and Description |
---|
MinimalHub(ServerSet servers)
Constructs a new hub, given running server objects.
|
Modifier and Type | Method and Description |
---|---|
Object |
execute(String method,
Vector params)
This method implements all the XML-RPC services offered by the hub.
|
void |
finalize() |
URI |
getHubId()
Get this hub's ID.
|
List |
getMessageRegisteredIds(URI message)
Get all the applications that support a particular message
|
String |
getName(URI id)
Get the name of this application, as used at registration.
|
List |
getRegisteredIds()
Get all the IDs of the currently registered applications.
|
List |
getUnderstoodMessages(URI id)
Get the messages understood by this application.
|
static void |
main(String[] args)
Main method.
|
List |
pollForMessages(URI id)
Not supported.
|
URI |
registerNoCallBack(String name)
Register this application with the hub, but don't send it any messages in return.
|
URI |
registerPolling(String name,
List supportedMessages)
Not supported.
|
URI |
registerRMI(String name,
List supportedMessages,
PlasticListener caller)
A java-rmi version of
registerXMLRPC |
URI |
registerXMLRPC(String name,
List supportedMessages,
URL callbackURL)
Register an application with the hub.
|
Map |
request(URI sender,
URI message,
List args)
Send a message to all registered Plastic applications.
|
void |
requestAsynch(URI sender,
URI message,
List args)
Send a request to all registered Plastic apps, but don't wait for a response.
|
Map |
requestToSubset(URI sender,
URI message,
List args,
List recipientIds)
Send a request to listed registered Plastic apps.
|
void |
requestToSubsetAsynch(URI sender,
URI message,
List args,
List recipientIds)
Send a request to listed registered Plastic apps, but don't wait for a response.
|
void |
stop()
Shuts down this hub and tidies up.
|
void |
unregister(URI id)
Unregister the application from the hub.
|
public MinimalHub(ServerSet servers) throws RemoteException
servers
- object encapsulating listening serversRemoteException
public URI getHubId()
PlasticHubListener
getHubId
in interface PlasticHubListener
public URI registerRMI(String name, List supportedMessages, PlasticListener caller)
PlasticHubListener
registerXMLRPC
registerRMI
in interface PlasticHubListener
name
- see registerRMI
caller
- the PlasticListener that wishes to registerfor other parameters
public URI registerXMLRPC(String name, List supportedMessages, URL callbackURL)
PlasticHubListener
registerXMLRPC
in interface PlasticHubListener
name
- An optional string with a short name describing the application. This may be added to the hub
assigned ID, making it more human friendly.supportedMessages
- an array of messages (as URIs) the application is interested in. An empty List signifies
"all".callbackURL
- the application's internal xmlrpc server URL. Used by the hub to send messages to the
application.PlasticHubListener.registerRMI(String, List, PlasticListener)
,
PlasticHubListener.registerNoCallBack(String)
public URI registerNoCallBack(String name)
PlasticHubListener
registerNoCallBack
in interface PlasticHubListener
for parameters
public void unregister(URI id)
PlasticHubListener
unregister
in interface PlasticHubListener
id
- the application to unregisterpublic List getRegisteredIds()
PlasticHubListener
getRegisteredIds
in interface PlasticHubListener
public String getName(URI id)
PlasticHubListener
getName
in interface PlasticHubListener
id
- the plastic ID returned at registrationpublic List getUnderstoodMessages(URI id)
PlasticHubListener
getUnderstoodMessages
in interface PlasticHubListener
id
- the plastic ID returned at registrationpublic List getMessageRegisteredIds(URI message)
PlasticHubListener
getMessageRegisteredIds
in interface PlasticHubListener
message
- the messageId you're interested inpublic Object execute(String method, Vector params) throws IOException, URISyntaxException
execute
in interface org.apache.xmlrpc.XmlRpcHandler
method
- XML-RPC method name, including the "plastic.hub"
prefixparams
- list of method argumentsIOException
URISyntaxException
public Map request(URI sender, URI message, List args)
PlasticHubListener
request
in interface PlasticHubListener
sender
- the id of the originating tool - provided by the hub on
registration. Note that the hub is at liberty to refused to forward requests that
don't come from an ID that it has registered.message
- the message to send.args
- any arguments to pass with the messagepublic Map requestToSubset(URI sender, URI message, List args, List recipientIds)
PlasticHubListener
request
for
details of the other parameters.requestToSubset
in interface PlasticHubListener
recipientIds
- a list of target application ids (as URIs)public void requestAsynch(URI sender, URI message, List args)
PlasticHubListener
request
for details of parameters.requestAsynch
in interface PlasticHubListener
public void requestToSubsetAsynch(URI sender, URI message, List args, List recipientIds)
PlasticHubListener
requestToSubsetAsynch
in interface PlasticHubListener
recipientIds
- a List of target application ids (as URIs). See request
for
details of the other parameters.public URI registerPolling(String name, List supportedMessages)
UnsupportedOperationException
- alwayspublic List pollForMessages(URI id)
UnsupportedOperationException
- alwayspublic void stop()
public void finalize() throws Throwable
public static void main(String[] args) throws IOException, RemoteException
PlasticHub.main(java.lang.String[])
.IOException
RemoteException
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.