KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > ir > IRServer


1 package org.jacorb.ir;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import java.lang.reflect.*;
24
25 /**
26  * The main server that starts the Interface Repository
27  *
28  * @author (c) Gerald Brose, FU Berlin 2000
29  * @version $Id: IRServer.java,v 1.10 2004/10/18 13:12:41 simon.mcqueen Exp $
30  */

31
32 public class IRServer
33 {
34     protected static char fileSeparator =
35         System.getProperty("file.separator").charAt(0);
36
37     /**
38      * @param args a vector of commandline arguments, where args[1]
39      * needs to be a filename string and args[0] a classpath string
40      */

41
42     public static void main( String JavaDoc args[] )
43     {
44         boolean load = false;
45
46         if( args.length != 2)
47         {
48             System.err.println("Usage: java org.jacorb.ir.IRServer <classpath> <IOR filename>");
49             System.exit(1);
50         }
51  
52         try
53         {
54             java.util.StringTokenizer JavaDoc strtok =
55                 new java.util.StringTokenizer JavaDoc( args[0], java.io.File.pathSeparator );
56
57             //#ifjdk 1.2
58
java.net.URL JavaDoc [] urls = new java.net.URL JavaDoc[strtok.countTokens()];
59                 for( int i = 0; strtok.hasMoreTokens(); i++ )
60                 {
61                     urls[i] = new java.io.File JavaDoc( strtok.nextToken() ).toURL();
62                 }
63                 
64                 java.net.URLClassLoader JavaDoc classLoader =
65                     new java.net.URLClassLoader JavaDoc( urls );
66                 
67                 Class JavaDoc repositoryClass =
68                     classLoader.loadClass("org.jacorb.ir.RepositoryImpl");
69             //#else
70
//# ClassLoader classLoader = null;
71
//# Class repositoryClass = Class.forName ("org.jacorb.ir.RepositoryImpl");
72
//#endif
73

74             Object JavaDoc repository =
75                 repositoryClass.getConstructors()[0].newInstance(
76                                      new Object JavaDoc[]{ args[0] ,
77                                                    args[1],
78                                                    classLoader });
79
80             repositoryClass.getDeclaredMethod("loadContents", (Class JavaDoc[]) null ).invoke( repository, (Object JavaDoc[]) null );
81             
82             Object JavaDoc lock = new Object JavaDoc();
83             synchronized( lock )
84             {
85                 lock.wait();
86             }
87
88         }
89         catch( Exception JavaDoc e )
90         {
91             e.printStackTrace();
92             System.exit(1);
93         }
94     }
95
96 }
97
98
99
100
101
102
103
104
105
106
107
Popular Tags