|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jvnet.hk2.component.Habitat
@Deprecated public class Habitat
A set of templates that constitute a world of objects.
Constructor Summary | |
---|---|
Habitat()
Deprecated. |
|
Habitat(Habitat parent,
String name)
Deprecated. |
|
Habitat(ServiceLocator delegate)
Deprecated. |
Method Summary | ||
---|---|---|
void |
add(Inhabitant<?> i)
Deprecated. Adds a new inhabitant. |
|
|
addComponent(T component)
Deprecated. Add an already instantiated component to this manager. |
|
void |
addIndex(Inhabitant<?> i,
String index,
String name)
Deprecated. Adds a new index to look up the given inhabitant. |
|
protected void |
addIndex(Inhabitant<?> i,
String index,
String name,
boolean notify)
Deprecated. |
|
|
create(Class<T> createMe)
Deprecated. This method will analyze the given class, and create it if can. |
|
|
createAndInitialize(Class<U> createMe)
Deprecated. This method creates, injects and post-constructs an object with the given class. |
|
|
getAllByContract(Class<T> contractType)
Deprecated. Gets all the inhabitants registered under the given Contract . |
|
|
getAllByContract(String contractType)
Deprecated. |
|
|
getAllByType(Class<T> implType)
Deprecated. Gets the object of the given type. |
|
List<ServiceHandle<?>> |
getAllServiceHandles(Annotation qualifier,
Annotation... qualifiers)
Deprecated. Gets service handles that can be used to get and destroy the returned services |
|
List<ServiceHandle<?>> |
getAllServiceHandles(Filter searchCriteria)
Deprecated. Gets a service handle that can be used to get and destroy the returned service. |
|
List<ServiceHandle<?>> |
getAllServiceHandles(Type contractOrImpl,
Annotation... qualifiers)
Deprecated. Gets service handles that can be used to get and destroy the returned services |
|
|
getAllServices(Annotation qualifier,
Annotation... qualifiers)
Deprecated. Gets the all the services from this locator that has the given qualifier or qualifiers |
|
List<?> |
getAllServices(Filter searchCriteria)
Deprecated. Gets the all the services from this locator that implements this contract or has this implementation |
|
|
getAllServices(Type contractOrImpl,
Annotation... qualifiers)
Deprecated. Gets the all the services from this locator that implements this contract or has this implementation |
|
ActiveDescriptor<?> |
getBestDescriptor(Filter filter)
Deprecated. Gets the descriptor that best matches this filter, taking ranking and service id into account |
|
|
getByContract(Class<T> contractType)
Deprecated. Gets the object that has the given contract. |
|
|
getByContract(String contractType)
Deprecated. |
|
|
getByType(Class<T> implType)
Deprecated. Gets the object of the given type. |
|
|
getByType(String implType)
Deprecated. Gets the object of the given type. |
|
|
getComponent(Class<T> clazz)
Deprecated. Obtains a reference to the component inside the manager. |
|
|
getComponent(Class<T> contract,
String name)
Deprecated. Loads a component that implements the given contract and has the given name. |
|
|
getComponent(String fullQualifiedName,
String name)
Deprecated. Analogous to the following: |
|
List<ActiveDescriptor<?>> |
getDescriptors(Filter filter)
Deprecated. Gets the list of descriptors that match the given filter |
|
|
getInhabitant(Class<T> contract,
String name)
Deprecated. Gets a lazy reference to the component. |
|
|
getInhabitant(Type type,
String name)
Deprecated. |
|
Inhabitant<?> |
getInhabitantByAnnotation(Class<? extends Annotation> contract,
String name)
Deprecated. Gets the inhabitant that has the given contract annotation and the given name. |
|
Inhabitant<?> |
getInhabitantByContract(String typeName)
Deprecated. Get the first inhabitant by contract |
|
Inhabitant |
getInhabitantByContract(String fullyQualifiedName,
String name)
Deprecated. |
|
|
getInhabitantByType(Class<T> implType)
Deprecated. Gets a lazy reference to the component. |
|
Inhabitant<?> |
getInhabitantByType(String fullyQualifiedClassName)
Deprecated. |
|
|
getInhabitantByType(Type implType)
Deprecated. |
|
|
getInhabitants(Class<T> type)
Deprecated. Gets all the inhabitants for a spcial contract. |
|
|
getInhabitants(Class<T> contract,
String name)
Deprecated. Gets all the inhabitants that has the given contract and the given name This method defers the actual instantiation of the component until Inhabitant.get() is invoked. |
|
Iterable<Inhabitant<?>> |
getInhabitantsByAnnotation(Class<? extends Annotation> contract,
String name)
Deprecated. Gets all the inhabitants that has the given contract annotation and the given name. |
|
Collection<Inhabitant<?>> |
getInhabitantsByContract(String fullyQualifiedClassName)
Deprecated. |
|
|
getInhabitantsByContract(Type contract)
Deprecated. Gets all the inhabitants that has the given contract. |
|
|
getInhabitantsByType(Class<T> implType)
Deprecated. Gets all the inhabitants that has the given implementation type. |
|
Collection<Inhabitant<?>> |
getInhabitantsByType(String fullyQualifiedClassName)
Deprecated. Gets all the inhabitants that has the given implementation type name. |
|
ActiveDescriptor<?> |
getInjecteeDescriptor(Injectee injectee)
Deprecated. This method will first find a descriptor for this injectee, and then reify that descriptor. |
|
long |
getLocatorId()
Deprecated. This returns the unique locator ID for this locator. |
|
String |
getName()
Deprecated. Returns the name of this ServiceLocator |
|
|
getProvider(Type type,
String name)
Deprecated. Gets an inhabitant from its type and optionally name |
|
|
getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root)
Deprecated. This method should be called by code getting injectee's on behalf of some root object. |
|
|
getService(Type contractOrImpl,
Annotation... qualifiers)
Deprecated. Gets the best service from this locator that implements this contract or has this implementation |
|
|
getService(Type contractOrImpl,
String name,
Annotation... qualifiers)
Deprecated. Gets the best service from this locator that implements this contract or has this implementation and has the given name |
|
|
getServiceHandle(ActiveDescriptor<T> activeDescriptor)
Deprecated. Gets a service handle that can be used to get and destroy the returned service. |
|
|
getServiceHandle(ActiveDescriptor<T> activeDescriptor,
Injectee injectee)
Deprecated. Gets a service handle that can be used to get and destroy the returned service. |
|
|
getServiceHandle(Type contractOrImpl,
Annotation... qualifiers)
Deprecated. Gets a service handle that can be used to get and destroy the returned service. |
|
|
getServiceHandle(Type contractOrImpl,
String name,
Annotation... qualifiers)
Deprecated. Gets a service handle that can be used to get and destroy the returned service |
|
protected static Long |
getServiceRanking(Inhabitant<?> i,
boolean wantNonNull)
Deprecated. |
|
void |
initialized()
Deprecated. FOR INTERNAL USE ONLY |
|
|
inject(Class<T> type)
Deprecated. Instantiate the passed type and injects all the org.jvnet.hk2.annotations.Inject
annotated fields and methods |
|
void |
inject(Object object)
Deprecated. This will analyze the given object and inject into its fields and methods. |
|
boolean |
isInitialized()
Deprecated. |
|
void |
postConstruct(Object postConstructMe)
Deprecated. This will analyze the given object and call the postConstruct method. |
|
void |
preDestroy(Object preDestroyMe)
Deprecated. This will analyze the given object and call the preDestroy method. |
|
ActiveDescriptor<?> |
reifyDescriptor(Descriptor descriptor)
Deprecated. Converts a descriptor to an ActiveDescriptor. |
|
ActiveDescriptor<?> |
reifyDescriptor(Descriptor descriptor,
Injectee injectee)
Deprecated. Converts a descriptor to an ActiveDescriptor. |
|
boolean |
remove(Inhabitant<?> inhabitant)
Deprecated. Removes an inhabitant |
|
boolean |
removeAllByType(Class<?> type)
Deprecated. Removes all inhabitants for a particular type |
|
boolean |
removeIndex(String index,
Object serviceOrInhabitant)
Deprecated. Removes a Contracted service |
|
boolean |
removeIndex(String index,
String name)
Deprecated. Removes a NamedInhabitant for a specific contract |
|
void |
shutdown()
Deprecated. This method will shutdown every service associated with this ServiceLocator. |
|
String |
toString()
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Habitat()
public Habitat(ServiceLocator delegate)
public Habitat(Habitat parent, String name)
Method Detail |
---|
public boolean removeAllByType(Class<?> type)
type
- of the component
public void add(Inhabitant<?> i)
Inhabitants
for typical ways to create Inhabitant
s.
public void addIndex(Inhabitant<?> i, String index, String name)
index
- Primary index name, such as contract FQCN.name
- Name that identifies the inhabitant among other inhabitants in
the same index. Can be null for unnamed inhabitants.protected void addIndex(Inhabitant<?> i, String index, String name, boolean notify)
protected static Long getServiceRanking(Inhabitant<?> i, boolean wantNonNull)
public boolean remove(Inhabitant<?> inhabitant)
inhabitant
- inhabitant to be removedpublic boolean removeIndex(String index, String name)
index
- contract namename
- instance name
public boolean removeIndex(String index, Object serviceOrInhabitant)
index
- the contract nameserviceOrInhabitant
- the service instance, or an Inhabitant instancepublic void initialized()
public boolean isInitialized()
public <T> Collection<T> getAllByContract(Class<T> contractType)
Contract
.
This is an example of heterogeneous type-safe container.
getAllByContract
in interface BaseServiceLocator
public <T> Collection<T> getAllByContract(String contractType)
getAllByContract
in interface BaseServiceLocator
public <T> Collection<T> getAllByType(Class<T> implType)
public <T> void addComponent(T component) throws ComponentException
component
- component instance
ComponentException
- if the passed object is not an HK2 component or
injection/extraction failed.public <T> T getComponent(Class<T> clazz) throws ComponentException
Scope
of the component, a new instance might be
created, or an existing instance might be returned.
getComponent
in interface BaseServiceLocator
ComponentException
- If failed to obtain a requested instance. In practice,
failure only happens when we try to create a new instance of
the component.public <T> T getComponent(Class<T> contract, String name) throws ComponentException
BaseServiceLocator
getComponent
in interface BaseServiceLocator
name
- can be null, in which case it'll only match to the unnamed
component.
ComponentException
public <T> T getComponent(String fullQualifiedName, String name)
BaseServiceLocator
getComponent(contractClass.getName(), name);
getComponent
in interface BaseServiceLocator
fullQualifiedName
- the contract class namename
- can be null, in which case it'll only match to the unnamed
component.
public <T> Inhabitant<T> getInhabitant(Class<T> contract, String name) throws ComponentException
Inhabitant.get()
is invoked.
ComponentException
public <T> Inhabitant<T> getInhabitant(Type type, String name)
public <T> Inhabitant<T> getInhabitantByType(Class<T> implType)
Inhabitant.get()
is invoked.
public <T> Inhabitant<T> getInhabitantByType(Type implType)
public Inhabitant<?> getInhabitantByType(String fullyQualifiedClassName)
public Inhabitant<?> getInhabitantByAnnotation(Class<? extends Annotation> contract, String name) throws ComponentException
Inhabitant.get()
is invoked.
ComponentException
public <T> Collection<Inhabitant<? extends T>> getInhabitants(Class<T> type)
T
- the parameterized typetype
- the contract type
public <T> Collection<Inhabitant<T>> getInhabitantsByContract(Type contract) throws ComponentException
getInhabitantsByContract
in interface SimpleServiceLocator
ComponentException
public <T> T inject(Class<T> type)
org.jvnet.hk2.annotations.Inject
annotated fields and methods
T
- type of the requested instancetype
- class of the requested instance
public <T> Collection<Inhabitant<T>> getInhabitantsByType(Class<T> implType) throws ComponentException
getInhabitantsByType
in interface SimpleServiceLocator
ComponentException
public Collection<Inhabitant<?>> getInhabitantsByType(String fullyQualifiedClassName)
getInhabitantsByType
in interface SimpleServiceLocator
public Inhabitant<?> getInhabitantByContract(String typeName)
typeName
- fullyQualifiedClassName
public Collection<Inhabitant<?>> getInhabitantsByContract(String fullyQualifiedClassName)
getInhabitantsByContract
in interface SimpleServiceLocator
public Inhabitant getInhabitantByContract(String fullyQualifiedName, String name)
public <T> Iterable<Inhabitant<? extends T>> getInhabitants(Class<T> contract, String name) throws ComponentException
Inhabitant.get()
is invoked.
ComponentException
public Iterable<Inhabitant<?>> getInhabitantsByAnnotation(Class<? extends Annotation> contract, String name) throws ComponentException
Inhabitant.get()
is invoked.
ComponentException
public <T> T getByType(Class<T> implType)
BaseServiceLocator
getByType
in interface BaseServiceLocator
public <T> T getByType(String implType)
BaseServiceLocator
getByType
in interface BaseServiceLocator
public <T> Inhabitant<T> getProvider(Type type, String name)
SimpleServiceLocator
getProvider
in interface SimpleServiceLocator
type
- requested inhabitant typename
- optional namepublic <T> T getByContract(Class<T> contractType)
getByContract
in interface BaseServiceLocator
public <T> T getByContract(String contractType)
getByContract
in interface BaseServiceLocator
public <T> T getService(Type contractOrImpl, Annotation... qualifiers) throws MultiException
ServiceLocator
Use this method only if destroying the service is not important
getService
in interface ServiceLocator
contractOrImpl
- May not be null, and is the contract
or concrete implementation to get the best instance ofqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic <T> T getService(Type contractOrImpl, String name, Annotation... qualifiers) throws MultiException
ServiceLocator
Use this method only if destroying the service is not important
getService
in interface ServiceLocator
contractOrImpl
- May not be null, and is the contract
or concrete implementation to get the best instance ofname
- May not be null, and is the name of the
implementation to be returnedqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic <T> List<T> getAllServices(Type contractOrImpl, Annotation... qualifiers) throws MultiException
ServiceLocator
Use this method only if destroying the service is not important
getAllServices
in interface ServiceLocator
contractOrImpl
- May not be null, and is the contract
or concrete implementation to get the best instance ofqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic List<?> getAllServices(Filter searchCriteria) throws MultiException
ServiceLocator
Use this method only if destroying the service is not important
This method should also be used with care to avoid classloading a large number of services
getAllServices
in interface ServiceLocator
searchCriteria
- The returned service will match the Filter
(in other words, searchCriteria.matches returns true). May not
be null
MultiException
- if there was an error during service creationpublic <T> ServiceHandle<T> getServiceHandle(Type contractOrImpl, Annotation... qualifiers) throws MultiException
ServiceLocator
It is assumed that this method is called by the top level code. All injection
points created because of this invocation must use the
getServiceHandle(ActiveDescriptor
getServiceHandle
in interface ServiceLocator
contractOrImpl
- May not be null, and is the contract
or concrete implementation to get the best instance ofqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creation
public <T> ServiceHandle<T> getServiceHandle(Type contractOrImpl, String name, Annotation... qualifiers) throws MultiException
ServiceLocator
getServiceHandle
in interface ServiceLocator
contractOrImpl
- May not be null, and is the contract
or concrete implementation to get the best instance ofname
- The name to use to further qualify the search (may be null)qualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic List<ServiceHandle<?>> getAllServiceHandles(Type contractOrImpl, Annotation... qualifiers) throws MultiException
ServiceLocator
getAllServiceHandles
in interface ServiceLocator
contractOrImpl
- May not be null, and is the contract
or concrete implementation to get the best instance ofqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic List<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria) throws MultiException
ServiceLocator
It is assumed that this method is called by the top level code. All injection
points created because of this invocation must use the
getServiceHandle(ActiveDescriptor
getAllServiceHandles
in interface ServiceLocator
searchCriteria
- A filter to use when determining which services should apply
MultiException
- if there was an error during service creation
public List<ActiveDescriptor<?>> getDescriptors(Filter filter)
ServiceLocator
getDescriptors
in interface ServiceLocator
filter
- A filter to use when determining which services should apply
public ActiveDescriptor<?> getBestDescriptor(Filter filter)
ServiceLocator
getBestDescriptor
in interface ServiceLocator
filter
- The filter to use to retrieve the set of descriptors
public ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor, Injectee injectee) throws MultiException
ServiceLocator
reifyDescriptor
in interface ServiceLocator
descriptor
- The descriptor to convert, may not be nullinjectee
- The injectee on behalf of whom this descriptor is being injected. May
be null if the injectee is unknown
HK2Loader
MultiException
- if there were errors when loading or analyzing the classpublic ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor) throws MultiException
ServiceLocator
reifyDescriptor
in interface ServiceLocator
descriptor
- The descriptor to convert, may not be null
HK2Loader
MultiException
- if there were errors when loading or analyzing the classpublic ActiveDescriptor<?> getInjecteeDescriptor(Injectee injectee) throws MultiException
ServiceLocator
getInjecteeDescriptor
in interface ServiceLocator
injectee
- the injection point for whom to find the ActiveDescriptor
MultiException
- if there were errors when loading or analyzing the classpublic <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor, Injectee injectee) throws MultiException
ServiceLocator
It is assumed that this method is called by the top level code. All injection
points created because of this invocation must use the
getServiceHandle(ActiveDescriptor
getServiceHandle
in interface ServiceLocator
activeDescriptor
- The service handle that can be used to get and destroy
this serviceinjectee
- The injectee on behalf of whom this descriptor is being injected. May
be null if the injectee is unknown
MultiException
- if there was an error during service creation
public <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor) throws MultiException
ServiceLocator
It is assumed that this method is called by the top level code. All injection
points created because of this invocation must use the
getServiceHandle(ActiveDescriptor
getServiceHandle
in interface ServiceLocator
activeDescriptor
- The service handle that can be used to get and destroy
this service
MultiException
- if there was an error during service creation
public <T> T getService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root) throws MultiException
ServiceLocator
getService
in interface ServiceLocator
activeDescriptor
- The descriptor whose service to createroot
- The ultimate parent of this service creation. May be null
MultiException
- if there was an error during service creationpublic String getName()
ServiceLocator
getName
in interface ServiceLocator
public long getLocatorId()
ServiceLocator
getLocatorId
in interface ServiceLocator
public void shutdown()
ServiceLocator
shutdown
in interface ServiceLocator
public <T> T create(Class<T> createMe)
ServiceLocator
create
in interface ServiceLocator
createMe
- The class to create, may not be null
public void inject(Object object)
ServiceLocator
inject
in interface ServiceLocator
object
- The object to be analyzed and injected intopublic void postConstruct(Object postConstructMe)
ServiceLocator
postConstruct
in interface ServiceLocator
postConstructMe
- The object to postConstructpublic void preDestroy(Object preDestroyMe)
ServiceLocator
preDestroy
in interface ServiceLocator
preDestroyMe
- The object to preDestroypublic <U> U createAndInitialize(Class<U> createMe)
ServiceLocator
ServiceLocator.create(Class)
method followed by the ServiceLocator.inject(Object)
method followed
by the ServiceLocator.postConstruct(Object)
method.
The object created is not managed by the locator.
createAndInitialize
in interface ServiceLocator
createMe
- The non-null class to create this object from
public <T> List<T> getAllServices(Annotation qualifier, Annotation... qualifiers) throws MultiException
ServiceLocator
Use this method only if destroying the services is not important
getAllServices
in interface ServiceLocator
qualifier
- May not be null, and is a qualifier that must
match the service definitionqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic List<ServiceHandle<?>> getAllServiceHandles(Annotation qualifier, Annotation... qualifiers) throws MultiException
ServiceLocator
getAllServiceHandles
in interface ServiceLocator
qualifier
- May not be null, and is a qualifier that must
match the service definitionqualifiers
- The set of qualifiers that must match this service
definition
MultiException
- if there was an error during service creationpublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |