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

PresentationManagerImpl

public final class PresentationManagerImpl extends Object implements com.sun.corba.se.spi.presentation.rmi.PresentationManager

Fields Summary
private Map
classToClassData
private Map
methodToDMM
private PresentationManager.StubFactoryFactory
staticStubFactoryFactory
private PresentationManager.StubFactoryFactory
dynamicStubFactoryFactory
private com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
private boolean
useDynamicStubs
Constructors Summary
public PresentationManagerImpl(boolean useDynamicStubs)


        
    
	this.useDynamicStubs = useDynamicStubs ;
	wrapper = ORBUtilSystemException.get( 
	    CORBALogDomains.RPC_PRESENTATION ) ;

	// XXX these should probably be WeakHashMaps.
	classToClassData = new HashMap() ;
	methodToDMM = new HashMap() ;
    
Methods Summary
private voidaddNodes(java.util.List resultList, java.util.Set nodeSet)

	Iterator iter = nodeSet.iterator() ;
	while (iter.hasNext()) {
	    NodeImpl node = (NodeImpl)iter.next() ;
	    String typeId = node.getTypeId() ;
	    resultList.add( typeId ) ;
	}
    
public synchronized ClassDatagetClassData(java.lang.Class cls)

	ClassData result = (ClassData)classToClassData.get( cls ) ;
	if (result == null) {
	    result = new ClassDataImpl( cls ) ;
	    classToClassData.put( cls, result ) ;
	}

	return result ;
    
public synchronized com.sun.corba.se.spi.presentation.rmi.DynamicMethodMarshallergetDynamicMethodMarshaller(java.lang.reflect.Method method)

	if (method == null)
	    return null ;

	DynamicMethodMarshaller result = 
	    (DynamicMethodMarshaller)methodToDMM.get( method ) ;
	if (result == null) {
	    result = new DynamicMethodMarshallerImpl( method ) ;
	    methodToDMM.put( method, result ) ;
	}

	return result ;
    
private java.lang.Class[]getInterfaces(java.util.Set roots)

	Class[] classes = new Class[ roots.size() ] ;
	Iterator iter = roots.iterator() ;
	int ctr = 0 ;
	while (iter.hasNext()) {
	    NodeImpl node = (NodeImpl)iter.next() ;
	    classes[ctr++] = node.getInterface() ;
	}

	return classes ;
    
private java.util.SetgetRootSet(java.lang.Class target, com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl$NodeImpl root, com.sun.corba.se.impl.orbutil.graph.Graph gr)

	Set rootSet = null ;

	if (target.isInterface()) {
	    gr.add( root ) ;
	    rootSet = gr.getRoots() ; // rootSet just contains root here
	} else {
	    // Use this class and its superclasses (not Object) as initial roots
	    Class superclass = target ;
	    Set initialRootSet = new HashSet() ;
	    while ((superclass != null) && !superclass.equals( Object.class )) {
		Node node = new NodeImpl( superclass ) ;
		gr.add( node ) ;
		initialRootSet.add( node ) ;
		superclass = superclass.getSuperclass() ;
	    }

	    // Expand all nodes into the graph
	    gr.getRoots() ; 

	    // remove the roots and find roots again
	    gr.removeAll( initialRootSet ) ;
	    rootSet = gr.getRoots() ;    
	}

	return rootSet ;
    
public PresentationManager.StubFactoryFactorygetStubFactoryFactory(boolean isDynamic)

	if (isDynamic)
	    return dynamicStubFactoryFactory ;
	else
	    return staticStubFactoryFactory ;
    
public javax.rmi.CORBA.TiegetTie()

	return dynamicStubFactoryFactory.getTie( null ) ;
    
private java.lang.String[]makeTypeIds(com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl$NodeImpl root, com.sun.corba.se.impl.orbutil.graph.Graph gr, java.util.Set rootSet)

	Set nonRootSet = new HashSet( gr ) ;
	nonRootSet.removeAll( rootSet ) ;

	// List<String> for the typeids
	List result = new ArrayList() ;

	if (rootSet.size() > 1) {
	    // If the rootSet has more than one element, we must
	    // put the type id of the implementation class first.
	    // Root represents the implementation class here.
	    result.add( root.getTypeId() ) ;
	}

	addNodes( result, rootSet ) ;
	addNodes( result, nonRootSet ) ;

	return (String[])result.toArray( new String[result.size()] ) ;
    
public voidsetStubFactoryFactory(boolean isDynamic, PresentationManager.StubFactoryFactory sff)

	if (isDynamic)
	    dynamicStubFactoryFactory = sff ;
	else
	    staticStubFactoryFactory = sff ;
    
public booleanuseDynamicStubs()

	return useDynamicStubs ;