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.5 by ajm, Thu Nov 30 03:06:39 2000 UTC vs.
Revision 1.23 by tdb, Sun Jan 28 06:03:58 2001 UTC

# Line 4 | Line 4 | package uk.ac.ukc.iscream.rootfilter;
4   //---IMPORTS---
5   import uk.ac.ukc.iscream.util.*;
6   import uk.ac.ukc.iscream.core.*;
7 + import uk.ac.ukc.iscream.componentmanager.*;
8 + import uk.ac.ukc.iscream.clientinterface.*;
9  
10   /**
11 < * A Filter Startup Class
11 > * The root filter is what all filters talk to
12 > * Hosts cannot talk to this implementation of a filter.
13 > * It provides hooks to all data interfaces for the system
14 > * namely the client interface and the db interface.
15 > * This is an i-scream component that starts the
16 > * RootFilter services.
17   *
18   * @author  $Author$
19   * @version $Id$
20   */
21 < class FilterMain {
21 > public class RootFilter implements Component {
22  
23   //---FINAL ATTRIBUTES---
24  
# Line 19 | Line 26 | class FilterMain {
26       * The current CVS revision of this class
27       */
28      public static final String REVISION = "$Revision$";
29 <    
29 >
30   //---STATIC METHODS---
31  
32 <    public static void main(String[] args) {
26 <        // ***************************************
27 <        // VERY TEMPORARY - will find a better way
28 <        System.setProperty("org.omg.CORBA.ORBClass","jacorb.orb.ORB");
29 <        System.setProperty("org.omg.CORBA.ORBSingletonClass","jacorb.orb.ORBSingleton");
30 <        // ***************************************
32 > //---CONSTRUCTORS---
33  
34 <        ReferenceManager refman = ReferenceManager.init(null, null);
33 <        
34 <        // can't have a real toString() :)
35 <        String toString = "RootFilter{" + refman.getName() + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
34 > //---PUBLIC METHODS---
35  
36 <        refman.getLogger().write(toString, Logger.SYSINIT, "coming up");
36 >    /**
37 >     * This starts the Root Filter for the system
38 >     */
39 >    public void start() throws ComponentStartException {
40 >
41 >        _logger.write(toString(), Logger.SYSINIT, "coming up");
42              
43          // configuration variables we require
44          String ourName = null;
45 +        String realInterface = null;
46 +        String dbInterface = null;
47          
48 <        Configuration config = refman.getCM().getConfiguration("RootFilter");
48 >        Configuration config = _refman.getCM().getConfiguration("RootFilter");
49          if (config == null) {
50 <            throw new RuntimeException ("CRITICAL:Unable to obtain configuration" +
51 <                                        "         Advise you check the i-scream log for more information.");
52 <        } else {
50 >            throw new ComponentStartException("Unable to obtain configuration for component");
51 >        }
52 >        else {
53              try {
54 <                ourName = config.getProperty("Filter.rootFilter");
54 >                // get the configuration properties we need
55 >                ourName = config.getProperty("RootFilter.name");
56 >                realInterface = config.getProperty("RootFilter.realtimeInterfaceName");
57 >                dbInterface = config.getProperty("RootFilter.dbInterfaceName");
58              } catch (org.omg.CORBA.MARSHAL e) {
59 <                refman.getLogger().write(toString, Logger.FATAL, "required config property not present");
51 <                throw new RuntimeException ("CRITICAL:Unable to obtain required configuration property" +
52 <                                            "         Advise you check the i-scream log for more information.");
53 <
59 >                throw new ComponentStartException("Unable to obtain requried configuration property for component");
60              }
61          }
62 +        
63          // now we have the name of the Root Filter we set it
64 <        refman.setName(ourName);
58 <        refman.getLogger().write(toString, Logger.SYSINIT, "configured");
64 >        NAME = ourName;
65          
66 <        // FilterServant start (for inbound child filter data)
61 <        refman.getLogger().write(toString, Logger.DEBUG, "starting Root Filter");
62 <        RootFilterServant filterServant = new RootFilterServant();
63 <        refman.bindToOrb(filterServant, "iscream.Filter." + refman.getName());
66 >        _logger.write(toString(), Logger.SYSINIT, "configured");
67          
68 <        // start the POA off
69 <        // now we are running, we just need to serve
70 <        // so we ask the orb to block for us until it has finished
71 <        refman.activatePOA();
72 <        refman.getLogger().write(toString, Logger.SYSINIT, "started");
73 <        refman.getORB().run();
68 >        ClientInterface ciReal = null, ciDB = null;
69 >        // get reference to the client interfaces - the real time one
70 >        if (realInterface != null) {
71 >            ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface));
72 >        }
73 >        // get reference to the client interfaces - and the db one
74 >        if (dbInterface != null) {
75 >            ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface));
76 >        }
77 >        
78 >        Queue queue = new Queue();
79 >        
80 >        if (realInterface == null) {        
81 >            _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface);
82 >            CIWrapper c = new CIWrapper(ciDB, queue);
83 >            c.start();
84 >        } else if (dbInterface == null) {
85 >            _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface);
86 >            CIWrapper c = new CIWrapper(ciReal, queue);
87 >            c.start();
88 >        } else {
89 >            _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface);
90 >            CIWrapper c = new CIWrapper(ciReal, queue);
91 >            c.start();
92 >            c = new CIWrapper(ciDB, queue);
93 >            c.start();
94 >        }
95 >                
96 >        // RootFilterServant start (for inbound child filter data)
97 >        _logger.write(toString(), Logger.DEBUG, "starting Root Filter");
98 >        RootFilterServant filterServant = new RootFilterServant(queue);
99 >        // bind to the naming service as a filter
100 >        _refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME);
101 >        
102 >        _logger.write(toString(), Logger.SYSINIT, "started");
103 >        
104      }
105 <
106 <    /**
107 <     * A simple method to print the usage of this class.
108 <     * It never returns, but instead exits to the system
109 <     * with a value 1, to indicate the system did not start
110 <     * properly.
105 >    
106 >    /**
107 >     * Overrides the {@link java.lang.Object#toString() Object.toString()}
108 >     * method to provide clean logging (every class should have this).
109 >     *
110 >     * This uses the uk.ac.ukc.iscream.util.NameFormat class
111 >     * to format the toString()
112 >     *
113 >     * @return the name of this class and its CVS revision
114       */
115 <    public static void usage() {
116 <        System.out.println("USAGE: java FilterMain <name>");
117 <        System.out.println("WHERE <name>:");
118 <        System.out.println("      The unique identifier for the Filter in the system.");
119 <        System.exit(1);
115 >    public String toString() {
116 >        return FormatName.getName(
117 >            NAME,
118 >            getClass().getName(),
119 >            REVISION);
120      }
121  
86 //---CONSTRUCTORS---
87
88 //---PUBLIC METHODS---
89
122   //---PRIVATE METHODS---
123  
124   //---ACCESSOR/MUTATOR METHODS---
125  
126   //---ATTRIBUTES---
127  
128 +    /**
129 +     * This holds a reference to the
130 +     * system logger that is being used.
131 +     */
132 +    private Logger _logger = ReferenceManager.getInstance().getLogger();
133 +
134 +    /**
135 +     * A reference to the reference manager in use
136 +     */
137 +    private ReferenceManager _refman = ReferenceManager.getInstance();
138 +
139   //---STATIC ATTRIBUTES---
140 +
141 +    /**
142 +     * The friendly name for this component, used by
143 +     * all related classes.
144 +     * This is set from the configuration.
145 +     */
146 +    public static String NAME;
147  
148   }            

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines