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

java.lang.Object
  extended by org.glassfish.hk2.utilities.DescriptorImpl
      extended by com.sun.hk2.component.AbstractInhabitantImpl<T>
          extended by com.sun.hk2.component.AbstractCreatorInhabitantImpl<T>
              extended by com.sun.hk2.component.ScopedInhabitant<T>
Type Parameters:
T - scoped inhabitant type.
All Implemented Interfaces:
Holder<T>, Serializable, Descriptor, Binding<T>, Factory<T>, ManagedComponentProvider<T>, Provider<T>, Releasable, Inhabitant<T>

Deprecated.

@Deprecated
public class ScopedInhabitant<T>
extends AbstractCreatorInhabitantImpl<T>

Scoped inhabitant.

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
 
Fields inherited from class com.sun.hk2.component.AbstractCreatorInhabitantImpl
creator
 
Fields inherited from class com.sun.hk2.component.AbstractInhabitantImpl
descriptor, logger
 
Constructor Summary
ScopedInhabitant(Creator<T> creator, Scope scope)
          Deprecated.  
 
Method Summary
 T get(Inhabitant onBehalfOf)
          Deprecated. Returns the instance of this inhabitant.
 boolean isActive()
          Deprecated. Returns true if the component has been instantiated.
 void release()
          Deprecated. Called to orderly shutdown ServiceLocator.
 
Methods inherited from class com.sun.hk2.component.AbstractCreatorInhabitantImpl
getCreator, metadata, type, typeName
 
Methods inherited from class com.sun.hk2.component.AbstractInhabitantImpl
companions, dispose, get, getAnnotation, getAnnotation, getAnnotations, getByType, getDescriptor, getDescriptorFor, getProvider, getProvider, getSerializedMetadata, getSerializedMetadata, lead, matches, setCompanions, toString
 
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.glassfish.hk2.api.Descriptor
getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, setRanking
 

Constructor Detail

ScopedInhabitant

public ScopedInhabitant(Creator<T> creator,
                        Scope scope)
Deprecated. 
Method Detail

get

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

THIS METHOD SHOULD BE ONLY USED BY HK2 IMPLEMENTATION.

Inhabitants are often used with the decorator pattern (see AbstractCreatorInhabitantImpl for example), yet during the object initializtion inside the Inhabitant.get() method, we often need the reference to the outer-most Inhabitant registered to the ServiceLocator (for example so that we can request the injection of {link Inhabita} that represents itself, or to inject companions.)

So this overloaded version of the get method takes the outer-most Inhabitant. This method is only invoked from within HK2 where the decorator pattern is used.


isActive

public boolean isActive()
Deprecated. 
Description copied from interface: Provider
Returns true if the component has been instantiated.

Returns:
true if the component is active.

release

public void release()
Deprecated. 
Description copied from interface: Inhabitant
Called to orderly shutdown ServiceLocator.

The expected behavior is for objects to get its PreDestroy callback invoked, and its reference released. For singleton objects, this method is expected to dispose that object.

For scoped objects, those are released when ScopeInstance.release() is invoked.



Copyright © 2013 Oracle Corporation. All Rights Reserved.