org.qtunes.auth.control
Class ControlMethodInvoker

java.lang.Object
  extended by org.qtunes.auth.control.ControlMethodInvoker

public class ControlMethodInvoker
extends java.lang.Object

The ControlMethodInvoker takes a method description to its "invoke" method and invokes the matching {link ControlMethod}.


Constructor Summary
ControlMethodInvoker(ServiceContext context)
          Create a new ControlMethodInvoker
 
Method Summary
protected  java.lang.Object convert(java.lang.Object o, java.lang.Class paramclass)
           
 java.util.List<java.lang.reflect.Method> getControlMethods(java.lang.Object o)
           
 java.lang.Object getObject(java.lang.String objectname)
          Given the name of an Object, return the Object itself.
 java.lang.Object invoke(ServiceContext context, java.lang.String objectname, java.util.List<Call> calls)
          Invoke a ControlMethod on an Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlMethodInvoker

public ControlMethodInvoker(ServiceContext context)
Create a new ControlMethodInvoker

Parameters:
qtunes - the qtunes;
Method Detail

getObject

public java.lang.Object getObject(java.lang.String objectname)
Given the name of an Object, return the Object itself. By default this maps "qtunes" and "db" to the main server and the Database, and maps Service by its service-name

Parameters:
objectname - the name of the Object
Returns:
the Object, or null if not found

invoke

public java.lang.Object invoke(ServiceContext context,
                               java.lang.String objectname,
                               java.util.List<Call> calls)
                        throws java.lang.Throwable
Invoke a ControlMethod on an Object. The object will be searched for a matching method, and the arguments - specified in the "args" map as either positional values like {1:"value1", 2:"value2"}, or by name eg {"track":"1", "index":0}. This class will attempt to cast the parameters (say converting "Album" into Field.Album an arrays into BitSet objects), and if that succeeds then it will call the method and return the return value or Void.TYPE if the method returns no value.

Parameters:
qtunes - the QTunes
objectname - the name of the Object, to be passed in to getObject(java.lang.String)
methodname - the name of the method on the Object to invoke
args - the parameters. These will be matched against the paramaters of the ControlMethod by type, using the convert(java.lang.Object, java.lang.Class) method to type match if necessary
Returns:
the Object returned from the method, or Void.TYPE if the method has no return
Throws:
java.lang.Throwable

convert

protected java.lang.Object convert(java.lang.Object o,
                                   java.lang.Class paramclass)
                            throws java.lang.Exception
Throws:
java.lang.Exception

getControlMethods

public java.util.List<java.lang.reflect.Method> getControlMethods(java.lang.Object o)