/[classpath]/classpath/gnu/CORBA/ObjectCreator.java
ViewVC logotype

Diff of /classpath/gnu/CORBA/ObjectCreator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.1 by gnu_andrew, Fri May 20 18:20:49 2005 UTC revision 1.1.2.2 by gnu_andrew, Fri May 27 00:01:44 2005 UTC
# Line 70  public class ObjectCreator Line 70  public class ObjectCreator
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
# Line 81  public class ObjectCreator Line 89  public class ObjectCreator
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    
# Line 105  public class ObjectCreator Line 122  public class ObjectCreator
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 =
# Line 229  public class ObjectCreator Line 246  public class ObjectCreator
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;
# Line 243  public class ObjectCreator Line 260  public class ObjectCreator
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    }    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26