1 |
//---PACKAGE DECLARATION--- |
2 |
|
3 |
//---IMPORTS--- |
4 |
import core.*; |
5 |
import org.omg.CORBA.*; |
6 |
import org.omg.CosNaming.*; |
7 |
import org.omg.PortableServer.*; |
8 |
|
9 |
/** |
10 |
* The main class for the CORE of the I-Scream system. |
11 |
* The main method of this class initialises the ORB |
12 |
* and then starts and registers CORE I-Scream services |
13 |
* with the name service. At which point it essentially |
14 |
* finishs its role and the started services continue to |
15 |
* serve requests from the I-Scream system. |
16 |
* |
17 |
* @author $Author: ajm4 $ |
18 |
* @version $Id: Core.java,v 1.1 2000/11/08 21:24:33 ajm4 Exp $ |
19 |
*/ |
20 |
class Core { |
21 |
|
22 |
//---FINAL ATTRIBUTES--- |
23 |
|
24 |
/** |
25 |
* The current CVS revision of this class |
26 |
*/ |
27 |
public static final String REVISION = "$Revision: 1.1 $"; |
28 |
|
29 |
//---STATIC METHODS--- |
30 |
|
31 |
/** |
32 |
* The main method which starts the CORE |
33 |
* Currently the args are passed direct to the ORB, |
34 |
* so any ORB paramaters could go there. |
35 |
* |
36 |
* @param args the command line arguments |
37 |
*/ |
38 |
public static void main(String[] args) { |
39 |
System.out.println("I-Scream CORE:" + REVISION + " - coming up."); |
40 |
try { |
41 |
// start the ORB |
42 |
ORB orb = ORB.init(args, null); |
43 |
|
44 |
// get the Root POA |
45 |
org.omg.CORBA.Object objRef = orb.resolve_initial_references("RootPOA"); |
46 |
POA poa = POAHelper.narrow(objRef); |
47 |
|
48 |
// get a hook to the name service |
49 |
objRef = orb.resolve_initial_references("NameService"); |
50 |
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); |
51 |
|
52 |
// get a ref to our servers |
53 |
// first the Configurator |
54 |
ConfiguratorServant configuratorRef = new ConfiguratorServant(poa); |
55 |
|
56 |
// then the logger |
57 |
ScreenLoggerServant loggerRef = new ScreenLoggerServant(); |
58 |
// FileLoggerServant loggerRef = new FileLoggerServant(); |
59 |
|
60 |
// advertise them to the naming context |
61 |
// Configurator |
62 |
objRef = poa.servant_to_reference(configuratorRef); |
63 |
ncRef.bind(ncRef.to_name("iscream.Configurator"), objRef); |
64 |
|
65 |
// Logger |
66 |
objRef = poa.servant_to_reference(loggerRef); |
67 |
ncRef.bind(ncRef.to_name("iscream.Logger"), objRef); |
68 |
|
69 |
// start the POA off |
70 |
poa.the_POAManager().activate(); |
71 |
|
72 |
System.out.println("I-Scream CORE:" + REVISION + " - started."); |
73 |
|
74 |
// now we are running, we just need to serve |
75 |
// so we ask the orb to block for us until it has finished |
76 |
orb.run(); |
77 |
|
78 |
// if there was a problem then we'll get to here |
79 |
} catch (Exception e) { |
80 |
|
81 |
// there is already another CORE of the same name registered |
82 |
if ( e instanceof org.omg.CosNaming.NamingContextPackage.AlreadyBound) { |
83 |
System.err.println("ERROR: Another I-Scream CORE is already registered under the same name."); |
84 |
|
85 |
// otherwise we don't know what happened |
86 |
// so print the error and do a stack trace |
87 |
} else { |
88 |
System.err.println("CORE ERROR: " + e); |
89 |
e.printStackTrace(System.out); |
90 |
} |
91 |
} |
92 |
} |
93 |
|
94 |
//---CONSTRUCTORS--- |
95 |
|
96 |
//---PUBLIC METHODS--- |
97 |
|
98 |
//---PRIVATE METHODS--- |
99 |
|
100 |
//---ACCESSOR/MUTATOR METHODS--- |
101 |
|
102 |
//---ATTRIBUTES--- |
103 |
|
104 |
//---STATIC ATTRIBUTES--- |
105 |
|
106 |
} |