|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.myfaces.trinidad.util.Service
public class Service
API for retrieving a service from an object. Services
remove the need for a class to directly implement an interface;
instead a class can implement the Service.Provider inner
interface. This makes it possible to "decorate" another
generic class - like RenderKit - without needing to know
in advance what optional interfaces the decorated object
might implement, or to even switch on and off implementations
dynamically. A developer can still choose to directly
implement an interface. The getService(java.lang.Object, java.lang.Class method
supports both direct implementation and the use of
the Service.Provider interface.
RenderKit rk = facesContext.getRenderKit();
// Retrieve the DialogService generically.
DialogService service = (DialogService)
ServiceUtils.getService(rk, DialogService.class);
| Nested Class Summary | |
|---|---|
static interface |
Service.Provider
Inner interface that should be implemented if a class needs to provide services other than by the default approach. |
| Constructor Summary | |
|---|---|
Service()
|
|
| Method Summary | ||
|---|---|---|
static
|
getRenderKitService(FacesContext context,
Class<T> serviceClass)
A convenience for retrieving a service from the current RenderKit. |
|
static
|
getService(Object from,
Class<T> serviceClass)
Returns a service that can be cast to the provided serviceClass, as vended by the from object. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Service()
| Method Detail |
|---|
public static <T> T getService(Object from,
Class<T> serviceClass)
from object. If the class
implements Provider, its getService() method will
be used. Otherwise, the default behavior will be to see
if from is an instance of serviceClass,
and return it if it is.
from - the object that is vending the serviceserviceClass - the type of object that must be returned
serviceClass, or null
if no such object could be located
public static <T> T getRenderKitService(FacesContext context,
Class<T> serviceClass)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||