|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@Contract public interface ServiceLocator
ServiceLocator is the registry for HK2 services
Services can be looked up from this instance
Method Summary | ||
---|---|---|
|
create(Class<T> createMe)
This method will analyze the given class, and create it if can. |
|
|
createAndInitialize(Class<U> createMe)
This method creates, injects and post-constructs an object with the given class. |
|
List<ServiceHandle<?>> |
getAllServiceHandles(Annotation qualifier,
Annotation... qualifiers)
Gets service handles that can be used to get and destroy the returned services |
|
List<ServiceHandle<?>> |
getAllServiceHandles(Filter searchCriteria)
Gets a service handle that can be used to get and destroy the returned service. |
|
List<ServiceHandle<?>> |
getAllServiceHandles(Type contractOrImpl,
Annotation... qualifiers)
Gets service handles that can be used to get and destroy the returned services |
|
|
getAllServices(Annotation qualifier,
Annotation... qualifiers)
Gets the all the services from this locator that has the given qualifier or qualifiers |
|
List<?> |
getAllServices(Filter searchCriteria)
Gets the all the services from this locator that implements this contract or has this implementation |
|
|
getAllServices(Type contractOrImpl,
Annotation... qualifiers)
Gets the all the services from this locator that implements this contract or has this implementation |
|
ActiveDescriptor<?> |
getBestDescriptor(Filter filter)
Gets the descriptor that best matches this filter, taking ranking and service id into account |
|
List<ActiveDescriptor<?>> |
getDescriptors(Filter filter)
Gets the list of descriptors that match the given filter |
|
ActiveDescriptor<?> |
getInjecteeDescriptor(Injectee injectee)
This method will first find a descriptor for this injectee, and then reify that descriptor. |
|
long |
getLocatorId()
This returns the unique locator ID for this locator. |
|
String |
getName()
Returns the name of this ServiceLocator |
|
|
getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root)
This method should be called by code getting injectee's on behalf of some root object. |
|
|
getService(Type contractOrImpl,
Annotation... qualifiers)
Gets the best service from this locator that implements this contract or has this implementation |
|
|
getService(Type contractOrImpl,
String name,
Annotation... qualifiers)
Gets the best service from this locator that implements this contract or has this implementation and has the given name |
|
|
getServiceHandle(ActiveDescriptor<T> activeDescriptor)
Gets a service handle that can be used to get and destroy the returned service. |
|
|
getServiceHandle(ActiveDescriptor<T> activeDescriptor,
Injectee injectee)
Gets a service handle that can be used to get and destroy the returned service. |
|
|
getServiceHandle(Type contractOrImpl,
Annotation... qualifiers)
Gets a service handle that can be used to get and destroy the returned service. |
|
|
getServiceHandle(Type contractOrImpl,
String name,
Annotation... qualifiers)
Gets a service handle that can be used to get and destroy the returned service |
|
void |
inject(Object injectMe)
This will analyze the given object and inject into its fields and methods. |
|
void |
postConstruct(Object postConstructMe)
This will analyze the given object and call the postConstruct method. |
|
void |
preDestroy(Object preDestroyMe)
This will analyze the given object and call the preDestroy method. |
|
ActiveDescriptor<?> |
reifyDescriptor(Descriptor descriptor)
Converts a descriptor to an ActiveDescriptor. |
|
ActiveDescriptor<?> |
reifyDescriptor(Descriptor descriptor,
Injectee injectee)
Converts a descriptor to an ActiveDescriptor. |
|
void |
shutdown()
This method will shutdown every service associated with this ServiceLocator. |
Method Detail |
---|
<T> T getService(Type contractOrImpl, Annotation... qualifiers) throws MultiException
Use this method only if destroying the service is not important
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<T> T getService(Type contractOrImpl, String name, Annotation... qualifiers) throws MultiException
Use this method only if destroying the service is not important
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 creation<T> List<T> getAllServices(Type contractOrImpl, Annotation... qualifiers) throws MultiException
Use this method only if destroying the service is not important
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<T> List<T> getAllServices(Annotation qualifier, Annotation... qualifiers) throws MultiException
Use this method only if destroying the services is not important
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 creationList<?> getAllServices(Filter searchCriteria) throws MultiException
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
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 creation<T> ServiceHandle<T> getServiceHandle(Type contractOrImpl, Annotation... qualifiers) throws MultiException
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
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
<T> ServiceHandle<T> getServiceHandle(Type contractOrImpl, String name, Annotation... qualifiers) throws MultiException
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 creation
IllegalArgumentException
- if contractOrImpl is nullList<ServiceHandle<?>> getAllServiceHandles(Type contractOrImpl, Annotation... qualifiers) throws MultiException
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
IllegalArgumentException
- if contractOrImpl is nullList<ServiceHandle<?>> getAllServiceHandles(Annotation qualifier, Annotation... qualifiers) throws MultiException
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 creation
IllegalArgumentException
- if contractOrImpl is nullList<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria) throws MultiException
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
searchCriteria
- A filter to use when determining which services should apply
MultiException
- if there was an error during service creation
List<ActiveDescriptor<?>> getDescriptors(Filter filter)
filter
- A filter to use when determining which services should apply
ActiveDescriptor<?> getBestDescriptor(Filter filter)
filter
- The filter to use to retrieve the set of descriptors
ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor, Injectee injectee) throws MultiException
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 classActiveDescriptor<?> reifyDescriptor(Descriptor descriptor) throws MultiException
descriptor
- The descriptor to convert, may not be null
HK2Loader
MultiException
- if there were errors when loading or analyzing the classActiveDescriptor<?> getInjecteeDescriptor(Injectee injectee) throws MultiException
injectee
- the injection point for whom to find the ActiveDescriptor
MultiException
- if there were errors when loading or analyzing the class<T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor, Injectee injectee) throws MultiException
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
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
<T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor) throws MultiException
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
activeDescriptor
- The service handle that can be used to get and destroy
this service
MultiException
- if there was an error during service creation
<T> T getService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root) throws MultiException
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 creationString getName()
long getLocatorId()
void shutdown()
<T> T create(Class<T> createMe)
createMe
- The class to create, may not be null
void inject(Object injectMe)
injectMe
- The object to be analyzed and injected intovoid postConstruct(Object postConstructMe)
postConstructMe
- The object to postConstructvoid preDestroy(Object preDestroyMe)
preDestroyMe
- The object to preDestroy<U> U createAndInitialize(Class<U> createMe)
create(Class)
method followed by the inject(Object)
method followed
by the postConstruct(Object)
method.
The object created is not managed by the locator.
createMe
- The non-null class to create this object from
MultiException
- if there was an error when creating or initializing the object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |