KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > presentation > rmi > StubFactoryFactoryDynamicBase


1 /*
2  * @(#)StubFactoryFactoryDynamicBase.java 1.11 04/05/25
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.presentation.rmi;
9
10 import java.rmi.Remote JavaDoc ;
11 import javax.rmi.CORBA.Tie JavaDoc ;
12
13 import javax.rmi.CORBA.Util JavaDoc;
14
15 import org.omg.CORBA.CompletionStatus JavaDoc;
16
17 import org.omg.CORBA.portable.IDLEntity JavaDoc ;
18
19 import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
20 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
21
22 import com.sun.corba.se.spi.orb.ORB;
23
24 import com.sun.corba.se.spi.logging.CORBALogDomains ;
25
26 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
27
28 public abstract class StubFactoryFactoryDynamicBase extends
29     StubFactoryFactoryBase
30 {
31     protected final ORBUtilSystemException wrapper ;
32
33     public StubFactoryFactoryDynamicBase()
34     {
35     wrapper = ORBUtilSystemException.get(
36         CORBALogDomains.RPC_PRESENTATION ) ;
37     }
38
39     public PresentationManager.StubFactory createStubFactory(
40     String JavaDoc className, boolean isIDLStub, String JavaDoc remoteCodeBase,
41     Class JavaDoc expectedClass, ClassLoader JavaDoc classLoader)
42     {
43     Class JavaDoc cls = null ;
44
45     try {
46         cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
47     } catch (ClassNotFoundException JavaDoc exc) {
48         throw wrapper.classNotFound3(
49         CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
50     }
51
52     PresentationManager pm = ORB.getPresentationManager() ;
53
54     if (IDLEntity JavaDoc.class.isAssignableFrom( cls ) &&
55         !Remote JavaDoc.class.isAssignableFrom( cls )) {
56         // IDL stubs must always use static factories.
57
PresentationManager.StubFactoryFactory sff =
58         pm.getStubFactoryFactory( false ) ;
59         PresentationManager.StubFactory sf =
60         sff.createStubFactory( className, true, remoteCodeBase,
61             expectedClass, classLoader ) ;
62         return sf ;
63     } else {
64         PresentationManager.ClassData classData = pm.getClassData( cls ) ;
65         return makeDynamicStubFactory( pm, classData, classLoader ) ;
66     }
67     }
68
69     public abstract PresentationManager.StubFactory makeDynamicStubFactory(
70     PresentationManager pm, PresentationManager.ClassData classData,
71     ClassLoader JavaDoc classLoader ) ;
72
73     public Tie JavaDoc getTie( Class JavaDoc cls )
74     {
75     PresentationManager pm = ORB.getPresentationManager() ;
76     return new ReflectiveTie( pm, wrapper ) ;
77     }
78
79     public boolean createsDynamicStubs()
80     {
81     return true ;
82     }
83 }
84
Popular Tags