OpenCOM
Class Delegator

java.lang.Object
  extended by OpenCOM.Delegator
All Implemented Interfaces:
java.lang.reflect.InvocationHandler, IDelegator

public class Delegator
extends java.lang.Object
implements java.lang.reflect.InvocationHandler, IDelegator

Class of individual delegator objects that are attached to each interface for the purpose of pre and post method interception. Note: The implementation mimics OpenCOM's dummy QI redirection using Java dynamic proxies instead.

See Also:
IDelegator, InvocationHandler

Field Summary
 java.lang.Object HigherObject
          The Outer Proxy of this delegator
 java.lang.Object obj
          The original Component that we are delegating from
static java.lang.Object ThisObject
          Static reference to this delegator
 
Constructor Summary
Delegator(java.lang.Object obj, IMetaInterception pIOCM)
           
 
Method Summary
 boolean addPostMethod(java.lang.Object interceptorObject, java.lang.String methodName)
          Inserts a post-method on this delegator.
 boolean addPreMethod(java.lang.Object Interceptorobject, java.lang.String methodName)
          Inserts a pre-method on this delegator.
 boolean delPostMethod(java.lang.String methodName)
          Deletes a specified post-method from this delegator.
 boolean delPreMethod(java.lang.String methodName)
          Deletes a specified pre-method from this delegator.
 TypedAttribute GetAttributeValue(java.lang.String Name)
          This method retrieves the value of a name-value pair.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method m, java.lang.Object[] args)
          invoke is called on this dynamic proxy whenever a method of the "inner" component is invoked.
static java.lang.Object newInstance(java.lang.Object obj)
          The dynamic proxy creation operation - takes the original component and wraps the dynamic invocation handler around it.
 boolean SetAttributeValue(java.lang.String Name, java.lang.String Type, java.lang.Object Value)
          For simplicity this version of OpenCOM attaches interface meta-data to the delagator.
 long viewPostMethods(java.lang.String[] methodNames)
          A Meta-Inspection operation.
 long viewPreMethods(java.lang.String[] methodNames)
          A Meta-Inspection operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

obj

public java.lang.Object obj
The original Component that we are delegating from


ThisObject

public static java.lang.Object ThisObject
Static reference to this delegator


HigherObject

public java.lang.Object HigherObject
The Outer Proxy of this delegator

Constructor Detail

Delegator

public Delegator(java.lang.Object obj,
                 IMetaInterception pIOCM)
Method Detail

newInstance

public static java.lang.Object newInstance(java.lang.Object obj)
The dynamic proxy creation operation - takes the original component and wraps the dynamic invocation handler around it.


invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method m,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
invoke is called on this dynamic proxy whenever a method of the "inner" component is invoked. Therefore, it will ensure that the pre methods are called before the actual operation and the post methods afterwards.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Parameters:
proxy - the proxy component.
m - The method to be invoked.
args - An object array with all the arguments of the original invocation.
Returns:
An object holding the result of the invocation.
Throws:
java.lang.Throwable

addPreMethod

public boolean addPreMethod(java.lang.Object Interceptorobject,
                            java.lang.String methodName)
Description copied from interface: IDelegator
Inserts a pre-method on this delegator. All subsequent invocation of interface operations first pass through this method. Multiple pre-methods can be inserted, they are traversed in the order they were inserted.

Specified by:
addPreMethod in interface IDelegator
Parameters:
Interceptorobject - A Java object containing the pre-method to insert.
methodName - A String describing the name of the pre-method.
Returns:
A boolean indicating the success of the operation.

addPostMethod

public boolean addPostMethod(java.lang.Object interceptorObject,
                             java.lang.String methodName)
Description copied from interface: IDelegator
Inserts a post-method on this delegator. All subsequent invocation of interface operations pass through this method after invocation. Multiple post-methods can be inserted, they are traversed in the order they were inserted.

Specified by:
addPostMethod in interface IDelegator
Parameters:
interceptorObject - A Java object containing the pre-method to insert.
methodName - A String describing the name of the pre-method.
Returns:
A boolean indicating the success of the operation.

delPostMethod

public boolean delPostMethod(java.lang.String methodName)
Description copied from interface: IDelegator
Deletes a specified post-method from this delegator.

Specified by:
delPostMethod in interface IDelegator
Parameters:
methodName - A String describing the name of the pre-method.
Returns:
A boolean indicating the success of the operation.

delPreMethod

public boolean delPreMethod(java.lang.String methodName)
Description copied from interface: IDelegator
Deletes a specified pre-method from this delegator.

Specified by:
delPreMethod in interface IDelegator
Parameters:
methodName - A String describing the name of the pre-method.
Returns:
A boolean indicating the success of the operation.

viewPostMethods

public long viewPostMethods(java.lang.String[] methodNames)
Description copied from interface: IDelegator
A Meta-Inspection operation. Returns a pointer to an array of strings representing the current list of post-methods attached to the delegator.

Specified by:
viewPostMethods in interface IDelegator
Parameters:
methodNames - A String array to be filled with the names of post-methods.
Returns:
A long describing the number of post-methods in the list.

viewPreMethods

public long viewPreMethods(java.lang.String[] methodNames)
Description copied from interface: IDelegator
A Meta-Inspection operation. Returns a pointer to an array of strings representing the current list of pre-methods attached to the delegator.

Specified by:
viewPreMethods in interface IDelegator
Parameters:
methodNames - A String array to be filled with the names of pre-methods.
Returns:
A long describing the number of pre-methods in the list.

SetAttributeValue

public boolean SetAttributeValue(java.lang.String Name,
                                 java.lang.String Type,
                                 java.lang.Object Value)
Description copied from interface: IDelegator
For simplicity this version of OpenCOM attaches interface meta-data to the delagator. For a cleaner separation see the Java implementation of OpenCOM v2. This method sets the name-value pair.

Specified by:
SetAttributeValue in interface IDelegator
Parameters:
Name - A string describing the meta-data attribute.
Value - An Object holding the value of the attribute.
Returns:
A boolean indicating if the attribute was added/updated or not.

GetAttributeValue

public TypedAttribute GetAttributeValue(java.lang.String Name)
Description copied from interface: IDelegator
This method retrieves the value of a name-value pair.

Specified by:
GetAttributeValue in interface IDelegator
Parameters:
Name - A string describing the meta-data attribute.
Returns:
A TypedAttribute Object holding the value and type of the attribute.