|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jvnet.hk2.internal.ServiceLocatorImpl
public class ServiceLocatorImpl
Constructor Summary | |
---|---|
ServiceLocatorImpl(String name,
ServiceLocator parent)
Called by the Generator, and hence must be a public method |
Method Summary | ||
---|---|---|
|
create(Class<T> createMe)
This method will analyze the given class, and create it if can. |
|
|
createAndInitialize(Class<U> createMe)
Creates, injects and postConstructs, all in one |
|
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. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ServiceLocatorImpl(String name, ServiceLocator parent)
name
- The name of this locatorparent
- The parent of this locator (may be null)Method Detail |
---|
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 <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> 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 <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 <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 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 String getName()
ServiceLocator
getName
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 injectMe)
ServiceLocator
inject
in interface ServiceLocator
injectMe
- 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)
createAndInitialize
in interface ServiceLocator
createMe
- The non-null class to create this object from
public <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 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 <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(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<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 long getLocatorId()
ServiceLocator
getLocatorId
in interface ServiceLocator
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |