com.ca.jcs.assoc
Class AssocAttributeOpProcessorProxy

java.lang.Object
  extended by com.ca.jcs.processor.ConnectorProcessorProxyHandler
      extended by com.ca.jcs.assoc.AssocAttributeOpProcessorProxy
All Implemented Interfaces:
InvocationHandler

public class AssocAttributeOpProcessorProxy
extends ConnectorProcessorProxyHandler

This Proxy can wrap any object implementing AssocAttributeOpProcessor and handle splitting association related attributes and operations out and dispatching them automatically to the appropriate association related methods, delegating only non-associative arguments to the ultimate concrete methods defined in AttributeStyleOpProcessor. For instance during a doAdd() call attributes not requiring any special association relating processing would be delegated to the wrapped doAdd() implementation, but those requiring special handling would are split off and after the wrapped doAdd() implementation completes, they are passed to AssocAttributeOpProcessor.doModifyAssocs(ObjectInfo objInfo, AssocModificationItem[] items, Object context) for post-processing.

This proxy therefore saves developers of connectors (including scripting connectors) from needing to implementing all the logic to split up method arguments and calling the appropriate association related methods. Note however, that it is the association related methods on the processor being wrapped that actually do the work, this proxy merely takes care of the mechanics of splitting requests into association related and non-association related portions and delegating as required.

This proxy is normally activated in a two-step process:

  1. Ensure your connector's concrete attribute style processor implements the AssocAttributeOpProcessor interface.
  2. Ensure that the your concrete connector implementation overrides BaseConnector.isAutoDirectAssocRequired() so that it returns true.
  3. If there are any methods for which you want to turn off automatic association then your concrete connector implementation overrides BaseConnector.getAutoDirectAssocExlusions() to include their names in the set it returns, in which this proxy will simply delegate this calls without performing any processing (such as splitting requests into association related and non-association related portions).
If you need to perform some pre / post association handling around an operation then this class can provide a template for you to work from if you understand how invoke(Object, Method, Object[]) is implemented.

See Also:
DefaultAssocDirectAttributeOpProcessor

Constructor Summary
AssocAttributeOpProcessorProxy(Connector connector, AttributeStyleOpProcessor proc)
          Note prerequisite (checked by assertion) is that connector.isObjectClassRequired() == true.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Wraps a call to method, so if it matches an Operation requiring special association handling the following processing steps are followed: method names is mapped to integer code, so that switch statements can be used arguments to methods requiring association handling are pre-processed by being split into non-association and association related portions the method is called with the non-association portion of its arguments if required, the association related portion of the method's arguments are then passed on for post-processing.
 
Methods inherited from class com.ca.jcs.processor.ConnectorProcessorProxyHandler
createAttributeStyleOpProcessorProxy, createMethodStyleOpProcessorProxy, createScriptStyleOpProcessorProxy, getConnector, getOperation, getTarget, getTargetAttributeStyleOpProcessor, getTargetMethodStyleOpProcessor, getTargetScriptStyleOpProcessor, logError, proxyToString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssocAttributeOpProcessorProxy

public AssocAttributeOpProcessorProxy(Connector connector,
                                      AttributeStyleOpProcessor proc)
Note prerequisite (checked by assertion) is that connector.isObjectClassRequired() == true.

Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Wraps a call to method, so if it matches an Operation requiring special association handling the following processing steps are followed:
  1. method names is mapped to integer code, so that switch statements can be used
  2. arguments to methods requiring association handling are pre-processed by being split into non-association and association related portions
  3. the method is called with the non-association portion of its arguments
  4. if required, the association related portion of the method's arguments are then passed on for post-processing.
Hence, if you want to understand the processing for a particular operation you just need to look at its pre and post processing steps in each of the two switch statements.

Specified by:
invoke in interface InvocationHandler
Specified by:
invoke in class ConnectorProcessorProxyHandler
Throws:
Throwable


Created 2011-07-14 13:27 EST