dist1.acb.common
Class HandlersHive

java.lang.Object
  extended bydist1.acb.common.HandlersHive

public class HandlersHive
extends java.lang.Object

Class for resolving input type of object and calling appropriate handler (method) for the input object of this type

Version:
$Revision: 1.4 $
Author:
Alexander Stasiv

Constructor Summary
HandlersHive(java.lang.Class handlersOwnerClass, java.lang.Class[] handlersParamTypes, java.lang.String name)
          Creates a new instance of HandlersHive
 
Method Summary
 void addHandler(java.lang.String requestType, java.lang.String handlerName)
          Add new handler to the hive.
 java.lang.Object handle(java.lang.Object obj, java.lang.Object handlersOwner)
          Resolves input type of the object and calls appropriate handler (method) for the input object of this type
 java.lang.Object handle(java.lang.Object obj, java.lang.Object handlersOwner, java.lang.Object[] handlersParams)
          Resolves input type of the object and calls appropriate handler (method) for specifed parameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandlersHive

public HandlersHive(java.lang.Class handlersOwnerClass,
                    java.lang.Class[] handlersParamTypes,
                    java.lang.String name)
Creates a new instance of HandlersHive

Parameters:
handlersOwnerClass - The owner of handlers (methods) which will be invoked
handlersParamTypes - Types of handler's parameters
name - Name of the HandlersHive
Method Detail

addHandler

public void addHandler(java.lang.String requestType,
                       java.lang.String handlerName)
                throws java.lang.NoSuchMethodException,
                       java.lang.SecurityException,
                       java.lang.ClassNotFoundException,
                       java.lang.NullPointerException
Add new handler to the hive. If a handler for the type exists, it is replaced.

Parameters:
requestType - Handled type
handlerName - Name of the method (handler)
Throws:
java.lang.NoSuchMethodException - if a matching method is not found or if the name is "init"or "clinit".
java.lang.SecurityException - if access to the information is denied.
java.lang.ClassNotFoundException - if the class cannot be located.
java.lang.NullPointerException - if handlerName is null

handle

public java.lang.Object handle(java.lang.Object obj,
                               java.lang.Object handlersOwner)
                        throws NoHandlerException,
                               java.lang.IllegalAccessException,
                               java.lang.IllegalArgumentException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NullPointerException,
                               java.lang.ExceptionInInitializerError
Resolves input type of the object and calls appropriate handler (method) for the input object of this type

Parameters:
obj - The input object to handle
handlersOwner - Class which owns the handlers
Returns:
Return value of the handler
Throws:
NoHandlerException - If the handler of the type was not found
java.lang.IllegalAccessException - if this Method object enforces Java language access control and the underlying method is inaccessible.
java.lang.IllegalArgumentException - if the method is an instance method and the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.
java.lang.reflect.InvocationTargetException - if the underlying method throws an exception.
java.lang.NullPointerException - if the specified object is null and the method is an instance method.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.

handle

public java.lang.Object handle(java.lang.Object obj,
                               java.lang.Object handlersOwner,
                               java.lang.Object[] handlersParams)
                        throws NoHandlerException,
                               java.lang.IllegalAccessException,
                               java.lang.IllegalArgumentException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NullPointerException,
                               java.lang.ExceptionInInitializerError
Resolves input type of the object and calls appropriate handler (method) for specifed parameters

Parameters:
obj - The input object to handle
handlersOwner - Class which owns the handlers
handlersParams - Parameters for the handler
Returns:
Return value of the handler
Throws:
NoHandlerException - If the handler of the type was not found
java.lang.IllegalAccessException - if this Method object enforces Java language access control and the underlying method is inaccessible.
java.lang.IllegalArgumentException - if the method is an instance method and the specified object argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.
java.lang.reflect.InvocationTargetException - if the underlying method throws an exception.
java.lang.NullPointerException - if the specified object is null and the method is an instance method.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.


Copyright © 2004 Phoenix Team (CMU/AIT). All Rights Reserved.