1 |
|
//---PACKAGE DECLARATION--- |
2 |
|
|
3 |
|
//---IMPORTS--- |
4 |
< |
import core.*; |
4 |
> |
import uk.ac.ukc.iscream.core.*; |
5 |
|
import org.omg.CORBA.*; |
6 |
|
import org.omg.CosNaming.*; |
7 |
|
import org.omg.PortableServer.*; |
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."); |
39 |
> |
System.out.println("--- I-Scream ---"); |
40 |
> |
|
41 |
> |
// can't have a real toString() :) |
42 |
> |
String toString = "CORE(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
43 |
> |
|
44 |
> |
System.out.println(toString + ": coming up"); |
45 |
> |
|
46 |
|
try { |
47 |
|
// start the ORB |
48 |
|
ORB orb = ORB.init(args, null); |
55 |
|
objRef = orb.resolve_initial_references("NameService"); |
56 |
|
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); |
57 |
|
|
58 |
< |
// get a ref to our servers |
59 |
< |
// first the Configurator |
60 |
< |
ConfiguratorServant configuratorRef = new ConfiguratorServant(poa); |
55 |
< |
|
56 |
< |
// then the logger |
58 |
> |
// start and bind each server in turn |
59 |
> |
|
60 |
> |
// create the logger (either Screen or File) |
61 |
|
ScreenLoggerServant loggerRef = new ScreenLoggerServant(); |
62 |
< |
// FileLoggerServant loggerRef = new FileLoggerServant(); |
62 |
> |
//FileLoggerServant loggerRef = new FileLoggerServant("core.log"); |
63 |
> |
// and advertise it to the naming context |
64 |
> |
objRef = poa.servant_to_reference(loggerRef); |
65 |
> |
ncRef.bind(ncRef.to_name("iscream.Logger"), objRef); |
66 |
|
|
67 |
< |
// advertise them to the naming context |
68 |
< |
// Configurator |
67 |
> |
// get a ref to the logger servant as a Logger reference |
68 |
> |
Logger logRef = LoggerHelper.narrow(objRef); |
69 |
> |
|
70 |
> |
// create the Configurator |
71 |
> |
ConfiguratorServant configuratorRef = new ConfiguratorServant(poa, logRef); |
72 |
> |
// and advertise it to the naming context |
73 |
|
objRef = poa.servant_to_reference(configuratorRef); |
74 |
|
ncRef.bind(ncRef.to_name("iscream.Configurator"), objRef); |
75 |
|
|
65 |
– |
// Logger |
66 |
– |
objRef = poa.servant_to_reference(loggerRef); |
67 |
– |
ncRef.bind(ncRef.to_name("iscream.Logger"), objRef); |
68 |
– |
|
76 |
|
// start the POA off |
77 |
|
poa.the_POAManager().activate(); |
78 |
< |
|
79 |
< |
System.out.println("I-Scream CORE:" + REVISION + " - started."); |
78 |
> |
|
79 |
> |
logRef.write(toString, "started"); |
80 |
|
|
81 |
|
// now we are running, we just need to serve |
82 |
|
// so we ask the orb to block for us until it has finished |