donaldp 2002/11/08 19:56:32
Modified: container/src/java/org/apache/excalibur/container/legacy
ComponentProxyGenerator.java
Log:
Make sure invocationHandler will only throw exceptions that the original
method could throw.
Other exceptions will not be thrown (ie IllegalAccess) due to the
architecture of proxying
Revision Changes Path
1.6 +21 -5
jakarta-avalon-excalibur/container/src/java/org/apache/excalibur/container/legacy/ComponentProxyGenerator.java
Index: ComponentProxyGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/container/src/java/org/apache/excalibur/container/legacy/ComponentProxyGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ComponentProxyGenerator.java 7 Nov 2002 05:18:31 -0000 1.5
+++ ComponentProxyGenerator.java 9 Nov 2002 03:56:32 -0000 1.6
@@ -58,6 +58,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationTargetException;
import org.apache.avalon.framework.component.Component;
/**
@@ -108,19 +109,34 @@
/**
* Internal class to handle the wrapping with Component
*/
- private final static class ComponentInvocationHandler implements
InvocationHandler
+ private final static class ComponentInvocationHandler
+ implements InvocationHandler
{
private final Object m_delagate;
- public ComponentInvocationHandler( final Object proxy )
+ public ComponentInvocationHandler( final Object delegate )
{
- m_delagate = proxy;
+ if( null == delegate )
+ {
+ throw new NullPointerException( "delegate" );
+ }
+
+ m_delagate = delegate;
}
- public Object invoke( Object proxy, Method meth, Object[] args )
+ public Object invoke( final Object proxy,
+ final Method meth,
+ final Object[] args )
throws Throwable
{
- return meth.invoke( m_delagate, args );
+ try
+ {
+ return meth.invoke( m_delagate, args );
+ }
+ catch( final InvocationTargetException ite )
+ {
+ throw ite.getTargetException();
+ }
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>