1 7 8 package com.sun.corba.se.impl.presentation.rmi; 9 10 import javax.rmi.CORBA.Util ; 11 import javax.rmi.CORBA.Tie ; 12 13 import org.omg.CORBA.CompletionStatus ; 14 15 import com.sun.corba.se.spi.presentation.rmi.PresentationManager; 16 17 import com.sun.corba.se.impl.util.PackagePrefixChecker; 18 import com.sun.corba.se.impl.util.Utility; 19 20 import com.sun.corba.se.spi.logging.CORBALogDomains ; 21 22 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 23 24 public class StubFactoryFactoryStaticImpl extends 25 StubFactoryFactoryBase 26 { 27 private ORBUtilSystemException wrapper = ORBUtilSystemException.get( 28 CORBALogDomains.RPC_PRESENTATION ) ; 29 30 public PresentationManager.StubFactory createStubFactory( 31 String className, boolean isIDLStub, String remoteCodeBase, Class 32 expectedClass, ClassLoader classLoader) 33 { 34 String stubName = null ; 35 36 if (isIDLStub) 37 stubName = Utility.idlStubName( className ) ; 38 else 39 stubName = Utility.stubNameForCompiler( className ) ; 40 41 ClassLoader expectedTypeClassLoader = 42 (expectedClass == null ? classLoader : 43 expectedClass.getClassLoader()); 44 45 52 String firstStubName = stubName ; 53 String secondStubName = stubName ; 54 55 if (PackagePrefixChecker.hasOffendingPrefix(stubName)) 56 firstStubName = PackagePrefixChecker.packagePrefix() + stubName ; 57 else 58 secondStubName = PackagePrefixChecker.packagePrefix() + stubName ; 59 60 Class clz = null; 61 62 try { 63 clz = Util.loadClass( firstStubName, remoteCodeBase, 64 expectedTypeClassLoader ) ; 65 } catch (ClassNotFoundException e1) { 66 wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE, 68 e1, firstStubName ) ; 69 try { 70 clz = Util.loadClass( secondStubName, remoteCodeBase, 71 expectedTypeClassLoader ) ; 72 } catch (ClassNotFoundException e2) { 73 throw wrapper.classNotFound2( 74 CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ; 75 } 76 } 77 78 if ((clz == null) || 83 ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) { 84 try { 85 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 86 if (cl == null) 87 cl = ClassLoader.getSystemClassLoader(); 88 89 clz = cl.loadClass(className); 90 } catch (Exception exc) { 91 IllegalStateException ise = new IllegalStateException ( 93 "Could not load class " + stubName ) ; 94 ise.initCause( exc ) ; 95 throw ise ; 96 } 97 } 98 99 return new StubFactoryStaticImpl( clz ) ; 100 } 101 102 public Tie getTie( Class cls ) 103 { 104 Class tieClass = null ; 105 String className = Utility.tieName(cls.getName()); 106 107 try { 109 try { 110 tieClass = Utility.loadClassForClass(className, Util.getCodebase(cls), 113 null, cls, cls.getClassLoader()); 114 return (Tie ) tieClass.newInstance(); 115 } catch (Exception err) { 116 tieClass = Utility.loadClassForClass( 117 PackagePrefixChecker.packagePrefix() + className, 118 Util.getCodebase(cls), null, cls, cls.getClassLoader()); 119 return (Tie ) tieClass.newInstance(); 120 } 121 } catch (Exception err) { 122 return null; 123 } 124 125 } 126 127 public boolean createsDynamicStubs() 128 { 129 return false ; 130 } 131 } 132 | Popular Tags |