org.jomc.ri
Class DefaultInvoker

Package class diagram package DefaultInvoker
java.lang.Object
  extended by org.jomc.ri.DefaultInvoker
All Implemented Interfaces:
org.jomc.spi.Invoker

@Generated(value="org.jomc.tools.JavaSources",
           comments="See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools")
public class DefaultInvoker
extends Object
implements org.jomc.spi.Invoker

Default Invoker implementation.

Version:
$Id: DefaultInvoker.java 1102 2009-12-07 03:01:58Z schulte2005 $
Author:
Christian Schulte 1.0
See Also:
DefaultInvocation

Constructor Summary
DefaultInvoker()
          Creates a new DefaultInvoker instance.
 
Method Summary
 void handleException(org.jomc.spi.Invocation invocation, Throwable t)
          Called whenever an exception has been caught.
 Object invoke(org.jomc.spi.Invocation invocation)
          Performs a method invocation on an object.
 org.jomc.spi.Invocation postInvoke(org.jomc.spi.Invocation invocation)
          Called after an invocation has been performed.
 org.jomc.spi.Invocation preInvoke(org.jomc.spi.Invocation invocation)
          Called before an invocation is performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInvoker

@Generated(value="org.jomc.tools.JavaSources",
           comments="See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools")
public DefaultInvoker()
Creates a new DefaultInvoker instance.

Method Detail

invoke

public Object invoke(org.jomc.spi.Invocation invocation)
              throws Throwable
Performs a method invocation on an object.

This method first passes the given invocation to the preInvoke method. If the result property of the invocation returned by the preInvoke method is an instance of Throwable, that instance will be thrown; otherwise the invocation returned by the preInvoke method is performed and then passed to the postInvoke method. If the result property of the invocation returned from the postInvoke method is an instance of Throwable, that instance will be thrown; otherwise the value of the result property is returned by this method.

Specified by:
invoke in interface org.jomc.spi.Invoker
Parameters:
invocation - The invocation to perform.
Returns:
The return value of the invocation. If the declared return type of the method of the invocation is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type of the method of the invocation. If the value returned by this method is null and the declared return type of the method of the invocation is primitive, then a NullPointerException will be thrown. If the value returned by this method is otherwise not compatible to the declared return type of the method of the invocation, a ClassCastException will be thrown.
Throws:
Throwable - The exception thrown from the method invocation. The exception's type must be assignable either to any of the exception types declared in the throws clause of the method of the invocation or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the method of the invocation, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown.
See Also:
preInvoke(org.jomc.spi.Invocation), postInvoke(org.jomc.spi.Invocation)

preInvoke

public org.jomc.spi.Invocation preInvoke(org.jomc.spi.Invocation invocation)
Called before an invocation is performed.

Overriding classes may use this method to perform any kind of operation prior to an invocation and to create custom invocation instances. If an overriding class wishes to throw an exception, it may do so by setting the result property of the returned invocation to an instance of Throwable thrown as the result of the invocation. If an overriding class wishes to provide a custom Invocation class, it may do so by returning a different instance from this method. By default, this method does nothing and returns the given invocation unchanged.

Parameters:
invocation - The invocation about to be performed.
Returns:
The processed invocation.
Throws:
NullPointerException - if invocation is null.

postInvoke

public org.jomc.spi.Invocation postInvoke(org.jomc.spi.Invocation invocation)
Called after an invocation has been performed.

Overriding classes may use this method to perform any kind of operation after an invocation has been performed and to maintain custom invocation instances. If an overriding class wishes to throw an exception, it may do so by setting the result property of the returned invocation to an instance of Throwable thrown as the result of the invocation. Since the result property of the given invocation already holds the result of the invocation (which may already be an instance of Throwable), care must be taken when updating that result. By default, this method does nothing and returns the given invocation unchanged.

Parameters:
invocation - The performed invocation.
Returns:
The processed invocation.
Throws:
NullPointerException - if invocation is null.

handleException

public void handleException(org.jomc.spi.Invocation invocation,
                            Throwable t)
Called whenever an exception has been caught.

Overriding classes may use this method for handling exceptions. By default, this method updates the result of the given invocation with the given throwable. If that throwable is an instance of InvocationTargetException, this method updates the result with the value of that exception's target exception. If the result of the given invocation already is an instance of Throwable, this method does not update the result.

Parameters:
invocation - The invocation to update.
t - The throwable to update invocation with.


Copyright © 2005-2009 The JOMC Project. All Rights Reserved.