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.3
Committed: Fri Jan 12 00:45:48 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.2: +2 -2 lines
Log Message:
Just an efficiency change.

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