You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2007/09/22 14:42:28 UTC
svn commit: r578421 [2/3] - 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/codec/
gshell-remote-common/s...
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/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/rsh/EchoMessage.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.message.rsh;
+
+import org.apache.geronimo.gshell.remote.marshall.Marshaller;
+import org.apache.geronimo.gshell.remote.message.MessageSupport;
+import org.apache.geronimo.gshell.remote.message.MessageType;
+import org.apache.geronimo.gshell.remote.message.MessageVisitor;
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Echo text.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoMessage
+ extends MessageSupport
+{
+ private String text;
+
+ public EchoMessage(final String text) {
+ super(MessageType.ECHO);
+
+ this.text = text;
+ }
+
+ public EchoMessage() {
+ this(null);
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void readExternal(final ByteBuffer in) throws Exception {
+ assert in != null;
+
+ super.readExternal(in);
+
+ text = Marshaller.readString(in);
+ }
+
+ public void writeExternal(final ByteBuffer out) throws Exception {
+ assert out != null;
+
+ super.writeExternal(out);
+
+ Marshaller.writeString(out, text);
+ }
+
+ public void process(final MessageVisitor visitor) throws Exception {
+ assert visitor != null;
+
+ visitor.visitEcho(this);
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/EchoMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.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/rsh/ExecuteMessage.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,216 @@
+/*
+ * 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.message.rsh;
+
+import org.apache.geronimo.gshell.command.CommandExecutor;
+import org.apache.geronimo.gshell.remote.marshall.Marshaller;
+import org.apache.geronimo.gshell.remote.message.MessageSupport;
+import org.apache.geronimo.gshell.remote.message.MessageType;
+import org.apache.geronimo.gshell.remote.message.MessageVisitor;
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Execute a command. This supports all flavors of the {@link CommandExecutor} execution methods.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExecuteMessage
+ extends MessageSupport
+{
+ private Flavor flavor;
+
+ private String path;
+
+ private Object[] args;
+
+ private ExecuteMessage(final Flavor flavor, final String path, final Object[] args) {
+ super(MessageType.EXECUTE);
+
+ this.flavor = flavor;
+ this.path = path;
+ this.args = args;
+ }
+
+ public ExecuteMessage(final String commandLine) {
+ this(Flavor.STRING, null, new Object[] { commandLine });
+ }
+
+ public ExecuteMessage(final Object[] args) {
+ this(Flavor.OBJECTS, null, args);
+ }
+
+ public ExecuteMessage(final String path, final Object[] args) {
+ this(Flavor.STRING_OBJECTS, path, args);
+ }
+
+ public ExecuteMessage() {
+ this(null, null, null);
+ }
+
+ public Object execute(final CommandExecutor executor) throws Exception {
+ assert executor != null;
+
+ return flavor.execute(this, executor);
+ }
+
+ public void readExternal(final ByteBuffer in) throws Exception {
+ assert in != null;
+
+ super.readExternal(in);
+
+ this.flavor = Marshaller.readEnum(in, Flavor.class);
+
+ this.path = Marshaller.readString(in);
+
+ this.args = (Object[]) Marshaller.readObject(in);
+ }
+
+ public void writeExternal(final ByteBuffer out) throws Exception {
+ assert out != null;
+
+ super.writeExternal(out);
+
+ Marshaller.writeEnum(out, flavor);
+
+ Marshaller.writeString(out, path);
+
+ Marshaller.writeObject(out, args);
+ }
+
+ public void process(final MessageVisitor visitor) throws Exception {
+ assert visitor != null;
+
+ visitor.visitExecute(this);
+ }
+
+ //
+ // Flavor
+ //
+
+ private static enum Flavor
+ {
+ STRING, // execute(String)
+ OBJECTS, // execute(Object[])
+ STRING_OBJECTS // execute(String, Object[])
+ ;
+
+ public Object execute(final ExecuteMessage msg, final CommandExecutor executor) throws Exception {
+ assert msg != null;
+ assert executor != null;
+
+ switch (this) {
+ case STRING:
+ return executor.execute((String)msg.args[0]);
+
+ case OBJECTS:
+ return executor.execute(msg.args);
+
+ case STRING_OBJECTS:
+ return executor.execute(msg.path, msg.args);
+ }
+
+ // This should never happen
+ throw new Error();
+ }
+ }
+
+ /**
+ * Container for the normal result of an execute command.
+ */
+ public static class Result
+ extends MessageSupport
+ {
+ private Object result;
+
+ protected Result(final MessageType type, final Object result) {
+ super(type);
+
+ this.result = result;
+ }
+
+ public Result(final Object result) {
+ this(MessageType.EXECUTE_RESULT, result);
+
+ this.result = result;
+ }
+
+ public Result() {
+ this(null, null);
+ }
+
+ public Object getResult() {
+ return result;
+ }
+
+ public void readExternal(final ByteBuffer in) throws Exception {
+ assert in != null;
+
+ super.readExternal(in);
+
+ result = Marshaller.readObject(in);
+ }
+
+ public void writeExternal(final ByteBuffer out) throws Exception {
+ assert out != null;
+
+ super.writeExternal(out);
+
+ Marshaller.writeObject(out, result);
+ }
+ }
+
+ /**
+ * Container for any exceptions thrown durring execution.
+ */
+ public static class Fault
+ extends Result
+ {
+ public Fault(final Throwable cause) {
+ super(MessageType.EXECUTE_FAULT, cause);
+ }
+
+ public Fault() {
+ this(null);
+ }
+
+ public Throwable getCause() {
+ return (Throwable) getResult();
+ }
+ }
+
+ /**
+ * Container for any notifications thrown durring execution.
+ */
+ public static class Notification
+ extends Result
+ {
+ public Notification(final org.apache.geronimo.gshell.common.Notification n) {
+ super(MessageType.EXECUTE_NOTIFICATION, n);
+ }
+
+ public Notification() {
+ this(null);
+ }
+
+ public org.apache.geronimo.gshell.common.Notification getNotification() {
+ return (org.apache.geronimo.gshell.common.Notification) getResult();
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/ExecuteMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/HandShakeMessage.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/rsh/HandShakeMessage.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/HandShakeMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/HandShakeMessage.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,106 @@
+/*
+ * 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.message.rsh;
+
+import java.security.PublicKey;
+
+import org.apache.geronimo.gshell.remote.marshall.Marshaller;
+import org.apache.geronimo.gshell.remote.message.CryptoAwareMessageSupport;
+import org.apache.geronimo.gshell.remote.message.MessageType;
+import org.apache.mina.common.ByteBuffer;
+
+//
+// NOTE: This message does not support MessageListener, actually should never make it to a message listener anyways
+// since this is consumed by the security filter.
+//
+
+/**
+ * Initial client handshake which contains the clients public key.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HandShakeMessage
+ extends CryptoAwareMessageSupport
+{
+ private PublicKey publicKey;
+
+ protected HandShakeMessage(final MessageType type, final PublicKey publicKey) {
+ super(type);
+
+ this.publicKey = publicKey;
+ }
+
+ public HandShakeMessage(final PublicKey publicKey) {
+ this(MessageType.HANDSHAKE, publicKey);
+ }
+
+ public HandShakeMessage() {
+ this(null);
+ }
+
+ public PublicKey getPublicKey() {
+ if (publicKey == null) {
+ throw new IllegalStateException("Missing public key");
+ }
+
+ return publicKey;
+ }
+
+ public void setPublicKey(final PublicKey publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ public void readExternal(final ByteBuffer in) throws Exception {
+ assert in != null;
+
+ super.readExternal(in);
+
+ byte[] bytes = Marshaller.readBytes(in);
+
+ if (bytes == null) {
+ throw new IllegalStateException();
+ }
+
+ publicKey = getCryptoContext().deserializePublicKey(bytes);
+ }
+
+ public void writeExternal(final ByteBuffer out) throws Exception {
+ assert out != null;
+
+ super.writeExternal(out);
+
+ Marshaller.writeBytes(out, getPublicKey().getEncoded());
+ }
+
+ /**
+ * Reply from server to client which contains the server's public key.
+ */
+ public static class Result
+ extends HandShakeMessage
+ {
+ public Result(final PublicKey publicKey) {
+ super(MessageType.HANDSHAKE_RESULT, publicKey);
+ }
+
+ public Result() {
+ this(null);
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/HandShakeMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/HandShakeMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/HandShakeMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.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/rsh/LoginMessage.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.message.rsh;
+
+import java.security.PublicKey;
+
+import org.apache.geronimo.gshell.remote.message.CryptoAwareMessageSupport;
+import org.apache.geronimo.gshell.remote.message.MessageSupport;
+import org.apache.geronimo.gshell.remote.message.MessageType;
+import org.apache.mina.common.ByteBuffer;
+
+//
+// NOTE: This message does not support MessageListener, actually should never make it to a message listener anyways
+// since this is consumed by the security filter.
+//
+
+/**
+ * Clients request to login to the server.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoginMessage
+ extends CryptoAwareMessageSupport
+{
+ private transient PublicKey serverKey;
+
+ private String username;
+
+ //
+ // NOTE: Marked as transiet to prevent the ToStringBuilder from displaying its value.
+ //
+
+ private transient String password;
+
+ public LoginMessage(final PublicKey serverKey, final String username, final String password) {
+ super(MessageType.LOGIN);
+
+ this.serverKey = serverKey;
+
+ this.username = username;
+
+ this.password = password;
+ }
+
+ public LoginMessage() {
+ this(null, null, null);
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void readExternal(final ByteBuffer in) throws Exception {
+ assert in != null;
+
+ super.readExternal(in);
+
+ username = decryptString(in);
+
+ password = decryptString(in);
+ }
+
+ public void writeExternal(final ByteBuffer out) throws Exception {
+ assert out != null;
+
+ super.writeExternal(out);
+
+ encryptString(out, serverKey, username);
+
+ encryptString(out, serverKey, password);
+ }
+
+ /**
+ * Server to client message to indicate successfull login.
+ */
+ public static class Result
+ extends MessageSupport
+ {
+ public Result() {
+ super(MessageType.LOGIN_RESULT);
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/LoginMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.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/rsh/OpenShellMessage.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,43 @@
+/*
+ * 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.message.rsh;
+
+import org.apache.geronimo.gshell.remote.message.MessageSupport;
+import org.apache.geronimo.gshell.remote.message.MessageType;
+import org.apache.geronimo.gshell.remote.message.MessageVisitor;
+
+/**
+ * Open a remote shell instance.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OpenShellMessage
+ extends MessageSupport
+{
+ public OpenShellMessage() {
+ super(MessageType.OPEN_SHELL);
+ }
+
+ public void process(final MessageVisitor visitor) throws Exception {
+ assert visitor != null;
+
+ visitor.visitOpenShell(this);
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/OpenShellMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/package-info.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/rsh/package-info.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/package-info.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/**
+ * Messages for the remote shell (rsh) protocol.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.remote.message.rsh;
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/rsh/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/DuplicateRequestException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/DuplicateRequestException.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/DuplicateRequestException.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/DuplicateRequestException.java Sat Sep 22 05:42:24 2007
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.remote.request;
+import org.apache.geronimo.gshell.remote.message.Message;
+
/**
* Thrown to indicate an operation was attempted for a duplicate request.
*
@@ -27,7 +29,7 @@
public class DuplicateRequestException
extends RequestException
{
- public DuplicateRequestException(final Request req) {
- super("Duplicate request: " + req.getId());
+ public DuplicateRequestException(final Message.ID id) {
+ super("Duplicate request: " + id);
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/InvalidRequestMappingException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/InvalidRequestMappingException.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/InvalidRequestMappingException.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/InvalidRequestMappingException.java Sat Sep 22 05:42:24 2007
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.remote.request;
+import org.apache.geronimo.gshell.remote.message.Message;
+
/**
* Thrown to indicate that an operation was attempted for an invalid request mapping.
*
@@ -27,7 +29,7 @@
public class InvalidRequestMappingException
extends RequestException
{
- public InvalidRequestMappingException(final Object id) {
+ public InvalidRequestMappingException(final Message.ID id) {
super("Invalid request mapping: " + id);
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/MissingRequestTimeoutException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/MissingRequestTimeoutException.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/MissingRequestTimeoutException.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/MissingRequestTimeoutException.java Sat Sep 22 05:42:24 2007
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.remote.request;
+import org.apache.geronimo.gshell.remote.message.Message;
+
/**
* Thrown to indicate that a timeout operation was attempted for a request with no timeout scheduled.
*
@@ -27,7 +29,7 @@
public class MissingRequestTimeoutException
extends RequestException
{
- public MissingRequestTimeoutException(final Object id) {
+ public MissingRequestTimeoutException(final Message.ID id) {
super("Missing request timeout: " + id);
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Request.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Request.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Request.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Request.java Sat Sep 22 05:42:24 2007
@@ -154,7 +154,7 @@
return null;
}
else if (obj == RequestTimeoutException.class) {
- throw new RequestTimeoutException(this);
+ throw new RequestTimeoutException(getId());
}
// This should never happen
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.request;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.geronimo.gshell.remote.crypto.CryptoContext;
+import org.apache.geronimo.gshell.remote.message.Message;
+import org.apache.geronimo.gshell.remote.message.MessageEncoder;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import org.apache.mina.filter.codec.demux.MessageEncoderFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class RequestEncoder
+ extends MessageEncoder
+{
+ @SuppressWarnings({"FieldCanBeLocal"})
+ private static final Set<Class<?>> MESSAGE_TYPES;
+
+ static {
+ Set<Class<?>> types = new HashSet<Class<?>>();
+
+ types.add(Request.class);
+
+ MESSAGE_TYPES = Collections.unmodifiableSet(types);
+ }
+
+ public RequestEncoder(final CryptoContext crypto) {
+ super(crypto);
+ }
+
+ public Set<Class<?>> getMessageTypes() {
+ return MESSAGE_TYPES;
+ }
+
+ public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception {
+ Request request = (Request) message;
+
+ Message msg = request.getMessage();
+
+ super.encode(session, msg, out);
+ }
+
+ //
+ // Factory
+ //
+
+ public static class Factory
+ extends FactorySupport
+ implements MessageEncoderFactory
+ {
+ public Factory(final CryptoContext crypto) {
+ super(crypto);
+ }
+
+ public MessageEncoder getEncoder() throws Exception {
+ return new RequestEncoder(crypto);
+ }
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestEncoder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestManager.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestManager.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestManager.java Sat Sep 22 05:42:24 2007
@@ -27,7 +27,7 @@
import java.util.concurrent.ScheduledFuture;
import org.apache.geronimo.gshell.remote.message.Message;
-import org.apache.geronimo.gshell.remote.util.SessionAttributeBinder;
+import org.apache.geronimo.gshell.remote.session.SessionAttributeBinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,12 +67,12 @@
public void add(final Request request) {
assert request != null;
+ Message.ID id = request.getId();
+
if (contains(request)) {
- throw new DuplicateRequestException(request);
+ throw new DuplicateRequestException(id);
}
- Message.ID id = request.getId();
-
if (log.isTraceEnabled()) {
log.trace("Adding: {}", request);
}
@@ -124,11 +124,11 @@
public void schedule(final Request request) {
assert request != null;
+ Message.ID id = request.getId();
+
if (timeouts.containsKey(request)) {
- throw new DuplicateRequestException(request);
+ throw new DuplicateRequestException(id);
}
-
- Message.ID id = request.getId();
if (request != get(id)) {
throw new InvalidRequestMappingException(id);
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestTimeoutException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestTimeoutException.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestTimeoutException.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/RequestTimeoutException.java Sat Sep 22 05:42:24 2007
@@ -19,6 +19,8 @@
package org.apache.geronimo.gshell.remote.request;
+import org.apache.geronimo.gshell.remote.message.Message;
+
/**
* Thrown to indicate that a request has been timed out.
*
@@ -29,15 +31,15 @@
{
private static final long serialVersionUID = 1;
- private final Object id;
+ private final Message.ID id;
- public RequestTimeoutException(final Request request) {
- super("Request timed out: " + request.getId());
+ public RequestTimeoutException(final Message.ID id) {
+ super("Request timed out: " + id);
- this.id = request.getId();
+ this.id = id;
}
- public Object getId() {
+ public Message.ID getId() {
return id;
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Response.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Response.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Response.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/request/Response.java Sat Sep 22 05:42:24 2007
@@ -82,6 +82,10 @@
return message;
}
+ public Message.ID getId() {
+ return getMessage().getId();
+ }
+
//
// Response Type
//
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/security/SecurityFilter.java Sat Sep 22 05:42:24 2007
@@ -23,12 +23,14 @@
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.apache.geronimo.gshell.remote.crypto.CryptoContext;
-import org.apache.geronimo.gshell.remote.message.HandShakeMessage;
-import org.apache.geronimo.gshell.remote.message.LoginMessage;
import org.apache.geronimo.gshell.remote.message.Message;
+import org.apache.geronimo.gshell.remote.message.rsh.HandShakeMessage;
+import org.apache.geronimo.gshell.remote.message.rsh.LoginMessage;
+import org.apache.geronimo.gshell.remote.util.NamedThreadFactory;
import org.apache.mina.common.IoFilterAdapter;
import org.apache.mina.common.IoSession;
import org.codehaus.plexus.component.annotations.Component;
@@ -64,11 +66,9 @@
private final UUID securityToken;
public SecurityFilter() throws Exception {
- //
- // TODO: Would be nice to use the schedular from the transport and not create another one... ?? or not...
- //
+ ThreadFactory tf = new NamedThreadFactory(SecurityFilter.class);
- scheduler = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors());
+ scheduler = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), tf);
//
// TODO: Create a token based on our public key er something, so we can better use it to determine session validitaty.
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,99 @@
+/*
+ * 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.session;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.ThreadModel;
+import org.apache.mina.filter.executor.ExecutorFilter;
+import org.apache.geronimo.gshell.remote.util.NamedThreadFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExecutorThreadModel
+ implements ThreadModel
+{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final String name;
+
+ private final ThreadGroup group;
+
+ private final AtomicLong counter = new AtomicLong(0);
+
+ private final ExecutorService executor;
+
+ private final ExecutorFilter filter;
+
+ public ExecutorThreadModel(final String name) {
+ assert name != null;
+
+ this.name = name;
+
+ this.group = new ThreadGroup(name);
+
+ ThreadFactory tf = new NamedThreadFactory(name, group);
+
+ //
+ // TODO: See which is better SynchronousQueue<Runnable> or LinkedBlockingQueue<Runnable>
+ //
+
+ this.executor = new ThreadPoolExecutor(
+ 1,
+ Integer.MAX_VALUE,
+ 60L,
+ TimeUnit.SECONDS,
+ new LinkedBlockingQueue<Runnable>(),
+ tf,
+ new ThreadPoolExecutor.AbortPolicy());
+
+ this.filter = new ExecutorFilter(executor);
+ }
+
+ public void close() {
+ List<Runnable> pending = executor.shutdownNow();
+
+ if (!pending.isEmpty()) {
+ log.warn("There were {} pending tasks which have not been run", pending.size());
+ }
+ }
+
+ //
+ // ThreadModel
+ //
+
+ public void buildFilterChain(final IoFilterChain chain) throws Exception {
+ assert chain != null;
+
+ chain.addFirst(getClass().getSimpleName(), filter);
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/ExecutorThreadModel.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/SessionAttributeBinder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/SessionAttributeBinder.java?rev=578421&r1=578362&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/SessionAttributeBinder.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/SessionAttributeBinder.java Sat Sep 22 05:42:24 2007
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.util;
+package org.apache.geronimo.gshell.remote.session;
import org.apache.mina.common.IoSession;
@@ -60,7 +60,7 @@
public void bind(final IoSession session, final T obj) {
assert session != null;
assert obj != null;
-
+
Object prev = session.getAttribute(key);
if (prev != null) {
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/package-info.java?rev=578421&r1=578362&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/package-info.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/session/package-info.java Sat Sep 22 05:42:24 2007
@@ -18,8 +18,8 @@
*/
/**
- * Utility classses supporing remote shell muck.
+ * Session support.
*
* @version $Rev$ $Date$
*/
-package org.apache.geronimo.gshell.remote.util;
\ No newline at end of file
+package org.apache.geronimo.gshell.remote.session;
\ No newline at end of file
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java Sat Sep 22 05:42:24 2007
@@ -29,7 +29,7 @@
import org.apache.geronimo.gshell.common.NestedIOException;
import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
-import org.apache.geronimo.gshell.remote.util.SessionAttributeBinder;
+import org.apache.geronimo.gshell.remote.session.SessionAttributeBinder;
import org.apache.mina.common.ByteBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java Sat Sep 22 05:42:24 2007
@@ -29,7 +29,7 @@
import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
import org.apache.geronimo.gshell.remote.message.Message;
-import org.apache.geronimo.gshell.remote.util.SessionAttributeBinder;
+import org.apache.geronimo.gshell.remote.session.SessionAttributeBinder;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.WriteFuture;
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/WriteStreamMessage.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/WriteStreamMessage.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/WriteStreamMessage.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/WriteStreamMessage.java Sat Sep 22 05:42:24 2007
@@ -19,7 +19,7 @@
package org.apache.geronimo.gshell.remote.stream;
-import org.apache.geronimo.gshell.remote.codec.MarshallingUtil;
+import org.apache.geronimo.gshell.remote.marshall.Marshaller;
import org.apache.geronimo.gshell.remote.message.MessageSupport;
import org.apache.geronimo.gshell.remote.message.MessageType;
import org.apache.mina.common.ByteBuffer;
@@ -64,7 +64,7 @@
super.readExternal(in);
- buffer = MarshallingUtil.readBuffer(in);
+ buffer = Marshaller.readBuffer(in);
}
public void writeExternal(final ByteBuffer out) throws Exception {
@@ -72,6 +72,6 @@
super.writeExternal(out);
- MarshallingUtil.writeBuffer(out, buffer);
+ Marshaller.writeBuffer(out, buffer);
}
}
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java (from r578362, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectionException.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectionException.java&r1=578362&r2=578421&rev=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectionException.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java Sat Sep 22 05:42:24 2007
@@ -20,28 +20,28 @@
package org.apache.geronimo.gshell.remote.transport;
/**
- * ???
+ * Thrown to indicate a connection related failure has occured.
*
* @version $Rev$ $Date$
*/
-public class ConnectionException
+public class ConnectException
extends TransportException
{
private static final long serialVersionUID = 1;
- public ConnectionException(final String msg, final Throwable cause) {
+ public ConnectException(final String msg, final Throwable cause) {
super(msg, cause);
}
- public ConnectionException(final String msg) {
+ public ConnectException(final String msg) {
super(msg);
}
- public ConnectionException(final Throwable cause) {
+ public ConnectException(final Throwable cause) {
super(cause);
}
- public ConnectionException() {
+ public ConnectException() {
super();
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/ConnectException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/Transport.java Sat Sep 22 05:42:24 2007
@@ -38,6 +38,10 @@
URI getLocalLocation();
+ void connect() throws Exception;
+
+ void close();
+
WriteFuture send(Object msg) throws Exception;
Message request(Message msg, long timeout, TimeUnit unit) throws Exception;
@@ -47,6 +51,4 @@
InputStream getInputStream();
OutputStream getOutputStream();
-
- void close();
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportException.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportException.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportException.java Sat Sep 22 05:42:24 2007
@@ -20,7 +20,7 @@
package org.apache.geronimo.gshell.remote.transport;
/**
- * ???
+ * Thrown to indicate a transport failure has occured.
*
* @version $Rev$ $Date$
*/
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.transport;
+
+import org.apache.mina.common.ExceptionMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportExceptionMonitor
+ extends ExceptionMonitor
+{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ public void exceptionCaught(final Throwable cause) {
+ assert cause != null;
+
+ log.error("Unhandled exception: " + cause, cause);
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportExceptionMonitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportFactoryLocator.java Sat Sep 22 05:42:24 2007
@@ -41,6 +41,7 @@
assert location != null;
String scheme = location.getScheme();
+
if (scheme == null) {
throw new MissingSchemeException(location);
}
Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java?rev=578421&r1=578420&r2=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportServer.java Sat Sep 22 05:42:24 2007
@@ -30,5 +30,7 @@
{
URI getLocation();
+ void bind() throws Exception;
+
void close();
}
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java (from r578377, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.java&r1=578377&r2=578421&rev=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/TransportCommon.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java Sat Sep 22 05:42:24 2007
@@ -17,18 +17,22 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.transport;
+package org.apache.geronimo.gshell.remote.transport.base;
import java.net.SocketAddress;
import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.common.tostring.ToStringStyle;
-import org.apache.geronimo.gshell.remote.codec.MessageCodecFactory;
+import org.apache.geronimo.gshell.remote.message.MessageCodecFactory;
+import org.apache.geronimo.gshell.remote.message.MessageHandler;
import org.apache.geronimo.gshell.remote.message.MessageVisitor;
import org.apache.geronimo.gshell.remote.request.RequestResponseFilter;
import org.apache.geronimo.gshell.remote.stream.SessionStreamFilter;
+import org.apache.geronimo.gshell.remote.transport.Transport;
+import org.apache.geronimo.gshell.remote.transport.TransportExceptionMonitor;
+import org.apache.geronimo.gshell.remote.transport.TransportServer;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.ExceptionMonitor;
import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoService;
@@ -38,8 +42,6 @@
import org.apache.mina.common.SimpleByteBufferAllocator;
import org.apache.mina.filter.LoggingFilter;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.management.IoSessionStat;
-import org.apache.mina.management.StatCollector;
import org.codehaus.plexus.PlexusContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,30 +51,52 @@
*
* @version $Rev$ $Date$
*/
-public abstract class TransportCommon
+public abstract class BaseCommon
{
+ static {
+ // Setup our exception monitor
+ ExceptionMonitor.setInstance(new TransportExceptionMonitor());
+
+ // Make sure that we use non-pooled fast buffers
+ ByteBuffer.setUseDirectBuffers(false);
+ ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
+ }
+
protected final Logger log = LoggerFactory.getLogger(getClass());
- // private StatCollector statCollector;
+ private IoHandler handler;
private IoService service;
- protected TransportCommon() {
- ByteBuffer.setUseDirectBuffers(false);
- ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
- }
+ // private StatCollector statCollector;
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
+ protected IoHandler getHandler() {
+ if (handler == null) {
+ throw new IllegalStateException("Handler not bound");
+ }
+
+ return handler;
+ }
+
+ public IoService getService() {
+ return service;
+ }
+
+ //
+ // Configuration
+ //
+
protected void configure(final IoService service) throws Exception {
assert service != null;
this.service = service;
service.addListener(new IoServiceListener() {
- public void serviceActivated(IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config) {
+ public void serviceActivated(final IoService service, final SocketAddress serviceAddress, final IoHandler handler, final IoServiceConfig config) {
log.info("Service activated: {}", service);
// log.info("Service activated: {}, {}, {}, {}", service, serviceAddress, handler, config);
@@ -80,60 +104,53 @@
logFilters(service);
}
- public void serviceDeactivated(IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config) {
+ public void serviceDeactivated(final IoService service, final SocketAddress serviceAddress, final IoHandler handler, final IoServiceConfig config) {
log.info("Service deactivated: {}", service);
// log.info("Service deactivated: {}, {}, {}, {}", service, serviceAddress, handler, config);
}
- public void sessionCreated(IoSession session) {
+ public void sessionCreated(final IoSession session) {
log.info("Session created: {}", session);
logFilters(session);
}
- public void sessionDestroyed(IoSession session) {
+ public void sessionDestroyed(final IoSession session) {
log.info("Session destroyed: {}", session);
}
});
- ProtocolHandler handler = getProtocolHandler();
-
- MessageVisitor visitor = getMessageVisitor();
-
- handler.setVisitor(visitor);
+ // Setup the io handler
+ handler = new MessageHandler(getMessageVisitor());
// Install the default set of filters
-
- DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
+ configure(service.getFilterChain());
//
- // NOTE: We don't need an executor filter here, since the ThreadModel does that for us
+ // TODO: Start up a scheduled task to periodically log stats
//
-
- // filterChain.addLast(ExecutorFilter.class.getSimpleName(), new ExecutorFilter(executor));
- // filterChain.addLast(ProfilerTimerFilter.class.getSimpleName(), new ProfilerTimerFilter());
+ // Setup stat collection
+ // statCollector = new StatCollector(service);
+ // statCollector.start();
+ }
- filterChain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(getMessageCodecFactory()));
+ protected void configure(final DefaultIoFilterChainBuilder chain) throws Exception {
+ assert chain != null;
- filterChain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
+ // We don't need an executor filter here (in Mina 1.1.x), since the ThreadModel does that for us
+ // chain.addLast(ExecutorFilter.class.getSimpleName(), new ExecutorFilter(executor));
- filterChain.addLast(SessionStreamFilter.class.getSimpleName(), new SessionStreamFilter());
+ // chain.addLast(ProfilerTimerFilter.class.getSimpleName(), new ProfilerTimerFilter());
- filterChain.addLast(RequestResponseFilter.class.getSimpleName(), new RequestResponseFilter());
+ chain.addLast(ProtocolCodecFilter.class.getSimpleName(), new ProtocolCodecFilter(getMessageCodecFactory()));
- //
- // TODO: Start up a scheduled task to periodically log stats
- //
+ chain.addLast(LoggingFilter.class.getSimpleName(), new LoggingFilter());
- // Setup stat collection
- // statCollector = new StatCollector(service);
- // statCollector.start();
- }
+ chain.addLast(SessionStreamFilter.class.getSimpleName(), new SessionStreamFilter());
- public IoService getService() {
- return service;
+ chain.addLast(RequestResponseFilter.class.getSimpleName(), new RequestResponseFilter());
}
public void close() {
@@ -144,27 +161,28 @@
// Logging Helpers
//
- protected void logFilters(IoService service) {
- DefaultIoFilterChainBuilder filterChain = service.getFilterChain();
+ protected void logFilters(final IoService service) {
+ assert service != null;
log.debug("Service filters:");
- for (IoFilterChain.Entry entry : filterChain.getAll()) {
+ for (IoFilterChain.Entry entry : service.getFilterChain().getAll()) {
log.debug(" {}", entry);
}
}
- protected void logFilters(IoSession session) {
- IoFilterChain filterChain = session.getFilterChain();
-
+ protected void logFilters(final IoSession session) {
+ assert session != null;
+
log.debug("Session filters:");
- for (IoFilterChain.Entry entry : filterChain.getAll()) {
+ for (IoFilterChain.Entry entry : session.getFilterChain().getAll()) {
log.debug(" {}", entry);
}
}
- protected void logStats(final IoSession session) throws Exception {
+ /*
+ protected void logStats(final IoSession session) {
assert session != null;
IoSessionStat stat = (IoSessionStat) session.getAttribute(StatCollector.KEY);
@@ -173,23 +191,18 @@
log.debug("Stats: {}", ReflectionToStringBuilder.toString(stat, ToStringStyle.SHORT_PREFIX_STYLE));
}
}
-
+ */
+
//
- // AutoWire Support
+ // AutoWire Support, Setters exposed to support Plexus autowire() Getters exposed to handle state checking.
//
private PlexusContainer container;
private MessageVisitor messageVisitor;
- private ProtocolHandler protocolHandler;
-
private MessageCodecFactory codecFactory;
- //
- // NOTE: Setters exposed to support Plexus autowire() Getters exposed to handle state checking.
- //
-
public void setMessageVisitor(final MessageVisitor messageVisitor) {
assert messageVisitor != null;
@@ -204,22 +217,6 @@
}
return messageVisitor;
- }
-
- public void setProtocolHandler(final ProtocolHandler protocolHandler) {
- assert protocolHandler != null;
-
- log.trace("Using protocol handler: {}", protocolHandler);
-
- this.protocolHandler = protocolHandler;
- }
-
- protected ProtocolHandler getProtocolHandler() {
- if (protocolHandler == null) {
- throw new IllegalStateException("Protocol handler not bound");
- }
-
- return protocolHandler;
}
public void setMessageCodecFactory(final MessageCodecFactory codecFactory) {
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseCommon.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java (from r578362, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java&r1=578362&r2=578421&rev=578421&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/tcp/TcpTransport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java Sat Sep 22 05:42:24 2007
@@ -17,41 +17,39 @@
* under the License.
*/
-package org.apache.geronimo.gshell.remote.transport.tcp;
+package org.apache.geronimo.gshell.remote.transport.base;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.URI;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.geronimo.gshell.remote.message.Message;
import org.apache.geronimo.gshell.remote.message.MessageVisitor;
import org.apache.geronimo.gshell.remote.request.Requestor;
+import org.apache.geronimo.gshell.remote.session.ExecutorThreadModel;
import org.apache.geronimo.gshell.remote.stream.SessionInputStream;
import org.apache.geronimo.gshell.remote.stream.SessionOutputStream;
import org.apache.geronimo.gshell.remote.transport.Transport;
-import org.apache.geronimo.gshell.remote.transport.TransportCommon;
import org.apache.mina.common.CloseFuture;
import org.apache.mina.common.ConnectFuture;
import org.apache.mina.common.IoConnector;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.WriteFuture;
-import org.apache.mina.transport.socket.nio.SocketConnector;
-import org.apache.mina.transport.socket.nio.SocketConnectorConfig;
/**
- * Provides TCP client-side support.
+ * Support for {@link Transport} implementations.
*
* @version $Rev$ $Date$
*/
-public class TcpTransport
- extends TransportCommon
+public abstract class BaseTransport
+ extends BaseCommon
implements Transport
{
+ private static final AtomicLong COUNTER = new AtomicLong(0);
+
protected final URI remoteLocation;
protected final SocketAddress remoteAddress;
@@ -62,11 +60,13 @@
protected IoConnector connector;
+ protected ExecutorThreadModel threadModel;
+
protected IoSession session;
protected boolean connected;
- protected TcpTransport(final URI remoteLocation, final SocketAddress remoteAddress, final URI localLocation, final SocketAddress localAddress) throws Exception {
+ protected BaseTransport(final URI remoteLocation, final SocketAddress remoteAddress, final URI localLocation, final SocketAddress localAddress) throws Exception {
assert remoteLocation != null;
assert remoteAddress != null;
@@ -77,37 +77,15 @@
this.localAddress = localAddress;
}
- public TcpTransport(final URI remote, final URI local) throws Exception {
- assert remote != null;
- // local may be null
-
- this.remoteLocation = remote;
- this.remoteAddress = new InetSocketAddress(InetAddress.getByName(remote.getHost()), remote.getPort());
-
- if (local != null) {
- this.localLocation = local;
- this.localAddress = new InetSocketAddress(InetAddress.getByName(local.getHost()), local.getPort());
- }
- else {
- // These are final, so make sure to mark them null if we have no local address
- this.localLocation = null;
- this.localAddress = null;
- }
- }
-
- protected IoConnector createConnector() throws Exception {
- SocketConnector connector = new SocketConnector(Runtime.getRuntime().availableProcessors() + 1, Executors.newCachedThreadPool());
-
- SocketConnectorConfig config = connector.getDefaultConfig();
-
- config.getSessionConfig().setKeepAlive(true);
-
- return connector;
- }
+ protected abstract IoConnector createConnector() throws Exception;
protected synchronized void init() throws Exception {
connector = createConnector();
+ // Install the thread model
+ threadModel = new ExecutorThreadModel(getClass().getSimpleName() + "-" + COUNTER.getAndIncrement());
+ connector.getDefaultConfig().setThreadModel(threadModel);
+
//
// HACK: Need to manually wire in the visitor impl for now... :-(
//
@@ -121,19 +99,19 @@
if (connected) {
throw new IllegalStateException("Already connected");
}
-
+
init();
log.info("Connecting to: {}", remoteAddress);
- ConnectFuture cf = connector.connect(remoteAddress, localAddress, getProtocolHandler());
+ ConnectFuture cf = connector.connect(remoteAddress, localAddress, getHandler());
cf.join();
session = cf.getSession();
connected = true;
-
+
log.info("Connected");
}
@@ -142,6 +120,8 @@
CloseFuture cf = session.close();
cf.join();
+
+ threadModel.close();
}
finally {
super.close();
@@ -169,7 +149,7 @@
return requestor.request(msg);
}
-
+
public Message request(final Message msg, final long timeout, final TimeUnit unit) throws Exception {
assert msg != null;
@@ -177,7 +157,7 @@
return requestor.request(msg, timeout, unit);
}
-
+
public InputStream getInputStream() {
return SessionInputStream.BINDER.lookup(session);
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransport.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java?rev=578421&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java Sat Sep 22 05:42:24 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.transport.base;
+
+import java.net.URI;
+
+import org.apache.geronimo.gshell.remote.transport.Transport;
+import org.apache.geronimo.gshell.remote.transport.TransportFactory;
+import org.apache.geronimo.gshell.remote.transport.TransportServer;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+/**
+ * Support for {@link TransportFactory} implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseTransportFactory
+ implements TransportFactory
+{
+ @Requirement
+ protected PlexusContainer container;
+
+ //
+ // NOTE: We use autowire() here to get a few components injected. These are injected via setters.
+ //
+
+ public Transport connect(final URI remote, final URI local) throws Exception {
+ assert remote != null;
+ // local can be null
+
+ Transport transport = createTransport(remote, local);
+
+ container.autowire(transport);
+
+ transport.connect();
+
+ return transport;
+ }
+
+ protected abstract Transport createTransport(final URI remote, final URI local) throws Exception;
+
+ public Transport connect(final URI remote) throws Exception {
+ return connect(remote, null);
+ }
+
+ public TransportServer bind(final URI location) throws Exception {
+ assert location != null;
+
+ TransportServer server = createTransportServer(location);
+
+ container.autowire(server);
+
+ server.bind();
+
+ return server;
+ }
+
+ protected abstract TransportServer createTransportServer(final URI location) throws Exception;
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/transport/base/BaseTransportFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain