activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r379619 [12/30] - in /incubator/activemq/trunk: ./ activecluster/ activecluster/src/java/org/apache/activecluster/ activecluster/src/java/org/apache/activecluster/election/ activecluster/src/java/org/apache/activecluster/election/impl/ acti...
Date Tue, 21 Feb 2006 23:14:17 GMT
Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelFactory.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelFactory.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelFactory.java Tue Feb 21 15:12:56 2006
@@ -1,127 +1,127 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.packet.sync.nio;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SocketChannel;
-
-import org.apache.activeio.packet.ByteBufferPacket;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.SyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-import org.apache.activeio.packet.sync.filter.WriteBufferedSyncChannel;
-import org.apache.activeio.util.URISupport;
-
-/**
- * A TcpSynchChannelFactory creates {@see org.apache.activeio.net.TcpSynchChannel}
- * and {@see org.apache.activeio.net.TcpSynchChannelServer} objects.
- * 
- * @version $Revision$
- */
-public class NIOSyncChannelFactory implements SyncChannelFactory {
-
-    protected static final int DEFAULT_BUFFER_SIZE = Integer.parseInt(System.getProperty("org.apache.activeio.net.nio.BufferSize", ""+(64*1024)));
-
-    protected static final int DEFAULT_BACKLOG = 500;
-    boolean useDirectBuffers = true;
-    private final boolean createWriteBufferedChannels;
-    private int backlog = DEFAULT_BACKLOG;
-    
-    public NIOSyncChannelFactory() {
-        this(true);
-    }
-    
-    public NIOSyncChannelFactory(boolean createWriteBufferedChannels) {
-        this.createWriteBufferedChannels = createWriteBufferedChannels;
-    }
-    
-    
-    /**
-     * Uses the {@param location}'s host and port to create a tcp connection to a remote host.
-     * 
-     * @see org.apache.activeio.SynchChannelFactory#openSyncChannel(java.net.URI)
-     */
-    public SyncChannel openSyncChannel(URI location) throws IOException {
-        SocketChannel channel = SocketChannel.open();
-        channel.connect(new InetSocketAddress(location.getHost(), location.getPort()));
-        return createSynchChannel(channel);
-    }
-
-    /**
-     * @param channel
-     * @return
-     * @throws IOException
-     */
-    protected SyncChannel createSynchChannel(SocketChannel socketChannel) throws IOException {
-        SyncChannel channel = new NIOSyncChannel(socketChannel);
-        if( createWriteBufferedChannels ) {
-            channel = new WriteBufferedSyncChannel(channel, ByteBufferPacket.createDefaultBuffer(useDirectBuffers));
-        }
-        return channel;
-    }
-
-    /**
-     * Binds a server socket a the {@param location}'s port. 
-     * 
-     * @see org.apache.activeio.SynchChannelFactory#bindSynchChannel(java.net.URI)
-     */
-    public SyncChannelServer bindSyncChannel(URI bindURI) throws IOException {
-        
-        String host = bindURI.getHost();
-        InetSocketAddress address;
-        if( host == null || host.length() == 0 || host.equals("localhost") || host.equals("0.0.0.0") || InetAddress.getLocalHost().getHostName().equals(host) ) {            
-            address = new InetSocketAddress(bindURI.getPort());
-        } else {
-            address = new InetSocketAddress(bindURI.getHost(), bindURI.getPort());
-        }
-        
-        ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
-        serverSocketChannel.socket().bind(address,backlog);
-        
-        URI connectURI = bindURI;
-        try {
-//            connectURI = URISupport.changeHost(connectURI, InetAddress.getLocalHost().getHostName());
-            connectURI = URISupport.changePort(connectURI, serverSocketChannel.socket().getLocalPort());
-        } catch (URISyntaxException e) {
-            throw (IOException)new IOException("Could not build connect URI: "+e).initCause(e);
-        }
-        
-        return new NIOSyncChannelServer(serverSocketChannel, bindURI, connectURI, createWriteBufferedChannels, useDirectBuffers);
-    }
-    
-    /**
-     * @return Returns the backlog.
-     */
-    public int getBacklog() {
-        return backlog;
-    }
-
-    /**
-     * @param backlog
-     *            The backlog to set.
-     */
-    public void setBacklog(int backlog) {
-        this.backlog = backlog;
-    }
-
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.packet.sync.nio;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+
+import org.apache.activeio.packet.ByteBufferPacket;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.SyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+import org.apache.activeio.packet.sync.filter.WriteBufferedSyncChannel;
+import org.apache.activeio.util.URISupport;
+
+/**
+ * A TcpSynchChannelFactory creates {@see org.apache.activeio.net.TcpSynchChannel}
+ * and {@see org.apache.activeio.net.TcpSynchChannelServer} objects.
+ * 
+ * @version $Revision$
+ */
+public class NIOSyncChannelFactory implements SyncChannelFactory {
+
+    protected static final int DEFAULT_BUFFER_SIZE = Integer.parseInt(System.getProperty("org.apache.activeio.net.nio.BufferSize", ""+(64*1024)));
+
+    protected static final int DEFAULT_BACKLOG = 500;
+    boolean useDirectBuffers = true;
+    private final boolean createWriteBufferedChannels;
+    private int backlog = DEFAULT_BACKLOG;
+    
+    public NIOSyncChannelFactory() {
+        this(true);
+    }
+    
+    public NIOSyncChannelFactory(boolean createWriteBufferedChannels) {
+        this.createWriteBufferedChannels = createWriteBufferedChannels;
+    }
+    
+    
+    /**
+     * Uses the {@param location}'s host and port to create a tcp connection to a remote host.
+     * 
+     * @see org.apache.activeio.SynchChannelFactory#openSyncChannel(java.net.URI)
+     */
+    public SyncChannel openSyncChannel(URI location) throws IOException {
+        SocketChannel channel = SocketChannel.open();
+        channel.connect(new InetSocketAddress(location.getHost(), location.getPort()));
+        return createSynchChannel(channel);
+    }
+
+    /**
+     * @param channel
+     * @return
+     * @throws IOException
+     */
+    protected SyncChannel createSynchChannel(SocketChannel socketChannel) throws IOException {
+        SyncChannel channel = new NIOSyncChannel(socketChannel);
+        if( createWriteBufferedChannels ) {
+            channel = new WriteBufferedSyncChannel(channel, ByteBufferPacket.createDefaultBuffer(useDirectBuffers));
+        }
+        return channel;
+    }
+
+    /**
+     * Binds a server socket a the {@param location}'s port. 
+     * 
+     * @see org.apache.activeio.SynchChannelFactory#bindSynchChannel(java.net.URI)
+     */
+    public SyncChannelServer bindSyncChannel(URI bindURI) throws IOException {
+        
+        String host = bindURI.getHost();
+        InetSocketAddress address;
+        if( host == null || host.length() == 0 || host.equals("localhost") || host.equals("0.0.0.0") || InetAddress.getLocalHost().getHostName().equals(host) ) {            
+            address = new InetSocketAddress(bindURI.getPort());
+        } else {
+            address = new InetSocketAddress(bindURI.getHost(), bindURI.getPort());
+        }
+        
+        ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
+        serverSocketChannel.socket().bind(address,backlog);
+        
+        URI connectURI = bindURI;
+        try {
+//            connectURI = URISupport.changeHost(connectURI, InetAddress.getLocalHost().getHostName());
+            connectURI = URISupport.changePort(connectURI, serverSocketChannel.socket().getLocalPort());
+        } catch (URISyntaxException e) {
+            throw (IOException)new IOException("Could not build connect URI: "+e).initCause(e);
+        }
+        
+        return new NIOSyncChannelServer(serverSocketChannel, bindURI, connectURI, createWriteBufferedChannels, useDirectBuffers);
+    }
+    
+    /**
+     * @return Returns the backlog.
+     */
+    public int getBacklog() {
+        return backlog;
+    }
+
+    /**
+     * @param backlog
+     *            The backlog to set.
+     */
+    public void setBacklog(int backlog) {
+        this.backlog = backlog;
+    }
+
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelServer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelServer.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelServer.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelServer.java Tue Feb 21 15:12:56 2006
@@ -1,56 +1,56 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-
-package org.apache.activeio.packet.sync.nio;
-
-import java.io.IOException;
-import java.net.URI;
-import java.nio.channels.ServerSocketChannel;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.packet.ByteBufferPacket;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.filter.WriteBufferedSyncChannel;
-import org.apache.activeio.packet.sync.socket.SocketSyncChannelServer;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
-
-/**
- * A SynchChannelServer that creates
- * {@see org.apache.activeio.net.TcpSynchChannel}objects from accepted
- * tcp socket connections.
- * 
- * @version $Revision$
- */
-public class NIOSyncChannelServer extends SocketSyncChannelServer {
-
-    private final boolean createWriteBufferedChannels;
-	private final boolean useDirectBuffers;
-
-    public NIOSyncChannelServer(ServerSocketChannel socketChannel, URI bindURI, URI connectURI, boolean createWriteBufferedChannels, boolean useDirectBuffers) {
-        super(socketChannel.socket(), bindURI, connectURI);
-        this.createWriteBufferedChannels = createWriteBufferedChannels;
-		this.useDirectBuffers = useDirectBuffers;
-    }
-    
-    protected Channel createChannel(SocketStreamChannel c) throws IOException {
-        SyncChannel channel = new NIOSyncChannel(c.getSocket().getChannel());
-        if( createWriteBufferedChannels ) {
-            channel = new WriteBufferedSyncChannel(channel, ByteBufferPacket.createDefaultBuffer(useDirectBuffers));
-        }
-        return channel;
-    }
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package org.apache.activeio.packet.sync.nio;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.channels.ServerSocketChannel;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.packet.ByteBufferPacket;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.filter.WriteBufferedSyncChannel;
+import org.apache.activeio.packet.sync.socket.SocketSyncChannelServer;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
+
+/**
+ * A SynchChannelServer that creates
+ * {@see org.apache.activeio.net.TcpSynchChannel}objects from accepted
+ * tcp socket connections.
+ * 
+ * @version $Revision$
+ */
+public class NIOSyncChannelServer extends SocketSyncChannelServer {
+
+    private final boolean createWriteBufferedChannels;
+	private final boolean useDirectBuffers;
+
+    public NIOSyncChannelServer(ServerSocketChannel socketChannel, URI bindURI, URI connectURI, boolean createWriteBufferedChannels, boolean useDirectBuffers) {
+        super(socketChannel.socket(), bindURI, connectURI);
+        this.createWriteBufferedChannels = createWriteBufferedChannels;
+		this.useDirectBuffers = useDirectBuffers;
+    }
+    
+    protected Channel createChannel(SocketStreamChannel c) throws IOException {
+        SyncChannel channel = new NIOSyncChannel(c.getSocket().getChannel());
+        if( createWriteBufferedChannels ) {
+            channel = new WriteBufferedSyncChannel(channel, ByteBufferPacket.createDefaultBuffer(useDirectBuffers));
+        }
+        return channel;
+    }
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/nio/NIOSyncChannelServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannel.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannel.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannel.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannel.java Tue Feb 21 15:12:56 2006
@@ -1,144 +1,144 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-
-package org.apache.activeio.packet.sync.socket;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.ByteSequence;
-import org.apache.activeio.packet.EOSPacket;
-import org.apache.activeio.packet.EmptyPacket;
-import org.apache.activeio.packet.Packet;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
-
-/**
- * A {@see org.apache.activeio.SynchChannel} implementation that uses a {@see java.net.Socket}
- *  to talk to the network.
- * 
- * @version $Revision$
- */
-public class SocketSyncChannel implements SyncChannel {
-
-    protected static final int DEFAULT_BUFFER_SIZE = 64 * 1024;
-    private final SocketStreamChannel channel;
-    private Packet inputPacket;
-    private final OutputStream os;
-    private final InputStream is;
-    
-    protected SocketSyncChannel(Socket socket) throws IOException {
-        this(new SocketStreamChannel(socket));
-    }
-
-    public SocketSyncChannel(SocketStreamChannel channel) throws IOException {
-        this.channel = channel;
-        os = channel.getOutputStream();
-        is = channel.getInputStream();
-        channel.setReceiveBufferSize(DEFAULT_BUFFER_SIZE);
-        channel.setSendBufferSize(DEFAULT_BUFFER_SIZE);
-    }
-
-    /**
-     * @see org.apache.activeio.SynchChannel#read(long)
-     */
-    synchronized public org.apache.activeio.packet.Packet read(long timeout) throws IOException {
-        try {
-            
-            if( timeout==SyncChannelServer.WAIT_FOREVER_TIMEOUT )
-                channel.setSoTimeout( 0 );
-            else if( timeout==SyncChannelServer.NO_WAIT_TIMEOUT )
-                channel.setSoTimeout( 1 );
-            else 
-                channel.setSoTimeout( (int)timeout );
-
-            if( inputPacket==null || !inputPacket.hasRemaining() ) {
-                inputPacket = allocatePacket();
-            }
-            
-            ByteSequence sequence = inputPacket.asByteSequence();
-            int size = is.read(sequence.getData(), sequence.getOffset(), sequence.getLength());
-            if( size == -1 )
-                return EOSPacket.EOS_PACKET;
-            if( size == 0 )
-                return EmptyPacket.EMPTY_PACKET;
-            inputPacket.position(size);
-            
-            Packet remaining = inputPacket.slice();
-            
-            inputPacket.flip();
-            Packet data = inputPacket.slice();
-
-            // Keep the remaining buffer around to fill with data.
-            inputPacket = remaining;            
-            return data;
-            
-        } catch (SocketTimeoutException e) {
-            return null;
-        }
-    }
-
-    private Packet allocatePacket() {
-        byte[] data = new byte[DEFAULT_BUFFER_SIZE];
-        return new ByteArrayPacket(data);
-    }
-
-    
-    /**
-     * @see org.apache.activeio.Channel#write(org.apache.activeio.packet.Packet)
-     */
-    public void write(Packet packet) throws IOException {
-        packet.writeTo(os);
-    }
-
-    /**
-     * @see org.apache.activeio.Channel#flush()
-     */
-    public void flush() throws IOException {
-        os.flush();
-    }
-
-    /**
-     * @see org.apache.activeio.Disposable#dispose()
-     */
-    public void dispose() {
-        channel.dispose();
-    }
-
-    public void start() throws IOException {
-        channel.start();
-    }
-    public void stop() throws IOException {
-        channel.stop();
-    }
-        
-    public Object getAdapter(Class target) {
-        if( target.isAssignableFrom(getClass()) ) {
-            return this;
-        }
-        return channel.getAdapter(target);
-    }
-
-    public String toString() {
-        return channel.toString();
-    }
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package org.apache.activeio.packet.sync.socket;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.ByteSequence;
+import org.apache.activeio.packet.EOSPacket;
+import org.apache.activeio.packet.EmptyPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
+
+/**
+ * A {@see org.apache.activeio.SynchChannel} implementation that uses a {@see java.net.Socket}
+ *  to talk to the network.
+ * 
+ * @version $Revision$
+ */
+public class SocketSyncChannel implements SyncChannel {
+
+    protected static final int DEFAULT_BUFFER_SIZE = 64 * 1024;
+    private final SocketStreamChannel channel;
+    private Packet inputPacket;
+    private final OutputStream os;
+    private final InputStream is;
+    
+    protected SocketSyncChannel(Socket socket) throws IOException {
+        this(new SocketStreamChannel(socket));
+    }
+
+    public SocketSyncChannel(SocketStreamChannel channel) throws IOException {
+        this.channel = channel;
+        os = channel.getOutputStream();
+        is = channel.getInputStream();
+        channel.setReceiveBufferSize(DEFAULT_BUFFER_SIZE);
+        channel.setSendBufferSize(DEFAULT_BUFFER_SIZE);
+    }
+
+    /**
+     * @see org.apache.activeio.SynchChannel#read(long)
+     */
+    synchronized public org.apache.activeio.packet.Packet read(long timeout) throws IOException {
+        try {
+            
+            if( timeout==SyncChannelServer.WAIT_FOREVER_TIMEOUT )
+                channel.setSoTimeout( 0 );
+            else if( timeout==SyncChannelServer.NO_WAIT_TIMEOUT )
+                channel.setSoTimeout( 1 );
+            else 
+                channel.setSoTimeout( (int)timeout );
+
+            if( inputPacket==null || !inputPacket.hasRemaining() ) {
+                inputPacket = allocatePacket();
+            }
+            
+            ByteSequence sequence = inputPacket.asByteSequence();
+            int size = is.read(sequence.getData(), sequence.getOffset(), sequence.getLength());
+            if( size == -1 )
+                return EOSPacket.EOS_PACKET;
+            if( size == 0 )
+                return EmptyPacket.EMPTY_PACKET;
+            inputPacket.position(size);
+            
+            Packet remaining = inputPacket.slice();
+            
+            inputPacket.flip();
+            Packet data = inputPacket.slice();
+
+            // Keep the remaining buffer around to fill with data.
+            inputPacket = remaining;            
+            return data;
+            
+        } catch (SocketTimeoutException e) {
+            return null;
+        }
+    }
+
+    private Packet allocatePacket() {
+        byte[] data = new byte[DEFAULT_BUFFER_SIZE];
+        return new ByteArrayPacket(data);
+    }
+
+    
+    /**
+     * @see org.apache.activeio.Channel#write(org.apache.activeio.packet.Packet)
+     */
+    public void write(Packet packet) throws IOException {
+        packet.writeTo(os);
+    }
+
+    /**
+     * @see org.apache.activeio.Channel#flush()
+     */
+    public void flush() throws IOException {
+        os.flush();
+    }
+
+    /**
+     * @see org.apache.activeio.Disposable#dispose()
+     */
+    public void dispose() {
+        channel.dispose();
+    }
+
+    public void start() throws IOException {
+        channel.start();
+    }
+    public void stop() throws IOException {
+        channel.stop();
+    }
+        
+    public Object getAdapter(Class target) {
+        if( target.isAssignableFrom(getClass()) ) {
+            return this;
+        }
+        return channel.getAdapter(target);
+    }
+
+    public String toString() {
+        return channel.toString();
+    }
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelFactory.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelFactory.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelFactory.java Tue Feb 21 15:12:56 2006
@@ -1,96 +1,96 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.packet.sync.socket;
-
-import java.io.IOException;
-import java.net.URI;
-
-import javax.net.ServerSocketFactory;
-import javax.net.SocketFactory;
-
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.SyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-import org.apache.activeio.stream.sync.StreamChannelServer;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannelFactory;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannelServer;
-
-/**
- * A TcpSynchChannelFactory creates {@see org.apache.activeio.net.TcpSynchChannel}
- * and {@see org.apache.activeio.net.TcpSynchChannelServer} objects.
- * 
- * @version $Revision$
- */
-public class SocketSyncChannelFactory implements SyncChannelFactory {
-
-    SocketStreamChannelFactory factory;
-    
-    public SocketSyncChannelFactory() {
-        this(SocketFactory.getDefault(), ServerSocketFactory.getDefault());
-    }
-
-    public SocketSyncChannelFactory(SocketFactory socketFactory, ServerSocketFactory serverSocketFactory) {
-        factory = new SocketStreamChannelFactory(socketFactory, serverSocketFactory);
-    }
-        
-    /**
-     * Uses the {@param location}'s host and port to create a tcp connection to a remote host.
-     * 
-     * @see org.apache.activeio.SyncChannelFactory#openSyncChannel(java.net.URI)
-     */
-    public SyncChannel openSyncChannel(URI location) throws IOException {
-        SocketStreamChannel channel = (SocketStreamChannel) factory.openStreamChannel(location);
-        return createSynchChannel(channel);
-    }
-
-    /**
-     * @param channel
-     * @return
-     * @throws IOException
-     */
-    protected SyncChannel createSynchChannel(SocketStreamChannel channel) throws IOException {
-        return new SocketSyncChannel(channel);
-    }
-
-    /**
-     * Binds a server socket a the {@param bindURI}'s port.
-     * 
-     * @see org.apache.activeio.SyncChannelFactory#bindSyncChannel(java.net.URI)
-     */
-    public SyncChannelServer bindSyncChannel(URI bindURI) throws IOException {
-        StreamChannelServer server = factory.bindStreamChannel(bindURI);
-        return new SocketSyncChannelServer((SocketStreamChannelServer) server);
-    }
-    
-    /**
-     * @return Returns the backlog.
-     */
-    public int getBacklog() {
-        return factory.getBacklog();
-    }
-
-    /**
-     * @param backlog
-     *            The backlog to set.
-     */
-    public void setBacklog(int backlog) {
-        factory.setBacklog(backlog);
-    }
-
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.packet.sync.socket;
+
+import java.io.IOException;
+import java.net.URI;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.SyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+import org.apache.activeio.stream.sync.StreamChannelServer;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannelFactory;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannelServer;
+
+/**
+ * A TcpSynchChannelFactory creates {@see org.apache.activeio.net.TcpSynchChannel}
+ * and {@see org.apache.activeio.net.TcpSynchChannelServer} objects.
+ * 
+ * @version $Revision$
+ */
+public class SocketSyncChannelFactory implements SyncChannelFactory {
+
+    SocketStreamChannelFactory factory;
+    
+    public SocketSyncChannelFactory() {
+        this(SocketFactory.getDefault(), ServerSocketFactory.getDefault());
+    }
+
+    public SocketSyncChannelFactory(SocketFactory socketFactory, ServerSocketFactory serverSocketFactory) {
+        factory = new SocketStreamChannelFactory(socketFactory, serverSocketFactory);
+    }
+        
+    /**
+     * Uses the {@param location}'s host and port to create a tcp connection to a remote host.
+     * 
+     * @see org.apache.activeio.SyncChannelFactory#openSyncChannel(java.net.URI)
+     */
+    public SyncChannel openSyncChannel(URI location) throws IOException {
+        SocketStreamChannel channel = (SocketStreamChannel) factory.openStreamChannel(location);
+        return createSynchChannel(channel);
+    }
+
+    /**
+     * @param channel
+     * @return
+     * @throws IOException
+     */
+    protected SyncChannel createSynchChannel(SocketStreamChannel channel) throws IOException {
+        return new SocketSyncChannel(channel);
+    }
+
+    /**
+     * Binds a server socket a the {@param bindURI}'s port.
+     * 
+     * @see org.apache.activeio.SyncChannelFactory#bindSyncChannel(java.net.URI)
+     */
+    public SyncChannelServer bindSyncChannel(URI bindURI) throws IOException {
+        StreamChannelServer server = factory.bindStreamChannel(bindURI);
+        return new SocketSyncChannelServer((SocketStreamChannelServer) server);
+    }
+    
+    /**
+     * @return Returns the backlog.
+     */
+    public int getBacklog() {
+        return factory.getBacklog();
+    }
+
+    /**
+     * @param backlog
+     *            The backlog to set.
+     */
+    public void setBacklog(int backlog) {
+        factory.setBacklog(backlog);
+    }
+
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelServer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelServer.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelServer.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelServer.java Tue Feb 21 15:12:56 2006
@@ -1,99 +1,99 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-
-package org.apache.activeio.packet.sync.socket;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.URI;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
-import org.apache.activeio.stream.sync.socket.SocketStreamChannelServer;
-
-/**
- * A SynchChannelServer that creates
- * {@see org.apache.activeio.net.TcpSynchChannel}objects from accepted
- * TCP socket connections.
- * 
- * @version $Revision$
- */
-public class SocketSyncChannelServer implements SyncChannelServer {
-
-    private final SocketStreamChannelServer server;
-
-    public SocketSyncChannelServer(SocketStreamChannelServer server) {
-        this.server = server;
-    }
-
-    public SocketSyncChannelServer(ServerSocket socket, URI bindURI, URI connectURI) {
-        this(new SocketStreamChannelServer(socket, bindURI, connectURI));
-    }
-
-    public Channel accept(long timeout) throws IOException {
-        Channel channel = server.accept(timeout);
-        if( channel != null ) {
-            channel = createChannel((SocketStreamChannel) channel);
-        }
-        return channel;
-    }
-
-    protected Channel createChannel(SocketStreamChannel channel) throws IOException {
-        return new SocketSyncChannel(channel);
-    }
-
-    /**
-     * @see org.apache.activeio.Disposable#dispose()
-     */
-    public void dispose() {
-        server.dispose();
-    }
-
-    /**
-     * @return Returns the bindURI.
-     */
-    public URI getBindURI() {
-        return server.getBindURI();
-    }
-
-    /**
-     * @return Returns the connectURI.
-     */
-    public URI getConnectURI() {
-        return server.getConnectURI();
-    }
-
-    public void start() throws IOException {
-        server.start();
-    }
-
-    public void stop() throws IOException {
-        server.stop();
-    }
-    
-    public Object getAdapter(Class target) {
-        if( target.isAssignableFrom(getClass()) ) {
-            return this;
-        }
-        return server.getAdapter(target);
-    }    
-    
-    public String toString() {
-        return server.toString();
-    }    
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package org.apache.activeio.packet.sync.socket;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.URI;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannel;
+import org.apache.activeio.stream.sync.socket.SocketStreamChannelServer;
+
+/**
+ * A SynchChannelServer that creates
+ * {@see org.apache.activeio.net.TcpSynchChannel}objects from accepted
+ * TCP socket connections.
+ * 
+ * @version $Revision$
+ */
+public class SocketSyncChannelServer implements SyncChannelServer {
+
+    private final SocketStreamChannelServer server;
+
+    public SocketSyncChannelServer(SocketStreamChannelServer server) {
+        this.server = server;
+    }
+
+    public SocketSyncChannelServer(ServerSocket socket, URI bindURI, URI connectURI) {
+        this(new SocketStreamChannelServer(socket, bindURI, connectURI));
+    }
+
+    public Channel accept(long timeout) throws IOException {
+        Channel channel = server.accept(timeout);
+        if( channel != null ) {
+            channel = createChannel((SocketStreamChannel) channel);
+        }
+        return channel;
+    }
+
+    protected Channel createChannel(SocketStreamChannel channel) throws IOException {
+        return new SocketSyncChannel(channel);
+    }
+
+    /**
+     * @see org.apache.activeio.Disposable#dispose()
+     */
+    public void dispose() {
+        server.dispose();
+    }
+
+    /**
+     * @return Returns the bindURI.
+     */
+    public URI getBindURI() {
+        return server.getBindURI();
+    }
+
+    /**
+     * @return Returns the connectURI.
+     */
+    public URI getConnectURI() {
+        return server.getConnectURI();
+    }
+
+    public void start() throws IOException {
+        server.start();
+    }
+
+    public void stop() throws IOException {
+        server.stop();
+    }
+    
+    public Object getAdapter(Class target) {
+        if( target.isAssignableFrom(getClass()) ) {
+            return this;
+        }
+        return server.getAdapter(target);
+    }    
+    
+    public String toString() {
+        return server.toString();
+    }    
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/socket/SocketSyncChannelServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/ssl/SslSocketSyncChannelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/ssl/SslSocketSyncChannelFactory.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/ssl/SslSocketSyncChannelFactory.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/ssl/SslSocketSyncChannelFactory.java Tue Feb 21 15:12:56 2006
@@ -1,35 +1,35 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.packet.sync.ssl;
-
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-import org.apache.activeio.packet.sync.socket.SocketSyncChannelFactory;
-
-/**
- * A SslSynchChannelFactory creates {@see org.apache.activeio.net.TcpSynchChannel}
- * and {@see org.apache.activeio.net.TcpSynchChannelServer} objects that use SSL.
- * 
- * @version $Revision$
- */
-public class SslSocketSyncChannelFactory extends SocketSyncChannelFactory {
-
-    public SslSocketSyncChannelFactory() {
-        super(SSLSocketFactory.getDefault(), SSLServerSocketFactory.getDefault());
-    }
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.packet.sync.ssl;
+
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.activeio.packet.sync.socket.SocketSyncChannelFactory;
+
+/**
+ * A SslSynchChannelFactory creates {@see org.apache.activeio.net.TcpSynchChannel}
+ * and {@see org.apache.activeio.net.TcpSynchChannelServer} objects that use SSL.
+ * 
+ * @version $Revision$
+ */
+public class SslSocketSyncChannelFactory extends SocketSyncChannelFactory {
+
+    public SslSocketSyncChannelFactory() {
+        super(SSLSocketFactory.getDefault(), SSLServerSocketFactory.getDefault());
+    }
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/packet/sync/ssl/SslSocketSyncChannelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannel.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannel.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannel.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannel.java Tue Feb 21 15:12:56 2006
@@ -1,33 +1,33 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-
-package org.apache.activeio.stream.sync;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.activeio.Channel;
-
-
-/**
- * @version $Revision$
- */
-public interface StreamChannel extends Channel {
-    InputStream getInputStream() throws IOException;
-    OutputStream getOutputStream() throws IOException;
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package org.apache.activeio.stream.sync;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.activeio.Channel;
+
+
+/**
+ * @version $Revision$
+ */
+public interface StreamChannel extends Channel {
+    InputStream getInputStream() throws IOException;
+    OutputStream getOutputStream() throws IOException;
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelFactory.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelFactory.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelFactory.java Tue Feb 21 15:12:56 2006
@@ -1,46 +1,46 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.stream.sync;
-
-import java.io.IOException;
-import java.net.URI;
-
-/**
- * StreamChannelFactory objects can create {@see org.apache.activeio.StreamChannel}
- * and {@see org.apache.activeio.StreamChannelServer} objects. 
- * 
- * @version $Revision$
- */
-public interface StreamChannelFactory {
-
-	/**
-     * Opens a connection to server.
-     * 
-     * @param location 
-     * @return
-     */
-	public StreamChannel openStreamChannel(URI location) throws IOException;
-	
-	/**
-     * Binds a server at the URI location.
-     * 
-     * @param location
-     * @return
-     */
-	public StreamChannelServer bindStreamChannel(URI location) throws IOException;
-	
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.stream.sync;
+
+import java.io.IOException;
+import java.net.URI;
+
+/**
+ * StreamChannelFactory objects can create {@see org.apache.activeio.StreamChannel}
+ * and {@see org.apache.activeio.StreamChannelServer} objects. 
+ * 
+ * @version $Revision$
+ */
+public interface StreamChannelFactory {
+
+	/**
+     * Opens a connection to server.
+     * 
+     * @param location 
+     * @return
+     */
+	public StreamChannel openStreamChannel(URI location) throws IOException;
+	
+	/**
+     * Binds a server at the URI location.
+     * 
+     * @param location
+     * @return
+     */
+	public StreamChannelServer bindStreamChannel(URI location) throws IOException;
+	
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelServer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelServer.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelServer.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelServer.java Tue Feb 21 15:12:56 2006
@@ -1,39 +1,39 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.stream.sync;
-
-import java.io.IOException;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.ChannelServer;
-
-
-
-/**
- * A StreamChannelServer object provides an <code>accept</code> method to synchronously 
- * accept and create {@see org.apache.activeio.channel.Channel} objects.
- * 
- * @version $Revision$
- */
-public interface StreamChannelServer extends ChannelServer {
-
-    static final public long NO_WAIT_TIMEOUT=0;
-	static final public long WAIT_FOREVER_TIMEOUT=-1;	
-	
-	public Channel accept(long timeout) throws IOException;
-	
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.stream.sync;
+
+import java.io.IOException;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelServer;
+
+
+
+/**
+ * A StreamChannelServer object provides an <code>accept</code> method to synchronously 
+ * accept and create {@see org.apache.activeio.channel.Channel} objects.
+ * 
+ * @version $Revision$
+ */
+public interface StreamChannelServer extends ChannelServer {
+
+    static final public long NO_WAIT_TIMEOUT=0;
+	static final public long WAIT_FOREVER_TIMEOUT=-1;	
+	
+	public Channel accept(long timeout) throws IOException;
+	
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/StreamChannelServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketMetadata.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketMetadata.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketMetadata.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketMetadata.java Tue Feb 21 15:12:56 2006
@@ -1,79 +1,79 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.stream.sync.socket;
-
-import java.net.InetAddress;
-import java.net.SocketAddress;
-import java.net.SocketException;
-
-/**
- */
-public interface SocketMetadata {
-    public InetAddress getInetAddress();
-
-    public boolean getKeepAlive() throws SocketException;
-
-    public InetAddress getLocalAddress();
-
-    public int getLocalPort();
-
-    public SocketAddress getLocalSocketAddress();
-
-    public int getPort();
-
-    public int getReceiveBufferSize() throws SocketException;
-
-    public SocketAddress getRemoteSocketAddress();
-
-    public boolean getReuseAddress() throws SocketException;
-
-    public int getSendBufferSize() throws SocketException;
-
-    public boolean getOOBInline() throws SocketException;
-
-    public int getSoLinger() throws SocketException;
-
-    public int getSoTimeout() throws SocketException;
-
-    public boolean getTcpNoDelay() throws SocketException;
-
-    public int getTrafficClass() throws SocketException;
-
-    public boolean isBound();
-
-    public boolean isClosed();
-
-    public boolean isConnected();
-
-    public void setKeepAlive(boolean on) throws SocketException;
-
-    public void setOOBInline(boolean on) throws SocketException;
-
-    public void setReceiveBufferSize(int size) throws SocketException;
-
-    public void setReuseAddress(boolean on) throws SocketException;
-
-    public void setSendBufferSize(int size) throws SocketException;
-
-    public void setSoLinger(boolean on, int linger) throws SocketException;
-    
-    public void setSoTimeout(int i) throws SocketException;
-
-    public void setTcpNoDelay(boolean on) throws SocketException;
-
-    public void setTrafficClass(int tc) throws SocketException;
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.stream.sync.socket;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+
+/**
+ */
+public interface SocketMetadata {
+    public InetAddress getInetAddress();
+
+    public boolean getKeepAlive() throws SocketException;
+
+    public InetAddress getLocalAddress();
+
+    public int getLocalPort();
+
+    public SocketAddress getLocalSocketAddress();
+
+    public int getPort();
+
+    public int getReceiveBufferSize() throws SocketException;
+
+    public SocketAddress getRemoteSocketAddress();
+
+    public boolean getReuseAddress() throws SocketException;
+
+    public int getSendBufferSize() throws SocketException;
+
+    public boolean getOOBInline() throws SocketException;
+
+    public int getSoLinger() throws SocketException;
+
+    public int getSoTimeout() throws SocketException;
+
+    public boolean getTcpNoDelay() throws SocketException;
+
+    public int getTrafficClass() throws SocketException;
+
+    public boolean isBound();
+
+    public boolean isClosed();
+
+    public boolean isConnected();
+
+    public void setKeepAlive(boolean on) throws SocketException;
+
+    public void setOOBInline(boolean on) throws SocketException;
+
+    public void setReceiveBufferSize(int size) throws SocketException;
+
+    public void setReuseAddress(boolean on) throws SocketException;
+
+    public void setSendBufferSize(int size) throws SocketException;
+
+    public void setSoLinger(boolean on, int linger) throws SocketException;
+    
+    public void setSoTimeout(int i) throws SocketException;
+
+    public void setTcpNoDelay(boolean on) throws SocketException;
+
+    public void setTrafficClass(int tc) throws SocketException;
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketMetadata.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannel.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannel.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannel.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannel.java Tue Feb 21 15:12:56 2006
@@ -1,186 +1,186 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-
-package org.apache.activeio.stream.sync.socket;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketException;
-
-import org.apache.activeio.stream.sync.StreamChannel;
-
-/**
- * A {@see org.apache.activeio.StreamChannel} implementation that uses a {@see java.net.Socket}
- *  to talk to the network.
- * 
- * @version $Revision$
- */
-public class SocketStreamChannel implements StreamChannel, SocketMetadata {
-
-    private final Socket socket;
-    private final OutputStream out;
-    private final InputStream in;    
-    private boolean disposed;
-    private int curentSoTimeout;
-
-    public SocketStreamChannel(Socket socket) throws IOException {
-        this.socket = socket;
-        in = socket.getInputStream();
-        out = socket.getOutputStream();        
-    }
-
-    public void setSoTimeout(int i) throws SocketException {
-        if( curentSoTimeout != i ) {
-            socket.setSoTimeout(i);
-            curentSoTimeout = i;
-        }
-    }
-    
-    /**
-     * @see org.apache.activeio.Disposable#dispose()
-     */
-    public void dispose() {
-        if (disposed)
-            return;
-
-        try {
-            out.close();
-        } catch (IOException ignore) {
-        }
-        try {
-            in.close();
-        } catch (IOException ignore) {
-        }
-        try {
-            socket.close();
-        } catch (IOException ignore) {
-        }
-        disposed = true;
-    }
-
-    public void start() throws IOException {
-    }
-    public void stop() throws IOException {
-    }
-    
-    public InetAddress getInetAddress() {
-        return socket.getInetAddress();
-    }
-    public boolean getKeepAlive() throws SocketException {
-        return socket.getKeepAlive();
-    }
-    public InetAddress getLocalAddress() {
-        return socket.getLocalAddress();
-    }
-    public int getLocalPort() {
-        return socket.getLocalPort();
-    }
-    public SocketAddress getLocalSocketAddress() {
-        return socket.getLocalSocketAddress();
-    }
-    public boolean getOOBInline() throws SocketException {
-        return socket.getOOBInline();
-    }
-    public int getPort() {
-        return socket.getPort();
-    }
-    public int getReceiveBufferSize() throws SocketException {
-        return socket.getReceiveBufferSize();
-    }
-    public SocketAddress getRemoteSocketAddress() {
-        return socket.getRemoteSocketAddress();
-    }
-    public boolean getReuseAddress() throws SocketException {
-        return socket.getReuseAddress();
-    }
-    public int getSendBufferSize() throws SocketException {
-        return socket.getSendBufferSize();
-    }
-    public int getSoLinger() throws SocketException {
-        return socket.getSoLinger();
-    }
-    public int getSoTimeout() throws SocketException {
-        return socket.getSoTimeout();
-    }
-    public boolean getTcpNoDelay() throws SocketException {
-        return socket.getTcpNoDelay();
-    }
-    public int getTrafficClass() throws SocketException {
-        return socket.getTrafficClass();
-    }
-    public boolean isBound() {
-        return socket.isBound();
-    }
-    public boolean isClosed() {
-        return socket.isClosed();
-    }
-    public boolean isConnected() {
-        return socket.isConnected();
-    }
-    public void setKeepAlive(boolean on) throws SocketException {
-        socket.setKeepAlive(on);
-    }
-    public void setOOBInline(boolean on) throws SocketException {
-        socket.setOOBInline(on);
-    }
-    public void setReceiveBufferSize(int size) throws SocketException {
-        socket.setReceiveBufferSize(size);
-    }
-    public void setReuseAddress(boolean on) throws SocketException {
-        socket.setReuseAddress(on);
-    }
-    public void setSendBufferSize(int size) throws SocketException {
-        socket.setSendBufferSize(size);
-    }
-    public void setSoLinger(boolean on, int linger) throws SocketException {
-        socket.setSoLinger(on, linger);
-    }
-    public void setTcpNoDelay(boolean on) throws SocketException {
-        socket.setTcpNoDelay(on);
-    }
-    public void setTrafficClass(int tc) throws SocketException {
-        socket.setTrafficClass(tc);
-    }
-    
-    public Object getAdapter(Class target) {
-        if( target.isAssignableFrom(getClass()) ) {
-            return this;
-        }
-        return null;
-    }
-
-    public String toString() {
-        return "Socket Connection: "+getLocalSocketAddress()+" -> "+getRemoteSocketAddress();
-    }
-
-    public InputStream getInputStream() throws IOException {
-        return in;
-    }
-
-    public OutputStream getOutputStream() throws IOException {
-        return out;
-    }
-
-    public Socket getSocket() {
-        return socket;
-    }
-
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+package org.apache.activeio.stream.sync.socket;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketException;
+
+import org.apache.activeio.stream.sync.StreamChannel;
+
+/**
+ * A {@see org.apache.activeio.StreamChannel} implementation that uses a {@see java.net.Socket}
+ *  to talk to the network.
+ * 
+ * @version $Revision$
+ */
+public class SocketStreamChannel implements StreamChannel, SocketMetadata {
+
+    private final Socket socket;
+    private final OutputStream out;
+    private final InputStream in;    
+    private boolean disposed;
+    private int curentSoTimeout;
+
+    public SocketStreamChannel(Socket socket) throws IOException {
+        this.socket = socket;
+        in = socket.getInputStream();
+        out = socket.getOutputStream();        
+    }
+
+    public void setSoTimeout(int i) throws SocketException {
+        if( curentSoTimeout != i ) {
+            socket.setSoTimeout(i);
+            curentSoTimeout = i;
+        }
+    }
+    
+    /**
+     * @see org.apache.activeio.Disposable#dispose()
+     */
+    public void dispose() {
+        if (disposed)
+            return;
+
+        try {
+            out.close();
+        } catch (IOException ignore) {
+        }
+        try {
+            in.close();
+        } catch (IOException ignore) {
+        }
+        try {
+            socket.close();
+        } catch (IOException ignore) {
+        }
+        disposed = true;
+    }
+
+    public void start() throws IOException {
+    }
+    public void stop() throws IOException {
+    }
+    
+    public InetAddress getInetAddress() {
+        return socket.getInetAddress();
+    }
+    public boolean getKeepAlive() throws SocketException {
+        return socket.getKeepAlive();
+    }
+    public InetAddress getLocalAddress() {
+        return socket.getLocalAddress();
+    }
+    public int getLocalPort() {
+        return socket.getLocalPort();
+    }
+    public SocketAddress getLocalSocketAddress() {
+        return socket.getLocalSocketAddress();
+    }
+    public boolean getOOBInline() throws SocketException {
+        return socket.getOOBInline();
+    }
+    public int getPort() {
+        return socket.getPort();
+    }
+    public int getReceiveBufferSize() throws SocketException {
+        return socket.getReceiveBufferSize();
+    }
+    public SocketAddress getRemoteSocketAddress() {
+        return socket.getRemoteSocketAddress();
+    }
+    public boolean getReuseAddress() throws SocketException {
+        return socket.getReuseAddress();
+    }
+    public int getSendBufferSize() throws SocketException {
+        return socket.getSendBufferSize();
+    }
+    public int getSoLinger() throws SocketException {
+        return socket.getSoLinger();
+    }
+    public int getSoTimeout() throws SocketException {
+        return socket.getSoTimeout();
+    }
+    public boolean getTcpNoDelay() throws SocketException {
+        return socket.getTcpNoDelay();
+    }
+    public int getTrafficClass() throws SocketException {
+        return socket.getTrafficClass();
+    }
+    public boolean isBound() {
+        return socket.isBound();
+    }
+    public boolean isClosed() {
+        return socket.isClosed();
+    }
+    public boolean isConnected() {
+        return socket.isConnected();
+    }
+    public void setKeepAlive(boolean on) throws SocketException {
+        socket.setKeepAlive(on);
+    }
+    public void setOOBInline(boolean on) throws SocketException {
+        socket.setOOBInline(on);
+    }
+    public void setReceiveBufferSize(int size) throws SocketException {
+        socket.setReceiveBufferSize(size);
+    }
+    public void setReuseAddress(boolean on) throws SocketException {
+        socket.setReuseAddress(on);
+    }
+    public void setSendBufferSize(int size) throws SocketException {
+        socket.setSendBufferSize(size);
+    }
+    public void setSoLinger(boolean on, int linger) throws SocketException {
+        socket.setSoLinger(on, linger);
+    }
+    public void setTcpNoDelay(boolean on) throws SocketException {
+        socket.setTcpNoDelay(on);
+    }
+    public void setTrafficClass(int tc) throws SocketException {
+        socket.setTrafficClass(tc);
+    }
+    
+    public Object getAdapter(Class target) {
+        if( target.isAssignableFrom(getClass()) ) {
+            return this;
+        }
+        return null;
+    }
+
+    public String toString() {
+        return "Socket Connection: "+getLocalSocketAddress()+" -> "+getRemoteSocketAddress();
+    }
+
+    public InputStream getInputStream() throws IOException {
+        return in;
+    }
+
+    public OutputStream getOutputStream() throws IOException {
+        return out;
+    }
+
+    public Socket getSocket() {
+        return socket;
+    }
+
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java Tue Feb 21 15:12:56 2006
@@ -1,145 +1,145 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * 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.
- */
-package org.apache.activeio.stream.sync.socket;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.net.ServerSocketFactory;
-import javax.net.SocketFactory;
-
-import org.apache.activeio.stream.sync.StreamChannel;
-import org.apache.activeio.stream.sync.StreamChannelFactory;
-import org.apache.activeio.stream.sync.StreamChannelServer;
-import org.apache.activeio.util.URISupport;
-
-/**
- * A TcpStreamChannelFactory creates {@see org.apache.activeio.net.TcpStreamChannel}
- * and {@see org.apache.activeio.net.TcpStreamChannelServer} objects.
- * 
- * @version $Revision$
- */
-public class SocketStreamChannelFactory implements StreamChannelFactory {
-
-    protected static final int DEFAULT_BACKLOG = 500;
-
-    private final SocketFactory socketFactory;
-    private final ServerSocketFactory serverSocketFactory;
-    private int backlog = DEFAULT_BACKLOG;
-    
-    public SocketStreamChannelFactory() {
-        this(SocketFactory.getDefault(), ServerSocketFactory.getDefault());
-    }
-
-    public SocketStreamChannelFactory(SocketFactory socketFactory, ServerSocketFactory serverSocketFactory) {
-        this.socketFactory = socketFactory;
-        this.serverSocketFactory = serverSocketFactory;
-    }
-        
-    /**
-     * Uses the {@param location}'s host and port to create a tcp connection to a remote host.
-     * 
-     * @see org.apache.activeio.StreamChannelFactory#openStreamChannel(java.net.URI)
-     */
-    public StreamChannel openStreamChannel(URI location) throws IOException {
-        Socket socket=null;
-        String path=location.getPath();
-        // see if the path is a local URI location
-        if(path!=null&&path.length()>0){
-            if (path.indexOf('/')==0){
-                //strip leading slash
-                path = path.substring(1,path.length());
-            }
-            int localPortIndex=path.indexOf(':');
-            try{
-                int localPort = Integer.parseInt(path.substring((localPortIndex+1),path.length()));
-                InetAddress localAddress = InetAddress.getByName(path);
-                socket = socketFactory.createSocket(location.getHost(), location.getPort(),localAddress,localPort);
-            }catch(Exception e){
-                System.err.println("Could not define local address and port from path: " + path);
-                e.printStackTrace();
-            }
-        }
-        if (socket==null){
-            socket = socketFactory.createSocket(location.getHost(), location.getPort());
-        }
-        return createStreamChannel(socket);
-    }
-
-    /**
-     * @param socket
-     * @return
-     * @throws IOException
-     */
-    protected StreamChannel createStreamChannel(Socket socket) throws IOException {
-        return new SocketStreamChannel(socket);
-    }
-
-    /**
-     * Binds a server socket a the {@param bindURI}'s port.
-     * 
-     * @see org.apache.activeio.StreamChannelFactory#bindStreamChannel(java.net.URI)
-     */
-    public StreamChannelServer bindStreamChannel(URI bindURI) throws IOException {
-        
-        String host = bindURI.getHost();
-        InetAddress addr;
-        if( host == null || host.length() == 0 || host.equals("localhost") || host.equals("0.0.0.0") || InetAddress.getLocalHost().getHostName().equals(host) ) {            
-            addr = InetAddress.getLocalHost();
-        } else {
-            addr = InetAddress.getByName(host);
-        }
-        ServerSocket serverSocket;
-        
-        if (addr.equals(InetAddress.getLocalHost())) {
-            serverSocket = serverSocketFactory.createServerSocket(bindURI.getPort(), backlog);
-        } else {
-            serverSocket = serverSocketFactory.createServerSocket(bindURI.getPort(), backlog, addr);
-        }
-
-        URI connectURI=bindURI;
-        try {
-            // connectURI = URISupport.changeHost(connectURI, addr.getHostName());
-            connectURI = URISupport.changePort(connectURI, serverSocket.getLocalPort());
-        } catch (URISyntaxException e) {
-            throw (IOException)new IOException("Could build connect URI: "+e).initCause(e);
-        }
-        
-        return new SocketStreamChannelServer(serverSocket, bindURI, connectURI);
-    }
-    
-    /**
-     * @return Returns the backlog.
-     */
-    public int getBacklog() {
-        return backlog;
-    }
-
-    /**
-     * @param backlog
-     *            The backlog to set.
-     */
-    public void setBacklog(int backlog) {
-        this.backlog = backlog;
-    }
-
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.activeio.stream.sync.socket;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import org.apache.activeio.stream.sync.StreamChannel;
+import org.apache.activeio.stream.sync.StreamChannelFactory;
+import org.apache.activeio.stream.sync.StreamChannelServer;
+import org.apache.activeio.util.URISupport;
+
+/**
+ * A TcpStreamChannelFactory creates {@see org.apache.activeio.net.TcpStreamChannel}
+ * and {@see org.apache.activeio.net.TcpStreamChannelServer} objects.
+ * 
+ * @version $Revision$
+ */
+public class SocketStreamChannelFactory implements StreamChannelFactory {
+
+    protected static final int DEFAULT_BACKLOG = 500;
+
+    private final SocketFactory socketFactory;
+    private final ServerSocketFactory serverSocketFactory;
+    private int backlog = DEFAULT_BACKLOG;
+    
+    public SocketStreamChannelFactory() {
+        this(SocketFactory.getDefault(), ServerSocketFactory.getDefault());
+    }
+
+    public SocketStreamChannelFactory(SocketFactory socketFactory, ServerSocketFactory serverSocketFactory) {
+        this.socketFactory = socketFactory;
+        this.serverSocketFactory = serverSocketFactory;
+    }
+        
+    /**
+     * Uses the {@param location}'s host and port to create a tcp connection to a remote host.
+     * 
+     * @see org.apache.activeio.StreamChannelFactory#openStreamChannel(java.net.URI)
+     */
+    public StreamChannel openStreamChannel(URI location) throws IOException {
+        Socket socket=null;
+        String path=location.getPath();
+        // see if the path is a local URI location
+        if(path!=null&&path.length()>0){
+            if (path.indexOf('/')==0){
+                //strip leading slash
+                path = path.substring(1,path.length());
+            }
+            int localPortIndex=path.indexOf(':');
+            try{
+                int localPort = Integer.parseInt(path.substring((localPortIndex+1),path.length()));
+                InetAddress localAddress = InetAddress.getByName(path);
+                socket = socketFactory.createSocket(location.getHost(), location.getPort(),localAddress,localPort);
+            }catch(Exception e){
+                System.err.println("Could not define local address and port from path: " + path);
+                e.printStackTrace();
+            }
+        }
+        if (socket==null){
+            socket = socketFactory.createSocket(location.getHost(), location.getPort());
+        }
+        return createStreamChannel(socket);
+    }
+
+    /**
+     * @param socket
+     * @return
+     * @throws IOException
+     */
+    protected StreamChannel createStreamChannel(Socket socket) throws IOException {
+        return new SocketStreamChannel(socket);
+    }
+
+    /**
+     * Binds a server socket a the {@param bindURI}'s port.
+     * 
+     * @see org.apache.activeio.StreamChannelFactory#bindStreamChannel(java.net.URI)
+     */
+    public StreamChannelServer bindStreamChannel(URI bindURI) throws IOException {
+        
+        String host = bindURI.getHost();
+        InetAddress addr;
+        if( host == null || host.length() == 0 || host.equals("localhost") || host.equals("0.0.0.0") || InetAddress.getLocalHost().getHostName().equals(host) ) {            
+            addr = InetAddress.getLocalHost();
+        } else {
+            addr = InetAddress.getByName(host);
+        }
+        ServerSocket serverSocket;
+        
+        if (addr.equals(InetAddress.getLocalHost())) {
+            serverSocket = serverSocketFactory.createServerSocket(bindURI.getPort(), backlog);
+        } else {
+            serverSocket = serverSocketFactory.createServerSocket(bindURI.getPort(), backlog, addr);
+        }
+
+        URI connectURI=bindURI;
+        try {
+            // connectURI = URISupport.changeHost(connectURI, addr.getHostName());
+            connectURI = URISupport.changePort(connectURI, serverSocket.getLocalPort());
+        } catch (URISyntaxException e) {
+            throw (IOException)new IOException("Could build connect URI: "+e).initCause(e);
+        }
+        
+        return new SocketStreamChannelServer(serverSocket, bindURI, connectURI);
+    }
+    
+    /**
+     * @return Returns the backlog.
+     */
+    public int getBacklog() {
+        return backlog;
+    }
+
+    /**
+     * @param backlog
+     *            The backlog to set.
+     */
+    public void setBacklog(int backlog) {
+        this.backlog = backlog;
+    }
+
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message