org.objectweb.dsrg.sofa.osgi
Class ServiceProxy

java.lang.Object
  extended by org.objectweb.dsrg.sofa.osgi.ServiceProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public class ServiceProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

Service Proxy

It handles method invocations on a SOFA2 interface and acts as a mediator between the interface and a service. Furthermore, it deals with method types (i.e. method parameters, return value, exceptions) when handling a method invocation.


Constructor Summary
ServiceProxy(java.lang.String version, boolean reverse)
          Service Proxy constructor
 
Method Summary
 java.lang.Object getService()
          Get the service implementation
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method m, java.lang.Object[] args)
          Handles a method invocation
 void setFallback(java.lang.Object content)
          Sets the fallback service implementation
 void setService(java.lang.Object service)
          Set the service implementation
 void setTimeout(long timeout)
          Sets the timeout value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceProxy

public ServiceProxy(java.lang.String version,
                    boolean reverse)
Service Proxy constructor

Parameters:
version - the interface type version
reverse - the proxy direction
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method m,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Handles a method invocation

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Parameters:
proxy - the proxy instance that the method was invoked on
m - the method being invoked
args - the method parameters
Returns:
the return value
Throws:
java.lang.Throwable

getService

public java.lang.Object getService()
Get the service implementation

Returns:
the service implementation if available, null otherwise

setService

public void setService(java.lang.Object service)
Set the service implementation

Parameters:
service - the service implementation

setTimeout

public void setTimeout(long timeout)
Sets the timeout value

Parameters:
timeout - time in miliseconds

setFallback

public void setFallback(java.lang.Object content)
Sets the fallback service implementation

Parameters:
content - the fallback service implementation