org.apache.tuscany.sca.implementation.java.injection
Class ResourceObjectFactory<T>

java.lang.Object
  extended by org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory<T>
All Implemented Interfaces:
ObjectFactory<T>

public class ResourceObjectFactory<T>
extends java.lang.Object
implements ObjectFactory<T>

Resolves a runtime resource to be injected on a field or method of a Java component type marked with Resource. If the mapped name of the resource is an absolute URI such as sca://localhost or jndi://localhost the host container namespace is searched; otherwise the URI is assumed to be relative and the parent composite is searched. If a mapped name is not provided, i.e. resolution is by type, the parent composite is first searched followed by the host namespace.


Constructor Summary
ResourceObjectFactory(java.lang.Class<T> type, boolean optional, ResourceHost host)
          Instantiates a factory that resolves resources by type
ResourceObjectFactory(java.lang.Class<T> type, java.lang.String mappedName, boolean optional, ResourceHost host)
          Instantiates a factory that resolves resources by mapped name
 
Method Summary
 T getInstance()
          Return a instance of the type that this factory creates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceObjectFactory

public ResourceObjectFactory(java.lang.Class<T> type,
                             boolean optional,
                             ResourceHost host)
Instantiates a factory that resolves resources by type

Parameters:
type - the type of the resource to inject
optional - true if an error should be thrown if the resource is not found
host - the runtime resource provider

ResourceObjectFactory

public ResourceObjectFactory(java.lang.Class<T> type,
                             java.lang.String mappedName,
                             boolean optional,
                             ResourceHost host)
Instantiates a factory that resolves resources by mapped name

Parameters:
type - the type of the resource to inject
mappedName - the resource name
optional - true if an error should be thrown if the resource is not found
host - the runtime resource provider
Method Detail

getInstance

public T getInstance()
              throws ObjectCreationException
Description copied from interface: ObjectFactory
Return a instance of the type that this factory creates.

Specified by:
getInstance in interface ObjectFactory<T>
Returns:
a instance from this factory
Throws:
ObjectCreationException