|
||||||||||
| 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(java.lang.Class<T> createMe)
This method will analyze the given class, and create it if can. |
|
|
createAndInitialize(java.lang.Class<U> createMe)
This method creates, injects and post-constructs an object with the given class. |
|
java.util.List<ServiceHandle<?>> |
getAllServiceHandles(java.lang.annotation.Annotation qualifier,
java.lang.annotation.Annotation... qualifiers)
Gets a list of ServiceHandle that can be used to get and destroy services
associated with descriptors that match the provided criteria |
|
|
getAllServiceHandles(java.lang.Class<T> contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets a list of ServiceHandle that can be used to get and destroy services
associated with descriptors that match the provided criteria |
|
java.util.List<ServiceHandle<?>> |
getAllServiceHandles(Filter searchCriteria)
Gets a list of ServiceHandle whose ActiveDescriptors match
the supplied filter. |
|
java.util.List<ServiceHandle<?>> |
getAllServiceHandles(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets a list of ServiceHandle that can be used to get and destroy services
associated with descriptors that match the provided criteria |
|
|
getAllServices(java.lang.annotation.Annotation qualifier,
java.lang.annotation.Annotation... qualifiers)
Gets the all the services from this locator that has the given qualifier or qualifiers |
|
|
getAllServices(java.lang.Class<T> contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets the all the services from this locator that implements this contract or has this implementation |
|
java.util.List<?> |
getAllServices(Filter searchCriteria)
Gets the all the services from this locator that matches the Filter |
|
|
getAllServices(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.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 |
|
java.util.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. |
|
java.lang.String |
getName()
Returns the name of this ServiceLocator |
|
|
getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root)
Deprecated. use getService(ActiveDescriptor, ServiceHandle, Injectee) |
|
|
getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root,
Injectee injectee)
This method should be called by code resolving injectee's on behalf of some root service, usually by an implementation of InjectionResolver.resolve(Injectee, ServiceHandle). |
|
|
getService(java.lang.Class<T> contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets the best service from this locator that implements this contract or has this implementation |
|
|
getService(java.lang.Class<T> contractOrImpl,
java.lang.String name,
java.lang.annotation.Annotation... qualifiers)
Gets the best service from this locator that implements this contract or has this implementation and has the given name |
|
|
getService(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets the best service from this locator that implements this contract or has this implementation |
|
|
getService(java.lang.reflect.Type contractOrImpl,
java.lang.String name,
java.lang.annotation.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 ServiceHandle that can be used to get and destroy the service
described by the ActiveDescriptor. |
|
|
getServiceHandle(ActiveDescriptor<T> activeDescriptor,
Injectee injectee)
Gets a ServiceHandle that can be used to get and destroy the service
described by the ActiveDescriptor. |
|
|
getServiceHandle(java.lang.Class<T> contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets a ServiceHandle that can be used to get and destroy the
service that best matches the given criteria |
|
|
getServiceHandle(java.lang.Class<T> contractOrImpl,
java.lang.String name,
java.lang.annotation.Annotation... qualifiers)
Gets a ServiceHandle that can be used to get and destroy the
service that best matches the given criteria |
|
|
getServiceHandle(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
Gets a ServiceHandle that can be used to get and destroy the
service that best matches the given criteria |
|
|
getServiceHandle(java.lang.reflect.Type contractOrImpl,
java.lang.String name,
java.lang.annotation.Annotation... qualifiers)
Gets a ServiceHandle that can be used to get and destroy the
service that best matches the given criteria |
|
void |
inject(java.lang.Object injectMe)
This will analyze the given object and inject into its fields and methods. |
|
void |
postConstruct(java.lang.Object postConstructMe)
This will analyze the given object and call the postConstruct method. |
|
void |
preDestroy(java.lang.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(java.lang.Class<T> contractOrImpl,
java.lang.annotation.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(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.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(java.lang.Class<T> contractOrImpl,
java.lang.String name,
java.lang.annotation.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 be null (to indicate any name is ok), 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> T getService(java.lang.reflect.Type contractOrImpl,
java.lang.String name,
java.lang.annotation.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 be null (to indicate any name is ok), 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> java.util.List<T> getAllServices(java.lang.Class<T> contractOrImpl,
java.lang.annotation.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> java.util.List<T> getAllServices(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.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> java.util.List<T> getAllServices(java.lang.annotation.Annotation qualifier,
java.lang.annotation.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 creation
java.util.List<?> getAllServices(Filter searchCriteria)
throws MultiException
Filter
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(java.lang.Class<T> contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy the
service that best matches the given criteria
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(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy the
service that best matches the given criteria
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(java.lang.Class<T> contractOrImpl,
java.lang.String name,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy the
service that best matches the given criteria
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,
indicating that any name will match)qualifiers - The set of qualifiers that must match this service
definition
MultiException - if there was an error during service creation
java.lang.IllegalArgumentException - if contractOrImpl is null
<T> ServiceHandle<T> getServiceHandle(java.lang.reflect.Type contractOrImpl,
java.lang.String name,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy the
service that best matches the given criteria
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,
indicating that any name will match)qualifiers - The set of qualifiers that must match this service
definition
MultiException - if there was an error during service creation
java.lang.IllegalArgumentException - if contractOrImpl is null
<T> java.util.List<ServiceHandle<T>> getAllServiceHandles(java.lang.Class<T> contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy services
associated with descriptors that match the provided criteria
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
java.lang.IllegalArgumentException - if contractOrImpl is null
java.util.List<ServiceHandle<?>> getAllServiceHandles(java.lang.reflect.Type contractOrImpl,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy services
associated with descriptors that match the provided criteria
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
java.lang.IllegalArgumentException - if contractOrImpl is null
java.util.List<ServiceHandle<?>> getAllServiceHandles(java.lang.annotation.Annotation qualifier,
java.lang.annotation.Annotation... qualifiers)
throws MultiException
ServiceHandle that can be used to get and destroy services
associated with descriptors that match the provided criteria
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
java.lang.IllegalArgumentException - if contractOrImpl is null
java.util.List<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria)
throws MultiException
ServiceHandle whose ActiveDescriptors match
the supplied filter. The returned ServiceHandles may be used to
get or destroy the services associated with the matching descriptors
searchCriteria - A filter to use when determining which descriptors should apply
MultiException - if there was an error during service handle creationjava.util.List<ActiveDescriptor<?>> getDescriptors(Filter filter)
filter - A filter to use when determining which services should apply
ActiveDescriptor<?> getBestDescriptor(Filter filter)
filter - The non-null filter to use to retrieve the best descriptor
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 class
ActiveDescriptor<?> 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 class
ActiveDescriptor<?> 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
ServiceHandle that can be used to get and destroy the service
described by the ActiveDescriptor. The injectee may be used to discover
the proper classloader to use when attempting to reify the ActiveDescriptor
activeDescriptor - The descriptor for which to create a ServiceHandle.
May not be nullinjectee - The injectee on behalf of whom this service is being injected. May
be null if the injectee is unknown
ServiceHandle that may be used to create or destroy the service
associated with this ActiveDescriptor
MultiException - if there was an error during service handle creation
<T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor)
throws MultiException
ServiceHandle that can be used to get and destroy the service
described by the ActiveDescriptor.
activeDescriptor - The descriptor for which to create a ServiceHandle.
May not be null
ServiceHandle that may be used to create or destroy the service
associated with this ActiveDescriptor
MultiException - if there was an error during service handle creation
@Deprecated
<T> T getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root)
throws MultiException
getService(ActiveDescriptor, ServiceHandle, Injectee)
InjectionResolver.resolve(Injectee, ServiceHandle). In
this way the objects associated with the root object can be destroyed in the proper sequence
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 creation
<T> T getService(ActiveDescriptor<T> activeDescriptor,
ServiceHandle<?> root,
Injectee injectee)
throws MultiException
InjectionResolver.resolve(Injectee, ServiceHandle). In
this way the objects associated with the root object can be destroyed in the proper sequence
activeDescriptor - The descriptor whose service to createroot - The ultimate parent of this service creation. May be nullinjectee - The injectee passed into the InjectionResolver.resolve(Injectee, ServiceHandle) if known,
null otherwise
MultiException - if there was an error during service creationjava.lang.String getName()
long getLocatorId()
void shutdown()
<T> T create(java.lang.Class<T> createMe)
createMe - The class to create, may not be null
void inject(java.lang.Object injectMe)
injectMe - The object to be analyzed and injected intovoid postConstruct(java.lang.Object postConstructMe)
postConstructMe - The object to postConstructvoid preDestroy(java.lang.Object preDestroyMe)
preDestroyMe - The object to preDestroy<U> U createAndInitialize(java.lang.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 | |||||||||