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.6
Committed: Fri Jan 19 01:16:03 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.5: +2 -2 lines
Log Message:
Made a mistake in the last commit, it's late :/

File Contents

# Content
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.componentmanager.*;
7 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 * @author $Author: tdb1 $
16 * @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 public final String REVISION = "$Revision: 1.5 $";
26
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 _queueID = queue.getQueue();
41 }
42
43 //---PUBLIC METHODS---
44
45 /**
46 * start the thread and thus gets and sends data
47 */
48 public void run() {
49 String xml = null;
50 while(true) {
51 try {
52 xml = (String) _queue.get(_queueID);
53 }
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 * Our Queue id.
84 */
85 private int _queueID;
86
87 /**
88 * the interface this thread is sending data to
89 */
90 private ClientInterface _destination;
91
92 /**
93 * This is the friendly identifier of the
94 * component this class is running in.
95 * eg, a Filter may be called "filter1",
96 * If this class does not have an owning
97 * component, a name from the configuration
98 * can be placed here. This name could also
99 * be changed to null for utility classes.
100 */
101 private String _name = RootFilter.NAME;
102
103 /**
104 * This holds a reference to the
105 * system logger that is being used.
106 */
107 private Logger _logger = ReferenceManager.getInstance().getLogger();
108
109 //---STATIC ATTRIBUTES---
110
111 }