|
Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bea.wlp.services.Services
public final class Services
A common factory for retrieving services.
The retrieval model is based on the service's type (Class object), and in some cases the current context and/or a service name.
Note that the actual instance of a service may go away (be garbage collected) if memory needs to be reclaimed. Therefore, services should be stateless, since any state they hold may be reclaimed by the garbage collector. If you need to interact with a particular service instance, you must hold the reference to that service for the duration of the conversation. But the need for this should be discouraged, as it is probably not thread-safe.
Method Summary | ||
---|---|---|
static
|
getService(Class<T> serviceType)
Retrieve a service of the given type. |
|
static
|
getService(Class<T> serviceType,
String serviceName)
Retrieve a named service of the given type. |
|
static Collection<String> |
getServiceNames(Class<?> serviceType)
Return all the known names of the named service of the given type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T getService(Class<T> serviceType)
This method simply calls getService(serviceType,null)
.
T
- the type of the serviceserviceType
- class object for the service being retrieved, generally an interface
ClassCastException
- if a service is found by name but is not if the
given type.
ServicesException
- if some other unrecoverable problem (like a
serious configuration error) is encountered.public static Collection<String> getServiceNames(Class<?> serviceType)
serviceType
- class object for the service being queried, generally an interface
ServicesException
- if some unrecoverable problem (like a
serious configuration error) is encountered.public static <T> T getService(Class<T> serviceType, String serviceName)
When the name is null, this method should return an unnamed service, or some service instance designated as the primary service. Where this is not possible (that is, the service does not exist or a name is required), null will be returned. It is up to the individual service to determine (and document) proper behavior in this regard.
T
- the type of the serviceserviceType
- class object for the service being retrieved, generally an interfaceserviceName
- the name of the service instance requested, or null to lookup
an unnamed or primary service instance.
getService(Class)
,
getServiceNames(Class)
|
Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |