net.sf.jasperreports.jsf.util
Class Services

java.lang.Object
  extended by net.sf.jasperreports.jsf.util.Services

public final class Services
extends Object

Utility class to handle the different kind of pluggable services required by the implementation.

Author:
A. Alonso Dominguez

Method Summary
static
<T> T
chain(Class<T> clazz, T defaultInstance)
          Loads a chain of services from the classpath.
static
<T> Map<String,T>
map(Class<T> clazz)
          Loads a service map from the classpath.
static
<T> Set<T>
set(Class<T> clazz)
          Loads a service set from the classpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

chain

public static <T> T chain(Class<T> clazz,
                          T defaultInstance)
               throws ServiceException
Loads a chain of services from the classpath.

Services are looked up following convention META-INF/services/[serviceClassName]. Service chains must be configured the same way that service sets but implementation classes must have a public constructor accepting another instance of the same service that may used as a delegator when implementing class doesn't know how to handle the request.

Type Parameters:
T - Service type to be obtained.
Parameters:
clazz - Service interface class object.
defaultInstance - Last service in the chain. May be null.
Returns:
Chained service implementations offered as a single instance.
Throws:
ServiceException - If any error happens when loading the service chain.

set

public static <T> Set<T> set(Class<T> clazz)
                  throws ServiceException
Loads a service set from the classpath.

Services are looked up following convention META-INF/services/[serviceClassName]. Services set configuration files must contain a list of service implementation classes.

Type Parameters:
T - Service type to be obtained.
Parameters:
clazz - Service interface class object.
Returns:
a set of services of the requested type.
Throws:
ServiceException

map

public static <T> Map<String,T> map(Class<T> clazz)
                         throws ServiceException
Loads a service map from the classpath.

Services are looked up following convention META-INF/services/[serviceClassName]. When loading service maps, service configuration file must contain entries as follows: [key]:[implementation class] .

Type Parameters:
T - Service type to be obtained.
Parameters:
clazz - Service interface class object.
Returns:
the map of services.
Throws:
ServiceException


Copyright © 2011 SourceForge.net. All Rights Reserved.