org.broadleafcommerce.core.extension
Class ExtensionManager<T extends ExtensionHandler>

java.lang.Object
  extended by org.broadleafcommerce.core.extension.ExtensionManager<T>
Type Parameters:
T -
All Implemented Interfaces:
InvocationHandler
Direct Known Subclasses:
MergeCartServiceExtensionManager, OfferServiceExtensionManager, OrderDaoExtensionManager, OrderServiceExtensionManager, SolrSearchServiceExtensionManager

public abstract class ExtensionManager<T extends ExtensionHandler>
extends Object
implements InvocationHandler

The ExtensionManager pattern is intended for out of box components to be extended by Broadleaf modules. Each component that needs an extension should define an interface which is a descendant of ExtensionHandler. The concrete ExtensionManager class will utilize that interface as a parameter (e.g. T below). The default extension manager pattern loops through all handlers and examines their ExtensionResultStatusType to determine whether or not to continue with other handlers.

Author:
bpolster

Field Summary
protected  T extensionHandler
           
protected  List<T> handlers
           
protected  boolean handlersSorted
           
protected static String LOCK_OBJECT
           
 
Constructor Summary
ExtensionManager(Class<T> _clazz)
          Should take in a className that matches the ExtensionHandler interface being managed.
 
Method Summary
 boolean continueOnHandled()
          Returns whether or not this extension manager continues on ExtensionResultStatusType.HANDLED.
 List<T> getHandlers()
           
 int getPriority()
          ExtensionManagers don't really need a priority but they pick up this property due to the fact that we want them to implement the same interface as the handlers they are managing.
 T getProxy()
           
 Object invoke(Object proxy, Method method, Object[] args)
           
 void setHandlers(List<T> handlers)
           
 boolean shouldContinue(ExtensionResultStatusType result, ExtensionHandler handler, Method method, Object[] args)
          Utility method that is useful for determining whether or not an ExtensionManager implementation should continue after processing a ExtensionHandler call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handlersSorted

protected boolean handlersSorted

LOCK_OBJECT

protected static String LOCK_OBJECT

extensionHandler

protected T extends ExtensionHandler extensionHandler

handlers

protected List<T extends ExtensionHandler> handlers
Constructor Detail

ExtensionManager

public ExtensionManager(Class<T> _clazz)
Should take in a className that matches the ExtensionHandler interface being managed.

Parameters:
className -
Method Detail

getProxy

public T getProxy()

getHandlers

public List<T> getHandlers()

setHandlers

public void setHandlers(List<T> handlers)

shouldContinue

public boolean shouldContinue(ExtensionResultStatusType result,
                              ExtensionHandler handler,
                              Method method,
                              Object[] args)
Utility method that is useful for determining whether or not an ExtensionManager implementation should continue after processing a ExtensionHandler call. By default, returns true for CONTINUE

Returns:

continueOnHandled

public boolean continueOnHandled()
Returns whether or not this extension manager continues on ExtensionResultStatusType.HANDLED.

Returns:

getPriority

public int getPriority()
ExtensionManagers don't really need a priority but they pick up this property due to the fact that we want them to implement the same interface as the handlers they are managing.

Returns:

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable


Copyright © 2013. All Rights Reserved.