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.7
Committed: Tue Mar 13 02:19:48 2001 UTC (23 years, 2 months ago) by tdb
Branch: MAIN
Changes since 1.6: +4 -1 lines
Log Message:
Given all the classes that extend Thread a name using Thread.setName(). It is
only representative as far as it will tell us which class the Thread is, but
this will go some way to aiding debugging. If time permitted, more effort could
be taken to name each thread according to what it was dealing with.

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.7 public final String REVISION = "$Revision: 1.6 $";
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 tdb 1.7 // set the Thread name
39     setName("rootfilter.CIWrapper");
40    
41 tdb 1.1 _destination = destination;
42     _queue = queue;
43 tdb 1.5 _queueID = queue.getQueue();
44 tdb 1.1 }
45    
46     //---PUBLIC METHODS---
47    
48     /**
49     * start the thread and thus gets and sends data
50     */
51     public void run() {
52 tdb 1.3 String xml = null;
53 tdb 1.1 while(true) {
54     try {
55 tdb 1.6 xml = (String) _queue.get(_queueID);
56 tdb 1.1 }
57     catch (InvalidQueueException e) {
58     _logger.write(toString(), Logger.ERROR, "Queue error: "+e);
59     }
60     _destination.receiveXML(xml);
61     }
62     }
63    
64     /**
65     * Overrides the {@link java.lang.Object#toString() Object.toString()}
66     * method to provide clean logging (every class should have this).
67     *
68     * @return the name of this class and its CVS revision
69     */
70     public String toString() {
71     return this.getClass().getName() + "{" + _name + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
72     }
73    
74     //---PRIVATE METHODS---
75    
76     //---ACCESSOR/MUTATOR METHODS---
77    
78     //---ATTRIBUTES---
79    
80     /**
81     * A reference to a Queue object.
82     */
83     private Queue _queue;
84 tdb 1.5
85     /**
86     * Our Queue id.
87     */
88     private int _queueID;
89 tdb 1.1
90     /**
91     * the interface this thread is sending data to
92     */
93     private ClientInterface _destination;
94    
95     /**
96     * This is the friendly identifier of the
97     * component this class is running in.
98     * eg, a Filter may be called "filter1",
99     * If this class does not have an owning
100     * component, a name from the configuration
101     * can be placed here. This name could also
102     * be changed to null for utility classes.
103     */
104     private String _name = RootFilter.NAME;
105    
106     /**
107     * This holds a reference to the
108     * system logger that is being used.
109     */
110     private Logger _logger = ReferenceManager.getInstance().getLogger();
111    
112     //---STATIC ATTRIBUTES---
113    
114     }