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/CIWrapper.java
Revision: 1.4
Committed: Thu Jan 18 23:17:05 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.3: +2 -1 lines
Log Message:
Changes to reflect move of Component, ComponentStartException, and the
ReferenceManager from util to componentmanager.

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2     package uk.ac.ukc.iscream.rootfilter;
3    
4     //---IMPORTS---
5     import uk.ac.ukc.iscream.core.*;
6 tdb 1.4 import uk.ac.ukc.iscream.componentmanager.*;
7 tdb 1.1 import uk.ac.ukc.iscream.clientinterface.*;
8     import uk.ac.ukc.iscream.util.*;
9    
10     /**
11     * A ClientInterface wrapper - the CI objects are pushed data,
12     * yet data is pulled from the queue. This will sit inbetween
13     * for now, until the CI design is changed.
14     *
15 tdb 1.2 * @author $Author: tdb1 $
16 tdb 1.1 * @version $Id $
17     */
18     public class CIWrapper extends Thread {
19    
20     //---FINAL ATTRIBUTES---
21    
22     /**
23     * The current CVS revision of this class
24     */
25 tdb 1.4 public final String REVISION = "$Revision: 1.3 $";
26 tdb 1.1
27     //---STATIC METHODS---
28    
29     //---CONSTRUCTORS---
30    
31     /**
32     * Sets up the wrapper, with a single destination and a queue.
33     *
34     * @param destination the client interface to send the xml to
35     * @param queue a reference to a queue to use
36     */
37     public CIWrapper(ClientInterface destination, Queue queue){
38     _destination = destination;
39     _queue = queue;
40     }
41    
42     //---PUBLIC METHODS---
43    
44     /**
45     * start the thread and thus gets and sends data
46     */
47     public void run() {
48     int n = _queue.getQueue();
49 tdb 1.3 String xml = null;
50 tdb 1.1 while(true) {
51     try {
52 tdb 1.2 xml = (String) _queue.get(n);
53 tdb 1.1 }
54     catch (InvalidQueueException e) {
55     _logger.write(toString(), Logger.ERROR, "Queue error: "+e);
56     }
57     _destination.receiveXML(xml);
58     }
59     }
60    
61     /**
62     * Overrides the {@link java.lang.Object#toString() Object.toString()}
63     * method to provide clean logging (every class should have this).
64     *
65     * @return the name of this class and its CVS revision
66     */
67     public String toString() {
68     return this.getClass().getName() + "{" + _name + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
69     }
70    
71     //---PRIVATE METHODS---
72    
73     //---ACCESSOR/MUTATOR METHODS---
74    
75     //---ATTRIBUTES---
76    
77     /**
78     * A reference to a Queue object.
79     */
80     private Queue _queue;
81    
82     /**
83     * the interface this thread is sending data to
84     */
85     private ClientInterface _destination;
86    
87     /**
88     * This is the friendly identifier of the
89     * component this class is running in.
90     * eg, a Filter may be called "filter1",
91     * If this class does not have an owning
92     * component, a name from the configuration
93     * can be placed here. This name could also
94     * be changed to null for utility classes.
95     */
96     private String _name = RootFilter.NAME;
97    
98     /**
99     * This holds a reference to the
100     * system logger that is being used.
101     */
102     private Logger _logger = ReferenceManager.getInstance().getLogger();
103    
104     //---STATIC ATTRIBUTES---
105    
106     }