01: package org.jacorb.ir;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1997-2004 Gerald Brose.
07: *
08: * This library is free software; you can redistribute it and/or
09: * 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: /**
24: * The main server that starts the Interface Repository
25: *
26: * @author Gerald Brose
27: * @version $Id: IRServer.java,v 1.11 2006/06/15 16:43:14 alphonse.bendt Exp $
28: */
29:
30: public class IRServer {
31: /**
32: * @param args a vector of commandline arguments, where args[1]
33: * needs to be a filename string and args[0] a classpath string
34: */
35: public static void main(String args[]) {
36: System.setProperty("jacorb.implname", "InterfaceRepository");
37:
38: if (args.length != 2) {
39: System.err
40: .println("Usage: java org.jacorb.ir.IRServer <classpath> <IOR filename>");
41: System.exit(1);
42: }
43:
44: try {
45: java.util.StringTokenizer strtok = new java.util.StringTokenizer(
46: args[0], java.io.File.pathSeparator);
47:
48: //#ifjdk 1.2
49: java.net.URL[] urls = new java.net.URL[strtok.countTokens()];
50: for (int i = 0; strtok.hasMoreTokens(); i++) {
51: urls[i] = new java.io.File(strtok.nextToken()).toURL();
52: }
53:
54: java.net.URLClassLoader classLoader = new java.net.URLClassLoader(
55: urls);
56:
57: Class repositoryClass = classLoader
58: .loadClass("org.jacorb.ir.RepositoryImpl");
59: //#else
60: //# ClassLoader classLoader = null;
61: //# Class repositoryClass = Class.forName ("org.jacorb.ir.RepositoryImpl");
62: //#endif
63:
64: Object repository = repositoryClass.getConstructors()[0]
65: .newInstance(new Object[] { args[0], args[1],
66: classLoader });
67:
68: repositoryClass.getDeclaredMethod("loadContents",
69: (Class[]) null).invoke(repository, (Object[]) null);
70:
71: Object lock = new Object();
72: synchronized (lock) {
73: lock.wait();
74: }
75:
76: } catch (Exception e) {
77: e.printStackTrace();
78: System.exit(1);
79: }
80: }
81:
82: }
|