|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.richfaces.application.ServiceTracker
public final class ServiceTracker
Tracker class to provide access to various framework implementation services.
Examples of such services are: SkinFactory
, TBD.
Supports either direct placement of service implementation instances or lazy
initialization via ServiceReference
interface.
This class represents application-scoped object that is replicated into attributes
of FacesContext
during runtime for better performance.
No modifications operations are allowed after ServiceTracker
is locked,
and IllegalStateException
is throws in this case.
Note: in initial state this class is not synchronized and presumes that all modification operations are done in a context of single-thread (in JSF initialization listener). In locked state read operations can be called from multiple threads concurrently without no need to synchronize explicitly.
Method Summary | ||
---|---|---|
static java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> |
getConcurrentStorage(javax.faces.context.FacesContext context)
Returns ConcurrentMap stored in ServiceTracker . |
|
static java.util.Collection<java.lang.Class<?>> |
getRegisteredServiceClasses(javax.faces.context.FacesContext context)
Returns unmodifiable collection of registered service classes. |
|
static
|
getService(javax.faces.context.FacesContext context,
java.lang.Class<T> serviceClass)
Lookup registered service implementation by service class. |
|
static java.util.Date |
getStartTime(javax.faces.context.FacesContext context)
Returns ServiceTracker instantiation time. |
|
static void |
lockModification(javax.faces.context.FacesContext context)
Switches application-scoped ServiceTracker to locked state, preventing further modifications
of registered services via setService(FacesContext, Class, Object) or
setServiceReference(FacesContext, Class, ServiceReference) methods. |
|
static void |
release(javax.faces.context.FacesContext context)
Releases application-scoped ServiceTracker . |
|
static
|
setService(javax.faces.context.FacesContext context,
java.lang.Class<T> serviceClass,
T serviceImplementation)
Registers service implementation for the given service class. |
|
static
|
setServiceReference(javax.faces.context.FacesContext context,
java.lang.Class<T> serviceClass,
ServiceReference<T> serviceReference)
Registers ServiceReference for the given service class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.Collection<java.lang.Class<?>> getRegisteredServiceClasses(javax.faces.context.FacesContext context)
context
- current instance of FacesContext
java.lang.NullPointerException
- if context
is null
public static <T> T getService(javax.faces.context.FacesContext context, java.lang.Class<T> serviceClass)
context
- current instance of FacesContext
serviceClass
- class for which implementation has been registered.
null
java.lang.NullPointerException
- if context
or serviceClass
is null
public static <T> void setService(javax.faces.context.FacesContext context, java.lang.Class<T> serviceClass, T serviceImplementation)
context
- current instance of FacesContext
serviceClass
- class for which implementation is to be registeredserviceImplementation
- service implementation
java.lang.NullPointerException
- if context
, serviceClass
or
serviceImplementation
is null
java.lang.IllegalStateException
- if current ServiceTracker
is in locked state.public static <T> void setServiceReference(javax.faces.context.FacesContext context, java.lang.Class<T> serviceClass, ServiceReference<T> serviceReference)
ServiceReference
for the given service class.
context
- current instance of FacesContext
serviceClass
- class for which reference is to be registeredserviceReference
- instance of service reference
java.lang.NullPointerException
- if context
, serviceClass
or
serviceReference
is null
java.lang.IllegalStateException
- if current ServiceTracker
is in locked state.public static void release(javax.faces.context.FacesContext context)
Releases application-scoped ServiceTracker
.
Called during application shutdown; shouldn't be called explicitly by user.
context
- current instance of FacesContext
public static void lockModification(javax.faces.context.FacesContext context)
Switches application-scoped ServiceTracker
to locked state, preventing further modifications
of registered services via setService(FacesContext, Class, Object)
or
setServiceReference(FacesContext, Class, ServiceReference)
methods.
Called at the beginning of the very first application request life cycle; shouldn't be called explicitly by user.
context
- current instance of FacesContext
public static java.util.Date getStartTime(javax.faces.context.FacesContext context)
ServiceTracker
instantiation time. Corresponds to application initialization time.
context
-
public static java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object> getConcurrentStorage(javax.faces.context.FacesContext context)
ConcurrentMap
stored in ServiceTracker
. This map is intended
to be used as fast application-scoped storage.
context
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |