geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r575504 - in /geronimo/sandbox/gshell/trunk/gshell-remote: gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/ gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ gshell-remote-server/src/m...
Date Fri, 14 Sep 2007 00:50:56 GMT
Author: jdillon
Date: Thu Sep 13 17:50:54 2007
New Revision: 575504

URL: http://svn.apache.org/viewvc?rev=575504&view=rev
Log:
Tidy up some loose ends, hook up visitors

Added:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java
      - copied, changed from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
  (contents, props changed)
      - copied, changed from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandlerSupport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorAdapter.java
      - copied, changed from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
  (contents, props changed)
      - copied, changed from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandlerSupport.java
Removed:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandlerSupport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandlerSupport.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java?rev=575504&r1=575503&r2=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClient.java
Thu Sep 13 17:50:54 2007
@@ -46,7 +46,7 @@
     private Logger log = LoggerFactory.getLogger(getClass());
 
     @Requirement(role=IoHandler.class, hint="rsh-client")
-    private RshClientProtocolHandlerSupport handler;
+    private RshClientProtocolHandler handler;
 
     private InetSocketAddress address;
 
@@ -63,6 +63,8 @@
 
         address = new InetSocketAddress(hostname, port);
 
+        handler.setVisitor(new RshClientMessageVisitor());
+        
         connector = new SocketConnector();
         connector.setConnectTimeout(30);
         connector.setHandler(handler);

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java
(from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java&r1=575500&r2=575504&rev=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientMessageVisitor.java
Thu Sep 13 17:50:54 2007
@@ -19,31 +19,20 @@
 
 package org.apache.geronimo.gshell.remote.client;
 
-import org.apache.geronimo.gshell.command.CommandSupport;
-import org.apache.geronimo.gshell.command.annotation.CommandComponent;
-import org.codehaus.plexus.component.annotations.Requirement;
+import org.apache.geronimo.gshell.remote.message.MessageVisitorAdapter;
+import org.apache.geronimo.gshell.remote.message.EchoMessage;
 
 /**
  * ???
  *
  * @version $Rev$ $Date$
  */
-@CommandComponent(id="rsh")
-public class RshCommand
-    extends CommandSupport
+public class RshClientMessageVisitor
+    extends MessageVisitorAdapter
 {
-    private String hostname = "localhost";
+    public void visitEchoCommand(final EchoMessage msg) {
+        assert msg != null;
 
-    private int port = 9999;
-
-    @Requirement
-    private RshClient client;
-
-    protected Object doExecute() throws Exception {
-        client.connect(hostname, port);
-
-        client.echo("TESTING");
-
-        return SUCCESS;
+        System.out.println("ECHO: " + msg.getText());
     }
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
(from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandlerSupport.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandlerSupport.java&r1=575500&r2=575504&rev=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandlerSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
Thu Sep 13 17:50:54 2007
@@ -20,7 +20,10 @@
 package org.apache.geronimo.gshell.remote.client;
 
 import org.apache.geronimo.gshell.remote.RshProtocolHandlerSupport;
+import org.apache.geronimo.gshell.remote.message.Message;
+import org.apache.geronimo.gshell.remote.message.MessageVisitor;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
 import org.codehaus.plexus.component.annotations.Component;
 
 /**
@@ -29,10 +32,33 @@
  * @version $Rev$ $Date$
  */
 @Component(role=IoHandler.class, hint="rsh-client")
-public class RshClientProtocolHandlerSupport
+public class RshClientProtocolHandler
     extends RshProtocolHandlerSupport
 {
-    //
-    // TODO:
-    //
+    private MessageVisitor visitor;
+
+    public MessageVisitor getVisitor() {
+        return visitor;
+    }
+
+    public void setVisitor(final MessageVisitor visitor) {
+        this.visitor = visitor;
+    }
+
+    public void messageReceived(final IoSession session, final Object message) throws Exception
{
+        assert session != null;
+        assert message != null;
+
+        super.messageReceived(session, message);
+
+        Message msg = (Message)message;
+
+        msg.setAttachment(session);
+
+        msg.setAttachment(session);
+
+        if (visitor != null) {
+            msg.process(visitor);
+        }
+    }
 }

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-client/src/main/java/org/apache/geronimo/gshell/remote/client/RshClientProtocolHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java?rev=575504&r1=575503&r2=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/EchoMessage.java
Thu Sep 13 17:50:54 2007
@@ -64,4 +64,10 @@
 
         writeString(buff, text);
     }
+
+    public void process(final MessageVisitor visitor) throws Exception {
+        assert visitor != null;
+
+        visitor.visitEchoCommand(this);
+    }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java?rev=575504&r1=575503&r2=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
Thu Sep 13 17:50:54 2007
@@ -46,15 +46,11 @@
         assert type != null;
         
         this.type = type;
+
+        this.id = ID_COUNTER.incrementAndGet();
     }
     
     public long getId() {
-        synchronized (ID_COUNTER) {
-            if (id == -1) {
-                id = ID_COUNTER.incrementAndGet();
-            }
-        }
-        
         return id;
     }
 

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java?rev=575504&r1=575503&r2=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
Thu Sep 13 17:50:54 2007
@@ -26,5 +26,5 @@
  */
 public interface MessageVisitor
 {
-    
+    void visitEchoCommand(EchoMessage msg);
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorAdapter.java
(from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorAdapter.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorAdapter.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java&r1=575500&r2=575504&rev=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageVisitorAdapter.java
Thu Sep 13 17:50:54 2007
@@ -24,7 +24,10 @@
  *
  * @version $Rev$ $Date$
  */
-public interface MessageVisitor
+public class MessageVisitorAdapter
+    implements MessageVisitor
 {
-    
+    public void visitEchoCommand(EchoMessage msg) {
+        // Empty
+    }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java?rev=575504&r1=575503&r2=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServer.java
Thu Sep 13 17:50:54 2007
@@ -37,13 +37,13 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role= RshServer.class)
+@Component(role=RshServer.class)
 public class RshServer
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
     @Requirement(role=IoHandler.class, hint="rsh-server")
-    private RshServerProtocolHandlerSupport handler;
+    private RshServerProtocolHandler handler;
 
     private SocketAcceptor acceptor;
 
@@ -53,6 +53,8 @@
         if (bound) {
             throw new IllegalStateException("Already bound");
         }
+
+        handler.setVisitor(new RshServerMessageVisitor());
 
         acceptor = new SocketAcceptor();
         acceptor.setLocalAddress(new InetSocketAddress(port));

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java?rev=575504&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
Thu Sep 13 17:50:54 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.remote.server;
+
+import org.apache.geronimo.gshell.remote.message.MessageVisitorAdapter;
+import org.apache.geronimo.gshell.remote.message.EchoMessage;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class RshServerMessageVisitor
+    extends MessageVisitorAdapter
+{
+    public void visitEchoCommand(final EchoMessage msg) {
+        assert msg != null;
+
+        System.out.println("ECHO: " + msg.getText());
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerMessageVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
(from r575500, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandlerSupport.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandlerSupport.java&r1=575500&r2=575504&rev=575504&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandlerSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
Thu Sep 13 17:50:54 2007
@@ -20,7 +20,10 @@
 package org.apache.geronimo.gshell.remote.server;
 
 import org.apache.geronimo.gshell.remote.RshProtocolHandlerSupport;
+import org.apache.geronimo.gshell.remote.message.Message;
+import org.apache.geronimo.gshell.remote.message.MessageVisitor;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
 import org.codehaus.plexus.component.annotations.Component;
 
 /**
@@ -29,10 +32,33 @@
  * @version $Rev$ $Date$
  */
 @Component(role=IoHandler.class, hint="rsh-server")
-public class RshServerProtocolHandlerSupport
+public class RshServerProtocolHandler
     extends RshProtocolHandlerSupport
 {
-    //
-    // TODO:
-    //
+    private MessageVisitor visitor;
+
+    public MessageVisitor getVisitor() {
+        return visitor;
+    }
+
+    public void setVisitor(final MessageVisitor visitor) {
+        this.visitor = visitor;
+    }
+
+    public void messageReceived(final IoSession session, final Object message) throws Exception
{
+        assert session != null;
+        assert message != null;
+
+        super.messageReceived(session, message);
+
+        Message msg = (Message)message;
+
+        msg.setAttachment(session);
+
+        msg.setAttachment(session);
+
+        if (visitor != null) {
+            msg.process(visitor);
+        }
+    }
 }

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-server/src/main/java/org/apache/geronimo/gshell/remote/server/RshServerProtocolHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message