com.sun.hk2.component
Class AbstractInhabitantImpl<T>

java.lang.Object
  extended by org.glassfish.hk2.utilities.DescriptorImpl
      extended by com.sun.hk2.component.AbstractInhabitantImpl<T>
All Implemented Interfaces:
Holder<T>, Serializable, Descriptor, Binding<T>, Factory<T>, ManagedComponentProvider<T>, Provider<T>, Releasable, Inhabitant<T>
Direct Known Subclasses:
AbstractCreatorImpl, AbstractCreatorInhabitantImpl, CreatorImpl, EventPublishingInhabitant, ExistingSingletonInhabitant, InhabitantImpl

Deprecated.

@Deprecated
public abstract class AbstractInhabitantImpl<T>
extends DescriptorImpl
implements Inhabitant<T>, Binding<T>

Partial implementation of Inhabitant that defines methods whose semantics is fixed by ServiceLocator.

Author:
Kohsuke Kawaguchi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sun.hk2.component.Holder
Holder.Impl<T>
 
Field Summary
protected  Descriptor descriptor
          Deprecated.  
protected static Logger logger
          Deprecated.  
 
Constructor Summary
AbstractInhabitantImpl(Descriptor descriptorOfSelf)
          Deprecated.  
 
Method Summary
 Collection<Inhabitant> companions()
          Deprecated. Returns the companion inhabitants associated with this inhabitant.
 void dispose(T object)
          Deprecated.  
 T get()
          Deprecated. Returns the instance of this inhabitant.
static
<V extends Annotation>
V
getAnnotation(Class<?> annotated, Class<V> annotation, boolean walkParentChain)
          Deprecated. FOR INTERNAL USE TO HK2
<V extends Annotation>
V
getAnnotation(Class<V> annotation)
          Deprecated.  
 Collection<Annotation> getAnnotations()
          Deprecated. The collection of annotations for this type.
<U> U
getByType(Class<U> type)
          Deprecated. Obtain a reference to the associated component/service.
 Descriptor getDescriptor()
          Deprecated. The Descriptor fully characterizes the attributes of this Provider.
protected static Descriptor getDescriptorFor(Inhabitant<?> i)
          Deprecated.  
 Provider<T> getProvider()
          Deprecated. Return a Provider with providing contextual information on how the provider will be used.
 Provider<T> getProvider(Context ctx)
          Deprecated. Return a Provider optionally providing contextual information for how the component provider will be used (e.g., for contextual injection, etc).
<T> T
getSerializedMetadata(Class<T> type)
          Deprecated. Obtains the metadata serialized into String.
<T> T
getSerializedMetadata(Class<T> type, String key)
          Deprecated. Obtains the serialized metadata.
 Inhabitant lead()
          Deprecated. If this inhabitant is a companion to another inhabitant (called "lead"), This method returns that inhabitant.
 boolean matches(Descriptor matchTo)
          Deprecated.  
 void setCompanions(Collection<Inhabitant> companions)
          Deprecated. This method is only meant to be invoked by ServiceLocator.
 String toString()
          Deprecated.  
 
Methods inherited from class org.glassfish.hk2.utilities.DescriptorImpl
addAdvertisedContract, addMetadata, addQualifier, equals, getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, hashCode, pretty, readObject, removeAdvertisedContract, removeAllMetadata, removeMetadata, removeQualifier, setBaseDescriptor, setDescriptorType, setImplementation, setLoader, setLocatorId, setName, setRanking, setScope, setServiceId, writeObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jvnet.hk2.component.Inhabitant
get, metadata, release, type, typeName
 
Methods inherited from interface org.glassfish.hk2.Provider
isActive
 
Methods inherited from interface org.glassfish.hk2.api.Descriptor
getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, setRanking
 

Field Detail

logger

protected static final Logger logger
Deprecated. 

descriptor

protected final Descriptor descriptor
Deprecated. 
Constructor Detail

AbstractInhabitantImpl

public AbstractInhabitantImpl(Descriptor descriptorOfSelf)
Deprecated. 
Method Detail

getDescriptorFor

protected static Descriptor getDescriptorFor(Inhabitant<?> i)
Deprecated. 

getProvider

public Provider<T> getProvider(Context ctx)
Deprecated. 
Description copied from interface: Binding
Return a Provider optionally providing contextual information for how the component provider will be used (e.g., for contextual injection, etc).

The return value may be unique based on the provided contextual information. Caller's should therefore not assume identity equality in the return value.

Specified by:
getProvider in interface Binding<T>
Parameters:
ctx - contextual information for how the provider will be used, or null
Returns:
a non-null component provider instance

