Package org.astrogrid.samp.web
Class WebHubXmlRpcHandler
- java.lang.Object
-
- org.astrogrid.samp.xmlrpc.ActorHandler
-
- org.astrogrid.samp.web.WebHubXmlRpcHandler
-
- All Implemented Interfaces:
SampXmlRpcHandler
public class WebHubXmlRpcHandler extends ActorHandler
SampXmlRpcHandler implementation which passes Web Profile-type XML-RPC calls to a hub connection factory to provide a Web Profile hub server.- Since:
- 2 Feb 2011
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description WebHubXmlRpcHandler(ClientProfile profile, ClientAuthorizer auth, KeyGenerator keyGen, java.net.URL baseUrl, UrlTracker urlTracker)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpServer.Handler
getUrlTranslationHandler()
Returns a handler suitable for performing URL translations on behalf of sandboxed clients as required by the Web Profile.java.lang.Object
handleCall(java.lang.String fqName, java.util.List params, java.lang.Object reqObj)
Processes an XML-RPC call.protected java.lang.Object
invokeMethod(java.lang.reflect.Method method, java.lang.Object obj, java.lang.Object[] args)
Invokes a method reflectively on an object.-
Methods inherited from class org.astrogrid.samp.xmlrpc.ActorHandler
canHandleCall, getActor
-
-
-
-
Constructor Detail
-
WebHubXmlRpcHandler
public WebHubXmlRpcHandler(ClientProfile profile, ClientAuthorizer auth, KeyGenerator keyGen, java.net.URL baseUrl, UrlTracker urlTracker)
Constructor.- Parameters:
profile
- hub connection factoryauth
- client authorizerkeyGen
- key generator for private keysbaseUrl
- base URL of HTTP server, used for URL translationurlTracker
- tracks URLs in messages to restrict use in URL translation service for security reasons; may be null for no restrictions
-
-
Method Detail
-
handleCall
public java.lang.Object handleCall(java.lang.String fqName, java.util.List params, java.lang.Object reqObj) throws java.lang.Exception
Description copied from interface:SampXmlRpcHandler
Processes an XML-RPC call. This method should only be called ifcanHandleCall(method)
returns true. Theparams
list and the return value must be SAMP-compatible, that is only Strings, Lists and String-keyed Maps are allowed in the data structures. ThereqInfo
parameter may be used to provide additional information about the XML-RPC request, for instance the originating host; this is implementation specific, and may be null.- Specified by:
handleCall
in interfaceSampXmlRpcHandler
- Overrides:
handleCall
in classActorHandler
- Parameters:
fqName
- XML-RPC method nameparams
- XML-RPC parameter list (SAMP-compatible)reqObj
- optional additional request information; may be null- Returns:
- return value (SAMP-compatible)
- Throws:
java.lang.Exception
-
getUrlTranslationHandler
public HttpServer.Handler getUrlTranslationHandler()
Returns a handler suitable for performing URL translations on behalf of sandboxed clients as required by the Web Profile.- Returns:
- url translation handler
-
invokeMethod
protected java.lang.Object invokeMethod(java.lang.reflect.Method method, java.lang.Object obj, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Description copied from class:ActorHandler
Invokes a method reflectively on an object. This method should be implemented in the obvious way, that isreturn method.invoke(obj,params)
.If the implementation is effectively prescribed, why is this abstract method here? It's tricky. The reason is so that reflective method invocation from this class is done by code within the actor implementation class itself rather than by code in the superclass,
ActorHandler
. That in turn means that theactorType
class specified in the constructor does not need to be visible fromActorHandler
's package, only from the package where the implementation class lives.- Specified by:
invokeMethod
in classActorHandler
- Parameters:
method
- method to invokeobj
- object to invoke the method onargs
- arguments for the method call- Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
- See Also:
Method.invoke(java.lang.Object, java.lang.Object...)
-
-