org.jboss.cache.factories
Class InterceptorChainFactory

java.lang.Object
  extended by org.jboss.cache.factories.ComponentFactory
      extended by org.jboss.cache.factories.InterceptorChainFactory

public class InterceptorChainFactory
extends ComponentFactory

Factory class that builds an interceptor chain based on cache configuration.

Author:
Manik Surtani (manik@jboss.org)

Field Summary
 
Fields inherited from class org.jboss.cache.factories.ComponentFactory
componentRegistry, configuration, log
 
Constructor Summary
InterceptorChainFactory()
           
 
Method Summary
static List<Interceptor> asList(Interceptor interceptor)
           
 Interceptor buildInterceptorChain()
           
protected
<T> T
construct(String componentName, Class<T> componentType)
          Initialises the interceptors with a CacheSPI instance.
 Interceptor correctInterceptorChaining(Interceptor first)
          The same as correctInterceptorChaining(java.util.List) except that it takes in the first interceptor in the chain instead of a list of interceptors, and traverses the chain to generate a list.
 Interceptor correctInterceptorChaining(List<Interceptor> interceptors)
          "Fixes" the next() and last() pointers for each interceptor, based on the order presented in the list passed in, and also re-assesses dependencies for each interceptor, injecting dependencies accordingingly.
static InterceptorChainFactory getInstance()
          Deprecated. 
static InterceptorChainFactory getInstance(ComponentRegistry componentRegistry, Configuration configuration)
           
 Interceptor setFirstInterceptor(Class<? extends Interceptor> clazz)
           
 Interceptor setFirstInterceptor(Interceptor i)
           
static Interceptor setLastInterceptorPointer(Interceptor first, Interceptor last)
           
 
Methods inherited from class org.jboss.cache.factories.ComponentFactory
assertTypeConstructable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterceptorChainFactory

public InterceptorChainFactory()
Method Detail

getInstance

@Deprecated
public static InterceptorChainFactory getInstance()
Deprecated. 

Note - this method used to return a singleton instance, and since 2.1.0 returns a new instance. The method is deprecated and you should use the no-arg constructor to create a new instance of this factory.

Returns:
a NEW instance of this class.

setLastInterceptorPointer

public static Interceptor setLastInterceptorPointer(Interceptor first,
                                                    Interceptor last)

buildInterceptorChain

public Interceptor buildInterceptorChain()
                                  throws IllegalAccessException,
                                         InstantiationException,
                                         ClassNotFoundException
Throws:
IllegalAccessException
InstantiationException
ClassNotFoundException

setFirstInterceptor

public Interceptor setFirstInterceptor(Class<? extends Interceptor> clazz)
                                throws IllegalAccessException,
                                       InstantiationException
Throws:
IllegalAccessException
InstantiationException

setFirstInterceptor

public Interceptor setFirstInterceptor(Interceptor i)

asList

public static List<Interceptor> asList(Interceptor interceptor)

correctInterceptorChaining

public Interceptor correctInterceptorChaining(Interceptor first)
The same as correctInterceptorChaining(java.util.List) except that it takes in the first interceptor in the chain instead of a list of interceptors, and traverses the chain to generate a list. Identical to calling
    InterceptorChainFactory.correctInterceptorChaining( InterceptorChainFactory.asList(first), configuration, componentRegistry );
 

Parameters:
first - first interceptor in the chain to correct.
Returns:
the first interceptor in the chain.

correctInterceptorChaining

public Interceptor correctInterceptorChaining(List<Interceptor> interceptors)
"Fixes" the next() and last() pointers for each interceptor, based on the order presented in the list passed in, and also re-assesses dependencies for each interceptor, injecting dependencies accordingingly.

Parameters:
interceptors - interceptor chain to correct
Returns:
the first interceptor in the chain.

construct

protected <T> T construct(String componentName,
                          Class<T> componentType)
Initialises the interceptors with a CacheSPI instance. Essentially calls setCache(). This is done AFTER the interceptor chain is created, and when Cache.start() is called, so the interceptors get a fully initialised cache.

Specified by:
construct in class ComponentFactory
Parameters:
componentName -
componentType - type of component
Returns:
a component

getInstance

public static InterceptorChainFactory getInstance(ComponentRegistry componentRegistry,
                                                  Configuration configuration)


Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.