getProvider

public Provider<T> getProvider()
Deprecated. 
Description copied from interface: Binding
Return a Provider with providing contextual information on how the provider will be used. Equivalent to calling getProvider(null).

Specified by:
getProvider in interface Binding<T>
Returns:
a non-null component provider instance

matches

public boolean matches(Descriptor matchTo)
Deprecated. 

getDescriptor

public Descriptor getDescriptor()
Deprecated. 
Description copied from interface: Binding
The Descriptor fully characterizes the attributes of this Provider.

Specified by:
getDescriptor in interface Binding<T>
Returns:
a non-null Descriptor describing the complete set of attributes of the provider.

toString

public String toString()
Deprecated. 
Overrides:
toString in class DescriptorImpl

get

public final T get()
Deprecated. 
Description copied from interface: Inhabitant
Returns the instance of this inhabitant.

Some Inhabitants return the same instance for multiple invocations (AKA singleton), but the method may return different instances to invocations from different context (AKA scope.) The extreme case is where the each invocation returns a different object.

Specified by:
get in interface Factory<T>
Specified by:
get in interface Provider<T>
Specified by:
get in interface Inhabitant<T>
Returns:
null is a valid return value. This is useful when a factory primarily does a look-up and it fails to find the specified component, yet you don't want that by itself to be an error. If the injection wants a non-null value (i.e., @Inject(optional=false)).

getByType

public <U> U getByType(Class<U> type)
Deprecated. 
Description copied from interface: Provider
Obtain a reference to the associated component/service. The given type may be used by the provider to obtain and return a proxy rather than the actual component.

Specified by:
getByType in interface Provider<T>
Parameters:
type - the required type of the returned object
Returns:
the component or a suitable proxy of the given type

getSerializedMetadata

public <T> T getSerializedMetadata(Class<T> type,
                                   String key)
Deprecated. 
Description copied from interface: Inhabitant
Obtains the serialized metadata.

This method is a wrapper around Inhabitant.metadata() and useful for defining a highly structured metadata that doesn't easily fit a simple string representation.

The implementation of this method is to obtain the value associated with this key as metadata().getOne(key), and if that exists, treat the value as base64-encoded binary, and deserializes it and returns the object.

The classes used in the serialization need to be available during the build time (normally during the HK2 compile mojo runs) so that the metadata can be serialized. The evolution of these classes need to be careful done, otherwise the deserialization of the metadata may fail unexpectedly.

Specified by:
getSerializedMetadata in interface Inhabitant<T>
Returns:
the deserialized object.

getSerializedMetadata

public final <T> T getSerializedMetadata(Class<T> type)
Deprecated. 
Description copied from interface: Inhabitant
Obtains the metadata serialized into String.

This is a convenient short-cut that does getSerializedMetadata(type,type.getName())

Specified by:
getSerializedMetadata in interface Inhabitant<T>

lead

public Inhabitant lead()
Deprecated. 
Description copied from interface: Inhabitant
If this inhabitant is a companion to another inhabitant (called "lead"), This method returns that inhabitant. Otherwise null.

Specified by:
lead in interface Inhabitant<T>

companions

public final Collection<Inhabitant> companions()
Deprecated. 
Description copied from interface: Inhabitant
Returns the companion inhabitants associated with this inhabitant.

This method works with the Inhabitant.lead() method in pairs, such that the following condition always holds:

x.companions().contains(y) <-> y.lead()==x

Specified by:
companions in interface Inhabitant<T>
Returns:
Can be empty but never null.

setCompanions

public final void setCompanions(Collection<Inhabitant> companions)
Deprecated. 
Description copied from interface: Inhabitant
This method is only meant to be invoked by ServiceLocator.

Specified by:
setCompanions in interface Inhabitant<T>

dispose

public void dispose(T object)
Deprecated. 

getAnnotation

public <V extends Annotation> V getAnnotation(Class<V> annotation)
Deprecated. 

getAnnotation

public static <V extends Annotation> V getAnnotation(Class<?> annotated,
                                                     Class<V> annotation,
                                                     boolean walkParentChain)
Deprecated. 
FOR INTERNAL USE TO HK2


getAnnotations

public Collection<Annotation> getAnnotations()
Deprecated. 
Description copied from interface: Provider
The collection of annotations for this type. Note that this may not be the same as the annotations on the Provider.type().

Specified by:
getAnnotations in interface Provider<T>
Returns:
a non-null collection of annotation classes for this provider type.


Copyright © 2013 Oracle Corporation. All Rights Reserved.