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.
RenderKit rk = facesContext.getRenderKit(); // Retrieve the DialogService generically. DialogService service = (DialogService) ServiceUtils.getService(rk, DialogService.class);
|Modifier and Type||Class and Description|
Inner interface that should be implemented if a class needs to provide services other than by the default approach.
|Constructor and Description|
|Modifier and Type||Method and Description|
A convenience for retrieving a service from the current RenderKit.
Returns a service that can be cast to the provided serviceClass, as vended by the
fromobject. If the class implements Provider, its
getService()method will be used. Otherwise, the default behavior will be to see if
fromis an instance of
serviceClass, and return it if it is.
from- the object that is vending the service
serviceClass- the type of object that must be returned
serviceClass, or null if no such object could be located
public static <T> T getRenderKitService(javax.faces.context.FacesContext context, Class<T> serviceClass)
Copyright © 2001-2016 The Apache Software Foundation. All Rights Reserved.