Package org.astrogrid.samp.xmlrpc
Class CallableClientServer
- java.lang.Object
-
- org.astrogrid.samp.xmlrpc.CallableClientServer
-
class CallableClientServer extends java.lang.Object
XML-RPC server which can hostCallableClient
instances. There should usually be only one instance of this class for each SampXmlRpcServer - seegetInstance(org.astrogrid.samp.xmlrpc.SampXmlRpcServerFactory)
.- Since:
- 16 Jul 2008
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description private ClientXmlRpcHandler
clientHandler_
private SampXmlRpcServer
server_
private static java.util.Map
serverMap_
private java.net.URL
url_
-
Constructor Summary
Constructors Constructor Description CallableClientServer(SampXmlRpcServer server)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClient(HubConnection connection, CallableClient callable)
Adds a CallableClient object to this server.void
close()
Tidies up resources.static CallableClientServer
getInstance(SampXmlRpcServerFactory serverFact)
Returns an instance of CallableClientServer for use with a given XML-RPC server.java.net.URL
getUrl()
Returns the XML-RPC endpoint for this server.(package private) boolean
hasClients()
Indicates whether this server currently has any clients.void
removeClient(HubConnection connection)
Removes a CallableClient object from this server.
-
-
-
Field Detail
-
url_
private final java.net.URL url_
-
server_
private SampXmlRpcServer server_
-
clientHandler_
private ClientXmlRpcHandler clientHandler_
-
serverMap_
private static final java.util.Map serverMap_
-
-
Constructor Detail
-
CallableClientServer
public CallableClientServer(SampXmlRpcServer server) throws java.io.IOException
Constructor. Note that agetInstance(org.astrogrid.samp.xmlrpc.SampXmlRpcServerFactory)
method exists as well.- Parameters:
server
- XML-RPC server hosting this client server- Throws:
java.io.IOException
-
-
Method Detail
-
getUrl
public java.net.URL getUrl()
Returns the XML-RPC endpoint for this server.- Returns:
- endpoint url
-
addClient
public void addClient(HubConnection connection, CallableClient callable)
Adds a CallableClient object to this server.- Parameters:
connection
- hub connection for the registered client on behalf of which the client will operatecallable
- callable client object
-
removeClient
public void removeClient(HubConnection connection)
Removes a CallableClient object from this server.- Parameters:
privateKey
- hub connection for which this client was added
-
close
public void close()
Tidies up resources. Following a call to this method, no further clients can be added.
-
hasClients
boolean hasClients()
Indicates whether this server currently has any clients.- Returns:
- true iff there are clients
-
getInstance
public static CallableClientServer getInstance(SampXmlRpcServerFactory serverFact) throws java.io.IOException
Returns an instance of CallableClientServer for use with a given XML-RPC server. Because of the implementation, only one CallableClientServer is permitted per XML-RPC server, so if one has already been installed for the givenserver
, that one will be returned. Otherwise a new one will be constructed, installed and returned.To prevent memory leaks, once any clients added to the returned server have been removed (the client count drops to zero), the server will be closed and cannot be re-used.
- Parameters:
server
- XML-RPC server- Returns:
- new or re-used CallableClientServer which is installed on
server
- Throws:
java.io.IOException
-
-