Skip navigation links
org.apache.myfaces.trinidad.util
Class Service
java.lang.Object
org.apache.myfaces.trinidad.util.Service
-
public class Service
- extends Object
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<T>) method supports both direct implementation and the use of the Service.Provider interface.
Example:
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. |
| Method Summary |
static
|
getRenderKitService(javax.faces.context.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 |
Service
public Service()
getService
public static <T> T getService(Object from,
Class<T> serviceClass)
- Returns a service that can be cast to the provided serviceClass, as vended by the
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.
-
- Parameters:
from - the object that is vending the service
serviceClass - the type of object that must be returned
- Returns:
- an object of type
serviceClass, or null if no such object could be located
getRenderKitService
public static <T> T getRenderKitService(javax.faces.context.FacesContext context,
Class<T> serviceClass)
- A convenience for retrieving a service from the current RenderKit.
Skip navigation links
Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.