ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/RootFilter.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/RootFilter.java (file contents):
Revision 1.4 by tdb, Thu Nov 30 02:42:56 2000 UTC vs.
Revision 1.8 by ajm, Mon Dec 4 18:12:13 2000 UTC

# Line 2 | Line 2
2   package uk.ac.ukc.iscream.rootfilter;
3  
4   //---IMPORTS---
5 import uk.ac.ukc.iscream.core.*;
6 import uk.ac.ukc.iscream.filter.*;
7 import org.omg.CORBA.*;
8 import org.omg.CosNaming.*;
9 import org.omg.PortableServer.*;
5   import uk.ac.ukc.iscream.util.*;
6 + import uk.ac.ukc.iscream.core.*;
7 + import uk.ac.ukc.iscream.clientinterface.*;
8  
9   /**
10 < * A RootFilter Startup Class
10 > * A Filter Startup Class
11   *
12   * @author  $Author$
13   * @version $Id$
# Line 27 | Line 24 | class RootFilterMain {
24   //---STATIC METHODS---
25  
26      public static void main(String[] args) {
27 +        // ***************************************
28 +        // VERY TEMPORARY - will find a better way
29          System.setProperty("org.omg.CORBA.ORBClass","jacorb.orb.ORB");
30          System.setProperty("org.omg.CORBA.ORBSingletonClass","jacorb.orb.ORBSingleton");
31 +        // ***************************************
32 +
33 +        ReferenceManager refman = ReferenceManager.init(null, null);
34          
33        // get our name from the command line
34        String ourName = "";
35        if (args.length == 1) {
36            ourName = args[0];
37        }
38        else {
39            usage();
40        }
41        
35          // can't have a real toString() :)
36 <        String toString = "RootFilter{" + ourName + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
37 <        
38 <        try {        
46 <            ORB orb = ORB.init(args, null);
36 >        String toString = "RootFilter{" + refman.getName() + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
37 >
38 >        refman.getLogger().write(toString, Logger.SYSINIT, "coming up");
39              
40 <            // something to hold objects
41 <            org.omg.CORBA.Object objRef = null;    
42 <            
43 <            // get the Root POA
44 <            objRef = orb.resolve_initial_references("RootPOA");
45 <            POA poa = POAHelper.narrow(objRef);
46 <            
47 <            // get a hook to the name service
48 <            objRef = orb.resolve_initial_references("NameService");
49 <            NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
50 <                
51 <            // get a ref to the ConfigurationManager, Logger & the FilterManager
52 <            
53 <            objRef = ncRef.resolve(ncRef.to_name("iscream.ConfigurationManager"));
54 <            ConfigurationManager configManager = ConfigurationManagerHelper.narrow(objRef);
55 <            
56 <            objRef = ncRef.resolve(ncRef.to_name("iscream.Logger"));
57 <            Logger logger = LoggerHelper.narrow(objRef);
58 <            
59 <            //objRef = ncRef.resolve(ncRef.to_name("iscream.FilterManager"));
68 <            //FilterManager filterManager = FilterManagerHelper.narrow(objRef);
69 <            
70 <            logger.write(toString, Logger.SYSINIT, "coming up");
71 <            
72 <            
73 <            // **** THIS SECTION WILL NEED CHANGING TO GET RELEVANT CONFIG
74 <            // **** Please ignore this block of code, it's just "copy/paste" :)
75 <            
76 <            // get the config
77 <            Configuration myConfig = configManager.getConfiguration(ourName);
78 <                      
79 <            logger.write(toString, Logger.SYSINIT, "configured");
80 <            
81 <            // **** END COMMENT
82 <            
83 <            // **** INITIAL FILTER MANAGER COMMUNICATIONS HERE
84 <            
85 <            // **** END COMMENT
86 <            
87 <            logger.write(toString, Logger.SYSINIT, "starting RootFilter");
88 <            
89 <            /**************************************************************
90 <              Here would be an ideal place to start another thread to do
91 <              the listening part of the Filter. Ideally it should just be
92 <              created and then run(). It may be necessary to pass some of
93 <              the following parameters into the thread by the constructor.
94 <              
95 <                  Logger logger
96 <                      - a reference to a Logger object
97 <                  FilterManager filterManager
98 <                      - a reference to the system filter manager
99 <                  ConfigurationManager configManager
100 <                      - a reference to the system configuration manager
101 <                  Configuration myConfig
102 <                      - a reference to the configuration object for this
103 <                        filter instance
104 <                  String ourName
105 <                      - our "identifier" name
106 <            
107 <            **************************************************************/
108 <            
109 <            // NOTE:
110 <            //   We will not need to bind to the ORB when the FilterManager
111 <            //   is running :)
112 <            
113 <            // create the RootFilterServant
114 <            RootFilterServant rfServant = new RootFilterServant(logger, ourName);
115 <            
116 <            // and advertise it to the naming context
117 <            objRef = poa.servant_to_reference(rfServant);
118 <            ncRef.bind(ncRef.to_name("iscream.Filter."+ourName), objRef);
119 <            
120 <            // start the POA off
121 <            poa.the_POAManager().activate();
122 <                        
123 <            logger.write(toString, Logger.SYSINIT, "started");
124 <            
125 <            // now we are running, we just need to serve
126 <            // so we ask the orb to block for us until it has finished
127 <            orb.run();
128 <            
129 <        } catch (Exception e) {
130 <            System.err.println("FILTER ERROR: " + e);
131 <            e.printStackTrace(System.out);
40 >        // configuration variables we require
41 >        String ourName = null;
42 >        String realInterface = null;
43 >        String dbInterface = null;
44 >        
45 >        Configuration config = refman.getCM().getConfiguration("RootFilter");
46 >        if (config == null) {
47 >            throw new RuntimeException ("CRITICAL:Unable to obtain configuration" +
48 >                                        "         Advise you check the i-scream log for more information.");
49 >        } else {
50 >            try {
51 >                ourName = config.getProperty("RootFilter.name");
52 >                realInterface = config.getProperty("RootFilter.realtimeInterfaceName");
53 >                dbInterface = config.getProperty("RootFilter.dbInterfaceName");
54 >            } catch (org.omg.CORBA.MARSHAL e) {
55 >                refman.getLogger().write(toString, Logger.FATAL, "required config property not present");
56 >                throw new RuntimeException ("CRITICAL:Unable to obtain required configuration property" +
57 >                                            "         Advise you check the i-scream log for more information.");
58 >
59 >            }
60          }
61 +        // now we have the name of the Root Filter we set it
62 +        refman.setName(ourName);
63 +        toString = "RootFilter{" + refman.getName() + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
64 +        refman.getLogger().write(toString, Logger.SYSINIT, "configured");
65 +                
66 +        // get reference to the client interfaces - the real time one
67 +        ClientInterface ciReal = ClientInterfaceHelper.narrow(refman.getCORBARef("iscream.ClientInterface." + realInterface));
68 +        // - the db one ... but it's not done yet
69 +        //ClientInterface ciDB = ClientInterfaceHelper.narrow(refman.getCORBARef("iscream.ClientInterface." + dbInterface));
70 +        // so for the time being we null it.
71 +        ClientInterface ciDB = null;
72 +        refman.getLogger().write(toString, Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface);
73 +        
74 +        ClientInterface[] clientInterfaces = {ciReal, ciDB};
75 +        
76 +        // RootFilterServant start (for inbound child filter data)
77 +        refman.getLogger().write(toString, Logger.DEBUG, "starting Root Filter");
78 +        RootFilterServant filterServant = new RootFilterServant(clientInterfaces);
79 +        // bind to the naming service as a filter
80 +        refman.bindToOrb(filterServant, "iscream.Filter." + refman.getName());
81 +        
82 +        // start the POA off
83 +        // now we are running, we just need to serve
84 +        // so we ask the orb to block for us until it has finished
85 +        refman.activatePOA();
86 +        refman.getLogger().write(toString, Logger.SYSINIT, "started");
87 +        refman.getORB().run();
88      }
89  
90      /**
# Line 139 | Line 94 | class RootFilterMain {
94       * properly.
95       */
96      public static void usage() {
97 <        System.out.println("USAGE: java RootFilter <name>");
97 >        System.out.println("USAGE: java FilterMain <name>");
98          System.out.println("WHERE <name>:");
99 <        System.out.println("      The unique identifier for the RootFilter in the system.");
99 >        System.out.println("      The unique identifier for the Filter in the system.");
100          System.exit(1);
101      }
102  
# Line 157 | Line 112 | class RootFilterMain {
112  
113   //---STATIC ATTRIBUTES---
114  
115 < }            
115 > }            

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines