You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2006/09/01 08:27:44 UTC
svn commit: r439204 - in /incubator/activemq/trunk:
activemq-core/src/main/java/org/apache/activemq/transport/activeio/
activemq-core/src/main/resources/META-INF/services/org/apache/activemq/transport/
activemq-core/src/test/java/org/apache/activemq/co...
Author: chirino
Date: Thu Aug 31 23:27:42 2006
New Revision: 439204
URL: http://svn.apache.org/viewvc?rev=439204&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQ-907
Added:
incubator/activemq/trunk/sandbox/activemq-activeio-transport/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/pom.xml (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransport.java (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportFactory.java (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportServer.java (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActivityMonitor.java (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/AsyncChannelToAsyncCommandChannel.java
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/PacketAggregatingAsyncChannel.java
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/package.html (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/DISCLAIMER.txt
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/LICENSE.txt (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/activeiossl
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/aio
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/jxta
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/nio
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/vmpipe
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/NIOActiveIOTransportBrokerTest.java
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/TCPActiveIOTransportBrokerTest.java (with props)
incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/resources/
Removed:
incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/activeio/
incubator/activemq/trunk/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/transport/activeiossl
incubator/activemq/trunk/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/transport/aio
incubator/activemq/trunk/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/transport/jxta
incubator/activemq/trunk/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/transport/nio
incubator/activemq/trunk/activemq-core/src/main/resources/META-INF/services/org/apache/activemq/transport/vmpipe
incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/activeio/
Modified:
incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml
Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java?rev=439204&r1=439203&r2=439204&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java (original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/config/ConfigTest.java Thu Aug 31 23:27:42 2006
@@ -34,15 +34,12 @@
import org.apache.activemq.broker.region.policy.TimedSubscriptionRecoveryPolicy;
import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.memory.UsageManager;
-import org.apache.activemq.openwire.OpenWireFormat;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
import org.apache.activemq.store.journal.JournalPersistenceAdapter;
import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
-import org.apache.activemq.transport.activeio.ActiveIOTransportServer;
import org.apache.activemq.transport.tcp.TcpTransportServer;
import org.apache.activemq.wireformat.ObjectStreamWireFormat;
-import org.apache.activemq.wireformat.WireFormat;
import org.apache.activemq.xbean.BrokerFactoryBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -181,20 +178,6 @@
assertTrue ("1st connector should be TcpTransportServer", ((TransportConnector)connectors.get(0)).getServer() instanceof TcpTransportServer);
assertTrue ("2nd connector should be TcpTransportServer", ((TransportConnector)connectors.get(1)).getServer() instanceof TcpTransportServer);
assertTrue ("3rd connector should be TcpTransportServer", ((TransportConnector)connectors.get(2)).getServer() instanceof TcpTransportServer);
- assertTrue ("4th connector should be ActiveIOTransportServer", ((TransportConnector)connectors.get(3)).getServer() instanceof ActiveIOTransportServer);
-
- // Check spring configured transport server (last transport connector only)
- ActiveIOTransportServer myTransportServer = (ActiveIOTransportServer)((TransportConnector)connectors.get(3)).getServer();
- assertEquals("URI should be ssl", "ssl://localhost:61634", myTransportServer.getConnectURI().toString());
- assertEquals("Error transport server config (stopTimeout)", 5000, myTransportServer.getStopTimeout());
-
- // Check spring configured wire format factory
- WireFormat myWireFormat = myTransportServer.getWireFormatFactory().createWireFormat();
- assertTrue("WireFormat should be OpenWireFormat", myWireFormat instanceof OpenWireFormat);
- assertEquals("WireFormat Config Error (stackTraceEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isStackTraceEnabled());
- assertEquals("WireFormat Config Error (tcpNoDelayEnabled)", true, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isTcpNoDelayEnabled());
- assertEquals("WireFormat Config Error (cacheEnabled)", false, ((OpenWireFormat)myWireFormat).getPreferedWireFormatInfo().isCacheEnabled());
- log.info("Success");
// Check network connectors
System.out.print("Checking network connectors... ");
Modified: incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml?rev=439204&r1=439203&r2=439204&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml (original)
+++ incubator/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/config/example.xml Thu Aug 31 23:27:42 2006
@@ -32,9 +32,6 @@
<amq:transportConnector uri="tcp://localhost:61635"/>
<amq:transportConnector uri="tcp://localhost:61636"/>
<amq:transportConnector uri="tcp://localhost:61637"/>
- <amq:transportConnector>
- <property name="server" ref="myTransportServer"/>
- </amq:transportConnector>
</amq:transportConnectors>
<amq:networkConnectors>
@@ -88,29 +85,5 @@
</amq:persistenceAdapter>
</amq:broker>
-
- <!-- testing normal Spring stuff inside the same config file -->
- <bean id="myTransportServer" class="org.apache.activemq.transport.activeio.ActiveIOTransportServer">
- <constructor-arg index="0">
- <bean id="brokerURI " class="java.net.URI">
- <constructor-arg index="0">
- <value>ssl://localhost:61634</value>
- </constructor-arg>
- </bean>
- </constructor-arg>
-
- <constructor-arg index="1">
- <map/>
- </constructor-arg>
-
- <property name="stopTimeout" value="5000"/>
- <property name="wireFormatFactory">
- <bean id="myWireFormatFactory" class="org.apache.activemq.openwire.OpenWireFormatFactory">
- <property name="stackTraceEnabled" value="false"/>
- <property name="tcpNoDelayEnabled" value="true"/>
- <property name="cacheEnabled" value="false" />
- </bean>
- </property>
- </bean>
</beans>
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/pom.xml?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/pom.xml (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/pom.xml Thu Aug 31 23:27:42 2006
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-parent</artifactId>
+ <version>4.1-incubator-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>activemq-activeio-transport</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ :: ActiveIO Transport</name>
+
+ <dependencies>
+ <!-- activemq -->
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>activemq-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>activemq-core</artifactId>
+ <scope>compile</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>activeio-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>aopalliance</groupId>
+ <artifactId>aopalliance</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+
+ <!-- Configure which tests are included/excuded -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <!--
+ <include>**/Nothing</include>
+ -->
+ <include>**/*Test.*</include>
+ </includes>
+ <excludes>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransport.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransport.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransport.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,209 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import java.io.IOException;
+import java.net.SocketException;
+
+import org.apache.activeio.command.AsyncCommandChannel;
+import org.apache.activeio.command.CommandListener;
+import org.apache.activeio.stream.sync.socket.SocketMetadata;
+import org.apache.activemq.command.Command;
+import org.apache.activemq.command.Response;
+import org.apache.activemq.command.WireFormatInfo;
+import org.apache.activemq.management.CountStatisticImpl;
+import org.apache.activemq.transport.FutureResponse;
+import org.apache.activemq.transport.ResponseCallback;
+import org.apache.activemq.transport.Transport;
+import org.apache.activemq.transport.TransportListener;
+
+/**
+ * An implementation of the {@link Transport} interface using ActiveIO
+ *
+ * @version $Revision$
+ */
+public class ActiveIOTransport implements Transport {
+
+ private AsyncCommandChannel commandChannel;
+ private TransportListener transportListener;
+ private long timeout = 2000;
+
+ private int minmumWireFormatVersion = 0;
+ private long maxInactivityDuration = 60000;
+ private boolean trace = false;
+ private long stopTimeout = 2000;
+ private CountStatisticImpl readCounter;
+ private CountStatisticImpl writeCounter;
+
+
+ public ActiveIOTransport(AsyncCommandChannel commandChannel) {
+ this.commandChannel = commandChannel;
+ this.commandChannel.setCommandListener(new CommandListener() {
+ public void onCommand(Object command) {
+ if (command.getClass() == WireFormatInfo.class) {
+ WireFormatInfo info = (WireFormatInfo) command;
+ try {
+ if (info.isTcpNoDelayEnabled()) {
+ enableTcpNodeDelay();
+ }
+ }
+ catch (IOException e) {
+ onError(e);
+ }
+ }
+ transportListener.onCommand((Command) command);
+ }
+
+ public void onError(Exception e) {
+ if (e instanceof IOException) {
+ transportListener.onException((IOException) e);
+ }
+ else {
+ transportListener.onException((IOException) new IOException().initCause(e));
+ }
+ }
+ });
+
+ }
+
+ private void enableTcpNodeDelay() throws SocketException {
+ SocketMetadata sm = (SocketMetadata) commandChannel.getAdapter(SocketMetadata.class);
+ if (sm != null) {
+ sm.setTcpNoDelay(true);
+ }
+ }
+
+ public void oneway(Command command) throws IOException {
+ if (command.getClass() == WireFormatInfo.class) {
+ WireFormatInfo info = (WireFormatInfo) command;
+ if (info.isTcpNoDelayEnabled()) {
+ enableTcpNodeDelay();
+ }
+ }
+ commandChannel.writeCommand(command);
+ }
+
+ public FutureResponse asyncRequest(Command command, ResponseCallback responseCallback) throws IOException {
+ throw new AssertionError("Unsupported Method");
+ }
+
+ public Response request(Command command) throws IOException {
+ throw new AssertionError("Unsupported Method");
+ }
+
+ public Response request(Command command,int timeout) throws IOException {
+ throw new AssertionError("Unsupported Method");
+ }
+
+ public void start() throws Exception {
+ commandChannel.start();
+ }
+
+ public void stop() throws Exception {
+ commandChannel.stop();
+ commandChannel.dispose();
+ }
+
+ // Properties
+ // -------------------------------------------------------------------------
+
+ public TransportListener getTransportListener() {
+ return transportListener;
+ }
+
+ public void setTransportListener(TransportListener listener) {
+ this.transportListener = listener;
+ }
+
+ public AsyncCommandChannel getCommandChannel() {
+ return commandChannel;
+ }
+
+ public long getTimeout() {
+ return timeout;
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public Object narrow(Class target) {
+ if (target.isAssignableFrom(getClass())) {
+ return this;
+ }
+ return null;
+ }
+
+ public int getMinmumWireFormatVersion() {
+ return minmumWireFormatVersion;
+ }
+
+ public void setMinmumWireFormatVersion(int minmumWireFormatVersion) {
+ this.minmumWireFormatVersion = minmumWireFormatVersion;
+ }
+
+ public long getMaxInactivityDuration() {
+ return maxInactivityDuration;
+ }
+
+ public void setMaxInactivityDuration(long maxInactivityDuration) {
+ this.maxInactivityDuration = maxInactivityDuration;
+ }
+
+ public long getStopTimeout() {
+ return stopTimeout;
+ }
+
+ public void setStopTimeout(long stopTimeout) {
+ this.stopTimeout = stopTimeout;
+ }
+
+ public boolean isTrace() {
+ return trace;
+ }
+
+ public void setTrace(boolean trace) {
+ this.trace = trace;
+ }
+
+ public void setReadCounter(CountStatisticImpl readCounter) {
+ this.readCounter = readCounter;
+ }
+
+ public void setWriteCounter(CountStatisticImpl writeCounter) {
+ this.writeCounter = writeCounter;
+ }
+
+ public CountStatisticImpl getReadCounter() {
+ return readCounter;
+ }
+
+ public CountStatisticImpl getWriteCounter() {
+ return writeCounter;
+ }
+
+ public String getRemoteAddress() {
+ SocketMetadata sm = (SocketMetadata) commandChannel.getAdapter(SocketMetadata.class);
+
+ if (sm != null) {
+ return "" + sm.getRemoteSocketAddress();
+ }
+ return null;
+ }
+
+}
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransport.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportFactory.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportFactory.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportFactory.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,294 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelFactory;
+import org.apache.activeio.adapter.SyncToAsyncChannel;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.stream.sync.socket.SocketMetadata;
+import org.apache.activemq.openwire.OpenWireFormat;
+import org.apache.activemq.transport.InactivityMonitor;
+import org.apache.activemq.transport.MutexTransport;
+import org.apache.activemq.transport.ResponseCorrelator;
+import org.apache.activemq.transport.Transport;
+import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.transport.TransportLogger;
+import org.apache.activemq.transport.TransportServer;
+import org.apache.activemq.transport.WireFormatNegotiator;
+import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.activemq.util.IntrospectionSupport;
+import org.apache.activemq.util.URISupport;
+import org.apache.activemq.wireformat.WireFormat;
+
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+
+public class ActiveIOTransportFactory extends TransportFactory {
+
+ public Transport doConnect(URI location) throws IOException {
+ try {
+ Map options = new HashMap(URISupport.parseParamters(location));
+ location = convertToActiveIOURI(location);
+ Transport rc = connect(location, createWireFormat(options), options);
+ if( !options.isEmpty() ) {
+ throw new IllegalArgumentException("Invalid connect parameters: "+options);
+ }
+ return rc;
+ } catch (URISyntaxException e) {
+ throw IOExceptionSupport.create(e);
+ }
+ }
+
+ /**
+ * Do a connect to get the transport
+ * @param location
+ * @param ex
+ * @return the transport
+ * @throws IOException
+ *
+ */
+ public Transport doConnect(URI location,Executor ex) throws IOException {
+ try {
+ Map options = new HashMap(URISupport.parseParamters(location));
+ location = convertToActiveIOURI(location);
+ Transport rc = connect(location, createWireFormat(options), options,ex);
+ if( !options.isEmpty() ) {
+ throw new IllegalArgumentException("Invalid connect parameters: "+options);
+ }
+ return rc;
+ } catch (URISyntaxException e) {
+ throw IOExceptionSupport.create(e);
+ }
+ }
+
+ /**
+ * do a Composite connect
+ * @param location
+ * @return the Transport
+ * @throws IOException
+ *
+ */
+ public Transport doCompositeConnect(URI location) throws IOException {
+ try {
+ Map options = URISupport.parseParamters(location);
+ location = convertToActiveIOURI(location);
+ Transport rc = compositeConnect(location, createWireFormat(options), options);
+ if( !options.isEmpty() ) {
+ throw new IllegalArgumentException("Invalid connect parameters: "+options);
+ }
+ return rc;
+ } catch (URISyntaxException e) {
+ throw IOExceptionSupport.create(e);
+ }
+ }
+
+ /**
+ * Do a Composite Connect
+ * @param location
+ * @param ex
+ * @return the Transport
+ * @throws IOException
+ *
+ */
+ public Transport doCompositeConnect(URI location,Executor ex) throws IOException {
+ try {
+ Map options = URISupport.parseParamters(location);
+ location = convertToActiveIOURI(location);
+ Transport rc = compositeConnect(location, createWireFormat(options), options,ex);
+ if( !options.isEmpty() ) {
+ throw new IllegalArgumentException("Invalid connect parameters: "+options);
+ }
+ return rc;
+ } catch (URISyntaxException e) {
+ throw IOExceptionSupport.create(e);
+ }
+ }
+
+ public TransportServer doBind(String brokerId,final URI location) throws IOException {
+ try {
+ Map options = new HashMap(URISupport.parseParamters(location));
+
+ ActiveIOTransportServer server = new ActiveIOTransportServer(convertToActiveIOURI(location), options) {
+ public URI getBindURI() {
+ return location;
+ }
+ public URI getConnectURI() {
+ return convertFromActiveIOURI(super.getConnectURI());
+ }
+ };
+ server.setWireFormatFactory(createWireFormatFactory(options));
+ IntrospectionSupport.setProperties(server, options);
+
+ return server;
+ } catch (URISyntaxException e) {
+ throw IOExceptionSupport.create(e);
+ }
+ }
+
+
+ static private final HashMap toSchemeMap = new HashMap();
+ static private final HashMap fromSchemeMap = new HashMap();
+ static {
+ toSchemeMap.put("tcp", "socket");
+ fromSchemeMap.put("socket", "tcp");
+ toSchemeMap.put("nio", "nio-async");
+ fromSchemeMap.put("nio-async", "nio");
+ toSchemeMap.put("aio", "aio");
+ fromSchemeMap.put("aio", "aio");
+ toSchemeMap.put("ssl", "ssl");
+ fromSchemeMap.put("ssl", "ssl");
+ toSchemeMap.put("vmpipe", "vmpipe");
+ fromSchemeMap.put("vmpipe", "vmpipe");
+ toSchemeMap.put("jxta", "jxta");
+ fromSchemeMap.put("jxta", "jxta");
+ }
+
+ static URI convertToActiveIOURI(URI location) {
+ try {
+ String scheme = location.getScheme();
+ String target = (String) toSchemeMap.get(scheme);
+ if( target!=null ) {
+ return new URI(target,
+ location.getSchemeSpecificPart(),
+ location.getFragment());
+ }
+ } catch (URISyntaxException e) {
+ }
+ return location;
+ }
+
+ static URI convertFromActiveIOURI(URI location) {
+ try {
+ String scheme = location.getScheme();
+ String target = (String) fromSchemeMap.get(scheme);
+ if( target!=null ) {
+ return new URI(target,
+ location.getSchemeSpecificPart(),
+ location.getFragment());
+ }
+ } catch (URISyntaxException e) {
+ }
+ return location;
+ }
+
+ public static Transport connect(URI location, WireFormat format, Map options) throws IOException {
+ return configure(new ChannelFactory().openAsyncChannel(location), format, options);
+ }
+
+ public static Transport connect(URI location, WireFormat format, Map options,Executor ex) throws IOException {
+ return configure(new ChannelFactory().openAsyncChannel(location), format, options,ex);
+ }
+
+ public static Transport configure(Channel c, WireFormat format, Map options) {
+ AsyncChannel channel = SyncToAsyncChannel.adapt(c);
+ return configure(channel,format,options);
+ }
+
+ public static Transport configure(Channel c, WireFormat format, Map options,Executor ex) {
+ AsyncChannel channel = SyncToAsyncChannel.adapt(c,ex);
+ return configure(channel,format,options);
+ }
+ public static Transport configure(AsyncChannel channel, WireFormat format, Map options) {
+
+ ActivityMonitor activityMonitor = new ActivityMonitor(channel);
+ channel = new PacketAggregatingAsyncChannel(activityMonitor);
+ AsyncChannelToAsyncCommandChannel commandChannel = new AsyncChannelToAsyncCommandChannel(channel,format);
+
+ // Flexible but dangerous! Allows you to configure all the properties of the socket via the URI!
+ SocketMetadata socketMetadata = (SocketMetadata)commandChannel.getAdapter(SocketMetadata.class);
+ if( socketMetadata !=null ) {
+ IntrospectionSupport.setProperties(socketMetadata, options);
+ }
+
+ ActiveIOTransport activeIOTransport = new ActiveIOTransport(commandChannel);
+ IntrospectionSupport.setProperties(activeIOTransport, options);
+ activeIOTransport.setReadCounter(activityMonitor.getReadCounter());
+ activeIOTransport.setWriteCounter(activityMonitor.getWriteCounter());
+
+ Transport transport = activeIOTransport;
+ if( activeIOTransport.isTrace() ) {
+ transport = new TransportLogger(transport);
+ }
+
+ transport = new InactivityMonitor(transport);
+
+ if( format instanceof OpenWireFormat ) {
+ transport = new WireFormatNegotiator(transport, (OpenWireFormat) format, activeIOTransport.getMinmumWireFormatVersion());
+ }
+
+ transport = new MutexTransport(transport);
+ transport = new ResponseCorrelator(transport);
+ return transport;
+ }
+
+ public static Transport compositeConnect(URI location, WireFormat format, Map options) throws IOException {
+ return compositeConfigure(new ChannelFactory().openAsyncChannel(location), format, options);
+ }
+
+ public static Transport compositeConnect(URI location, WireFormat format, Map options,Executor ex) throws IOException {
+ return compositeConfigure(new ChannelFactory().openAsyncChannel(location), format, options,ex);
+ }
+
+ public static Transport compositeConfigure(Channel c, WireFormat format, Map options) {
+ AsyncChannel channel = SyncToAsyncChannel.adapt(c);
+ return compositeConfigure(channel, format, options);
+ }
+
+ public static Transport compositeConfigure(Channel c, WireFormat format, Map options,Executor ex) {
+ AsyncChannel channel = SyncToAsyncChannel.adapt(c,ex);
+ return compositeConfigure(channel, format, options);
+ }
+
+
+ public static Transport compositeConfigure(AsyncChannel channel, WireFormat format, Map options) {
+ ActivityMonitor activityMonitor = new ActivityMonitor(channel);
+ channel = new PacketAggregatingAsyncChannel(activityMonitor);
+ AsyncChannelToAsyncCommandChannel commandChannel = new AsyncChannelToAsyncCommandChannel(channel,format);
+
+ // Flexible but dangerous! Allows you to configure all the properties of the socket via the URI!
+ SocketMetadata socketMetadata = (SocketMetadata)commandChannel.getAdapter(SocketMetadata.class);
+ if( socketMetadata !=null ) {
+ IntrospectionSupport.setProperties(socketMetadata, options, "socket.");
+ }
+
+ ActiveIOTransport activeIOTransport = new ActiveIOTransport(commandChannel);
+ IntrospectionSupport.setProperties(activeIOTransport, options);
+ activeIOTransport.setReadCounter(activityMonitor.getReadCounter());
+ activeIOTransport.setWriteCounter(activityMonitor.getWriteCounter());
+
+ Transport transport = activeIOTransport;
+ if( activeIOTransport.isTrace() ) {
+ transport = new TransportLogger(transport);
+ }
+
+ transport = new InactivityMonitor(transport);
+
+ if( format instanceof OpenWireFormat ) {
+ transport = new WireFormatNegotiator(transport, (OpenWireFormat) format, activeIOTransport.getMinmumWireFormatVersion());
+ }
+ return transport;
+ }
+
+
+}
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportFactory.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportServer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportServer.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportServer.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportServer.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,124 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.activeio.AcceptListener;
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelFactory;
+import org.apache.activeio.packet.async.AsyncChannelServer;
+import org.apache.activemq.ThreadPriorities;
+import org.apache.activemq.command.BrokerInfo;
+import org.apache.activemq.openwire.OpenWireFormatFactory;
+import org.apache.activemq.transport.TransportAcceptListener;
+import org.apache.activemq.transport.TransportServer;
+import org.apache.activemq.wireformat.WireFormat;
+import org.apache.activemq.wireformat.WireFormatFactory;
+
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+import edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
+
+public class ActiveIOTransportServer implements TransportServer {
+
+ private AsyncChannelServer server;
+ private TransportAcceptListener acceptListener;
+ private WireFormatFactory wireFormatFactory = new OpenWireFormatFactory();
+ private long stopTimeout = 2000;
+ static protected final Executor BROKER_CONNECTION_EXECUTOR = new ScheduledThreadPoolExecutor(5, new ThreadFactory() {
+ public Thread newThread(Runnable run) {
+ Thread thread = new Thread(run);
+ thread.setPriority(ThreadPriorities.INBOUND_BROKER_CONNECTION);
+ return thread;
+ }
+ });
+
+ /**
+ * @param location
+ * @throws IOException
+ */
+ public ActiveIOTransportServer(URI location, final Map options) throws IOException {
+ server = new ChannelFactory().bindAsyncChannel(location);
+ server.setAcceptListener(new AcceptListener(){
+ public void onAccept(Channel c) {
+ if( acceptListener==null ) {
+ c.dispose();
+ } else {
+ WireFormat format = (WireFormat) wireFormatFactory.createWireFormat();
+ acceptListener.onAccept( ActiveIOTransportFactory.configure(c, format, options,BROKER_CONNECTION_EXECUTOR));
+ }
+ }
+ public void onAcceptError(IOException error) {
+ if( acceptListener!=null ) {
+ acceptListener.onAcceptError(error);
+ }
+ }
+ });
+ }
+
+ public void setAcceptListener(TransportAcceptListener acceptListener) {
+ this.acceptListener = acceptListener;
+ }
+
+ public void start() throws Exception {
+ server.start();
+ }
+
+ public void stop() throws Exception {
+ server.stop();
+ server.dispose();
+ }
+
+ public URI getConnectURI() {
+ return server.getConnectURI();
+ }
+
+ public URI getBindURI() {
+ return server.getBindURI();
+ }
+
+ public WireFormatFactory getWireFormatFactory() {
+ return wireFormatFactory;
+ }
+
+ public void setWireFormatFactory(WireFormatFactory wireFormatFactory) {
+ this.wireFormatFactory = wireFormatFactory;
+ }
+
+ public void setBrokerInfo(BrokerInfo brokerInfo) {
+ }
+
+ public long getStopTimeout() {
+ return stopTimeout;
+ }
+
+ public void setStopTimeout(long stopTimeout) {
+ this.stopTimeout = stopTimeout;
+ }
+
+ public InetSocketAddress getSocketAddress() {
+ // TODO: need to drill into the server object to get the socket address
+ return null;
+ }
+
+
+}
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActiveIOTransportServer.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActivityMonitor.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActivityMonitor.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActivityMonitor.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActivityMonitor.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,59 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import java.io.IOException;
+
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.packet.async.FilterAsyncChannel;
+import org.apache.activemq.management.CountStatisticImpl;
+
+/**
+ * Used to make sure that commands are arriving periodically from the peer of the transport.
+ *
+ * @version $Revision$
+ */
+public class ActivityMonitor extends FilterAsyncChannel {
+
+ final CountStatisticImpl writeCounter = new CountStatisticImpl("writeCounter", "The number of bytes written to the transport");
+ final CountStatisticImpl readCounter = new CountStatisticImpl("readCoutner", "The number bytes written to the transport");
+
+ public ActivityMonitor(AsyncChannel next) {
+ super(next);
+ }
+
+ public void onPacket(Packet packet) {
+ readCounter.add(packet.remaining());
+ super.onPacket(packet);
+ }
+
+ public void write(Packet packet) throws IOException {
+ writeCounter.add(packet.remaining());
+ super.write(packet);
+ }
+
+ public CountStatisticImpl getWriteCounter() {
+ return writeCounter;
+ }
+
+ public CountStatisticImpl getReadCounter() {
+ return readCounter;
+ }
+
+}
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/ActivityMonitor.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/AsyncChannelToAsyncCommandChannel.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/AsyncChannelToAsyncCommandChannel.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/AsyncChannelToAsyncCommandChannel.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/AsyncChannelToAsyncCommandChannel.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import java.io.EOFException;
+import java.io.IOException;
+
+import org.apache.activeio.command.AsyncCommandChannel;
+import org.apache.activeio.command.CommandListener;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.EOSPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.packet.async.AsyncChannelListener;
+import org.apache.activemq.util.ByteSequence;
+import org.apache.activemq.wireformat.WireFormat;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class AsyncChannelToAsyncCommandChannel implements AsyncCommandChannel {
+ private AsyncChannel channel;
+ private WireFormat wireFormat;
+
+ public AsyncChannelToAsyncCommandChannel(AsyncChannel channel, WireFormat wireFormat) {
+ this.channel = channel;
+ this.wireFormat = wireFormat;
+ }
+
+ public Packet toPacket(ByteSequence sequence) {
+ return new ByteArrayPacket(new org.apache.activeio.packet.ByteSequence(sequence.data, sequence.offset, sequence.length));
+ }
+
+ public ByteSequence toByteSequence(Packet packet) {
+ org.apache.activeio.packet.ByteSequence sequence = packet.asByteSequence();
+ return new ByteSequence(sequence.getData(), sequence.getOffset(), sequence.getLength());
+ }
+
+ public void writeCommand(Object command) throws IOException {
+ ByteSequence sequence = wireFormat.marshal(command);
+ channel.write(toPacket(sequence));
+ channel.flush();
+ }
+
+ public Object getAdapter(Class target) {
+ return channel.getAdapter(target);
+ }
+
+ public void dispose() {
+ channel.dispose();
+ }
+
+ public void start() throws IOException {
+ channel.start();
+ }
+
+ public void stop() throws IOException {
+ channel.stop();
+ }
+
+ public void setCommandListener(final CommandListener listener) {
+ channel.setAsyncChannelListener(new AsyncChannelListener() {
+ public void onPacket(Packet packet) {
+ if( packet == EOSPacket.EOS_PACKET ) {
+ listener.onError(new EOFException("Peer disconnected."));
+ return;
+ }
+ try {
+ Object command = wireFormat.unmarshal(toByteSequence(packet));
+ listener.onCommand(command);
+ }
+ catch (IOException e) {
+ listener.onError(e);
+ }
+ }
+
+ public void onPacketError(IOException error) {
+ listener.onError(error);
+ }
+ });
+ }
+}
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/PacketAggregatingAsyncChannel.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/PacketAggregatingAsyncChannel.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/PacketAggregatingAsyncChannel.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/PacketAggregatingAsyncChannel.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,113 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import java.io.IOException;
+
+import org.apache.activeio.packet.AppendedPacket;
+import org.apache.activeio.packet.EOSPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.PacketData;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.packet.async.FilterAsyncChannel;
+
+/**
+ * This PacketAggregatingAsyncChannel can be used when the client is sending a
+ * 'record' style packet down the channel stack and needs receiving end to
+ * receive the same 'record' packets.
+ *
+ * This is very useful since in general, a channel does not grantee that a
+ * Packet that is sent down will not be fragmented or combined with other Packet
+ * objects.
+ *
+ * This {@see org.activeio.AsyncChannel} adds a 4 byte header
+ * to each packet that is sent down.
+ *
+ * @version $Revision$
+ */
+final public class PacketAggregatingAsyncChannel extends FilterAsyncChannel {
+
+ private static final int HEADER_LENGTH = 4;
+
+ Packet incompleteUpPacket;
+ boolean headerLoaded;
+ private int upPacketLength;
+
+ public PacketAggregatingAsyncChannel(AsyncChannel next) {
+ super(next);
+ }
+
+ public void onPacket(Packet packet) {
+
+ try {
+ // Pass through the EOS packet.
+ if( packet == EOSPacket.EOS_PACKET ) {
+ channelListener.onPacket(packet);
+ return;
+ }
+
+ if (incompleteUpPacket != null) {
+ packet = AppendedPacket.join(incompleteUpPacket, packet);
+ incompleteUpPacket = null;
+ }
+
+ while (true) {
+
+ if (!headerLoaded) {
+ headerLoaded = packet.remaining() >= HEADER_LENGTH;
+ if( headerLoaded ) {
+ int pos = packet.position();
+ upPacketLength = PacketData.readIntBig(packet);
+ packet.position(pos);
+
+ if( upPacketLength < 0 ) {
+ throw new IOException("Up packet length was invalid: "+upPacketLength);
+ }
+ upPacketLength+=4;
+ }
+ if( !headerLoaded )
+ break;
+ }
+
+ if (packet.remaining() < upPacketLength )
+ break;
+
+ // Get ready to create a slice to send up.
+ int origLimit = packet.limit();
+ packet.limit(upPacketLength);
+ channelListener.onPacket(packet.slice());
+
+ // Get a slice of the remaining since that will dump
+ // the first packets of an AppendedPacket
+ packet.position(upPacketLength);
+ packet.limit(origLimit);
+ packet = packet.slice();
+
+ // Need to load a header again now.
+ headerLoaded = false;
+ }
+ if (packet.hasRemaining()) {
+ incompleteUpPacket = packet;
+ }
+ } catch (IOException e) {
+ channelListener.onPacketError(e);
+ }
+
+ }
+
+}
\ No newline at end of file
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/package.html
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/package.html?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/package.html (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/package.html Thu Aug 31 23:27:42 2006
@@ -0,0 +1,25 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+<a href="http://activeio.org/">ActiveIO</a> based Transport implementation.
+
+</body>
+</html>
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/java/org/apache/activemq/transport/activeio/package.html
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/DISCLAIMER.txt
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/DISCLAIMER.txt?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/DISCLAIMER.txt (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/DISCLAIMER.txt Thu Aug 31 23:27:42 2006
@@ -0,0 +1,7 @@
+ActiveMQ is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Geronimo PMC. Incubation is required of all newly
+accepted projects until a further review indicates that the infrastructure,
+communications, and decision making process have stabilized in a manner
+consistent with other successful ASF projects. While incubation status is not
+necessarily a reflection of the completeness or stability of the code, it does
+indicate that the project has yet to be fully endorsed by the ASF.
\ No newline at end of file
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/LICENSE.txt?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/LICENSE.txt (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/LICENSE.txt Thu Aug 31 23:27:42 2006
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/activeiossl
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/activeiossl?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/activeiossl (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/activeiossl Thu Aug 31 23:27:42 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.activeio.ActiveIOTransportFactory
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/aio
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/aio?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/aio (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/aio Thu Aug 31 23:27:42 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.activeio.ActiveIOTransportFactory
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/jxta
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/jxta?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/jxta (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/jxta Thu Aug 31 23:27:42 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.activeio.ActiveIOTransportFactory
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/nio
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/nio?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/nio (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/nio Thu Aug 31 23:27:42 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.activeio.ActiveIOTransportFactory
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/vmpipe
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/vmpipe?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/vmpipe (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/main/resources/META-INF/services/org/apache/activemq/transport/vmpipe Thu Aug 31 23:27:42 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.activeio.ActiveIOTransportFactory
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/NIOActiveIOTransportBrokerTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/NIOActiveIOTransportBrokerTest.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/NIOActiveIOTransportBrokerTest.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/NIOActiveIOTransportBrokerTest.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,44 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import org.apache.activemq.transport.TransportBrokerTestSupport;
+
+import junit.framework.Test;
+
+public class NIOActiveIOTransportBrokerTest extends TransportBrokerTestSupport {
+
+ protected String getBindLocation() {
+ return "nio://localhost:0?wireFormat.tcpNoDelayEnabled=true&wireFormat.cacheEnabled=true";
+ }
+
+ protected void setUp() throws Exception {
+ MAX_WAIT=2000;
+ super.setUp();
+ }
+
+ public static Test suite() {
+ return suite(NIOActiveIOTransportBrokerTest.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+
+}
Added: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/TCPActiveIOTransportBrokerTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/TCPActiveIOTransportBrokerTest.java?rev=439204&view=auto
==============================================================================
--- incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/TCPActiveIOTransportBrokerTest.java (added)
+++ incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/TCPActiveIOTransportBrokerTest.java Thu Aug 31 23:27:42 2006
@@ -0,0 +1,44 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.transport.activeio;
+
+import org.apache.activemq.transport.TransportBrokerTestSupport;
+
+import junit.framework.Test;
+
+public class TCPActiveIOTransportBrokerTest extends TransportBrokerTestSupport {
+
+ protected String getBindLocation() {
+ return "tcp://localhost:0?wireFormat.tcpNoDelayEnabled=true&wireFormat.cacheEnabled=true";
+ }
+
+ protected void setUp() throws Exception {
+ MAX_WAIT=2000;
+ super.setUp();
+ }
+
+ public static Test suite() {
+ return suite(TCPActiveIOTransportBrokerTest.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+
+}
Propchange: incubator/activemq/trunk/sandbox/activemq-activeio-transport/src/test/java/org/apache/activemq/transport/activeio/TCPActiveIOTransportBrokerTest.java
------------------------------------------------------------------------------
svn:executable = *