70 |
public static final String JAVA_PREFIX = "org.omg."; |
public static final String JAVA_PREFIX = "org.omg."; |
71 |
|
|
72 |
/** |
/** |
73 |
|
* The prefix for classes that are placed instide the |
74 |
|
* gnu.CORBA namespace. |
75 |
|
*/ |
76 |
|
public static final String CLASSPATH_PREFIX = "gnu.CORBA"; |
77 |
|
|
78 |
|
/** |
79 |
* Try to instantiate an object with the given IDL name. |
* Try to instantiate an object with the given IDL name. |
80 |
* The object must be mapped to the local java class. |
* The object must be mapped to the local java class. |
81 |
|
* The omg.org domain must be mapped into the object in either |
82 |
|
* org/omg or gnu/CORBA namespace. |
83 |
* |
* |
84 |
* @param IDL name |
* @param IDL name |
85 |
* @return instantiated object instance or null if no such |
* @return instantiated object instance or null if no such |
89 |
{ |
{ |
90 |
try |
try |
91 |
{ |
{ |
92 |
return Class.forName(toClassName(idl) + suffix).newInstance(); |
return Class.forName(toClassName(JAVA_PREFIX, idl) + suffix) |
93 |
|
.newInstance(); |
94 |
} |
} |
95 |
catch (Exception ex) |
catch (Exception ex) |
96 |
{ |
{ |
97 |
return null; |
try |
98 |
|
{ |
99 |
|
return Class.forName(toClassName(CLASSPATH_PREFIX, idl) + suffix) |
100 |
|
.newInstance(); |
101 |
|
} |
102 |
|
catch (Exception exex) |
103 |
|
{ |
104 |
|
return null; |
105 |
|
} |
106 |
} |
} |
107 |
} |
} |
108 |
|
|
122 |
{ |
{ |
123 |
try |
try |
124 |
{ |
{ |
125 |
String cl = toClassName(idl); |
String cl = toClassName(JAVA_PREFIX, idl); |
126 |
Class exClass = Class.forName(cl); |
Class exClass = Class.forName(cl); |
127 |
|
|
128 |
Constructor constructor = |
Constructor constructor = |
246 |
} |
} |
247 |
|
|
248 |
/** |
/** |
249 |
* Converts teh given IDL name to class name. |
* Converts the given IDL name to class name. |
250 |
* |
* |
251 |
* @param IDL the idl name. |
* @param IDL the idl name. |
252 |
* |
* |
253 |
*/ |
*/ |
254 |
protected static String toClassName(String IDL) |
protected static String toClassName(String prefix, String IDL) |
255 |
{ |
{ |
256 |
String s = IDL; |
String s = IDL; |
257 |
int a = s.indexOf(':') + 1; |
int a = s.indexOf(':') + 1; |
260 |
s = IDL.substring(a, b); |
s = IDL.substring(a, b); |
261 |
|
|
262 |
if (s.startsWith(OMG_PREFIX)) |
if (s.startsWith(OMG_PREFIX)) |
263 |
s = JAVA_PREFIX + s.substring(OMG_PREFIX.length()); |
s = prefix + s.substring(OMG_PREFIX.length()); |
264 |
|
|
265 |
return s.replace('/', '.'); |
return s.replace('/', '.'); |
266 |
} |
} |