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.10 by ajm, Tue Dec 12 19:54:55 2000 UTC vs.
Revision 1.26 by ajm, Fri Feb 23 17:08:50 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   /**
# Line 17 | Line 18 | import uk.ac.ukc.iscream.clientinterface.*;
18   * @author  $Author$
19   * @version $Id$
20   */
21 < public class RootFilter implements uk.ac.ukc.iscream.util.Component {
21 > public class RootFilter implements Component {
22  
23   //---FINAL ATTRIBUTES---
24  
# Line 36 | Line 37 | public class RootFilter implements uk.ac.ukc.iscream.u
37       * This starts the Root Filter for the system
38       */
39      public void start() throws ComponentStartException {
40 <
40 >        // get references to key objects
41 >        _refman = ReferenceManager.getInstance();
42 >        _logger = ReferenceManager.getInstance().getLogger();
43 >        
44          _logger.write(toString(), Logger.SYSINIT, "coming up");
45              
46          // configuration variables we require
47          String ourName = null;
48          String realInterface = null;
49          String dbInterface = null;
50 +        int queueMonitorInterval = 0;
51          
52          Configuration config = _refman.getCM().getConfiguration("RootFilter");
53          if (config == null) {
54 <            System.err.println("CRITICAL:Unable to obtain configuration" +
55 <                               "\n         Advise you check the i-scream log for more information.");
56 <            _logger.write(toString(), Logger.FATAL, "ERROR - unable to obtain configuration");
52 <            System.exit(1);
53 <        } else {
54 >            throw new ComponentStartException("Unable to obtain configuration for component");
55 >        }
56 >        else {
57              try {
58 +                // get the configuration properties we need
59                  ourName = config.getProperty("RootFilter.name");
60                  realInterface = config.getProperty("RootFilter.realtimeInterfaceName");
61                  dbInterface = config.getProperty("RootFilter.dbInterfaceName");
62 +                queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval"));
63              } catch (org.omg.CORBA.MARSHAL e) {
64 <                System.err.println ("CRITICAL:Unable to obtain required configuration property" +
60 <                                    "\n         Advise you check the i-scream log for more information.");
61 <                _logger.write(toString(), Logger.FATAL, "ERROR - required configuration property not present");
62 <                System.exit(1);
64 >                throw new ComponentStartException("Unable to obtain requried configuration property for component");
65              }
66          }
67 +        
68          // now we have the name of the Root Filter we set it
69          NAME = ourName;
70          
71          _logger.write(toString(), Logger.SYSINIT, "configured");
72 <                
72 >        
73 >        ClientInterface ciReal = null, ciDB = null;
74          // get reference to the client interfaces - the real time one
75 <        ClientInterface ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface));
75 >        if (realInterface != null) {
76 >            ciReal = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + realInterface));
77 >        }
78          // get reference to the client interfaces - and the db one
79 <        ClientInterface ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface));
80 <        _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface);
79 >        if (dbInterface != null) {
80 >            ciDB = ClientInterfaceHelper.narrow(_refman.getCORBARef("iscream.ClientInterface." + dbInterface));
81 >        }
82          
83 <        ClientInterface[] clientInterfaces = {ciReal, ciDB};
83 >        Queue queue = new Queue();
84 >        // startup a monitor on this queue, every minute
85 >        String queueName = NAME + " RootFilter";
86 >        queue.startMonitor(queueMonitorInterval*1000, queueName);
87          
88 +        if (realInterface == null) {        
89 +            _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + dbInterface);
90 +            CIWrapper c = new CIWrapper(ciDB, queue);
91 +            c.start();
92 +        } else if (dbInterface == null) {
93 +            _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface);
94 +            CIWrapper c = new CIWrapper(ciReal, queue);
95 +            c.start();
96 +        } else {
97 +            _logger.write(toString(), Logger.DEBUG, "hooked to interfaces - " + realInterface + " & " + dbInterface);
98 +            CIWrapper c = new CIWrapper(ciReal, queue);
99 +            c.start();
100 +            c = new CIWrapper(ciDB, queue);
101 +            c.start();
102 +        }
103 +                
104          // RootFilterServant start (for inbound child filter data)
105          _logger.write(toString(), Logger.DEBUG, "starting Root Filter");
106 <        RootFilterServant filterServant = new RootFilterServant(clientInterfaces);
106 >        RootFilterServant filterServant = new RootFilterServant(queue);
107          // bind to the naming service as a filter
108 <        _refman.bindToOrb(filterServant, "iscream.Filter." + _name);
108 >        _refman.bindToOrb(filterServant, "iscream.Filter." + RootFilter.NAME);
109          
110          _logger.write(toString(), Logger.SYSINIT, "started");
111 +        
112      }
113      
114      /**
# Line 95 | Line 122 | public class RootFilter implements uk.ac.ukc.iscream.u
122       */
123      public String toString() {
124          return FormatName.getName(
125 <            _name,
125 >            NAME,
126              getClass().getName(),
127              REVISION);
128      }
# Line 107 | Line 134 | public class RootFilter implements uk.ac.ukc.iscream.u
134   //---ATTRIBUTES---
135  
136      /**
110     * This is the friendly identifier of the
111     * component this class is running in.
112     * eg, a Filter may be called "filter1",
113     * If this class does not have an owning
114     * component,  a name from the configuration
115     * can be placed here.  This name could also
116     * be changed to null for utility classes.
117     */
118    private String _name = RootFilter.NAME;
119
120    /**
137       * This holds a reference to the
138       * system logger that is being used.
139       */
140 <    private Logger _logger = ReferenceManager.getInstance().getLogger();
140 >    private Logger _logger;
141  
142      /**
143       * A reference to the reference manager in use
144       */
145 <    private ReferenceManager _refman = ReferenceManager.getInstance();
145 >    private ReferenceManager _refman;
146  
147   //---STATIC ATTRIBUTES---
148  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines