Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[stellation-res] Duhhhh.... Here's the patch

Duhhh... Mark stupid. Mark forget to attach patch to last message. Now
stupid Mark whack himself in head with flute, and try again.

	-mARK

-- 

Index: src/org/eclipse/stellation/remote/engine/Connection.java
===================================================================
RCS file: /home/technology/org.eclipse.stellation/plugins/org.eclipse.stellation.remote/src/org/eclipse/stellation/remote/engine/Connection.java,v
retrieving revision 1.3
diff -u -r1.3 Connection.java
--- src/org/eclipse/stellation/remote/engine/Connection.java	12 Feb 2003 18:29:35 -0000	1.3
+++ src/org/eclipse/stellation/remote/engine/Connection.java	15 Jul 2003 19:40:29 -0000
@@ -135,7 +135,7 @@
                     }
                     pw.close();
                     // Now, extract the tagname of the top-level XML tag.
-                    Document doc = _core.handleDocument(caw.toString());
+                    Document doc = _core.handleDocument(caw.toString()); 
                     Message ev = new Message(_id, type, target, doc);
                     synchronized (_messageQueue) {
                         _messageQueue.enqueue(ev);
@@ -166,7 +166,7 @@
                     continue;
                 }
                 
-            } catch (IOException ioe) {
+            } catch (IOException ioe) {           	
                 if (_dying) {
                     logger.debug("Connection thread terminating");
                     return;
@@ -176,8 +176,9 @@
                 	_core.removeConnection(this);               	
                 	return;
                 }
-                else
-                    logger.info("IO Exception in message thread in connection " + getID());
+                else {                
+                    logger.info("IO Exception in message thread in connection " + getID());                    
+                }
             }
         }
     }
Index: src/org/eclipse/stellation/remote/engine/Engine.java
===================================================================
RCS file: /home/technology/org.eclipse.stellation/plugins/org.eclipse.stellation.remote/src/org/eclipse/stellation/remote/engine/Engine.java,v
retrieving revision 1.4
diff -u -r1.4 Engine.java
--- src/org/eclipse/stellation/remote/engine/Engine.java	17 Apr 2003 01:02:45 -0000	1.4
+++ src/org/eclipse/stellation/remote/engine/Engine.java	15 Jul 2003 19:40:30 -0000
@@ -144,6 +144,16 @@
         }
     }
     
+    public Engine(String name, int poolsize) {
+    	this(poolsize);
+    	_engineName = name;
+    }
+    
+    public Engine(String name) {
+    	this();
+    	_engineName = name;
+    }
+    
     public Engine() {
         this(5);
     }
@@ -195,6 +205,10 @@
         }
         return _engineID;
     }
+    
+    public String getEngineName() {
+    	return _engineName;
+    }
 
     /************************************************************
      ** Subscription management
@@ -277,7 +291,7 @@
             Connection c = (Connection) connections.next();
             if (c.getID().equals(connID)) {
                 PrintWriter out = c.getWriter();
-                out.flush();
+                out.flush();                
             }
         }
     }
@@ -377,7 +391,7 @@
                 serverSock = new ServerSocket(_port);
             }
             catch (IOException ioe) {
-                System.err.println("CServer Connection thread: error listening for connections");
+                System.err.println("*** CServer Connection thread: error listening for connections");
                 return;
             }
             log.debug("--> AccessPoint started connection thread");
@@ -485,6 +499,7 @@
 	    BufferedReader in = conn.getReader();
 	    String line = in.readLine();
 	    while (!line.equals("<?end-of-subscriptions?>")) {
+	    	//System.err.println("Subscription to: " + line);
 	        if (_perl.match(SubscribeRE, line)) {
 	            String type = _perl.group(1);
 	            String engineid = _perl.group(2);
@@ -577,7 +592,7 @@
      */
     class DeliveryThread extends Thread {
         public void run() {
-            log.debug("DELIVERYTHREAD: started");
+            log.debug("DELIVERYTHREAD: started"); 
             Engine.this.runDeliveryThread();
         }
     }
