JBoss Remoting SVN: r4620 - remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-23 11:50:43 -0400 (Thu, 23 Oct 2008)
New Revision: 4620
Modified:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java
Log:
Fix a bug found in the map impl
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java 2008-10-23 02:06:03 UTC (rev 4619)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java 2008-10-23 15:50:43 UTC (rev 4620)
@@ -109,7 +109,6 @@
values[idx] = value;
return;
}
- hc++;
}
}
16 years, 2 months
JBoss Remoting SVN: r4619 - remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 22:06:03 -0400 (Wed, 22 Oct 2008)
New Revision: 4619
Modified:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java
Log:
fix incomplete javadoc commit
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java 2008-10-23 02:04:40 UTC (rev 4618)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java 2008-10-23 02:06:03 UTC (rev 4619)
@@ -99,21 +99,37 @@
}
/**
- * Get the executor to use to execute
- * @return
+ * Get the executor to use to execute handlers.
+ *
+ * @return the executor
*/
public Executor getExecutor() {
return executor;
}
+ /**
+ * Set the executor to use to execute handlers.
+ *
+ * @param executor the executor
+ */
public void setExecutor(final Executor executor) {
this.executor = executor;
}
+ /**
+ * Get the buffer allocator to use for outbound messages on this connection.
+ *
+ * @return the allocator
+ */
public BufferAllocator<ByteBuffer> getAllocator() {
return allocator;
}
+ /**
+ * Set the buffer allocator to use for outbound messages on this connection.
+ *
+ * @param allocator the allocator
+ */
public void setAllocator(final BufferAllocator<ByteBuffer> allocator) {
this.allocator = allocator;
}
16 years, 2 months
JBoss Remoting SVN: r4618 - remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 22:04:40 -0400 (Wed, 22 Oct 2008)
New Revision: 4618
Removed:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/AbstractConnection.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConfigValue.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConnectionListener.java
Modified:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MessageType.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/SimpleWriteHandler.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/WriteHandler.java
Log:
javadoc & cleanup
Deleted: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/AbstractConnection.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/AbstractConnection.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/AbstractConnection.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.protocol.multiplex;
-
-import org.jboss.remoting.spi.AbstractSimpleCloseable;
-import java.util.concurrent.Executor;
-
-/**
- *
- */
-public abstract class AbstractConnection extends AbstractSimpleCloseable {
- /**
- * Basic constructor.
- *
- * @param executor the executor used to execute the close notification handlers
- */
- protected AbstractConnection(final Executor executor) {
- super(executor);
- }
-
- public String toString() {
- return "connection <" + Integer.toString(hashCode()) + ">";
- }
-}
Deleted: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConfigValue.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConfigValue.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConfigValue.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.protocol.multiplex;
-
-/**
- *
- */
-public enum ConfigValue {
-
- /**
- * The protocol version to use. Value type is {@code int}.
- */
- PROTOCOL_VERSION(0),
- /**
- * The name of the marshaller to use. Value type is {@code String}.
- */
- MARSHALLER_NAME(1),
- ;
- private final int id;
-
- private ConfigValue(final int id) {
- this.id = id;
- }
-
- /**
- * Get the integer ID for this config value.
- *
- * @return the integer ID
- */
- public int getId() {
- return id;
- }
-
- /**
- * Get the config value for an integer ID.
- *
- * @param id the integer ID
- * @return the config value instance
- */
- public static ConfigValue getConfigValue(final int id) {
- switch (id) {
- case 0: return PROTOCOL_VERSION;
- case 1: return MARSHALLER_NAME;
- default: throw new IllegalArgumentException("Invalid config value ID");
- }
- }
-}
Deleted: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConnectionListener.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConnectionListener.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/ConnectionListener.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.protocol.multiplex;
-
-import org.jboss.remoting.SimpleCloseable;
-
-/**
- *
- */
-public interface ConnectionListener {
- void handleOpened(SimpleCloseable connection);
-}
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/IdentityIntMap.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -27,7 +27,7 @@
/**
*
*/
-public final class IdentityIntMap<T> {
+final class IdentityIntMap<T> {
private int[] values;
private Object[] keys;
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MessageType.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MessageType.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MessageType.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -25,7 +25,7 @@
/**
* The type of a protocol message.
*/
-public enum MessageType {
+enum MessageType {
// One-way request, no return value may be sent
// Two-way request, return value is expected
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -29,7 +29,7 @@
import org.jboss.marshalling.Configuration;
/**
- *
+ * A configuration object for the multiplex protocol.
*/
public final class MultiplexConfiguration {
private MarshallerFactory marshallerFactory;
@@ -38,33 +38,70 @@
private Executor executor;
private BufferAllocator<ByteBuffer> allocator;
+ /**
+ * Construct a new instance.
+ */
public MultiplexConfiguration() {
}
+ /**
+ * Get the marshaller factory to use for messages transmitted and received by this multiplex connection.
+ *
+ * @return the marshaller factory
+ */
public MarshallerFactory getMarshallerFactory() {
return marshallerFactory;
}
+ /**
+ * Set the marshaller factory to use for messages transmitted and received by this multiplex connection.
+ *
+ * @param marshallerFactory the marshaller factory
+ */
public void setMarshallerFactory(final MarshallerFactory marshallerFactory) {
this.marshallerFactory = marshallerFactory;
}
+ /**
+ * Get the marshaller configuration to pass into the marshaller factory.
+ *
+ * @return the configuration
+ */
public Configuration getMarshallingConfiguration() {
return marshallingConfiguration;
}
+ /**
+ * Set the marshaller configuration to pass into the marshaller factory.
+ *
+ * @param marshallingConfiguration the configuration
+ */
public void setMarshallingConfiguration(final Configuration marshallingConfiguration) {
this.marshallingConfiguration = marshallingConfiguration;
}
+ /**
+ * Get the link metric to assign to this multiplex connection.
+ *
+ * @return the link metric
+ */
public int getLinkMetric() {
return linkMetric;
}
+ /**
+ * Set the link metric to assign to this multiplex connection.
+ *
+ * @param linkMetric the link metric
+ */
public void setLinkMetric(final int linkMetric) {
this.linkMetric = linkMetric;
}
+ /**
+ * Get the executor to use to execute
+ * @return
+ */
public Executor getExecutor() {
return executor;
}
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -63,10 +63,8 @@
/**
* Protocol handler for the basic message-oriented Remoting protocol.
- *
- * @param <A> stream channel address type (Void if streams are not supported)
*/
-public final class MultiplexHandler implements IoHandler<AllocatedMessageChannel> {
+final class MultiplexHandler implements IoHandler<AllocatedMessageChannel> {
private static final Logger log = Logger.getLogger(MultiplexHandler.class);
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -27,6 +27,7 @@
import org.jboss.remoting.Endpoint;
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.spi.AbstractSimpleCloseable;
import org.jboss.xnio.IoHandlerFactory;
import org.jboss.xnio.ChannelSource;
import org.jboss.xnio.IoFuture;
@@ -34,6 +35,7 @@
import org.jboss.xnio.IoHandler;
import org.jboss.xnio.channels.AllocatedMessageChannel;
import java.io.IOException;
+import java.util.concurrent.Executor;
/**
*
@@ -75,4 +77,15 @@
}
};
}
+
+ private abstract static class AbstractConnection extends AbstractSimpleCloseable {
+
+ protected AbstractConnection(final Executor executor) {
+ super(executor);
+ }
+
+ public String toString() {
+ return "connection <" + Integer.toString(hashCode()) + ">";
+ }
+ }
}
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/SimpleWriteHandler.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/SimpleWriteHandler.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/SimpleWriteHandler.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -32,7 +32,7 @@
/**
*
*/
-public final class SimpleWriteHandler implements WriteHandler {
+final class SimpleWriteHandler implements WriteHandler {
private static final Logger log = Logger.getLogger(SimpleWriteHandler.class);
private final BufferAllocator<ByteBuffer> allocator;
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/WriteHandler.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/WriteHandler.java 2008-10-23 01:44:56 UTC (rev 4617)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/WriteHandler.java 2008-10-23 02:04:40 UTC (rev 4618)
@@ -27,6 +27,6 @@
/**
*
*/
-public interface WriteHandler {
+interface WriteHandler {
boolean handleWrite(WritableMessageChannel channel);
}
16 years, 2 months
JBoss Remoting SVN: r4617 - remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 21:44:56 -0400 (Wed, 22 Oct 2008)
New Revision: 4617
Added:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java
Removed:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java
Modified:
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java
Log:
Multiplex reorganization
Copied: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java (from rev 4614, remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java)
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java (rev 0)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConfiguration.java 2008-10-23 01:44:56 UTC (rev 4617)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.protocol.multiplex;
+
+import java.util.concurrent.Executor;
+import java.nio.ByteBuffer;
+import org.jboss.xnio.BufferAllocator;
+import org.jboss.marshalling.MarshallerFactory;
+import org.jboss.marshalling.Configuration;
+
+/**
+ *
+ */
+public final class MultiplexConfiguration {
+ private MarshallerFactory marshallerFactory;
+ private Configuration marshallingConfiguration;
+ private int linkMetric;
+ private Executor executor;
+ private BufferAllocator<ByteBuffer> allocator;
+
+ public MultiplexConfiguration() {
+ }
+
+ public MarshallerFactory getMarshallerFactory() {
+ return marshallerFactory;
+ }
+
+ public void setMarshallerFactory(final MarshallerFactory marshallerFactory) {
+ this.marshallerFactory = marshallerFactory;
+ }
+
+ public Configuration getMarshallingConfiguration() {
+ return marshallingConfiguration;
+ }
+
+ public void setMarshallingConfiguration(final Configuration marshallingConfiguration) {
+ this.marshallingConfiguration = marshallingConfiguration;
+ }
+
+ public int getLinkMetric() {
+ return linkMetric;
+ }
+
+ public void setLinkMetric(final int linkMetric) {
+ this.linkMetric = linkMetric;
+ }
+
+ public Executor getExecutor() {
+ return executor;
+ }
+
+ public void setExecutor(final Executor executor) {
+ this.executor = executor;
+ }
+
+ public BufferAllocator<ByteBuffer> getAllocator() {
+ return allocator;
+ }
+
+ public void setAllocator(final BufferAllocator<ByteBuffer> allocator) {
+ this.allocator = allocator;
+ }
+}
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java 2008-10-23 01:44:01 UTC (rev 4616)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java 2008-10-23 01:44:56 UTC (rev 4617)
@@ -66,7 +66,7 @@
*
* @param <A> stream channel address type (Void if streams are not supported)
*/
-public final class MultiplexHandler<A> implements IoHandler<AllocatedMessageChannel> {
+public final class MultiplexHandler implements IoHandler<AllocatedMessageChannel> {
private static final Logger log = Logger.getLogger(MultiplexHandler.class);
@@ -107,7 +107,7 @@
private volatile AllocatedMessageChannel channel;
- public MultiplexHandler(final Endpoint endpoint, final RemotingChannelConfiguration configuration) {
+ public MultiplexHandler(final Endpoint endpoint, final MultiplexConfiguration configuration) {
this.endpoint = endpoint;
allocator = configuration.getAllocator();
executor = configuration.getExecutor();
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java 2008-10-23 01:44:01 UTC (rev 4616)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java 2008-10-23 01:44:56 UTC (rev 4617)
@@ -32,37 +32,26 @@
import org.jboss.xnio.IoFuture;
import org.jboss.xnio.AbstractConvertingIoFuture;
import org.jboss.xnio.IoHandler;
-import org.jboss.xnio.BufferAllocator;
-import org.jboss.xnio.log.Logger;
import org.jboss.xnio.channels.AllocatedMessageChannel;
import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.concurrent.Executor;
/**
*
*/
public final class MultiplexProtocol {
- private static final Logger log = Logger.getLogger(MultiplexProtocol.class);
-
private MultiplexProtocol() {
}
/**
* Create a request server for the multiplex protocol.
*
- * @return a handler factory for passing to an XNIO server @param executor the executor to use for invocations
- * @param allocator the buffer allocator to use
+ * @return a handler factory for passing to an XNIO server @param executor the executor to use for invocations @param configuration
*/
- public static <A> IoHandlerFactory<AllocatedMessageChannel> createServer(final Endpoint endpoint, final Executor executor, final BufferAllocator<ByteBuffer> allocator) {
+ public static IoHandlerFactory<AllocatedMessageChannel> createServer(final Endpoint endpoint, final MultiplexConfiguration configuration) {
return new IoHandlerFactory<AllocatedMessageChannel>() {
public IoHandler<? super AllocatedMessageChannel> createHandler() {
- final RemotingChannelConfiguration configuration = new RemotingChannelConfiguration();
- configuration.setAllocator(allocator);
- configuration.setExecutor(executor);
- // todo marshaller factory... etc
- return new MultiplexHandler<A>(endpoint, configuration);
+ return new MultiplexHandler(endpoint, configuration);
}
};
}
@@ -71,19 +60,14 @@
* Create a request client for the multiplex protocol.
*
* @return a handle which may be used to close the connection
- * @throws IOException if an error occurs @param executor the executor to use for invocations @param channelSource the XNIO channel source to use to establish the connection
- * @param allocator the buffer allocator to use
+ * @throws IOException if an error occurs @param executor the executor to use for invocations @param channelSource the XNIO channel source to use to establish the connection @param allocator the buffer allocator to use @param configuration
*/
- public static <A> IoFuture<SimpleCloseable> connect(final Endpoint endpoint, final Executor executor, final ChannelSource<AllocatedMessageChannel> channelSource, final BufferAllocator<ByteBuffer> allocator) throws IOException {
- final RemotingChannelConfiguration configuration = new RemotingChannelConfiguration();
- configuration.setAllocator(allocator);
- configuration.setExecutor(executor);
- // todo marshaller factory... etc
- final MultiplexHandler<A> multiplexHandler = new MultiplexHandler<A>(endpoint, configuration);
+ public static IoFuture<SimpleCloseable> connect(final Endpoint endpoint, final MultiplexConfiguration configuration, final ChannelSource<AllocatedMessageChannel> channelSource) throws IOException {
+ final MultiplexHandler multiplexHandler = new MultiplexHandler(endpoint, configuration);
final IoFuture<AllocatedMessageChannel> futureChannel = channelSource.open(multiplexHandler);
return new AbstractConvertingIoFuture<SimpleCloseable, AllocatedMessageChannel>(futureChannel) {
protected SimpleCloseable convert(final AllocatedMessageChannel channel) throws RemotingException {
- return new AbstractConnection(executor) {
+ return new AbstractConnection(configuration.getExecutor()) {
public Handle<RequestHandlerSource> getServiceForId(final int id) throws IOException {
return multiplexHandler.getRemoteService(id).getHandle();
}
Deleted: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java 2008-10-23 01:44:01 UTC (rev 4616)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java 2008-10-23 01:44:56 UTC (rev 4617)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.protocol.multiplex;
-
-import java.util.concurrent.Executor;
-import java.nio.ByteBuffer;
-import org.jboss.xnio.BufferAllocator;
-import org.jboss.marshalling.MarshallerFactory;
-import org.jboss.marshalling.Configuration;
-
-/**
- *
- */
-public final class RemotingChannelConfiguration {
- private MarshallerFactory marshallerFactory;
- private Configuration marshallingConfiguration;
- private int linkMetric;
- private Executor executor;
- private BufferAllocator<ByteBuffer> allocator;
-
- public RemotingChannelConfiguration() {
- }
-
- public MarshallerFactory getMarshallerFactory() {
- return marshallerFactory;
- }
-
- public void setMarshallerFactory(final MarshallerFactory marshallerFactory) {
- this.marshallerFactory = marshallerFactory;
- }
-
- public Configuration getMarshallingConfiguration() {
- return marshallingConfiguration;
- }
-
- public void setMarshallingConfiguration(final Configuration marshallingConfiguration) {
- this.marshallingConfiguration = marshallingConfiguration;
- }
-
- public int getLinkMetric() {
- return linkMetric;
- }
-
- public void setLinkMetric(final int linkMetric) {
- this.linkMetric = linkMetric;
- }
-
- public Executor getExecutor() {
- return executor;
- }
-
- public void setExecutor(final Executor executor) {
- this.executor = executor;
- }
-
- public BufferAllocator<ByteBuffer> getAllocator() {
- return allocator;
- }
-
- public void setAllocator(final BufferAllocator<ByteBuffer> allocator) {
- this.allocator = allocator;
- }
-}
16 years, 2 months
JBoss Remoting SVN: r4616 - in remoting3/trunk: core/src/main/java/org/jboss/remoting/core and 4 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 21:44:01 -0400 (Wed, 22 Oct 2008)
New Revision: 4616
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractHandleableCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractSimpleCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/AbstractContextImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientContextImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureClientSource.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestListenerExecutor.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceContextImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/util/DecodingBuilder.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/StringRot13RequestListener.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/OrderedExecutor.java
Log:
Imports and minor cleanup
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,11 +22,10 @@
package org.jboss.remoting.spi;
+import java.io.IOException;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
-import java.io.IOException;
import org.jboss.remoting.RemotingException;
-import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.log.Logger;
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractHandleableCloseable.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractHandleableCloseable.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractHandleableCloseable.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,20 +22,19 @@
package org.jboss.remoting.spi;
-import org.jboss.remoting.HandleableCloseable;
-import org.jboss.remoting.RemotingException;
-import org.jboss.remoting.CloseHandler;
-import org.jboss.remoting.spi.SpiUtils;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.log.Logger;
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.io.IOException;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.HandleableCloseable;
+import org.jboss.remoting.RemotingException;
+import org.jboss.xnio.IoUtils;
+import org.jboss.xnio.log.Logger;
/**
* A basic implementation of a closeable resource. Use as a convenient base class for your closeable resources.
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractSimpleCloseable.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractSimpleCloseable.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractSimpleCloseable.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,8 +22,8 @@
package org.jboss.remoting.spi;
+import java.util.concurrent.Executor;
import org.jboss.remoting.SimpleCloseable;
-import java.util.concurrent.Executor;
/**
* An abstract simple closeable implementation.
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,9 +22,9 @@
package org.jboss.remoting.spi;
+import java.io.IOException;
+import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.HandleableCloseable;
-import org.jboss.remoting.CloseHandler;
-import java.io.IOException;
/**
* A handle to a local resource.
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,10 +22,10 @@
package org.jboss.remoting.spi;
+import java.io.IOException;
+import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.HandleableCloseable;
import org.jboss.remoting.RemotingException;
-import org.jboss.remoting.CloseHandler;
-import java.io.IOException;
/**
* A request handler, which can be passed to remote endpoints. Remote systems can then use the handler
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,10 +22,10 @@
package org.jboss.remoting.spi;
+import java.io.IOException;
+import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.HandleableCloseable;
import org.jboss.remoting.RemotingException;
-import org.jboss.remoting.CloseHandler;
-import java.io.IOException;
/**
* A request handler source, which can be passed to remote endpoints. Remote systems can then use the handler source
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,13 +22,11 @@
package org.jboss.remoting.spi;
-import org.jboss.remoting.spi.ReplyHandler;
-import org.jboss.remoting.spi.RemoteRequestContext;
+import java.io.IOException;
+import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.RequestCancelHandler;
import org.jboss.remoting.RequestContext;
-import org.jboss.remoting.CloseHandler;
import org.jboss.xnio.log.Logger;
-import java.io.IOException;
/**
* Utility methods for Remoting service providers.
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/AbstractContextImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/AbstractContextImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/AbstractContextImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -24,8 +24,8 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
+import org.jboss.remoting.spi.AbstractHandleableCloseable;
import org.jboss.remoting.util.CollectionUtil;
-import org.jboss.remoting.spi.AbstractHandleableCloseable;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientContextImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientContextImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientContextImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,9 +22,9 @@
package org.jboss.remoting.core;
+import java.util.concurrent.Executor;
import org.jboss.remoting.ClientContext;
import org.jboss.remoting.ServiceContext;
-import java.util.concurrent.Executor;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,12 +22,12 @@
package org.jboss.remoting.core;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.jboss.marshalling.Creator;
import org.jboss.marshalling.Externalizer;
-import org.jboss.marshalling.Creator;
import org.jboss.remoting.spi.RequestHandler;
-import java.io.ObjectOutput;
-import java.io.IOException;
-import java.io.ObjectInput;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,16 +22,16 @@
package org.jboss.remoting.core;
+import java.io.IOException;
+import java.util.concurrent.Executor;
import org.jboss.remoting.Client;
import org.jboss.remoting.IndeterminateOutcomeException;
import org.jboss.remoting.core.util.QueueExecutor;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
import org.jboss.remoting.spi.RequestHandler;
-import org.jboss.remoting.spi.ReplyHandler;
-import org.jboss.remoting.spi.RemoteRequestContext;
-import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoFuture;
-import java.util.concurrent.Executor;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,15 +22,15 @@
package org.jboss.remoting.core;
+import java.io.IOException;
+import org.jboss.remoting.Client;
import org.jboss.remoting.ClientSource;
-import org.jboss.remoting.Client;
import org.jboss.remoting.Endpoint;
+import org.jboss.remoting.spi.AbstractHandleableCloseable;
+import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.RequestHandler;
import org.jboss.remoting.spi.RequestHandlerSource;
-import org.jboss.remoting.spi.Handle;
-import org.jboss.remoting.spi.AbstractHandleableCloseable;
import org.jboss.xnio.IoUtils;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -1,37 +1,37 @@
package org.jboss.remoting.core;
+import java.io.Closeable;
+import java.io.IOException;
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import java.util.Set;
-import java.util.Map;
-import java.util.List;
-import java.io.Closeable;
-import java.io.IOException;
-import java.net.URI;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ClientSource;
+import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.Endpoint;
import org.jboss.remoting.RequestListener;
-import org.jboss.remoting.CloseHandler;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.ClientSource;
+import org.jboss.remoting.ServiceListener;
import org.jboss.remoting.SimpleCloseable;
-import org.jboss.remoting.ServiceListener;
-import org.jboss.remoting.util.OrderedExecutorFactory;
+import org.jboss.remoting.spi.AbstractSimpleCloseable;
+import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.RequestHandler;
import org.jboss.remoting.spi.RequestHandlerSource;
-import org.jboss.remoting.spi.Handle;
-import org.jboss.remoting.spi.AbstractSimpleCloseable;
import org.jboss.remoting.util.CollectionUtil;
import org.jboss.remoting.util.NamingThreadFactory;
+import org.jboss.remoting.util.OrderedExecutorFactory;
import org.jboss.remoting.util.ServiceURI;
import org.jboss.remoting.version.Version;
+import org.jboss.xnio.FailedIoFuture;
+import org.jboss.xnio.FinishedIoFuture;
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.IoFuture;
-import org.jboss.xnio.FinishedIoFuture;
-import org.jboss.xnio.FailedIoFuture;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureClientSource.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureClientSource.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureClientSource.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,12 +22,12 @@
package org.jboss.remoting.core;
+import java.io.IOException;
+import org.jboss.remoting.ClientSource;
+import org.jboss.remoting.SimpleCloseable;
import org.jboss.xnio.AbstractIoFuture;
import org.jboss.xnio.IoFuture;
import org.jboss.xnio.IoUtils;
-import org.jboss.remoting.ClientSource;
-import org.jboss.remoting.SimpleCloseable;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,12 +22,12 @@
package org.jboss.remoting.core;
+import java.io.IOException;
+import java.util.concurrent.Executor;
+import org.jboss.remoting.spi.RemoteRequestContext;
import org.jboss.remoting.spi.ReplyHandler;
-import org.jboss.remoting.spi.RemoteRequestContext;
import org.jboss.xnio.AbstractIoFuture;
import org.jboss.xnio.IoFuture;
-import java.util.concurrent.Executor;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,17 +22,17 @@
package org.jboss.remoting.core;
-import org.jboss.remoting.spi.RequestHandler;
+import java.io.IOException;
+import java.util.concurrent.Executor;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.RemoteExecutionException;
+import org.jboss.remoting.RequestListener;
+import org.jboss.remoting.spi.AbstractAutoCloseable;
import org.jboss.remoting.spi.RemoteRequestContext;
import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RequestHandler;
import org.jboss.remoting.spi.SpiUtils;
-import org.jboss.remoting.spi.AbstractAutoCloseable;
-import org.jboss.remoting.RequestListener;
-import org.jboss.remoting.RemoteExecutionException;
-import org.jboss.remoting.CloseHandler;
import org.jboss.xnio.log.Logger;
-import java.util.concurrent.Executor;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,15 +22,15 @@
package org.jboss.remoting.core;
+import java.io.IOException;
+import java.util.concurrent.Executor;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.RequestListener;
+import org.jboss.remoting.spi.AbstractAutoCloseable;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.spi.RequestHandler;
import org.jboss.remoting.spi.RequestHandlerSource;
-import org.jboss.remoting.spi.RequestHandler;
-import org.jboss.remoting.spi.Handle;
-import org.jboss.remoting.spi.AbstractAutoCloseable;
-import org.jboss.remoting.RequestListener;
-import org.jboss.remoting.CloseHandler;
import org.jboss.xnio.log.Logger;
-import java.util.concurrent.Executor;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,19 +22,19 @@
package org.jboss.remoting.core;
-import org.jboss.remoting.RequestContext;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.remoting.ClientContext;
-import org.jboss.remoting.RequestCancelHandler;
+import org.jboss.remoting.IndeterminateOutcomeException;
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.RemoteReplyException;
-import org.jboss.remoting.IndeterminateOutcomeException;
+import org.jboss.remoting.RequestCancelHandler;
+import org.jboss.remoting.RequestContext;
import org.jboss.remoting.spi.ReplyHandler;
import org.jboss.remoting.spi.SpiUtils;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.Set;
-import java.util.HashSet;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestListenerExecutor.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestListenerExecutor.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestListenerExecutor.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,8 +22,8 @@
package org.jboss.remoting.core;
+import java.util.Set;
import java.util.concurrent.Executor;
-import java.util.Set;
import org.jboss.remoting.util.CollectionUtil;
/**
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceContextImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceContextImpl.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceContextImpl.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,8 +22,8 @@
package org.jboss.remoting.core;
+import java.util.concurrent.Executor;
import org.jboss.remoting.ServiceContext;
-import java.util.concurrent.Executor;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,8 +22,8 @@
package org.jboss.remoting.core;
+import org.jboss.remoting.SimpleCloseable;
import org.jboss.remoting.spi.RequestHandlerSource;
-import org.jboss.remoting.SimpleCloseable;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/util/DecodingBuilder.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/util/DecodingBuilder.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/util/DecodingBuilder.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -24,8 +24,8 @@
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
+import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
-import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;
import static org.jboss.xnio.Buffers.flip;
Modified: remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/EndpointMetaData.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -8,8 +8,8 @@
import org.jboss.remoting.util.CollectionUtil;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlTransient;
/**
* Metadata that describes the creation of a Remoting endpoint.
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/StringRot13RequestListener.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/StringRot13RequestListener.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/StringRot13RequestListener.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -1,9 +1,9 @@
package org.jboss.remoting.samples.simple;
+import java.io.IOException;
import org.jboss.remoting.AbstractRequestListener;
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.RequestContext;
-import java.io.IOException;
/**
*
Modified: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -11,12 +11,12 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.Set;
import java.util.WeakHashMap;
-import java.util.ListIterator;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
Modified: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/OrderedExecutor.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/OrderedExecutor.java 2008-10-23 01:11:53 UTC (rev 4615)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/OrderedExecutor.java 2008-10-23 01:44:01 UTC (rev 4616)
@@ -22,8 +22,8 @@
package org.jboss.remoting.util;
+import java.util.LinkedList;
import java.util.concurrent.Executor;
-import java.util.LinkedList;
import org.jboss.xnio.log.Logger;
/**
16 years, 2 months
JBoss Remoting SVN: r4615 - in remoting3/trunk: mc-deployers/src/main/java/org/jboss/remoting and 2 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 21:11:53 -0400 (Wed, 22 Oct 2008)
New Revision: 4615
Removed:
remoting3/trunk/api/src/main/java/org/jboss/remoting/CommonKeys.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/beans/
remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaData.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaDataAttribute.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AtomicStateMachine.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeHashMap.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeKey.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeMap.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64DecodingException.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64Util.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/DelegateIterable.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/State.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/StateLock.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Translator.java
Modified:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java
remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java
Log:
Yet more cleanup
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/CommonKeys.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/CommonKeys.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/CommonKeys.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,60 +0,0 @@
-package org.jboss.remoting;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.jboss.remoting.util.AttributeKey;
-import static org.jboss.remoting.util.AttributeKey.key;
-
-import javax.security.auth.callback.CallbackHandler;
-
-/**
- * A set of attribute keys that are common across various protocols.
- */
-public final class CommonKeys {
- private CommonKeys() { /* no construction */ }
-
- // SASL
-
- /**
- * A key that represents the SASL properties to be used for this connection or server.
- */
- public static final AttributeKey<Map<String, ?>> SASL_PROPERTIES = key("SASL_PROPERTIES");
- /**
- * The SASL client mechanisms to try, in order. If none are given, then the list is generated based on the registered
- * providers.
- */
- public static final AttributeKey<List<String>> SASL_CLIENT_MECHANISMS = key("SASL_CLIENT_MECHANISMS");
- /**
- * The SASL server mechanisms to make available to clients. If none are given, then the set is generated based on
- * the registered providers.
- */
- public static final AttributeKey<Set<String>> SASL_SERVER_MECHANISMS = key("SASL_SERVER_MECHANISMS");
-
- // Generic auth
-
- /**
- * The authentication callback handler to make available to the authentication layer.
- */
- public static final AttributeKey<CallbackHandler> AUTH_CALLBACK_HANDLER = key("AUTH_CALLBACK_HANDLER");
- /**
- * The client authorization ID to send to the server. If not specified, defaults to the local endpoint name. If
- * the local endpoint is anonymous, defaults to {@code null}.
- */
- public static final AttributeKey<String> AUTHORIZATION_ID = key("AUTHORIZATION_ID");
- /**
- * The maximum number of times to retry authentication before giving up and failing.
- */
- public static final AttributeKey<Integer> AUTH_MAX_RETRIES = key("AUTH_MAX_RETRIES");
-
- // TODO: add keys for SSL/TLS
-
- // Protocol keys
-
- /**
- * The keepalive interval. For protocols that are represented by a connection of some sort, this property indicates
- * that a "keepalive" message should be sent at regular intervals to prevent an idle connection from being
- * automatically closed by a firewall (for example).
- */
- public static final AttributeKey<Integer> KEEPALIVE_INTERVAL = key("KEEPALIVE_INTERVAL");
-}
Modified: remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/RemotingMetaData.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -26,7 +26,6 @@
private static final long serialVersionUID = 1L;
private List<EndpointMetaData> endpoints;
- private List<SessionMetaData> sessions;
/**
* Get the list of nested endpoints as metadata.
@@ -48,25 +47,6 @@
}
/**
- * Get the list of nested sessions as metadata.
- *
- * @return the session metadata list
- */
- public List<SessionMetaData> getSessions() {
- return sessions;
- }
-
- /**
- * Set the list of nested sessions as metadata.
- *
- * @param sessions the session metadata list
- */
- @XmlElement(name = "session")
- public void setSessions(final List<SessionMetaData> sessions) {
- this.sessions = sessions;
- }
-
- /**
* Create a duplicate of this object.
*
* @return a duplicate of this object
@@ -77,9 +57,6 @@
for (EndpointMetaData endpointMetaData : endpoints) {
metaData.endpoints.add(endpointMetaData.clone());
}
- for (SessionMetaData sessionMetaData : sessions) {
- metaData.sessions.add(sessionMetaData.clone());
- }
return metaData;
}
@@ -94,9 +71,6 @@
for (EndpointMetaData endpointMetaData : endpoints) {
metaDataList.addAll(endpointMetaData.getBeans());
}
- for (SessionMetaData sessionMetaData : sessions) {
- metaDataList.addAll(sessionMetaData.getBeans());
- }
return Collections.unmodifiableList(metaDataList);
}
}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaData.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaData.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaData.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,105 +0,0 @@
-package org.jboss.remoting.metadata;
-
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.remoting.util.AttributeMap;
-import org.jboss.remoting.util.AttributeHashMap;
-import org.jboss.remoting.util.AttributeKey;
-import org.jboss.remoting.util.CollectionUtil;
-import org.jboss.remoting.CommonKeys;
-import java.io.Serializable;
-import java.util.List;
-import java.net.URI;
-import java.lang.reflect.Field;
-
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-/**
- * Metadata which describes a session to be established and maintained with another endpoint.
- */
-@XmlType(namespace = "urn:jboss:remoting:3.0", name = "session")
-public class SessionMetaData implements BeanMetaDataFactory, Serializable {
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String endpoint;
- private URI destination;
- private List<SessionMetaDataAttribute> attributeList;
-
- public String getName() {
- return name;
- }
-
- @XmlAttribute(required = true)
- public void setName(final String name) {
- this.name = name;
- }
-
- public String getEndpoint() {
- return endpoint;
- }
-
- @XmlAttribute(required = true)
- public void setEndpoint(final String endpoint) {
- this.endpoint = endpoint;
- }
-
- public URI getDestination() {
- return destination;
- }
-
- @XmlAttribute(required = true)
- public void setDestination(final URI destination) {
- this.destination = destination;
- }
-
- public List<SessionMetaDataAttribute> getAttributeList() {
- return attributeList;
- }
-
- @XmlElement(name = "attribute")
- public void setAttributeList(final List<SessionMetaDataAttribute> attributeList) {
- this.attributeList = attributeList;
- }
-
- public SessionMetaData clone() throws CloneNotSupportedException {
- return (SessionMetaData) super.clone();
- }
-
- @XmlTransient
- public List<BeanMetaData> getBeans() {
- return CollectionUtil.unmodifiableList(createSessionMetaData());
- }
-
- @SuppressWarnings({"unchecked"})
- private static <T> void putAttribute(AttributeMap attributeMap, AttributeKey<T> key, Object value) {
- attributeMap.put(key, (T) value);
- }
-
- private BeanMetaData createSessionMetaData() {
- final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name);
- builder.addPropertyMetaData("endpoint", builder.createInject(endpoint));
- builder.addPropertyMetaData("destination", destination);
- final AttributeMap attributeMap = new AttributeHashMap();
- try {
- for (SessionMetaDataAttribute attribute : attributeList) {
- Class<?> claxx = Class.forName(attribute.getClaxx());
- if (claxx == null) {
- claxx = CommonKeys.class;
- }
- final String fieldName = attribute.getName();
- final Field field = claxx.getDeclaredField(fieldName);
- final AttributeKey<?> keyInstance = (AttributeKey<?>) field.get(null);
- putAttribute(attributeMap, keyInstance, attribute.getValue());
- }
- } catch (Exception e) {
- throw new IllegalArgumentException("Error reading field", e);
- }
- builder.addPropertyMetaData("attributeMap", attributeMap);
- return builder.getBeanMetaData();
- }
-}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaDataAttribute.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaDataAttribute.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/remoting/metadata/SessionMetaDataAttribute.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,42 +0,0 @@
-package org.jboss.remoting.metadata;
-
-import javax.xml.bind.annotation.XmlAnyElement;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- *
- */
-@XmlType(namespace = "urn:jboss:remoting:3.0", name = "attribute")
-public class SessionMetaDataAttribute {
- private String claxx;
- private String name;
- private Object value;
-
- public String getClaxx() {
- return claxx;
- }
-
- @XmlAttribute(name = "class")
- public void setClaxx(final String claxx) {
- this.claxx = claxx;
- }
-
- public String getName() {
- return name;
- }
-
- @XmlAttribute(name = "name", required = true)
- public void setName(final String name) {
- this.name = name;
- }
-
- public Object getValue() {
- return value;
- }
-
- @XmlAnyElement
- public void setValue(final Object value) {
- this.value = value;
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AtomicStateMachine.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AtomicStateMachine.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AtomicStateMachine.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,371 +0,0 @@
-package org.jboss.remoting.util;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- *
- */
-public final class AtomicStateMachine<T extends Enum<T> & State<T>> {
- // protected by {@code lock}
- private T state;
-
- private final StateLock stateLock = new StateLock();
-
- public static <T extends Enum<T> & State<T>> AtomicStateMachine<T> start(final T initialState) {
- return new AtomicStateMachine<T>(initialState);
- }
-
- private AtomicStateMachine(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- this.state = state;
- }
-
- public boolean transition(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockExclusive();
- try {
- if (this.state == state) {
- return false;
- }
- this.state = state;
- return true;
- } finally {
- stateLock.unlockExclusive();
- }
- }
-
- /**
- * Transition the state, and hold it at the given state until {@link #release()} is called. Must not be
- * called if the state is already held from this thread.
- *
- * Example:
- * <pre>
- * if (state.transitionHold(State.STOPPING)) try {
- * // do stuff
- * } finally {
- * state.release();
- * }
- * </pre>
- *
- * @param state the target state
- * @return {@code true} if the transition happened
- */
- public boolean transitionHold(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockExclusive();
- try {
- if (this.state == state) {
- return false;
- }
- this.state = state;
- stateLock.lockShared();
- return true;
- } finally {
- stateLock.unlockExclusive();
- }
- }
-
- public boolean transitionExclusive(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockExclusive();
- if (this.state == state) {
- return false;
- }
- this.state = state;
- return true;
- }
-
- /**
- * Release a held state. Must be called from the same thread that is holding the state.
- */
- public void release() {
- stateLock.unlockShared();
- }
-
- public void releaseExclusive() {
- stateLock.unlockExclusive();
- }
-
- public void releaseDowngrade() {
- stateLock.lockShared();
- stateLock.unlockExclusive();
- }
-
- public boolean transition(final T fromState, final T toState) {
- if (fromState == null) {
- throw new NullPointerException("fromState is null");
- }
- if (toState == null) {
- throw new NullPointerException("toState is null");
- }
- stateLock.lockExclusive();
- try {
- if (state != fromState) {
- return false;
- }
- state = toState;
- return true;
- } finally {
- stateLock.unlockExclusive();
- }
- }
-
- public boolean transitionHold(final T fromState, final T toState) {
- if (fromState == null) {
- throw new NullPointerException("fromState is null");
- }
- if (toState == null) {
- throw new NullPointerException("toState is null");
- }
- stateLock.lockExclusive();
- try {
- if (state != fromState) {
- return false;
- }
- state = toState;
- stateLock.lockShared();
- return true;
- } finally {
- stateLock.unlockExclusive();
- }
- }
-
- public boolean transitionExclusive(final T fromState, final T toState) {
- if (fromState == null) {
- throw new NullPointerException("fromState is null");
- }
- if (toState == null) {
- throw new NullPointerException("toState is null");
- }
- stateLock.lockExclusive();
- boolean ok = false;
- try {
- if (state != fromState) {
- return false;
- }
- state = toState;
- ok = true;
- return true;
- } finally {
- if (! ok) {
- stateLock.unlockExclusive();
- }
- }
- }
-
- public void requireTransition(final T state) {
- if (! transition(state)) {
- throw new IllegalStateException("Already in state " + state);
- }
- }
-
- public void requireTransitionHold(final T state) {
- if (! transitionHold(state)) {
- throw new IllegalStateException("Already in state " + state);
- }
- }
-
- public void requireTransition(final T fromState, final T toState) {
- if (! transition(fromState, toState)) {
- throw new IllegalStateException("Cannot transition from " + fromState + " to " + toState + " (current state is " + state + ")");
- }
- }
-
- public void requireTransitionHold(final T fromState, final T toState) {
- if (! transitionHold(fromState, toState)) {
- throw new IllegalStateException("Cannot transition from " + fromState + " to " + toState + " (current state is " + state + ")");
- }
- }
-
- public void requireTransitionExclusive(T fromState, T toState) {
- if (! transitionExclusive(fromState, toState)) {
- throw new IllegalStateException("Cannot transition from " + fromState + " to " + toState + " (current state is " + state + ")");
- }
- }
-
- public void waitInterruptiblyFor(final T state) throws InterruptedException {
- stateLock.lockShared();
- while (this.state != state) {
- if (this.state.isReachable(state)) {
- stateLock.yieldShared();
- } else try {
- throw new IllegalStateException("Destination state " + state + " is unreachable from " + this.state);
- } finally {
- stateLock.unlockShared();
- }
- }
- stateLock.unlockShared();
- return;
- }
-
- public void waitFor(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockShared();
- while (this.state != state) {
- if (this.state.isReachable(state)) {
- stateLock.yieldShared();
- } else try {
- throw new IllegalStateException("Destination state " + state + " is unreachable from " + this.state);
- } finally {
- stateLock.unlockShared();
- }
- }
- stateLock.unlockShared();
- return;
- }
-
- public void waitForHold(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockShared();
- while (this.state != state) {
- if (this.state.isReachable(state)) {
- stateLock.yieldShared();
- } else try {
- throw new IllegalStateException("Destination state " + state + " is unreachable from " + this.state);
- } finally {
- stateLock.unlockShared();
- }
- }
- return;
- }
-
- public T waitInterruptiblyForNotHold(final T state) throws InterruptedException {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockShared();
- while (this.state == state) {
- stateLock.yieldShared();
- }
- return this.state;
- }
-
- public T waitForNot(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockShared();
- while (this.state == state) {
- stateLock.yieldShared();
- }
- try {
- return this.state;
- } finally {
- stateLock.unlockShared();
- }
- }
-
- public T waitForNotHold(final T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- stateLock.lockShared();
- while (this.state == state) {
- stateLock.yieldShared();
- }
- return this.state;
- }
-
- public T waitInterruptiblyForNotHold(final T state, final long timeout, final TimeUnit timeUnit) throws InterruptedException {
- throw new RuntimeException("TODO - Implement");
- }
-
- public T waitForNotHold(final T state, final long timeout, final TimeUnit timeUnit) {
- throw new RuntimeException("TODO - Implement");
- }
-
- public T getState() {
- stateLock.lockShared();
- try {
- return state;
- } finally {
- stateLock.unlockShared();
- }
- }
-
- public T getStateHold() {
- stateLock.lockShared();
- return state;
- }
-
- public T getStateExclusive() {
- stateLock.lockExclusive();
- return state;
- }
-
- public boolean inHold(T state) {
- stateLock.lockShared();
- boolean ok = false;
- try {
- ok = this.state == state;
- return ok;
- } finally {
- if (! ok) {
- stateLock.unlockShared();
- }
- }
- }
-
- public boolean in(T state) {
- stateLock.lockShared();
- try {
- return this.state == state;
- } finally {
- stateLock.unlockShared();
- }
- }
-
- public boolean in(T... states) {
- if (states == null) {
- throw new NullPointerException("states is null");
- }
- stateLock.lockShared();
- try {
- for (T state : states) {
- if (this.state == state) {
- return true;
- }
- }
- return false;
- } finally {
- stateLock.unlockShared();
- }
- }
-
- public void requireHold(T state) {
- if (state == null) {
- throw new NullPointerException("state is null");
- }
- boolean ok = false;
- stateLock.lockShared();
- try {
- if (this.state != state) {
- throw new IllegalStateException("Invalid state (expected " + state + ", but current state is " + this.state + ")");
- }
- ok = true;
- } finally {
- if (! ok) stateLock.unlockShared();
- }
- }
-
- public String toString() {
- stateLock.lockShared();
- try {
- return "State = " + state;
- } finally {
- stateLock.unlockShared();
- }
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeHashMap.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeHashMap.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeHashMap.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,105 +0,0 @@
-package org.jboss.remoting.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- *
- */
-public final class AttributeHashMap implements AttributeMap {
- private final ConcurrentMap<AttributeKey<?>, Object> map = CollectionUtil.concurrentMap();
-
- @SuppressWarnings ({"unchecked"})
- public <T> T get(AttributeKey<T> key) {
- return (T) map.get(key);
- }
-
- @SuppressWarnings ({"unchecked"})
- public <T> T put(AttributeKey<T> key, T value) {
- return (T) map.put(key, value);
- }
-
- @SuppressWarnings ({"unchecked"})
- public <T> T remove(AttributeKey<T> key) {
- return (T) map.remove(key);
- }
-
- public <T> boolean remove(AttributeKey<T> key, T value) {
- return map.remove(key, value);
- }
-
- @SuppressWarnings ({"unchecked"})
- public <T> T putIfAbsent(AttributeKey<T> key, T value) {
- return (T) map.putIfAbsent(key, value);
- }
-
- public <T> boolean replace(AttributeKey<T> key, T oldValue, T newValue) {
- return map.replace(key, oldValue, newValue);
- }
-
- public <T> boolean containsKey(AttributeKey<T> key) {
- return map.containsKey(key);
- }
-
- public <T> boolean containsValue(T value) {
- return map.containsValue(value);
- }
-
- public Iterable<Entry<?>> entries() {
- return new Iterable<Entry<?>>() {
- public Iterator<Entry<?>> iterator() {
- final Iterator<Map.Entry<AttributeKey<?>, Object>> i = map.entrySet().iterator();
- return new Iterator<Entry<?>>() {
- public boolean hasNext() {
- return i.hasNext();
- }
-
- public Entry<?> next() {
- final Map.Entry<AttributeKey<?>, Object> ie = i.next();
- return new Entry<Object>() {
- @SuppressWarnings ({"unchecked"})
- public AttributeKey<Object> getKey() {
- return (AttributeKey<Object>) ie.getKey();
- }
-
- public Object getValue() {
- return ie.getValue();
- }
-
- public void setValue(final Object newValue) {
- ie.setValue(newValue);
- }
- };
- }
-
- public void remove() {
- i.remove();
- }
- };
- }
- };
- }
-
- public Set<AttributeKey<?>> keySet() {
- return map.keySet();
- }
-
- public Collection<?> values() {
- return map.values();
- }
-
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- public int size() {
- return map.size();
- }
-
- public void clear() {
- map.clear();
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeKey.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeKey.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeKey.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,20 +0,0 @@
-package org.jboss.remoting.util;
-
-/**
- *
- */
-public final class AttributeKey<T> {
- private final String name;
-
- public static <T> AttributeKey<T> key(String name) {
- return new AttributeKey<T>(name);
- }
-
- public AttributeKey(final String name) {
- this.name = name;
- }
-
- public String toString() {
- return "Key \"" + name + "\"";
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeMap.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeMap.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/AttributeMap.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,150 +0,0 @@
-package org.jboss.remoting.util;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * A map whose value types are determined by the key.
- */
-public interface AttributeMap {
-
- /**
- * The empty attribute map.
- */
- AttributeMap EMPTY = CollectionUtil.emptyAttributeMap();
-
- /**
- * Get a value from the map.
- *
- * @param key the key
- * @return the value
- */
- <T> T get(AttributeKey<T> key);
-
- /**
- * Store a value into the map. Any previous mapping for this value is overwritten.
- *
- * @param key the key
- * @param value the new value
- * @return the old value (may be {@code null}), or {@code null} if there was no mapping for this key
- */
- <T> T put(AttributeKey<T> key, T value);
-
- /**
- * Remove a mapping from the map.
- *
- * @param key the key
- * @return the old value (may be {@code null}), or {@code null} if there was no mapping for this key
- */
- <T> T remove(AttributeKey<T> key);
-
- /**
- * Remove a mapping from the map. Both the key and value must match the values given.
- *
- * @param key the key
- * @param value the value
- * @return {@code true} if a matching mapping was located and removed
- */
- <T> boolean remove(AttributeKey<T> key, T value);
-
- /**
- * Store a value into the map if there is no value currently stored.
- *
- * @param key the key
- * @param value the value
- * @return the old value if there was a previous mapping
- */
- <T> T putIfAbsent(AttributeKey<T> key, T value);
-
- /**
- * Replace a mapping in the map.
- *
- * @param key the key
- * @param oldValue the old value
- * @param newValue the replacement value
- * @return {@code true} if a matching mapping was located and replaced
- */
- <T> boolean replace(AttributeKey<T> key, T oldValue, T newValue);
-
- /**
- * Test the map for the presence of a key.
- *
- * @param key the key
- * @return {@code true} if the key is present in the map
- */
- <T> boolean containsKey(AttributeKey<T> key);
-
- /**
- * Test the map for the presence of a value.
- *
- * @param value the value
- * @return {@code true} if the value is present in the map
- */
- <T> boolean containsValue(T value);
-
- /**
- * Get all the map entries.
- *
- * @return the entries
- */
- Iterable<Entry<?>> entries();
-
- /**
- * Get the key set for this map. The returned set supports all set operations except for {@code add} and {@code addAll}.
- *
- * @return the key set
- */
- Set<AttributeKey<?>> keySet();
-
- /**
- * Get the collection of values for this map.
- *
- * @return the values
- */
- Collection<?> values();
-
- /**
- * Determine whether this map is empty.
- *
- * @return {@code true} if the map has no mappings
- */
- boolean isEmpty();
-
- /**
- * Determine the number of entries in the map.
- *
- * @return the number of entries
- */
- int size();
-
- /**
- * Clear the map of all mappings.
- */
- void clear();
-
- /**
- * An entry in the {@code AttributeMap}.
- */
- interface Entry<T> {
- /**
- * Get the entry key.
- *
- * @return the key
- */
- AttributeKey<T> getKey();
-
- /**
- * Get the entry value.
- *
- * @return the value
- */
- T getValue();
-
- /**
- * Change the entry value.
- *
- * @param newValue the new value
- */
- void setValue(T newValue);
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64DecodingException.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64DecodingException.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64DecodingException.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,21 +0,0 @@
-package org.jboss.remoting.util;
-
-/**
- *
- */
-public final class Base64DecodingException extends Exception {
- public Base64DecodingException() {
- }
-
- public Base64DecodingException(String message) {
- super(message);
- }
-
- public Base64DecodingException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public Base64DecodingException(Throwable cause) {
- super(cause);
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64Util.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64Util.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Base64Util.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,151 +0,0 @@
-package org.jboss.remoting.util;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-
-/**
- *
- */
-public final class Base64Util {
-
- private Base64Util() {
- }
-
- /**
- * Base-64 decode a character buffer into a byte buffer.
- *
- * @param source the base-64 encoded source material
- * @param target the target for the decoded data
- * @throws Base64DecodingException if the source data is not in base-64 format
- */
- public static void base64Decode(CharBuffer source, ByteBuffer target) throws Base64DecodingException {
- int triad;
- while (source.hasRemaining()) {
- triad = 0;
- char ch = source.get();
- if (ch >= 'A' && ch <= 'Z') {
- triad |= (ch - 'A') << 18;
- } else if (ch >= 'a' && ch <= 'z') {
- triad |= (ch - 'a' + 26) << 18;
- } else if (ch >= '0' && ch <= '9') {
- triad |= (ch - '0' + 52) << 18;
- } else if (ch == '+' || ch == '-') {
- triad |= 62 << 18;
- } else if (ch == '/' || ch == '_') {
- triad |= 63 << 18;
- } else if (ch == '=') {
- throw new Base64DecodingException("Unexpected padding encountered");
- }
- if (! source.hasRemaining()) {
- throw new Base64DecodingException("Unexpected end of source data");
- }
-
- ch = source.get();
- if (ch >= 'A' && ch <= 'Z') {
- triad |= (ch - 'A') << 12;
- } else if (ch >= 'a' && ch <= 'z') {
- triad |= (ch - 'a' + 26) << 12;
- } else if (ch >= '0' && ch <= '9') {
- triad |= (ch - '0' + 52) << 12;
- } else if (ch == '+' || ch == '-') {
- triad |= 62 << 12;
- } else if (ch == '/' || ch == '_') {
- triad |= 63 << 12;
- } else if (ch == '=') {
- throw new Base64DecodingException("Unexpected padding encountered");
- }
- if (! source.hasRemaining()) {
- throw new Base64DecodingException("Unexpected end of source data");
- }
-
- ch = source.get();
- if (ch >= 'A' && ch <= 'Z') {
- triad |= (ch - 'A') << 6;
- } else if (ch >= 'a' && ch <= 'z') {
- triad |= (ch - 'a' + 26) << 6;
- } else if (ch >= '0' && ch <= '9') {
- triad |= (ch - '0' + 52) << 6;
- } else if (ch == '+' || ch == '-') {
- triad |= 62 << 6;
- } else if (ch == '/' || ch == '_') {
- triad |= 63 << 6;
- } else if (ch == '=') {
- if (source.hasRemaining() && source.get() == '=') {
- if (! source.hasRemaining()) {
- target.put((byte) (triad >> 16));
- return;
- } else {
- throw new Base64DecodingException("Extra data after padding");
- }
- } else {
- throw new Base64DecodingException("Unexpected end of source data");
- }
- }
-
- ch = source.get();
- if (ch >= 'A' && ch <= 'Z') {
- triad |= ch - 'A';
- } else if (ch >= 'a' && ch <= 'z') {
- triad |= ch - 'a' + 26;
- } else if (ch >= '0' && ch <= '9') {
- triad |= ch - '0' + 52;
- } else if (ch == '+' || ch == '-') {
- triad |= 62;
- } else if (ch == '/' || ch == '_') {
- triad |= 63;
- } else if (ch == '=') {
- if (! source.hasRemaining()) {
- target.putShort((short) (triad >> 8));
- return;
- } else {
- throw new Base64DecodingException("Extra data after padding");
- }
- }
-
- target.put((byte) (triad >> 16));
- target.putShort((short) triad);
- }
- }
-
- private static final char[] base64table = new char[] {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '+', '/',
- };
-
- /**
- * Base-64 encode a byte buffer into a character buffer.
- *
- * @param source the binary data to encode
- * @param target the target for the encoded material
- */
- public static void base64Encode(ByteBuffer source, CharBuffer target) {
- int idx = 0;
- while (source.hasRemaining()) {
- int b = source.get() & 0xff;
- target.put(base64table[b >>> 2]);
- idx = b << 4 & 0x3f;
- if (! source.hasRemaining()) {
- target.put(base64table[idx]);
- target.put("==");
- return;
- }
- b = source.get() & 0xff;
- target.put(base64table[idx | (b >>> 4)]);
- idx = b << 2 & 0x3f;
- if (! source.hasRemaining()) {
- target.put(base64table[idx]);
- target.put('=');
- return;
- }
- b = source.get() & 0xff;
- target.put(base64table[idx | (b >>> 6)]);
- target.put(base64table[b & 0x3f]);
- }
- }
-}
Modified: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/CollectionUtil.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -3,7 +3,6 @@
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Enumeration;
@@ -345,78 +344,6 @@
}
/**
- * Run a translation function for each element of an {@code Enumeration}.
- *
- * @param input the input data
- * @param translator the translator
- * @return the translated data
- */
- public static <I,O> Enumeration<O> translate(final Enumeration<I> input, final Translator<I, O> translator) {
- return new Enumeration<O>() {
- public boolean hasMoreElements() {
- return input.hasMoreElements();
- }
-
- public O nextElement() {
- return translator.translate(input.nextElement());
- }
- };
- }
-
- /**
- * Run a translation function for each element of an {@code Iterator}.
- *
- * @param input the input data
- * @param translator the translator
- * @return the translated data
- */
- public static <I,O> Iterator<O> translate(final Iterator<I> input, final Translator<I, O> translator) {
- return new Iterator<O>() {
- public boolean hasNext() {
- return input.hasNext();
- }
-
- public O next() {
- return translator.translate(input.next());
- }
-
- public void remove() {
- input.remove();
- }
- };
- }
-
- /**
- * Run a translation function for each element of an {@code Iterable}.
- *
- * @param input the input data
- * @param translator the translator
- * @return the translated data
- */
- public static <I,O> Iterable<O> translate(final Iterable<I> input, final Translator<I, O> translator) {
- return new Iterable<O>() {
- public Iterator<O> iterator() {
- return translate(input.iterator(), translator);
- }
- };
- }
-
- /**
- * Run a translation function for each element of a {@code List}, returning an {@code ArrayList}.
- *
- * @param input the input list
- * @param translator the translator
- * @return the translated data
- */
- public static <I,O> ArrayList<O> translate(final List<I> input, final Translator<I, O> translator) {
- final ArrayList<O> output = new ArrayList<O>(input.size());
- for (I item : input) {
- output.add(translator.translate(item));
- }
- return output;
- }
-
- /**
* Create an iterable view of a string split by a given delimiter.
*
* @param delimiter the delimiter
@@ -556,71 +483,6 @@
return true;
}
- public static AttributeMap emptyAttributeMap() {
- return EMPTY_ATTRIBUTE_MAP;
- }
-
- private static final AttributeMap EMPTY_ATTRIBUTE_MAP = new EmptyAttributeMap();
-
- private static final class EmptyAttributeMap implements AttributeMap {
-
- public <T> T get(final AttributeKey<T> key) {
- return null;
- }
-
- public <T> T put(final AttributeKey<T> key, final T value) {
- throw new UnsupportedOperationException("put()");
- }
-
- public <T> T remove(final AttributeKey<T> key) {
- return null;
- }
-
- public <T> boolean remove(final AttributeKey<T> key, final T value) {
- return false;
- }
-
- public <T> T putIfAbsent(final AttributeKey<T> key, final T value) {
- throw new UnsupportedOperationException("putIfAbsent()");
- }
-
- public <T> boolean replace(final AttributeKey<T> key, final T oldValue, final T newValue) {
- return false;
- }
-
- public <T> boolean containsKey(final AttributeKey<T> key) {
- return false;
- }
-
- public <T> boolean containsValue(final T value) {
- return false;
- }
-
- public Iterable<Entry<?>> entries() {
- return emptyIterable();
- }
-
- public Set<AttributeKey<?>> keySet() {
- return Collections.emptySet();
- }
-
- public Collection<?> values() {
- return Collections.emptySet();
- }
-
- public boolean isEmpty() {
- return true;
- }
-
- public int size() {
- return 0;
- }
-
- public void clear() {
- // might as well let it succeed
- }
- }
-
/**
* Get the empty iterable.
*
@@ -853,4 +715,17 @@
public static <T> Iterable<T> combine(final Iterable<? extends T> first, final Iterable<? extends T> second, final Iterable<? extends T> third, final Iterable<? extends T> fourth) {
return combine(combine(first, second), combine(third, fourth));
}
+
+ private static final class DelegateIterable<T> implements Iterable<T> {
+
+ private final Iterable<T> delegate;
+
+ public DelegateIterable(final Iterable<T> delegate) {
+ this.delegate = delegate;
+ }
+
+ public Iterator<T> iterator() {
+ return delegate.iterator();
+ }
+ }
}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/DelegateIterable.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/DelegateIterable.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/DelegateIterable.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,18 +0,0 @@
-package org.jboss.remoting.util;
-
-import java.util.Iterator;
-
-/**
- *
- */
-public final class DelegateIterable<T> implements Iterable<T> {
- private final Iterable<T> delegate;
-
- public DelegateIterable(final Iterable<T> delegate) {
- this.delegate = delegate;
- }
-
- public Iterator<T> iterator() {
- return delegate.iterator();
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/State.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/State.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/State.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,8 +0,0 @@
-package org.jboss.remoting.util;
-
-/**
- *
- */
-public interface State<T extends Enum<T> & State<T>> {
- boolean isReachable(T dest);
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/StateLock.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/StateLock.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/StateLock.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,263 +0,0 @@
-package org.jboss.remoting.util;
-
-/**
- * Lock rules:
- *
- * Shared acquire:
- * - Unlocked
- * or
- * - Shared-locked
- *
- * Exclusive acquire:
- * - Unlocked
- * or
- * - All previously waiting readers have had a chance to lock
- */
-public final class StateLock {
- private static final class ReaderToken {
- private int count;
-
- private ReaderToken(final int count) {
- this.count = count;
- }
- }
-
- private static final String LOCK_NOT_HELD = "Unlock when lock isn't held";
-
- private final Object lock = new Object();
- /**
- * A counter for the readers that will be granted after the next exclusive lock is released.
- *
- * @protectedby {@code lock}
- */
- private ReaderToken nextReaderToken = new ReaderToken(0);
- /**
- * A counter for the readers that must be granted before an exclusive lock can be granted.
- *
- * @protectedby {@code lock}
- */
- private ReaderToken currentReaderToken = new ReaderToken(0);
-
- // @protectedby {@code lock} (writes only)
- private volatile int sharedHolderCount = 0;
- // @protectedby {@code lock} (writes only)
- private volatile boolean exclusive = false;
-
- // @protectedby {@code lock} (all accesses)
- private int serial = 0;
-
- private final ThreadLocal<LockState> localLockState = new ThreadLocal<LockState>();
-
- private void incLocalExclCount() {
- final LockState lockState = localLockState.get();
- if (lockState == null) {
- localLockState.set(new LockState(1, 0));
- } else {
- lockState.exclLevel++;
- }
- }
-
- private boolean decLocalExclCount() {
- final LockState lockState = localLockState.get();
- if (lockState == null || lockState.exclLevel == 0) {
- throw new IllegalMonitorStateException(LOCK_NOT_HELD);
- }
- return --lockState.exclLevel == 0;
- }
-
- private int getLocalExclCount() {
- final LockState lockState = localLockState.get();
- if (lockState == null) {
- return 0;
- } else {
- return lockState.exclLevel;
- }
- }
-
- private void incLocalShrdCount() {
- final LockState lockState = localLockState.get();
- if (lockState == null) {
- localLockState.set(new LockState(0, 1));
- } else {
- lockState.shrdLevel++;
- }
- }
-
- private boolean decLocalShrdCount() {
- final LockState lockState = localLockState.get();
- if (lockState == null || lockState.shrdLevel == 0) {
- throw new IllegalMonitorStateException(LOCK_NOT_HELD);
- }
- return --lockState.shrdLevel == 0;
- }
-
- private int getLocalShrdCount() {
- final LockState lockState = localLockState.get();
- if (lockState == null) {
- return 0;
- } else {
- return lockState.shrdLevel;
- }
- }
-
- public void lockExclusive() {
- if (getLocalExclCount() > 0) {
- incLocalExclCount();
- return;
- }
- if (getLocalShrdCount() > 0) {
- throw new IllegalMonitorStateException("Lock exclusive while shared lock is held");
- }
- synchronized (lock) {
- boolean intr = false;
- try {
- while (exclusive || currentReaderToken.count > 0 || sharedHolderCount > 0) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- intr = true;
- }
- }
- exclusive = true;
- serial++;
- incLocalExclCount();
- return;
- } finally {
- if (intr) Thread.currentThread().interrupt();
- }
- }
- }
-
- public void unlockExclusive() {
- if (! exclusive) {
- throw new IllegalMonitorStateException(LOCK_NOT_HELD);
- }
- if (decLocalExclCount()) {
- synchronized (lock) {
- exclusive = false;
- currentReaderToken = nextReaderToken;
- nextReaderToken = new ReaderToken(0);
- lock.notifyAll();
- }
- }
- }
-
- public void lockShared() {
- if (getLocalShrdCount() > 0) {
- incLocalShrdCount();
- return;
- }
- if (getLocalExclCount() > 0) {
- sharedHolderCount++;
- incLocalShrdCount();
- return;
- }
- synchronized (lock) {
- boolean intr = false;
- try {
- final ReaderToken token = currentReaderToken;
- if (exclusive) {
- token.count++;
- while (exclusive) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- intr = true;
- }
- }
- token.count--;
- }
- sharedHolderCount++;
- incLocalShrdCount();
- return;
- } finally {
- if (intr) Thread.currentThread().interrupt();
- }
- }
- }
-
- public void unlockShared() {
- if (decLocalShrdCount()) {
- synchronized (lock) {
- if (--sharedHolderCount == 0) {
- lock.notifyAll();
- }
- }
- }
- }
-
- public void yieldShared() {
- if (getLocalShrdCount() == 1 && getLocalExclCount() == 0) {
- synchronized (lock) {
- boolean intr = false;
- try {
- final ReaderToken token = nextReaderToken;
- token.count++;
- sharedHolderCount--;
- if (sharedHolderCount == 0) {
- lock.notifyAll();
- }
- final int origSerial = serial;
- while (serial == origSerial || exclusive) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- intr = true;
- }
- }
- token.count--;
- sharedHolderCount++;
- } finally {
- if (intr) Thread.currentThread().interrupt();
- }
- }
- } else {
- throw new IllegalMonitorStateException("May only hold one shared lock to invoke yieldShared()");
- }
- }
-
- public void awaitExclusive() {
- if (getLocalExclCount() == 0) {
- throw new IllegalMonitorStateException("await() called when lock not held");
- }
- synchronized (lock) {
- boolean intr = false;
- try {
- exclusive = false;
- try {
- lock.wait();
- } catch (InterruptedException e) {
- intr = true;
- }
- while (exclusive || currentReaderToken.count > 0 || sharedHolderCount > 0) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- intr = true;
- }
- }
- exclusive = true;
- incLocalExclCount();
- return;
- } finally {
- if (intr) Thread.currentThread().interrupt();
- }
- }
- }
-
- public void signal() {
- synchronized (lock) {
- lock.notifyAll();
- }
- }
-
- private static final class LockState {
- private int exclLevel;
- private int shrdLevel;
-
- private LockState(final int exclLevel, final int shrdLevel) {
- this.exclLevel = exclLevel;
- this.shrdLevel = shrdLevel;
- }
- }
-}
Deleted: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Translator.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Translator.java 2008-10-23 00:50:37 UTC (rev 4614)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/Translator.java 2008-10-23 01:11:53 UTC (rev 4615)
@@ -1,8 +0,0 @@
-package org.jboss.remoting.util;
-
-/**
- *
- */
-public interface Translator<I, O> {
- O translate(I input);
-}
16 years, 2 months
JBoss Remoting SVN: r4614 - in remoting3/trunk: api/src/main/java/org/jboss/remoting and 12 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 20:50:37 -0400 (Wed, 22 Oct 2008)
New Revision: 4614
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientSourceWrapper.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientWrapper.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/EndpointWrapper.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContextWrapper.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RemoteRequestContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/ReplyHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java
Removed:
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/remote/
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/stream/
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/wrapper/
remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferInputStream.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferOutputStream.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferReader.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferWriter.java
remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferInputStreamTestCase.java
remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferOutputStreamTestCase.java
remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferReaderTestCase.java
remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferWriterTestCase.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/service/
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/stream/
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/StreamContextImpl.java
remoting3/trunk/tools/
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java
remoting3/trunk/api/src/main/resources/META-INF/jboss-classloading.xml
remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceExternalizer.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java
remoting3/trunk/core/src/test/java/org/jboss/remoting/core/EndpointTestCase.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicConfiguration.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandlerReplyConsumer.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicProtocol.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicRequestHandler.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerReplyTransmitter.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerRequestConsumer.java
remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/FutureBasicReply.java
remoting3/trunk/protocol/basic/src/test/java/org/jboss/remoting/protocol/basic/BasicTestCase.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java
remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java
remoting3/trunk/transporter/src/main/java/org/jboss/remoting/transporter/Transporter.java
Log:
More major code cleanup
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientSourceWrapper.java (from rev 4601, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/wrapper/ClientSourceWrapper.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientSourceWrapper.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientSourceWrapper.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,50 @@
+package org.jboss.remoting;
+
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ClientSource;
+import java.io.IOException;
+
+/**
+ * A simple delegating wrapper for client sources.
+ *
+ * @param <I> the request type
+ * @param <O> the reply type
+ */
+public class ClientSourceWrapper<I, O> implements ClientSource<I, O> {
+ private final ClientSource<I, O> delegate;
+
+ /**
+ * Construct a new instance. Calls will be sent to the given {@code delegate} by default.
+ *
+ * @param delegate the delegate client instance
+ */
+ protected ClientSourceWrapper(ClientSource<I, O> delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void close() throws IOException {
+ delegate.close();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void addCloseHandler(final CloseHandler<? super ClientSource<I, O>> closeHandler) {
+ delegate.addCloseHandler(new CloseHandler<ClientSource<I, O>>() {
+ public void handleClose(final ClientSource<I, O> closed) {
+ closeHandler.handleClose(ClientSourceWrapper.this);
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public Client<I, O> createClient() throws IOException {
+ return delegate.createClient();
+ }
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientWrapper.java (from rev 4611, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/wrapper/ClientWrapper.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientWrapper.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientWrapper.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,65 @@
+package org.jboss.remoting;
+
+import java.util.concurrent.ConcurrentMap;
+import java.io.IOException;
+import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.Client;
+import org.jboss.xnio.IoFuture;
+
+/**
+ * A simple delegating wrapper for clients.
+ *
+ * @param <I> the request type
+ * @param <O> the reply type
+ */
+public class ClientWrapper<I, O> implements Client<I, O> {
+ protected final Client<I, O> delegate;
+
+ /**
+ * Construct a new instance. Calls will be sent to the given {@code delegate} by default.
+ *
+ * @param delegate the delegate client instance
+ */
+ protected ClientWrapper(final Client<I, O> delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void close() throws IOException {
+ delegate.close();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void addCloseHandler(final CloseHandler<? super Client<I, O>> closeHandler) {
+ delegate.addCloseHandler(new CloseHandler<Client<I, O>>() {
+ public void handleClose(final Client<I, O> closed) {
+ closeHandler.handleClose(ClientWrapper.this);
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public O invoke(final I request) throws IOException {
+ return delegate.invoke(request);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public IoFuture<O> send(final I request) throws IOException {
+ return delegate.send(request);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public ConcurrentMap<Object, Object> getAttributes() {
+ return delegate.getAttributes();
+ }
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -3,9 +3,9 @@
import java.util.concurrent.ConcurrentMap;
import java.net.URI;
import java.io.IOException;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoFuture;
/**
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/EndpointWrapper.java (from rev 4601, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/wrapper/EndpointWrapper.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/EndpointWrapper.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/EndpointWrapper.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,94 @@
+package org.jboss.remoting;
+
+import java.util.concurrent.ConcurrentMap;
+import java.io.IOException;
+import java.net.URI;
+import org.jboss.remoting.Endpoint;
+import org.jboss.remoting.RequestListener;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ClientSource;
+import org.jboss.remoting.SimpleCloseable;
+import org.jboss.remoting.ServiceListener;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.xnio.IoFuture;
+
+/**
+ * A simple delegating wrapper for endpoints.
+ */
+public class EndpointWrapper implements Endpoint {
+ protected final Endpoint delegate;
+
+ /**
+ * Construct a new instance. Calls will be sent to the given {@code delegate} by default.
+ *
+ * @param delegate the delegate client instance
+ */
+ protected EndpointWrapper(final Endpoint delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public ConcurrentMap<Object, Object> getAttributes() {
+ return delegate.getAttributes();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public String getName() {
+ return delegate.getName();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public <I, O> Handle<RequestHandler> createRequestHandler(final RequestListener<I, O> requestListener) throws IOException {
+ return delegate.createRequestHandler(requestListener);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public <I, O> Handle<RequestHandlerSource> createRequestHandlerSource(final RequestListener<I, O> requestListener, final String serviceType, final String groupName) throws IOException {
+ return delegate.createRequestHandlerSource(requestListener, serviceType, groupName);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public <I, O> Client<I, O> createClient(final RequestHandler handler) throws IOException {
+ return delegate.createClient(handler);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public <I, O> ClientSource<I, O> createClientSource(final RequestHandlerSource handlerSource) throws IOException {
+ return delegate.createClientSource(handlerSource);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public <I, O> IoFuture<ClientSource<I, O>> locateService(final URI serviceUri) throws IllegalArgumentException {
+ return delegate.locateService(serviceUri);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public SimpleCloseable registerRemoteService(final String serviceType, final String groupName, final String endpointName, final RequestHandlerSource handlerSource, final int metric) throws IllegalArgumentException, IOException {
+ return delegate.registerRemoteService(serviceType, groupName, endpointName, handlerSource, metric);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public SimpleCloseable addServiceListener(final ServiceListener serviceListener, final boolean onlyNew) {
+ return delegate.addServiceListener(serviceListener, true);
+ }
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContextWrapper.java (from rev 4601, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/wrapper/RequestContextWrapper.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContextWrapper.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContextWrapper.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,73 @@
+package org.jboss.remoting;
+
+import org.jboss.remoting.RequestCancelHandler;
+import org.jboss.remoting.RequestContext;
+import org.jboss.remoting.ClientContext;
+import java.io.IOException;
+
+/**
+ * A simple delegating wrapper for request context instances.
+ *
+ * @param <O> the reply type
+ */
+public class RequestContextWrapper<O> implements RequestContext<O> {
+ protected final RequestContext<O> delegate;
+
+ /**
+ * Construct a new instance. Calls will be sent to the given {@code delegate} by default.
+ *
+ * @param delegate the delegate client instance
+ */
+ protected RequestContextWrapper(final RequestContext<O> delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public ClientContext getContext() {
+ return delegate.getContext();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public boolean isCancelled() {
+ return delegate.isCancelled();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void sendReply(O reply) throws IOException, IllegalStateException {
+ delegate.sendReply(reply);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void sendFailure(String msg, Throwable cause) throws IOException, IllegalStateException {
+ delegate.sendFailure(msg, cause);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void sendCancelled() throws IOException, IllegalStateException {
+ delegate.sendCancelled();
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void addCancelHandler(final RequestCancelHandler<O> requestCancelHandler) {
+ delegate.addCancelHandler(requestCancelHandler);
+ }
+
+ /**
+ * {@inheritDoc} This implementation calls the same method on the delegate object.
+ */
+ public void execute(final Runnable command) {
+ delegate.execute(command);
+ }
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,7 +22,7 @@
package org.jboss.remoting;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
+import org.jboss.remoting.spi.RequestHandlerSource;
/**
* A listener for watching service registrations on an endpoint.
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/AbstractAutoCloseable.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -26,7 +26,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.io.IOException;
import org.jboss.remoting.RemotingException;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.log.Logger;
/**
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java (from rev 4601, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/remote/Handle.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/Handle.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.spi;
+
+import org.jboss.remoting.HandleableCloseable;
+import org.jboss.remoting.CloseHandler;
+import java.io.IOException;
+
+/**
+ * A handle to a local resource.
+ */
+public interface Handle<T> extends HandleableCloseable<Handle<T>> {
+
+ /**
+ * Get the resource.
+ *
+ * @return the resource
+ */
+ T getResource();
+
+ /**
+ * Close this reference.
+ *
+ * @throws IOException if the close failed
+ */
+ void close() throws IOException;
+
+ /**
+ * Add a handler that is invoked when this handle is closed.
+ *
+ * @param handler the handler
+ */
+ void addCloseHandler(final CloseHandler<? super Handle<T>> handler);
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RemoteRequestContext.java (from rev 4601, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/remote/RemoteRequestContext.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RemoteRequestContext.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RemoteRequestContext.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.spi;
+
+/**
+ * The context of an outstanding remote request. This instance should be discarded when a reply (of any sort)
+ * is received for the request.
+ */
+public interface RemoteRequestContext {
+
+ /**
+ * Signal that the request should be cancelled, if possible.
+ */
+ void cancel();
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/ReplyHandler.java (from rev 4607, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/remote/ReplyHandler.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/ReplyHandler.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/ReplyHandler.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.spi;
+
+import java.io.IOException;
+
+/**
+ * A handler for replies from a request. The handler should respect the first invocation made on it, and ignore
+ * any subsequent invocations.
+ */
+public interface ReplyHandler {
+
+ /**
+ * Handle a successful reply. If the reply could not be forwarded, an exception is thrown.
+ *
+ * @param reply the reply
+ */
+ void handleReply(Object reply) throws IOException;
+
+ /**
+ * Handle an exception. If the exception could not be forwarded, a (different) {@code IOException} is thrown.
+ *
+ * @param exception an exception which describes the problem
+ */
+ void handleException(IOException exception) throws IOException;
+
+ /**
+ * Handle a cancellation acknowledgement. If the cancellation acknowledgement could not be forwarded, an
+ * exception is thrown.
+ */
+ void handleCancellation() throws IOException;
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java (from rev 4611, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/remote/RequestHandler.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandler.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.spi;
+
+import org.jboss.remoting.HandleableCloseable;
+import org.jboss.remoting.RemotingException;
+import org.jboss.remoting.CloseHandler;
+import java.io.IOException;
+
+/**
+ * A request handler, which can be passed to remote endpoints. Remote systems can then use the handler
+ * to make invocations, or they may forward a handler on to other remote systems.
+ */
+public interface RequestHandler extends HandleableCloseable<RequestHandler> {
+
+ /**
+ * Receive a request from a remote system. This method is intended to be called by protocol handlers. If the
+ * request cannot be accepted for some reason, the
+ * {@link ReplyHandler#handleException(java.io.IOException)}
+ * method is called immediately.
+ *
+ * @param request the request
+ * @param replyHandler a handler for the reply
+ * @return a context which may be used to cancel the request
+ */
+ RemoteRequestContext receiveRequest(Object request, ReplyHandler replyHandler);
+
+ /**
+ * Get a handle to this request handler. The request handler will not auto-close as long as there is at least
+ * one open handle. If a handle is "leaked", it will be closed
+ * automatically if/when the garbage collector invokes its {@link Object#finalize()} method, with a log message
+ * warning of the leak.
+ *
+ * @return the handle
+ * @throws IOException if a handle could not be acquired
+ */
+ Handle<RequestHandler> getHandle() throws IOException;
+
+ /**
+ * Close this request handler. The outcome of any outstanding requests is not defined, though implementations
+ * should make an effort to cancel any outstanding requests.
+ *
+ * @throws RemotingException if the client endpoint could not be closed
+ */
+ void close() throws IOException;
+
+ /**
+ * Add a handler that is called when the request handler is closed.
+ *
+ * @param handler the handler to be called
+ */
+ void addCloseHandler(final CloseHandler<? super RequestHandler> handler);
+}
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java (from rev 4601, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/remote/RequestHandlerSource.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/RequestHandlerSource.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting.spi;
+
+import org.jboss.remoting.HandleableCloseable;
+import org.jboss.remoting.RemotingException;
+import org.jboss.remoting.CloseHandler;
+import java.io.IOException;
+
+/**
+ * A request handler source, which can be passed to remote endpoints. Remote systems can then use the handler source
+ * to acquire request handlers, or they may pass it on to other systems. Acquiring a request handler using this method
+ * has the advantage that a round trip to the remote side is not necessary; the local side can spawn a request handler
+ * and simply notify the remote side of the change.
+ */
+public interface RequestHandlerSource extends HandleableCloseable<RequestHandlerSource> {
+
+ /**
+ * Create a request handler for the service corresponding to this request handler source.
+ *
+ * @return a request handler
+ * @throws RemotingException if a client could not be opened
+ */
+ Handle<RequestHandler> createRequestHandler() throws IOException;
+
+ /**
+ * Get a handle to this request handler source. The request handler source will not auto-close as long as there is at least
+ * one open handle, or request handler. If a handle is "leaked", it will be closed
+ * automatically if/when the garbage collector invokes its {@link Object#finalize()} method, with a log message
+ * warning of the leak.
+ *
+ * @return the handle
+ * @throws RemotingException if a handle could not be acquired
+ */
+ Handle<RequestHandlerSource> getHandle() throws IOException;
+
+ /**
+ * Close this request handler source immediately.
+ */
+ void close() throws IOException;
+
+ /**
+ * Add a handler that is called when the request handler source is closed.
+ *
+ * @param handler the handler to be called
+ */
+ void addCloseHandler(final CloseHandler<? super RequestHandlerSource> handler);
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/SpiUtils.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,8 +22,8 @@
package org.jboss.remoting.spi;
-import org.jboss.remoting.spi.remote.ReplyHandler;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
import org.jboss.remoting.RequestCancelHandler;
import org.jboss.remoting.RequestContext;
import org.jboss.remoting.CloseHandler;
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferInputStream.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferInputStream.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferInputStream.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import org.jboss.xnio.BufferAllocator;
-import org.jboss.xnio.IoUtils;
-
-/**
- * An input stream that reads from byte buffers. Instances of this class are not safe to use concurrently from
- * multiple threads.
- */
-public final class ByteBufferInputStream extends InputStream {
- private final ObjectSource<ByteBuffer> bufferSource;
- private final BufferAllocator<ByteBuffer> allocator;
-
- private boolean closed;
- private ByteBuffer current;
-
- public ByteBufferInputStream(final ObjectSource<ByteBuffer> bufferSource, final BufferAllocator<ByteBuffer> allocator) {
- this.bufferSource = bufferSource;
- this.allocator = allocator;
- }
-
- public int read() throws IOException {
- if (closed) {
- return -1;
- }
- ByteBuffer buffer = getBuffer();
- if (buffer == null) {
- return -1;
- }
- try {
- return buffer.get() & 0xff;
- } finally {
- if (! buffer.hasRemaining()) {
- current = null;
- allocator.free(buffer);
- }
- }
- }
-
- public int read(final byte[] b, int off, int len) throws IOException {
- if (closed) {
- return -1;
- }
- int t = 0;
- while (len > 0) {
- ByteBuffer buffer = getBuffer();
- if (buffer == null) {
- return t == 0 ? -1 : t;
- }
- final int rem = Math.min(len, buffer.remaining());
- if (rem > 0) {
- buffer.get(b, off, rem);
- off += rem;
- len -= rem;
- t += rem;
- }
- if (! buffer.hasRemaining()) {
- current = null;
- allocator.free(buffer);
- }
- }
- return t;
- }
-
- public int available() throws IOException {
- final ByteBuffer buffer = current;
- return (buffer == null ? 0 : buffer.remaining());
- }
-
- public void close() throws IOException {
- try {
- final ByteBuffer buffer = current;
- current = null;
- if (buffer != null) {
- allocator.free(buffer);
- }
- bufferSource.close();
- } finally {
- closed = true;
- IoUtils.safeClose(bufferSource);
- }
- }
-
- private ByteBuffer getBuffer() throws IOException {
- final ByteBuffer buffer = current;
- if (buffer == null) {
- while (bufferSource.hasNext()) {
- final ByteBuffer newBuffer = bufferSource.next();
- if (newBuffer.hasRemaining()) {
- current = newBuffer;
- return newBuffer;
- } else {
- allocator.free(newBuffer);
- }
- }
- return null;
- } else {
- return buffer;
- }
- }
-}
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferOutputStream.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferOutputStream.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/ByteBufferOutputStream.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,132 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import java.io.OutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import org.jboss.xnio.BufferAllocator;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.Buffers;
-
-/**
- * An output stream that writes to buffers. Instances of this class are not normally safe to use from multiple threads
- * concurrently.
- */
-public final class ByteBufferOutputStream extends OutputStream {
- private final ObjectSink<ByteBuffer> bufferSink;
- private final BufferAllocator<ByteBuffer> allocator;
-
- private ByteBuffer current;
- private boolean closed;
-
- /**
- * Construct a new stream instance.
- *
- * @param bufferSink the buffer sink to which full buffers will be written
- * @param allocator the allocator from which empty buffers will be allocated
- */
- public ByteBufferOutputStream(final ObjectSink<ByteBuffer> bufferSink, final BufferAllocator<ByteBuffer> allocator) {
- this.bufferSink = bufferSink;
- this.allocator = allocator;
- }
-
- private ByteBuffer getBuffer() throws IOException {
- final ByteBuffer buffer = current;
- if (buffer == null) {
- ByteBuffer newbuf = allocator.allocate();
- if (newbuf == null) {
- throw new IOException("No buffers available");
- }
- current = newbuf;
- return newbuf;
- } else {
- return buffer;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void write(final int b) throws IOException {
- if (closed) {
- throw new IOException("Write to closed outputstream");
- }
- final ByteBuffer buffer = getBuffer();
- buffer.put((byte)b);
- if (! buffer.hasRemaining()) {
- localFlush();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void write(final byte[] b, int off, int len) throws IOException {
- if (closed) {
- throw new IOException("Write to closed outputstream");
- }
- do {
- final ByteBuffer buffer = getBuffer();
- final int rem = Math.min(len, buffer.remaining());
- buffer.put(b, off, rem);
- if (! buffer.hasRemaining()) {
- localFlush();
- }
- len -= rem; off += rem;
- } while (len > 0);
- }
-
- private void localFlush() throws IOException {
- if (closed) {
- throw new IOException("Flush on closed outputstream");
- }
- final ByteBuffer buffer = current;
- if (buffer != null) try {
- bufferSink.accept(Buffers.flip(buffer));
- } finally {
- current = null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void flush() throws IOException {
- localFlush();
- bufferSink.flush();
- }
-
- /**
- * {@inheritDoc}
- */
- public void close() throws IOException {
- if (! closed) try {
- flush();
- bufferSink.close();
- } finally {
- closed = true;
- IoUtils.safeClose(bufferSink);
- }
- }
-}
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferReader.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferReader.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferReader.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,166 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.CharBuffer;
-import org.jboss.xnio.BufferAllocator;
-import org.jboss.xnio.IoUtils;
-
-/**
- * A reader that reads from char buffers. Instances of this class are not safe to use concurrently from
- * multiple threads.
- */
-public final class CharBufferReader extends Reader {
- private final ObjectSource<CharBuffer> bufferSource;
- private final BufferAllocator<CharBuffer> allocator;
-
- private boolean closed;
- private CharBuffer current;
-
- public CharBufferReader(final ObjectSource<CharBuffer> bufferSource, final BufferAllocator<CharBuffer> allocator) {
- this.bufferSource = bufferSource;
- this.allocator = allocator;
- }
-
- /**
- * {@inheritDoc}
- */
- public int read() throws IOException {
- if (closed) {
- return -1;
- }
- CharBuffer buffer = getBuffer();
- if (buffer == null) {
- return -1;
- }
- try {
- return buffer.get() & 0xff;
- } finally {
- if (! buffer.hasRemaining()) {
- current = null;
- allocator.free(buffer);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int read(final char[] cbuf, int off, int len) throws IOException {
- if (closed) {
- return -1;
- }
- int t = 0;
- while (len > 0) {
- CharBuffer buffer = getBuffer();
- if (buffer == null) {
- return t == 0 ? -1 : t;
- }
- final int rem = Math.min(len, buffer.remaining());
- if (rem > 0) {
- buffer.get(cbuf, off, rem);
- off += rem;
- len -= rem;
- t += rem;
- }
- if (! buffer.hasRemaining()) {
- current = null;
- allocator.free(buffer);
- }
- }
- return t;
- }
-
- /**
- * {@inheritDoc}
- */
- public void close() throws IOException {
- try {
- final CharBuffer buffer = current;
- current = null;
- if (buffer != null) {
- allocator.free(buffer);
- }
- bufferSource.close();
- } finally {
- closed = true;
- IoUtils.safeClose(bufferSource);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int read(final CharBuffer target) throws IOException {
- if (closed) {
- return -1;
- }
- int t = 0;
- int len = target.remaining();
- while (len > 0) {
- CharBuffer buffer = getBuffer();
- if (buffer == null) {
- return t == 0 ? -1 : t;
- }
- final int rem = Math.min(len, buffer.remaining());
- if (rem > 0) {
- buffer.read(target);
- len -= rem;
- t += rem;
- }
- if (! buffer.hasRemaining()) {
- current = null;
- allocator.free(buffer);
- }
- }
- return t;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean ready() throws IOException {
- final CharBuffer buffer = current;
- return buffer != null && buffer.hasRemaining();
- }
-
- private CharBuffer getBuffer() throws IOException {
- final CharBuffer buffer = current;
- if (buffer == null) {
- while (bufferSource.hasNext()) {
- final CharBuffer newBuffer = bufferSource.next();
- if (newBuffer.hasRemaining()) {
- current = newBuffer;
- return newBuffer;
- } else {
- allocator.free(newBuffer);
- }
- }
- return null;
- } else {
- return buffer;
- }
- }
-}
\ No newline at end of file
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferWriter.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferWriter.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/stream/CharBufferWriter.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.CharBuffer;
-import org.jboss.xnio.BufferAllocator;
-import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.Buffers;
-
-/**
- * A writer that writes to buffers. Instances of this class are not normally safe to use from multiple threads
- * concurrently.
- */
-public final class CharBufferWriter extends Writer {
- private final ObjectSink<CharBuffer> bufferSink;
- private final BufferAllocator<CharBuffer> allocator;
-
- private CharBuffer current;
- private boolean closed;
-
- /**
- * Construct a new stream instance.
- *
- * @param bufferSink the buffer sink to which full buffers will be written
- * @param allocator the allocator from which empty buffers will be allocated
- */
- public CharBufferWriter(final ObjectSink<CharBuffer> bufferSink, final BufferAllocator<CharBuffer> allocator) {
- this.bufferSink = bufferSink;
- this.allocator = allocator;
- }
-
- private CharBuffer getBuffer() throws IOException {
- final CharBuffer buffer = current;
- if (buffer == null) {
- CharBuffer newbuf = allocator.allocate();
- if (newbuf == null) {
- throw new IOException("No buffers available");
- }
- current = newbuf;
- return newbuf;
- } else {
- return buffer;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void write(final int b) throws IOException {
- if (closed) {
- throw new IOException("Write to closed writer");
- }
- final CharBuffer buffer = getBuffer();
- buffer.put((char)b);
- if (! buffer.hasRemaining()) {
- localFlush();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void write(final char[] b, int off, int len) throws IOException {
- if (closed) {
- throw new IOException("Write to closed writer");
- }
- do {
- final CharBuffer buffer = getBuffer();
- final int rem = Math.min(len, buffer.remaining());
- buffer.put(b, off, rem);
- if (! buffer.hasRemaining()) {
- localFlush();
- }
- len -= rem; off += rem;
- } while (len > 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public void write(final String str, int off, int len) throws IOException {
- if (closed) {
- throw new IOException("Write to closed writer");
- }
- do {
- final CharBuffer buffer = getBuffer();
- final int rem = Math.min(len, buffer.remaining());
- buffer.put(str, off, off + rem);
- if (! buffer.hasRemaining()) {
- localFlush();
- }
- len -= rem; off += rem;
- } while (len > 0);
- }
-
- /**
- * {@inheritDoc}
- */
- public void flush() throws IOException {
- localFlush();
- bufferSink.flush();
- }
-
- /**
- * {@inheritDoc}
- */
- public void close() throws IOException {
- if (! closed) try {
- flush();
- bufferSink.close();
- } finally {
- closed = true;
- IoUtils.safeClose(bufferSink);
- }
- }
-
- private void localFlush() throws IOException {
- if (closed) {
- throw new IOException("Flush on closed writer");
- }
- final CharBuffer buffer = current;
- if (buffer != null) try {
- bufferSink.accept(Buffers.flip(buffer));
- } finally {
- current = null;
- }
- }
-}
\ No newline at end of file
Modified: remoting3/trunk/api/src/main/resources/META-INF/jboss-classloading.xml
===================================================================
--- remoting3/trunk/api/src/main/resources/META-INF/jboss-classloading.xml 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/main/resources/META-INF/jboss-classloading.xml 2008-10-23 00:50:37 UTC (rev 4614)
@@ -4,9 +4,6 @@
<capabilities>
<package name="org.jboss.remoting" version="3.0.0"/>
<package name="org.jboss.remoting.spi" version="3.0.0"/>
- <package name="org.jboss.remoting.spi.remote" version="3.0.0"/>
- <package name="org.jboss.remoting.spi.stream" version="3.0.0"/>
- <package name="org.jboss.remoting.spi.wrapper" version="3.0.0"/>
<package name="org.jboss.remoting.stream" version="3.0.0"/>
</capabilities>
<requirements>
Modified: remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/CloseableTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -31,7 +31,7 @@
import org.jboss.xnio.IoUtils;
import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.test.support.LoggingHelper;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.Handle;
/**
*
Deleted: remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferInputStreamTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferInputStreamTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferInputStreamTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import junit.framework.TestCase;
-import java.util.Arrays;
-import java.nio.ByteBuffer;
-import org.jboss.remoting.test.support.TestByteBufferAllocator;
-import org.jboss.remoting.test.support.LoggingHelper;
-
-/**
- *
- */
-public final class ByteBufferInputStreamTestCase extends TestCase {
- static {
- LoggingHelper.init();
- }
-
- public void testBasic() throws Throwable {
- final TestByteBufferAllocator allocator = new TestByteBufferAllocator(3);
- final ByteBufferInputStream stream = new ByteBufferInputStream(Streams.<ByteBuffer>getIteratorObjectSource(Arrays.<ByteBuffer>asList(
- ByteBuffer.wrap(new byte[] { 5, 100, 30, 12, -60, 25 }),
- ByteBuffer.wrap(new byte[] { 15 }),
- ByteBuffer.wrap(new byte[] { }),
- ByteBuffer.wrap(new byte[] { 100, 0, 0, -128, 127, 0 })).iterator()), allocator);
- assertEquals(5, stream.read());
- assertEquals(100, stream.read());
- assertEquals(30, stream.read());
- assertEquals(12, stream.read());
- assertEquals(-60 & 0xff, stream.read());
- assertEquals(25, stream.read());
- assertEquals(15, stream.read());
- assertEquals(100, stream.read());
- assertEquals(0, stream.read());
- assertEquals(0, stream.read());
- assertEquals(-128 & 0xff, stream.read());
- assertEquals(127, stream.read());
- assertEquals(0, stream.read());
- assertEquals(-1, stream.read());
- assertEquals(-1, stream.read());
- // I fed it four buffers, so there should be -4
- allocator.check(-4);
- }
-
- public void testArrayRead() throws Throwable {
- final TestByteBufferAllocator allocator = new TestByteBufferAllocator(3);
- final ByteBufferInputStream stream = new ByteBufferInputStream(Streams.<ByteBuffer>getIteratorObjectSource(Arrays.<ByteBuffer>asList(
- ByteBuffer.wrap(new byte[] { 5, 100, 30, 12, -60, 25 }),
- ByteBuffer.wrap(new byte[] { 15 }),
- ByteBuffer.wrap(new byte[] { }),
- ByteBuffer.wrap(new byte[] { 100, 0, 0, -128, 127, 0 })).iterator()), allocator);
- assertEquals(5, stream.read());
- assertEquals(100, stream.read());
- assertEquals(30, stream.read());
- byte[] bytes = new byte[5];
- assertEquals(5, stream.read(bytes));
- assertTrue(Arrays.equals(new byte[] { 12, -60, 25, 15, 100 }, bytes));
- assertEquals(0, stream.read());
- bytes = new byte[15];
- Arrays.fill(bytes, (byte) 7);
- assertEquals(3, stream.read(bytes, 4, 3));
- assertTrue(Arrays.equals(new byte[] { 7, 7, 7, 7, 0, -128, 127, 7, 7, 7, 7, 7, 7, 7, 7 }, bytes));
- assertEquals(0, stream.read());
- assertEquals(-1, stream.read());
- assertEquals(-1, stream.read());
- // I fed it four buffers, so there should be -4
- allocator.check(-4);
- }
-}
Deleted: remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferOutputStreamTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferOutputStreamTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/ByteBufferOutputStreamTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import junit.framework.TestCase;
-import org.jboss.remoting.test.support.TestByteBufferAllocator;
-import org.jboss.remoting.test.support.LoggingHelper;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- */
-public final class ByteBufferOutputStreamTestCase extends TestCase {
- static {
- LoggingHelper.init();
- }
-
- public void testBasic() throws Throwable {
- final TestByteBufferAllocator allocator = new TestByteBufferAllocator(4);
- final List<ByteBuffer> list = new ArrayList<ByteBuffer>();
- final ObjectSink<ByteBuffer> sink = Streams.getCollectionObjectSink(list);
- final ByteBufferOutputStream stream = new ByteBufferOutputStream(sink, allocator);
- stream.write(new byte[] { 6, 1, 5, 2, 4, 3, 2, 4, 1, 5, 0, 6 });
- stream.write(new byte[0]);
- stream.write(new byte[] { 4, 5, 6, 45, -20, 0, 0, 1, 12, 13, 19, 34 }, 3, 7);
- stream.write(new byte[] { 45, -20, 0, 0, 1, 12, 13 }, 4, 0);
- stream.write(0);
- stream.write(10);
- stream.flush();
- stream.close();
- final ByteBufferInputStream inputStream = new ByteBufferInputStream(Streams.getIteratorObjectSource(list.iterator()), allocator);
- assertEquals(6, inputStream.read());
- assertEquals(1, inputStream.read());
- assertEquals(5, inputStream.read());
- assertEquals(2, inputStream.read());
- assertEquals(4, inputStream.read());
- assertEquals(3, inputStream.read());
- assertEquals(2, inputStream.read());
- assertEquals(4, inputStream.read());
- assertEquals(1, inputStream.read());
- assertEquals(5, inputStream.read());
- assertEquals(0, inputStream.read());
- assertEquals(6, inputStream.read());
- assertEquals(45, inputStream.read());
- assertEquals(-20 & 0xff, inputStream.read());
- assertEquals(0, inputStream.read());
- assertEquals(0, inputStream.read());
- assertEquals(1, inputStream.read());
- assertEquals(12, inputStream.read());
- assertEquals(13, inputStream.read());
- assertEquals(0, inputStream.read());
- assertEquals(10, inputStream.read());
- assertEquals(-1, inputStream.read());
- inputStream.close();
- allocator.check(0);
- }
-}
Deleted: remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferReaderTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferReaderTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferReaderTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import junit.framework.TestCase;
-import org.jboss.remoting.test.support.TestCharBufferAllocator;
-import org.jboss.remoting.test.support.LoggingHelper;
-import java.util.Arrays;
-import java.nio.CharBuffer;
-
-/**
- *
- */
-public final class CharBufferReaderTestCase extends TestCase {
- static {
- LoggingHelper.init();
- }
-
- public void testBasic() throws Throwable {
- final TestCharBufferAllocator allocator = new TestCharBufferAllocator(10);
- final ObjectSource<CharBuffer> source = Streams.getIteratorObjectSource(Arrays.asList(
- CharBuffer.wrap("The quick brown "),
- CharBuffer.wrap("fox j"),
- CharBuffer.wrap("u"),
- CharBuffer.allocate(0),
- CharBuffer.wrap("mps over the la"),
- CharBuffer.wrap("zy dogs.")
- ).iterator());
- CharBufferReader reader = new CharBufferReader(source, allocator);
- String s = "The quick brown fox jumps over the lazy dogs.";
- for (int i = 0; i < s.length(); i ++) {
- assertEquals(s.charAt(i), reader.read());
- }
- assertEquals(-1, reader.read());
- allocator.check(-6);
- }
-}
Deleted: remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferWriterTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferWriterTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/stream/CharBufferWriterTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.stream;
-
-import junit.framework.TestCase;
-import java.util.ArrayList;
-import java.util.List;
-import java.nio.CharBuffer;
-import org.jboss.remoting.test.support.TestCharBufferAllocator;
-import org.jboss.remoting.test.support.LoggingHelper;
-
-/**
- *
- */
-public final class CharBufferWriterTestCase extends TestCase {
- static {
- LoggingHelper.init();
- }
-
- public void testBasic() throws Throwable {
- final TestCharBufferAllocator allocator = new TestCharBufferAllocator(7);
- final List<CharBuffer> list = new ArrayList<CharBuffer>();
- final ObjectSink<CharBuffer> sink = Streams.getCollectionObjectSink(list);
- final CharBufferWriter writer = new CharBufferWriter(sink, allocator);
- writer.append("Th");
- writer.append("blah e qui blah", 5, 10);
- writer.append('c');
- writer.write('k');
- writer.write(new char[] { ' ', 'b', 'r' });
- writer.write(new char[] { 'x', 'x', 'o', 'w', 'n', ' ', 'x' }, 2, 4);
- writer.write("fox jumps");
- writer.write("blah over the lazy dogs. blah", 4, 20);
- writer.flush();
- writer.close();
- final ObjectSource<CharBuffer> source = Streams.getIteratorObjectSource(list.iterator());
- CharBufferReader reader = new CharBufferReader(source, allocator);
- String s = "The quick brown fox jumps over the lazy dogs.";
- for (int i = 0; i < s.length(); i ++) {
- assertEquals("position = " + i, (char)s.charAt(i), (char)reader.read());
- }
- assertEquals(-1, reader.read());
- allocator.check(0);
- }
-}
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientExternalizer.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -24,7 +24,7 @@
import org.jboss.marshalling.Externalizer;
import org.jboss.marshalling.Creator;
-import org.jboss.remoting.spi.remote.RequestHandler;
+import org.jboss.remoting.spi.RequestHandler;
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientImpl.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -25,10 +25,10 @@
import org.jboss.remoting.Client;
import org.jboss.remoting.IndeterminateOutcomeException;
import org.jboss.remoting.core.util.QueueExecutor;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.ReplyHandler;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoFuture;
import java.util.concurrent.Executor;
import java.io.IOException;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceExternalizer.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceExternalizer.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceExternalizer.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -27,7 +27,7 @@
import java.io.ObjectOutput;
import org.jboss.marshalling.Creator;
import org.jboss.marshalling.Externalizer;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
+import org.jboss.remoting.spi.RequestHandlerSource;
/**
*
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ClientSourceImpl.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -25,9 +25,9 @@
import org.jboss.remoting.ClientSource;
import org.jboss.remoting.Client;
import org.jboss.remoting.Endpoint;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.AbstractHandleableCloseable;
import org.jboss.xnio.IoUtils;
import java.io.IOException;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -19,9 +19,9 @@
import org.jboss.remoting.SimpleCloseable;
import org.jboss.remoting.ServiceListener;
import org.jboss.remoting.util.OrderedExecutorFactory;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.AbstractSimpleCloseable;
import org.jboss.remoting.util.CollectionUtil;
import org.jboss.remoting.util.NamingThreadFactory;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/FutureReplyImpl.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,8 +22,8 @@
package org.jboss.remoting.core;
-import org.jboss.remoting.spi.remote.ReplyHandler;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
import org.jboss.xnio.AbstractIoFuture;
import org.jboss.xnio.IoFuture;
import java.util.concurrent.Executor;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandler.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,9 +22,9 @@
package org.jboss.remoting.core;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
-import org.jboss.remoting.spi.remote.ReplyHandler;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
import org.jboss.remoting.spi.SpiUtils;
import org.jboss.remoting.spi.AbstractAutoCloseable;
import org.jboss.remoting.RequestListener;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/LocalRequestHandlerSource.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,9 +22,9 @@
package org.jboss.remoting.core;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.AbstractAutoCloseable;
import org.jboss.remoting.RequestListener;
import org.jboss.remoting.CloseHandler;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -28,7 +28,7 @@
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.RemoteReplyException;
import org.jboss.remoting.IndeterminateOutcomeException;
-import org.jboss.remoting.spi.remote.ReplyHandler;
+import org.jboss.remoting.spi.ReplyHandler;
import org.jboss.remoting.spi.SpiUtils;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/ServiceRegistration.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,7 +22,7 @@
package org.jboss.remoting.core;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
+import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.SimpleCloseable;
/**
Modified: remoting3/trunk/core/src/test/java/org/jboss/remoting/core/EndpointTestCase.java
===================================================================
--- remoting3/trunk/core/src/test/java/org/jboss/remoting/core/EndpointTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/core/src/test/java/org/jboss/remoting/core/EndpointTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -34,8 +34,8 @@
import org.jboss.remoting.CloseHandler;
import org.jboss.remoting.Client;
import org.jboss.remoting.test.support.LoggingHelper;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoUtils;
/**
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicConfiguration.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicConfiguration.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicConfiguration.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -25,7 +25,6 @@
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Configuration;
import org.jboss.xnio.BufferAllocator;
-import org.jboss.remoting.spi.stream.StreamDetector;
import java.util.concurrent.Executor;
import java.nio.ByteBuffer;
@@ -38,7 +37,6 @@
private int linkMetric;
private Executor executor;
private BufferAllocator<ByteBuffer> allocator;
- private StreamDetector streamDetector;
public MarshallerFactory getMarshallerFactory() {
return marshallerFactory;
@@ -79,12 +77,4 @@
public void setAllocator(final BufferAllocator<ByteBuffer> allocator) {
this.allocator = allocator;
}
-
- public StreamDetector getStreamDetector() {
- return streamDetector;
- }
-
- public void setStreamDetector(final StreamDetector streamDetector) {
- this.streamDetector = streamDetector;
- }
}
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandlerReplyConsumer.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandlerReplyConsumer.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandlerReplyConsumer.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -30,7 +30,7 @@
import org.jboss.xnio.channels.StreamChannel;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
-import org.jboss.remoting.spi.remote.ReplyHandler;
+import org.jboss.remoting.spi.ReplyHandler;
import org.jboss.remoting.spi.SpiUtils;
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.ReplyException;
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicProtocol.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicProtocol.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicProtocol.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,9 +22,9 @@
package org.jboss.remoting.protocol.basic;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.ReplyHandler;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.channels.StreamChannel;
import org.jboss.xnio.channels.ChannelOutputStream;
import org.jboss.xnio.channels.ChannelInputStream;
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicRequestHandler.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicRequestHandler.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicRequestHandler.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -22,9 +22,9 @@
package org.jboss.remoting.protocol.basic;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.ReplyHandler;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
import org.jboss.remoting.spi.SpiUtils;
import org.jboss.remoting.spi.AbstractAutoCloseable;
import org.jboss.marshalling.Marshaller;
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerReplyTransmitter.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerReplyTransmitter.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerReplyTransmitter.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -27,8 +27,8 @@
import org.jboss.xnio.channels.StreamChannel;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.Handle;
/**
*
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerRequestConsumer.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerRequestConsumer.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicServerRequestConsumer.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -23,10 +23,10 @@
package org.jboss.remoting.protocol.basic;
import org.jboss.marshalling.Unmarshaller;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.Handle;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
-import org.jboss.remoting.spi.remote.ReplyHandler;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
import org.jboss.xnio.channels.StreamChannel;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/FutureBasicReply.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/FutureBasicReply.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/FutureBasicReply.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -24,7 +24,7 @@
import org.jboss.xnio.AbstractIoFuture;
import org.jboss.xnio.IoFuture;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
+import org.jboss.remoting.spi.RemoteRequestContext;
import java.io.IOException;
/**
Modified: remoting3/trunk/protocol/basic/src/test/java/org/jboss/remoting/protocol/basic/BasicTestCase.java
===================================================================
--- remoting3/trunk/protocol/basic/src/test/java/org/jboss/remoting/protocol/basic/BasicTestCase.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/basic/src/test/java/org/jboss/remoting/protocol/basic/BasicTestCase.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -38,10 +38,9 @@
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.Client;
import org.jboss.remoting.test.support.LoggingHelper;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.Handle;
import org.jboss.marshalling.Configuration;
-import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.LinkedBlockingQueue;
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexHandler.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -23,24 +23,17 @@
package org.jboss.remoting.protocol.multiplex;
import org.jboss.xnio.channels.AllocatedMessageChannel;
-import org.jboss.xnio.channels.StreamChannel;
import org.jboss.xnio.IoHandler;
import org.jboss.xnio.BufferAllocator;
import org.jboss.xnio.IoUtils;
-import org.jboss.xnio.IoFuture;
-import org.jboss.xnio.Connector;
-import org.jboss.xnio.Acceptor;
import org.jboss.xnio.log.Logger;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.ReplyHandler;
-import org.jboss.remoting.spi.remote.RemoteRequestContext;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.SpiUtils;
import org.jboss.remoting.spi.AbstractAutoCloseable;
-import org.jboss.remoting.spi.stream.StreamDetector;
-import org.jboss.remoting.spi.stream.StreamSerializerFactory;
-import org.jboss.remoting.spi.stream.StreamProvider;
import static org.jboss.remoting.util.CollectionUtil.concurrentIntegerMap;
import org.jboss.remoting.util.CollectionUtil;
import org.jboss.remoting.util.ConcurrentIntegerMap;
@@ -84,11 +77,6 @@
private final Executor executor;
// buffer allocator for outbound message assembly
private final BufferAllocator<ByteBuffer> allocator;
- private final StreamDetector streamDetector;
- private final Connector<A, AllocatedMessageChannel> messageConnector;
- private final Acceptor<A, AllocatedMessageChannel> messageAcceptor;
- private final Connector<A, StreamChannel> streamConnector;
- private final Acceptor<A, StreamChannel> streamAcceptor;
// running on remote node
private final ConcurrentIntegerMap<ReplyHandler> remoteRequests = concurrentIntegerMap();
@@ -119,18 +107,13 @@
private volatile AllocatedMessageChannel channel;
- public MultiplexHandler(final Endpoint endpoint, final RemotingChannelConfiguration configuration, final StreamProvider<A> streamProvider) {
+ public MultiplexHandler(final Endpoint endpoint, final RemotingChannelConfiguration configuration) {
this.endpoint = endpoint;
- messageConnector = streamProvider.getMessageChannelConnector();
- messageAcceptor = streamProvider.getMessageChannelAcceptor();
- streamConnector = streamProvider.getStreamChannelConnector();
- streamAcceptor = streamProvider.getStreamChannelAcceptor();
allocator = configuration.getAllocator();
executor = configuration.getExecutor();
marshallerFactory = configuration.getMarshallerFactory();
marshallingConfiguration = configuration.getMarshallingConfiguration();
linkMetric = configuration.getLinkMetric();
- streamDetector = configuration.getStreamDetector();
}
public void handleOpened(final AllocatedMessageChannel channel) {
@@ -805,13 +788,6 @@
final RequestHandlerSource requestHandlerSource = (RequestHandlerSource) o;
} else {
- final StreamSerializerFactory ssf = streamDetector.detectStream(o);
- if (ssf != null) {
- final IoHandler<? super AllocatedMessageChannel> streamHandler = ssf.getLocalSide(o, new StreamContextImpl(executor, marshallerFactory, marshallingConfiguration));
- // todo - this should really be the "server" side
- final IoFuture<AllocatedMessageChannel> futureChannel = messageConnector.connectTo(null, streamHandler);
-
- }
}
return null;
}
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexProtocol.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -25,9 +25,8 @@
import org.jboss.remoting.RemotingException;
import org.jboss.remoting.SimpleCloseable;
import org.jboss.remoting.Endpoint;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.Handle;
-import org.jboss.remoting.spi.stream.StreamProvider;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoHandlerFactory;
import org.jboss.xnio.ChannelSource;
import org.jboss.xnio.IoFuture;
@@ -53,19 +52,17 @@
/**
* Create a request server for the multiplex protocol.
*
- * @param executor the executor to use for invocations
+ * @return a handler factory for passing to an XNIO server @param executor the executor to use for invocations
* @param allocator the buffer allocator to use
- * @return a handler factory for passing to an XNIO server
- * @param <A> stream channel address type
*/
- public static <A> IoHandlerFactory<AllocatedMessageChannel> createServer(final Endpoint endpoint, final Executor executor, final BufferAllocator<ByteBuffer> allocator, final StreamProvider<A> streamProvider) {
+ public static <A> IoHandlerFactory<AllocatedMessageChannel> createServer(final Endpoint endpoint, final Executor executor, final BufferAllocator<ByteBuffer> allocator) {
return new IoHandlerFactory<AllocatedMessageChannel>() {
public IoHandler<? super AllocatedMessageChannel> createHandler() {
final RemotingChannelConfiguration configuration = new RemotingChannelConfiguration();
configuration.setAllocator(allocator);
configuration.setExecutor(executor);
// todo marshaller factory... etc
- return new MultiplexHandler<A>(endpoint, configuration, streamProvider);
+ return new MultiplexHandler<A>(endpoint, configuration);
}
};
}
@@ -74,17 +71,15 @@
* Create a request client for the multiplex protocol.
*
* @return a handle which may be used to close the connection
- * @throws IOException if an error occurs @param executor the executor to use for invocations
- * @param channelSource the XNIO channel source to use to establish the connection
+ * @throws IOException if an error occurs @param executor the executor to use for invocations @param channelSource the XNIO channel source to use to establish the connection
* @param allocator the buffer allocator to use
- * @param streamProvider
*/
- public static <A> IoFuture<SimpleCloseable> connect(final Endpoint endpoint, final Executor executor, final ChannelSource<AllocatedMessageChannel> channelSource, final BufferAllocator<ByteBuffer> allocator, final StreamProvider<A> streamProvider) throws IOException {
+ public static <A> IoFuture<SimpleCloseable> connect(final Endpoint endpoint, final Executor executor, final ChannelSource<AllocatedMessageChannel> channelSource, final BufferAllocator<ByteBuffer> allocator) throws IOException {
final RemotingChannelConfiguration configuration = new RemotingChannelConfiguration();
configuration.setAllocator(allocator);
configuration.setExecutor(executor);
// todo marshaller factory... etc
- final MultiplexHandler<A> multiplexHandler = new MultiplexHandler<A>(endpoint, configuration, streamProvider);
+ final MultiplexHandler<A> multiplexHandler = new MultiplexHandler<A>(endpoint, configuration);
final IoFuture<AllocatedMessageChannel> futureChannel = channelSource.open(multiplexHandler);
return new AbstractConvertingIoFuture<SimpleCloseable, AllocatedMessageChannel>(futureChannel) {
protected SimpleCloseable convert(final AllocatedMessageChannel channel) throws RemotingException {
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/RemotingChannelConfiguration.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -27,7 +27,6 @@
import org.jboss.xnio.BufferAllocator;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Configuration;
-import org.jboss.remoting.spi.stream.StreamDetector;
/**
*
@@ -38,7 +37,6 @@
private int linkMetric;
private Executor executor;
private BufferAllocator<ByteBuffer> allocator;
- private StreamDetector streamDetector;
public RemotingChannelConfiguration() {
}
@@ -82,12 +80,4 @@
public void setAllocator(final BufferAllocator<ByteBuffer> allocator) {
this.allocator = allocator;
}
-
- public StreamDetector getStreamDetector() {
- return streamDetector;
- }
-
- public void setStreamDetector(final StreamDetector streamDetector) {
- this.streamDetector = streamDetector;
- }
}
Deleted: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/StreamContextImpl.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/StreamContextImpl.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/StreamContextImpl.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.remoting.protocol.multiplex;
-
-import org.jboss.remoting.spi.stream.StreamContext;
-import org.jboss.marshalling.Marshaller;
-import org.jboss.marshalling.Unmarshaller;
-import org.jboss.marshalling.Configuration;
-import org.jboss.marshalling.MarshallerFactory;
-import java.util.concurrent.Executor;
-import java.io.IOException;
-
-/**
- *
- */
-public final class StreamContextImpl implements StreamContext {
-
- private final Executor executor;
- private final MarshallerFactory marshallerFactory;
- private final Configuration marshallerConfiguration;
-
- StreamContextImpl(final Executor executor, final MarshallerFactory marshallerFactory, final Configuration marshallerConfiguration) {
- this.executor = executor;
- this.marshallerFactory = marshallerFactory;
- this.marshallerConfiguration = marshallerConfiguration;
- }
-
- public Executor getExecutor() {
- return executor;
- }
-
- public Marshaller createMarshaller() throws IOException {
- return marshallerFactory.createMarshaller(marshallerConfiguration);
- }
-
- public Unmarshaller createUnmarshaller() throws IOException {
- return marshallerFactory.createUnmarshaller(marshallerConfiguration);
- }
-}
Modified: remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java
===================================================================
--- remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -2,9 +2,9 @@
import java.io.IOException;
import org.jboss.remoting.core.EndpointImpl;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.RequestHandlerSource;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoUtils;
/**
Modified: remoting3/trunk/transporter/src/main/java/org/jboss/remoting/transporter/Transporter.java
===================================================================
--- remoting3/trunk/transporter/src/main/java/org/jboss/remoting/transporter/Transporter.java 2008-10-23 00:14:24 UTC (rev 4613)
+++ remoting3/trunk/transporter/src/main/java/org/jboss/remoting/transporter/Transporter.java 2008-10-23 00:50:37 UTC (rev 4614)
@@ -24,8 +24,8 @@
import org.jboss.remoting.Endpoint;
import org.jboss.remoting.Client;
-import org.jboss.remoting.spi.remote.RequestHandler;
-import org.jboss.remoting.spi.remote.Handle;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoUtils;
import java.io.IOException;
import java.lang.reflect.Proxy;
16 years, 2 months
JBoss Remoting SVN: r4613 - remoting3/trunk/api/src/main/java/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 20:14:24 -0400 (Wed, 22 Oct 2008)
New Revision: 4613
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java
Log:
small clarification (javadoc)
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java 2008-10-23 00:12:05 UTC (rev 4612)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java 2008-10-23 00:14:24 UTC (rev 4613)
@@ -35,7 +35,7 @@
* locally, a {@code ReplyException} is thrown. In this case the operation is known to have completed without error
* but the actual detailed reply cannot be known. In cases where the reply would be ignored anyway, this exception
* type may be safely ignored (possibly logging it for informational purposes). This exception is typically caused
- * by an {@code ObjectStreamException} thrown while marshalling the reply, though other causes are also possible.
+ * by an {@code ObjectStreamException} thrown while unmarshalling the reply, though other causes are also possible.
* <p/>
* If the result of the operation is known to be impossible to ascertain, then an {@code IndeterminateOutcomeException}
* is thrown. Possible causes of this condition include (but are not limited to) the connection to the remote side
16 years, 2 months
JBoss Remoting SVN: r4612 - remoting3/trunk/core/src/main/java/org/jboss/remoting/core.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-10-22 20:12:05 -0400 (Wed, 22 Oct 2008)
New Revision: 4612
Modified:
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java
Log:
More post oneway cleanup
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java 2008-10-23 00:10:17 UTC (rev 4611)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/RequestContextImpl.java 2008-10-23 00:12:05 UTC (rev 4612)
@@ -60,14 +60,6 @@
executor = new RequestListenerExecutor(clientContext.getExecutor(), this);
}
- // todo - used by one-way requests... :|
- RequestContextImpl(final ClientContextImpl clientContext) {
- this.clientContext = clientContext;
- //noinspection ThisEscapedInObjectConstruction
- executor = new RequestListenerExecutor(clientContext.getExecutor(), this);
- replyHandler = null;
- }
-
public ClientContext getContext() {
return clientContext;
}
@@ -80,12 +72,12 @@
public void sendReply(final O reply) throws IOException, IllegalStateException {
if (! closed.getAndSet(true)) {
- if (replyHandler != null) try {
+ try {
replyHandler.handleReply(reply);
} catch (IOException e) {
SpiUtils.safeHandleException(replyHandler, new RemoteReplyException("Remote reply failed", e));
throw e;
- } else throw new IllegalStateException("Cannot send a reply to a one-way invocation");
+ }
} else {
throw new IllegalStateException("Reply already sent");
}
@@ -93,9 +85,7 @@
public void sendFailure(final String msg, final Throwable cause) throws IOException, IllegalStateException {
if (! closed.getAndSet(true)) {
- if (replyHandler != null) {
- replyHandler.handleException(new RemoteExecutionException(msg, cause));
- } else throw new IllegalStateException("Cannot send a reply to a one-way invocation");
+ replyHandler.handleException(new RemoteExecutionException(msg, cause));
} else {
throw new IllegalStateException("Reply already sent");
}
@@ -103,12 +93,12 @@
public void sendCancelled() throws IOException, IllegalStateException {
if (! closed.getAndSet(true)) {
- if (replyHandler != null) try {
+ try {
replyHandler.handleCancellation();
} catch (IOException e) {
// this is highly unlikely to succeed
SpiUtils.safeHandleException(replyHandler, new RemoteReplyException("Remote cancellation acknowledgement failed", e));
- } else throw new IllegalStateException("Cannot send a reply to a one-way invocation");
+ }
} else {
throw new IllegalStateException("Reply already sent");
}
16 years, 2 months