org.picocontainer.gems.jndi
Class JNDIProvided<T>

java.lang.Object
  extended by org.picocontainer.gems.jndi.JNDIProvided<T>
All Implemented Interfaces:
Serializable, ComponentAdapter<T>

public class JNDIProvided<T>
extends Object
implements ComponentAdapter<T>, Serializable

represents dependency provided via JNDI. This dependency is not to be managed by container at all, so there is no lifecycle, no monitoring etc.

Author:
Konstantin Pribluda
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
ComponentAdapter.NOTHING
 
Constructor Summary
JNDIProvided(JNDIObjectReference<T> reference)
          create adapter with JNDI reference.
JNDIProvided(Object componentKey, JNDIObjectReference<T> reference)
          create adapter with specified key and reference
JNDIProvided(String jndiName)
          create adapter based on JNDI name.
 
Method Summary
 void accept(PicoVisitor visitor)
          as there is no puprose of proceeding further down, we do nothing here
<U extends ComponentAdapter>
U
findAdapterOfType(Class<U> componentAdapterType)
          Locates a component adapter of type componentAdapterType in the ComponentAdapter chain.
 Class getComponentImplementation()
          Retrieve the class of the component.
 T getComponentInstance(PicoContainer container)
          Retrieve the component instance.
 T getComponentInstance(PicoContainer container, Type into)
          retrieve instance out of JNDI
 Object getComponentKey()
          Retrieve the key associated with the component.
 ComponentAdapter<T> getDelegate()
          Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain.
 String getDescriptor()
          Get a string key descriptor of the component adapter.
 void verify(PicoContainer container)
          we have nothing to verify here
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNDIProvided

public JNDIProvided(Object componentKey,
                    JNDIObjectReference<T> reference)
create adapter with specified key and reference

Parameters:
componentKey - component key
reference - JNDI reference storing component

JNDIProvided

public JNDIProvided(JNDIObjectReference<T> reference)
create adapter with JNDI reference. referenced object class will be takes as key

Parameters:
reference - JNDI reference storing component

JNDIProvided

public JNDIProvided(String jndiName)
             throws NamingException
create adapter based on JNDI name. I leave this unchecked because type is really not known at this time

Parameters:
jndiName - name to be used
Throws:
NamingException - will be thrown if something goes wrong in JNDI
Method Detail

getComponentKey

public Object getComponentKey()
Description copied from interface: ComponentAdapter
Retrieve the key associated with the component.

Specified by:
getComponentKey in interface ComponentAdapter<T>
Returns:
the component's key. Should either be a class type (normally an interface) or an identifier that is unique (within the scope of the current PicoContainer).

getComponentImplementation

public Class getComponentImplementation()
Description copied from interface: ComponentAdapter
Retrieve the class of the component.

Specified by:
getComponentImplementation in interface ComponentAdapter<T>
Returns:
the component's implementation class. Should normally be a concrete class (ie, a class that can be instantiated).

getComponentInstance

public T getComponentInstance(PicoContainer container)
                       throws PicoCompositionException
Description copied from interface: ComponentAdapter
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example, Cached will always return the same instance.

Specified by:
getComponentInstance in interface ComponentAdapter<T>
Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
Returns:
the component instance.
Throws:
PicoCompositionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.

getComponentInstance

public T getComponentInstance(PicoContainer container,
                              Type into)
                       throws PicoCompositionException
retrieve instance out of JNDI

Specified by:
getComponentInstance in interface ComponentAdapter<T>
Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
into - the class that is about to be injected into. Use ComponentAdapter.NOTHING.class if this is not important to you.
Returns:
the component instance.
Throws:
PicoCompositionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambiguous situation within the container.

verify

public void verify(PicoContainer container)
            throws PicoCompositionException
we have nothing to verify here

Specified by:
verify in interface ComponentAdapter<T>
Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
Throws:
PicoCompositionException - if one or more dependencies cannot be resolved.

accept

public void accept(PicoVisitor visitor)
as there is no puprose of proceeding further down, we do nothing here

Specified by:
accept in interface ComponentAdapter<T>
Parameters:
visitor - the visitor.

getDelegate

public ComponentAdapter<T> getDelegate()
Description copied from interface: ComponentAdapter
Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain.

Specified by:
getDelegate in interface ComponentAdapter<T>
Returns:
the next component adapter in line or null if there is no delegate ComponentAdapter.

findAdapterOfType

public <U extends ComponentAdapter> U findAdapterOfType(Class<U> componentAdapterType)
Description copied from interface: ComponentAdapter
Locates a component adapter of type componentAdapterType in the ComponentAdapter chain. Will return null if there is no adapter of the given type.

Specified by:
findAdapterOfType in interface ComponentAdapter<T>
Type Parameters:
U - the type of ComponentAdapter being located.
Parameters:
componentAdapterType - the class of the adapter type being located. Never null.
Returns:
the appropriate component adapter of type U. May return null if the component adapter type is not returned.

getDescriptor

public String getDescriptor()
Description copied from interface: ComponentAdapter
Get a string key descriptor of the component adapter.

Specified by:
getDescriptor in interface ComponentAdapter<T>
Returns:


Copyright © 2003-2010 Codehaus. All Rights Reserved.