FileDocCategorySizeDatePackage
InvocationHandlerFactoryImpl.javaAPI DocJava SE 5 API4883Fri Aug 26 14:54:30 BST 2005com.sun.corba.se.impl.presentation.rmi

InvocationHandlerFactoryImpl

public class InvocationHandlerFactoryImpl extends Object implements com.sun.corba.se.spi.orbutil.proxy.InvocationHandlerFactory

Fields Summary
private final PresentationManager.ClassData
classData
private final com.sun.corba.se.spi.presentation.rmi.PresentationManager
pm
private Class[]
proxyInterfaces
Constructors Summary
public InvocationHandlerFactoryImpl(com.sun.corba.se.spi.presentation.rmi.PresentationManager pm, PresentationManager.ClassData classData)

	this.classData = classData ;
	this.pm = pm ;

    	Class[] remoteInterfaces = 
	    classData.getIDLNameTranslator().getInterfaces() ;
	proxyInterfaces = new Class[ remoteInterfaces.length + 1 ] ;
	for (int ctr=0; ctr<remoteInterfaces.length; ctr++)
	    proxyInterfaces[ctr] = remoteInterfaces[ctr] ;

	proxyInterfaces[remoteInterfaces.length] = DynamicStub.class ;
    
Methods Summary
public java.lang.reflect.InvocationHandlergetInvocationHandler()

	final DynamicStub stub = new DynamicStubImpl( 
	    classData.getTypeIds() ) ; 

	return getInvocationHandler( stub ) ;
    
java.lang.reflect.InvocationHandlergetInvocationHandler(com.sun.corba.se.spi.presentation.rmi.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 explict
	// checks for the three special classes, rather than a general
	// table lookup that usually fails.
	handler.setDefaultHandler( stubMethodHandler ) ;

	return handler ;
    
public java.lang.Class[]getProxyInterfaces()

	return proxyInterfaces ;