com.sun.hk2.component
Class EventPublishingInhabitant<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.EventPublishingInhabitant<T>
All Implemented Interfaces:
Holder<T>, Serializable, Descriptor, Binding<T>, Factory<T>, ManagedComponentProvider<T>, Provider<T>, Releasable, Inhabitant<T>
Direct Known Subclasses:
LazyInhabitant

Deprecated.

@Deprecated
public class EventPublishingInhabitant<T>
extends AbstractInhabitantImpl<T>

An inhabitant that implements InhabitantEventPublisher, and maintains a list of listeners to notify for interesting changes of the underlying delegate.

Author:
Jeff Trent
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sun.hk2.component.Holder
Holder.Impl<T>
 
Field Summary
protected  Inhabitant<T> real
          Deprecated. Real Inhabitant object.
 
Fields inherited from class com.sun.hk2.component.AbstractInhabitantImpl
descriptor, logger
 
Constructor Summary
EventPublishingInhabitant(ServiceLocator serviceLocator, Descriptor descriptor)
          Deprecated.  
EventPublishingInhabitant(ServiceLocator serviceLocator, Inhabitant<?> delegate)
          Deprecated.  
EventPublishingInhabitant(ServiceLocator serviceLocator, Inhabitant<?> delegate, InhabitantListener listener)
          Deprecated.  
 
Method Summary
 void addInhabitantListener(InhabitantListener listener)
          Deprecated.  
 boolean equals(Object o)
          Deprecated.  
protected  void fetch()
          Deprecated.  
 T get(Inhabitant onBehalfOf)
          Deprecated. Returns the instance of this inhabitant.
 ServiceLocator getServiceLocator()
          Deprecated.  
 int hashCode()
          Deprecated.  
 boolean isActive()
          Deprecated. Returns true if the component has been instantiated.
 Map<String,List<String>> metadata()
          Deprecated. Gets the metadata associated with this inhabitant.
protected  void notify(InhabitantListener.EventType eventType)
          Deprecated.  
 void release()
          Deprecated. Called to orderly shutdown ServiceLocator.
 boolean removeInhabitantListener(InhabitantListener listener)
          Deprecated.  
 String toString()
          Deprecated.  
 Class<? extends T> type()
          Deprecated. Type of the inhabitant.
 String typeName()
          Deprecated. The short-cut for type().getName() but this allows us to defer loading the actual types.
 
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
 
Methods inherited from class org.glassfish.hk2.utilities.DescriptorImpl
addAdvertisedContract, addMetadata, addQualifier, getAdvertisedContracts, getBaseDescriptor, getDescriptorType, getImplementation, getLoader, getLocatorId, getMetadata, getName, getQualifiers, getRanking, getScope, getServiceId, 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
 

Field Detail

real

protected volatile Inhabitant<T> real
Deprecated. 
Real Inhabitant object.

Constructor Detail

EventPublishingInhabitant

public EventPublishingInhabitant(ServiceLocator serviceLocator,
                                 Descriptor descriptor)
Deprecated. 

EventPublishingInhabitant

public EventPublishingInhabitant(ServiceLocator serviceLocator,
                                 Inhabitant<?> delegate)
Deprecated. 

EventPublishingInhabitant

public EventPublishingInhabitant(ServiceLocator serviceLocator,
                                 Inhabitant<?> delegate,
                                 InhabitantListener listener)
Deprecated. 
Method Detail

typeName

public String typeName()
Deprecated. 
Description copied from interface: Inhabitant
The short-cut for type().getName() but this allows us to defer loading the actual types.


metadata

public Map<String,List<String>> metadata()
Deprecated. 
Description copied from interface: Inhabitant
Gets the metadata associated with this inhabitant.

This data is usually used by a sub-system of HK2, and not really meant to be used by applications. (At least for now.) The main benefit of metadata is that it's available right away as soon as the ServiceLocator is properly initialized, even before component classes are loaded. In contrast, accessing annotations would require classes to be loaded and resolved.

Returns:
can be empty but never null. The values are read-only.
See Also:
Service.metadata()

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.


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.

type

public Class<? extends T> type()
Deprecated. 
Description copied from interface: Inhabitant
Type of the inhabitant.

The only binding contract that needs to be honored is that the Inhabitant.get() method returns an instance assignable to this type. That is, get().getClass()==type() doesn't necessarily have to hold, but type().isInstance(get()) must.

This is particularly true when Factory is involved, as in such case HK2 has no way of knowing the actual type. That said, this method is not designed for the semantics of contract/implementation split --- implementations of a contract should return the concrete type from this method, and use habitat index to support look-up by contract.

Returns:
Always non-null, same value.

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.


fetch

protected void fetch()
Deprecated. 

addInhabitantListener

public void addInhabitantListener(InhabitantListener listener)
Deprecated. 

removeInhabitantListener

public boolean removeInhabitantListener(InhabitantListener listener)
Deprecated. 

notify

protected void notify(InhabitantListener.EventType eventType)
Deprecated. 

getServiceLocator

public ServiceLocator getServiceLocator()
Deprecated. 

hashCode

public int hashCode()
Deprecated. 
Overrides:
hashCode in class DescriptorImpl

equals

public boolean equals(Object o)
Deprecated. 
Overrides:
equals in class DescriptorImpl

toString

public String toString()
Deprecated. 
Overrides:
toString in class AbstractInhabitantImpl<T>


Copyright © 2013 Oracle Corporation. All Rights Reserved.