org.gcube.common.core.utils.proxies
Class GCUBEProxyFactory

java.lang.Object
  extended by org.gcube.common.core.utils.proxies.GCUBEProxyFactory

public class GCUBEProxyFactory
extends Object

Factory of proxies associated with GCUBEProxyContexts.

Author:
Fabio Simeoni (University of Strathclyde)

Nested Class Summary
static class GCUBEProxyFactory.FlexEnhancer
           
 
Field Summary
protected static Map<Class<? extends Annotation>,Class<? extends GCUBEProxyContext<?>>> proxyClasses
          Registered GCUBEProxyContext classes, indexed by the associated annotation classes.
 
Constructor Summary
GCUBEProxyFactory()
           
 
Method Summary
protected static
<ANNOTATION extends Annotation>
GCUBEProxyContext<ANNOTATION>
getProxy(Class<? extends ANNOTATION> annotationClass)
          Returns an instance of a registered GCUBEProxyContext form the class of its associated annotation.
static
<TYPE> TYPE
getProxy(GCUBEProxyContext<?> context, TYPE proxied, Class<?>... optionalInterface)
          Given an arbitrary object, returns a proxy associated with a given GCUBEProxyContext for that object.
static
<TYPE> TYPE
getProxy(TYPE proxied, Class<?>... optionalInterface)
          Given an arbitrary object, returns a proxy associated with ForwardProxyContext for that object.
static void registerContexts(Class<? extends GCUBEProxyContext<?>>... contextClasses)
          Registers one or more GCUBEProxyContext classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

proxyClasses

protected static Map<Class<? extends Annotation>,Class<? extends GCUBEProxyContext<?>>> proxyClasses
Registered GCUBEProxyContext classes, indexed by the associated annotation classes.

Constructor Detail

GCUBEProxyFactory

public GCUBEProxyFactory()
Method Detail

registerContexts

public static void registerContexts(Class<? extends GCUBEProxyContext<?>>... contextClasses)
                             throws Exception
Registers one or more GCUBEProxyContext classes.

Parameters:
contextClasses - the classes.
Throws:
Exception - if one of the classes could not be registered.

getProxy

protected static <ANNOTATION extends Annotation> GCUBEProxyContext<ANNOTATION> getProxy(Class<? extends ANNOTATION> annotationClass)
                                                                    throws Exception
Returns an instance of a registered GCUBEProxyContext form the class of its associated annotation.

Type Parameters:
ANNOTATION - the type of the annotation.
Parameters:
annotationClass - the annotation class.
Returns:
the context, or null if the context was not previously registered.
Throws:
Exception - if the context was found but could not be instantiated.

getProxy

public static <TYPE> TYPE getProxy(TYPE proxied,
                                   Class<?>... optionalInterface)
                     throws Exception
Given an arbitrary object, returns a proxy associated with ForwardProxyContext for that object.

Type Parameters:
TYPE - the object's type.
Parameters:
proxied - the object.
optionalInterface - (optional) an optional interface which the proxy should implement.
Returns:
the proxy.
Throws:
Exception - if the object could not be proxied.

getProxy

public static <TYPE> TYPE getProxy(GCUBEProxyContext<?> context,
                                   TYPE proxied,
                                   Class<?>... optionalInterface)
                     throws Exception
Given an arbitrary object, returns a proxy associated with a given GCUBEProxyContext for that object.

Type Parameters:
TYPE - the object's type.
Parameters:
context - the context.
proxied - the object.
optionalInterface - (optional) an optional interface which the proxy should implement.
Returns:
the proxy.
Throws:
Exception - if the object could not be proxied.


Copyright © 2012. All Rights Reserved.