final InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
pm, classData, stub ) ;
// Create a composite handler that handles the DynamicStub interface
// as well as the remote interfaces.
final CompositeInvocationHandler handler =
new CustomCompositeInvocationHandlerImpl( stub ) ;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
handler.addInvocationHandler( DynamicStub.class,
dynamicStubHandler ) ;
handler.addInvocationHandler( org.omg.CORBA.Object.class,
dynamicStubHandler ) ;
handler.addInvocationHandler( Object.class,
dynamicStubHandler ) ;
return null;
}
});
// If the method passed to invoke is not from DynamicStub or its superclasses,
// it must be from an implemented interface, so we just handle
// all of these with the stubMethodHandler. This used to be
// done be adding explicit entries for stubMethodHandler for
// each remote interface, but that does not work correctly
// for abstract interfaces, since the graph analysis ignores
// abstract interfaces in order to compute the type ids
// correctly (see PresentationManagerImpl.NodeImpl.getChildren).
// Rather than produce more graph traversal code to handle this
// problem, we simply use a default.
// This also points to a possible optimization: just use explict
// checks for the three special classes, rather than a general
// table lookup that usually fails.
handler.setDefaultHandler( stubMethodHandler ) ;
return handler ;
}