@@ -619,6 +634,8 @@
     public synchronized void sendMessage(Message msg) {
         /* First, send it to local subscribers */
         log.debug("-> Send message: " + msg);
+        if (msg.getSource() == null) 
+            msg.setSource(getEngineID());
 
         Iterator /*<MessageHandler>*/
         localSubs = _subscribers.getMatchingElements(msg.getType());
@@ -646,7 +663,8 @@
                 StringIterator connIDs = subs.iterator();
                 while (connIDs.hasNext()) {
                     String connID = connIDs.next();
-                    Connection c = (Connection) _connections.get(connID);
+                    
+                    Connection c = (Connection) _connections.get(connID);         
                     PrintWriter out = c.getWriter(); 
                     try {
                         msg.emit(out);
@@ -1306,7 +1324,9 @@
     public synchronized void shutdown() {
         log.info("Shutting down server");
     	_dying = true;
-        Iterator conns = _connections.values().iterator();
+    	List connList = new ArrayList(_connections.values().size());
+    	connList.addAll(_connections.values());
+        Iterator conns = connList.iterator();
         while (conns.hasNext()) {
             Connection c = (Connection) conns.next();
             closeConnection(c);
@@ -1439,6 +1459,11 @@
      * the identifier of the engine.
      */
     protected String _engineID = null;
+    
+    /**
+     * A human readable name for the engine, to be used in logging.
+     */
+    protected String _engineName = "anonymous";
 
     /**
      * A queue of messages that have been received, and need to be delivered
Index: src/org/eclipse/stellation/remote/engine/Message.java
===================================================================
RCS file: /home/technology/org.eclipse.stellation/plugins/org.eclipse.stellation.remote/src/org/eclipse/stellation/remote/engine/Message.java,v
retrieving revision 1.3
diff -u -r1.3 Message.java
--- src/org/eclipse/stellation/remote/engine/Message.java	12 Feb 2003 18:29:35 -0000	1.3
+++ src/org/eclipse/stellation/remote/engine/Message.java	15 Jul 2003 19:40:30 -0000
@@ -15,6 +15,7 @@
 import java.io.PrintWriter;
 import java.io.IOException;
 import org.jdom.Document;
+import org.jdom.Element;
 import org.jdom.output.XMLOutputter;
 
 /**
@@ -32,8 +33,27 @@
         _connID = connID;
         _type = type;
         _target = target;
-        _detail = det;
+        if (det instanceof Element)
+        	_detail = new Document((Element)det);
+        else
+        	_detail = det;
     }
+    
+    /**
+     * Create an message.
+     * @param type the message type.
+     * @param target the id of the message target.
+     * @param detail the message detail information wrapped in an XML document.
+     */
+    public Message(String type, String target, Object det) {
+        _connID = null;
+        _type = type;
+        _target = target;
+        if (det instanceof Element)
+        	_detail = new Document((Element)det);
+        else
+	        _detail = det;
+    }    
 
     /**
      * Get the most general family the message is a member of.
@@ -57,6 +77,10 @@
         return _connID;
     }
     
+    protected void setSource(String cid) {
+        _connID = cid;
+    }
+    
     /**
      * Get the ID of the target resource of the message.
      * @return the ID of the target resource.
@@ -80,8 +104,12 @@
     public Document getDocument() {
         if (_detail instanceof Document)
             return (Document)_detail;
-        else
-            return null;
+        else if (_detail instanceof Element) {
+        	_detail = new Document((Element)_detail);
+        	return (Document)_detail;
+        }
+        else 
+        	return null;
     }
     
     /**
Index: src/org/eclipse/stellation/remote/engine/MessageHandler.java
===================================================================
RCS file: /home/technology/org.eclipse.stellation/plugins/org.eclipse.stellation.remote/src/org/eclipse/stellation/remote/engine/MessageHandler.java,v
retrieving revision 1.3
diff -u -r1.3 MessageHandler.java
--- src/org/eclipse/stellation/remote/engine/MessageHandler.java	12 Feb 2003 18:29:35 -0000	1.3
+++ src/org/eclipse/stellation/remote/engine/MessageHandler.java	15 Jul 2003 19:40:30 -0000
@@ -24,12 +24,12 @@
      * (2) The message handling performs some communication operation which
      *    could, potentially, result in a deadlock condition if it runs
      *    in the Core message handling thread.
-     * @param e the message.
+     * @param m the message.
      */
-    public boolean dispatch(Message e);
+    public boolean dispatch(Message m);
 
     /**
      * Handle the message.
      */
-    public void handleMessage(Message e);        
+    public void handleMessage(Message m);        
 }

Back to the top