InvocationHandler getInvocationHandler(DynamicStub stub) { // Create an invocation handler for the methods defined on DynamicStub, which extends org.omg.CORBA.Object. This // handler delegates all calls directly to a DynamicStubImpl, which extends org.omg.CORBA.portable.ObjectImpl. InvocationHandler dynamicStubHandler = DelegateInvocationHandlerImpl.create(stub); // Create an invocation handler that handles any remote interface methods. 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); handler.addInvocationHandler(DynamicStub.class, dynamicStubHandler); handler.addInvocationHandler(org.omg.CORBA.Object.class, dynamicStubHandler); handler.addInvocationHandler(Object.class, dynamicStubHandler); // 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 explicit checks // for the three special classes, rather than a general table lookup that usually fails. handler.setDefaultHandler(stubMethodHandler); return handler; }
InvocationHandler getInvocationHandler(DynamicStub stub) { // Create an invocation handler for the methods defined on DynamicStub, which extends org.omg.CORBA.Object. This // handler delegates all calls directly to a DynamicStubImpl, which extends org.omg.CORBA.portable.ObjectImpl. InvocationHandler dynamicStubHandler = DelegateInvocationHandlerImpl.create(stub); // Create an invocation handler that handles any remote interface methods. 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); handler.addInvocationHandler(DynamicStub.class, dynamicStubHandler); handler.addInvocationHandler(org.omg.CORBA.Object.class, dynamicStubHandler); handler.addInvocationHandler(Object.class, dynamicStubHandler); // 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 explicit checks // for the three special classes, rather than a general table lookup that usually fails. handler.setDefaultHandler(stubMethodHandler); return handler; }