activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r379619 [3/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/ activ...
Date Tue, 21 Feb 2006 23:14:17 GMT
Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/Service.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/Service.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/Service.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/Service.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;
-
-import java.io.IOException;
-
-/**
- * The Service interface is used control the running state of a channel.
- *  
- * Some channels may use background threads to provide SEDA style processing.  By
- * implenting the Service interface, a protcol can allow a container to
- * control those threads.
- *  
- * @version $Revision$
- */
-public interface Service {
-
-	static final public long NO_WAIT_TIMEOUT=0;
-	static final public long WAIT_FOREVER_TIMEOUT=-1;	
-
-	/**
-	 * Starts the channel.  Once started, the channel is in the running state.  
-	 *  
-	 * @throws IOException
-	 */
-    void start() throws IOException;
-
-    /**
-	 * Stops the channel.  Once stopped, the channel is in the stopped state.
-	 * 
-	 * @throws IOException
-	 */
-    void stop() throws IOException;
-        
-    /**
-     * Disposes the channel.  Once disposed, the channel cannot be used anymore.
-     * 
-     * @throws IOException
-     */
-    void dispose();
-}
+/**
+ *
+ * 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;
+
+import java.io.IOException;
+
+/**
+ * The Service interface is used control the running state of a channel.
+ *  
+ * Some channels may use background threads to provide SEDA style processing.  By
+ * implenting the Service interface, a protcol can allow a container to
+ * control those threads.
+ *  
+ * @version $Revision$
+ */
+public interface Service {
+
+	static final public long NO_WAIT_TIMEOUT=0;
+	static final public long WAIT_FOREVER_TIMEOUT=-1;	
+
+	/**
+	 * Starts the channel.  Once started, the channel is in the running state.  
+	 *  
+	 * @throws IOException
+	 */
+    void start() throws IOException;
+
+    /**
+	 * Stops the channel.  Once stopped, the channel is in the stopped state.
+	 * 
+	 * @throws IOException
+	 */
+    void stop() throws IOException;
+        
+    /**
+     * Disposes the channel.  Once disposed, the channel cannot be used anymore.
+     * 
+     * @throws IOException
+     */
+    void dispose();
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncChannelToOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncChannelToOutputStream.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncChannelToOutputStream.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncChannelToOutputStream.java Tue Feb 21 15:12:56 2006
@@ -1,72 +1,72 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.BytePacket;
-import org.apache.activeio.packet.async.AsyncChannel;
-
-/**
- */
-public class AsyncChannelToOutputStream extends OutputStream {
-
-    private final AsyncChannel channel;
-    private boolean closed;
-
-    /**
-     * @param channel
-     */
-    public AsyncChannelToOutputStream(AsyncChannel channel) {
-        this.channel = channel;
-    }
-
-    /**
-     * @see java.io.OutputStream#write(int)
-     */
-    public void write(int b) throws IOException {
-        channel.write(new BytePacket((byte) b));
-    }
-
-    /**
-     * @see java.io.OutputStream#write(byte[], int, int)
-     */
-    public void write(byte[] b, int off, int len) throws IOException {
-        channel.write(new ByteArrayPacket(b, off, len));
-    }
-    
-    /**
-     * @see java.io.OutputStream#flush()
-     */
-    public void flush() throws IOException {
-        channel.flush();
-    }
-            
-    /**
-     * @see java.io.InputStream#close()
-     */
-    public void close() throws IOException {
-        closed=true;
-        super.close();
-    }
-    
-    public boolean isClosed() {
-        return closed;
-    }    
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.BytePacket;
+import org.apache.activeio.packet.async.AsyncChannel;
+
+/**
+ */
+public class AsyncChannelToOutputStream extends OutputStream {
+
+    private final AsyncChannel channel;
+    private boolean closed;
+
+    /**
+     * @param channel
+     */
+    public AsyncChannelToOutputStream(AsyncChannel channel) {
+        this.channel = channel;
+    }
+
+    /**
+     * @see java.io.OutputStream#write(int)
+     */
+    public void write(int b) throws IOException {
+        channel.write(new BytePacket((byte) b));
+    }
+
+    /**
+     * @see java.io.OutputStream#write(byte[], int, int)
+     */
+    public void write(byte[] b, int off, int len) throws IOException {
+        channel.write(new ByteArrayPacket(b, off, len));
+    }
+    
+    /**
+     * @see java.io.OutputStream#flush()
+     */
+    public void flush() throws IOException {
+        channel.flush();
+    }
+            
+    /**
+     * @see java.io.InputStream#close()
+     */
+    public void close() throws IOException {
+        closed=true;
+        super.close();
+    }
+    
+    public boolean isClosed() {
+        return closed;
+    }    
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannel.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannel.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannel.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannel.java Tue Feb 21 15:12:56 2006
@@ -1,180 +1,180 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-
-import org.apache.activeio.packet.Packet;
-import org.apache.activeio.packet.async.AsyncChannel;
-import org.apache.activeio.packet.async.AsyncChannelListener;
-import org.apache.activeio.packet.sync.SyncChannel;
-
-import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-
-/**
- * Adapts a {@see org.apache.activeio.AsyncChannel} so that it provides an 
- * {@see org.apache.activeio.SynchChannel} interface.  
- * 
- * This object buffers asynchronous messages from the {@see org.apache.activeio.AsyncChannel} 
- * and buffers them in a {@see edu.emory.mathcs.backport.java.util.concurrent.Channel} util the client receives them.
- * 
- * @version $Revision$
- */
-final public class AsyncToSyncChannel implements SyncChannel, AsyncChannelListener {
-
-    private final AsyncChannel asyncChannel;    
-    private final BlockingQueue buffer;
-
-    static public SyncChannel adapt(org.apache.activeio.Channel channel) {
-        return adapt(channel, new LinkedBlockingQueue());
-    }
-
-    static public SyncChannel adapt(org.apache.activeio.Channel channel, BlockingQueue upPacketChannel) {
-
-        // It might not need adapting
-        if( channel instanceof SyncChannel ) {
-            return (SyncChannel) channel;
-        }
-
-        // Can we just just undo the adaptor
-        if( channel.getClass() == SyncToAsyncChannel.class ) {
-            return ((SyncToAsyncChannel)channel).getSynchChannel();
-        }
-        
-        return new AsyncToSyncChannel((AsyncChannel)channel, upPacketChannel);        
-    }
-    
-    /**
-     * @deprecated {@see #adapt(AsyncChannel)}
-     */
-    public AsyncToSyncChannel(AsyncChannel asyncChannel) {
-        this(asyncChannel, new LinkedBlockingQueue());
-    }
-    
-    /**
-     * @deprecated {@see #adapt(AsyncChannel, Channel)}
-     */
-    public AsyncToSyncChannel(AsyncChannel asyncChannel, BlockingQueue upPacketChannel){
-        this.asyncChannel = asyncChannel;
-        this.asyncChannel.setAsyncChannelListener(this);
-        this.buffer=upPacketChannel;
-    }
-
-    /**
-     * @see org.apache.activeio.Channel#write(org.apache.activeio.packet.Packet)
-     */
-    public void write(org.apache.activeio.packet.Packet packet) throws IOException {
-        asyncChannel.write(packet);
-    }
-
-    /**
-     * @see org.apache.activeio.Channel#flush()
-     */
-    public void flush() throws IOException {
-        asyncChannel.flush();
-    }
-
-    /**
-     * @see org.apache.activeio.packet.sync.SyncChannel#read(long)
-     */
-    public Packet read(long timeout) throws IOException {
-        try {
-            
-            Object o;
-            if( timeout == NO_WAIT_TIMEOUT ) {
-                o = buffer.poll(0, TimeUnit.MILLISECONDS);
-            } else if( timeout == WAIT_FOREVER_TIMEOUT ) {
-                o = buffer.take();            
-            } else {
-                o = buffer.poll(timeout, TimeUnit.MILLISECONDS);                        
-            }
-            
-            if( o == null )
-                return null;
-            
-            if( o instanceof Packet )
-                return (Packet)o;     
-            
-            Throwable e = (Throwable)o;
-            throw (IOException)new IOException("Async error occurred: "+e).initCause(e);
-            
-        } catch (InterruptedException e) {
-            throw new InterruptedIOException(e.getMessage());
-        }
-    }
-
-    /**
-     * @see org.apache.activeio.Disposable#dispose()
-     */
-    public void dispose() {
-        asyncChannel.dispose();
-    }
-
-    /**
-     * @see org.apache.activeio.Service#start()
-     */
-    public void start() throws IOException {
-        asyncChannel.start();
-    }
-
-    /**
-     * @see org.apache.activeio.Service#stop()
-     */
-    public void stop() throws IOException {
-        asyncChannel.stop();
-    }
-
-    /**
-     * @see org.apache.activeio.packet.async.AsyncChannelListener#onPacket(org.apache.activeio.packet.Packet)
-     */
-    public void onPacket(Packet packet) {
-        try {
-            buffer.put(packet);
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-        }        
-    }
-
-    /**
-     * @see org.apache.activeio.packet.async.AsyncChannelListener#onPacketError(org.apache.activeio.ChannelException)
-     */
-    public void onPacketError(IOException error) {
-        try {
-            buffer.put(error);
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-        }        
-    }
-
-    public Object getAdapter(Class target) {
-        if( target.isAssignableFrom(getClass()) ) {
-            return this;
-        }
-        return asyncChannel.getAdapter(target);
-    }    
-
-    public AsyncChannel getAsyncChannel() {
-        return asyncChannel;
-    }
-    
-    public String toString() {
-        return asyncChannel.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.adapter;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.packet.async.AsyncChannelListener;
+import org.apache.activeio.packet.sync.SyncChannel;
+
+import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+
+/**
+ * Adapts a {@see org.apache.activeio.AsyncChannel} so that it provides an 
+ * {@see org.apache.activeio.SynchChannel} interface.  
+ * 
+ * This object buffers asynchronous messages from the {@see org.apache.activeio.AsyncChannel} 
+ * and buffers them in a {@see edu.emory.mathcs.backport.java.util.concurrent.Channel} util the client receives them.
+ * 
+ * @version $Revision$
+ */
+final public class AsyncToSyncChannel implements SyncChannel, AsyncChannelListener {
+
+    private final AsyncChannel asyncChannel;    
+    private final BlockingQueue buffer;
+
+    static public SyncChannel adapt(org.apache.activeio.Channel channel) {
+        return adapt(channel, new LinkedBlockingQueue());
+    }
+
+    static public SyncChannel adapt(org.apache.activeio.Channel channel, BlockingQueue upPacketChannel) {
+
+        // It might not need adapting
+        if( channel instanceof SyncChannel ) {
+            return (SyncChannel) channel;
+        }
+
+        // Can we just just undo the adaptor
+        if( channel.getClass() == SyncToAsyncChannel.class ) {
+            return ((SyncToAsyncChannel)channel).getSynchChannel();
+        }
+        
+        return new AsyncToSyncChannel((AsyncChannel)channel, upPacketChannel);        
+    }
+    
+    /**
+     * @deprecated {@see #adapt(AsyncChannel)}
+     */
+    public AsyncToSyncChannel(AsyncChannel asyncChannel) {
+        this(asyncChannel, new LinkedBlockingQueue());
+    }
+    
+    /**
+     * @deprecated {@see #adapt(AsyncChannel, Channel)}
+     */
+    public AsyncToSyncChannel(AsyncChannel asyncChannel, BlockingQueue upPacketChannel){
+        this.asyncChannel = asyncChannel;
+        this.asyncChannel.setAsyncChannelListener(this);
+        this.buffer=upPacketChannel;
+    }
+
+    /**
+     * @see org.apache.activeio.Channel#write(org.apache.activeio.packet.Packet)
+     */
+    public void write(org.apache.activeio.packet.Packet packet) throws IOException {
+        asyncChannel.write(packet);
+    }
+
+    /**
+     * @see org.apache.activeio.Channel#flush()
+     */
+    public void flush() throws IOException {
+        asyncChannel.flush();
+    }
+
+    /**
+     * @see org.apache.activeio.packet.sync.SyncChannel#read(long)
+     */
+    public Packet read(long timeout) throws IOException {
+        try {
+            
+            Object o;
+            if( timeout == NO_WAIT_TIMEOUT ) {
+                o = buffer.poll(0, TimeUnit.MILLISECONDS);
+            } else if( timeout == WAIT_FOREVER_TIMEOUT ) {
+                o = buffer.take();            
+            } else {
+                o = buffer.poll(timeout, TimeUnit.MILLISECONDS);                        
+            }
+            
+            if( o == null )
+                return null;
+            
+            if( o instanceof Packet )
+                return (Packet)o;     
+            
+            Throwable e = (Throwable)o;
+            throw (IOException)new IOException("Async error occurred: "+e).initCause(e);
+            
+        } catch (InterruptedException e) {
+            throw new InterruptedIOException(e.getMessage());
+        }
+    }
+
+    /**
+     * @see org.apache.activeio.Disposable#dispose()
+     */
+    public void dispose() {
+        asyncChannel.dispose();
+    }
+
+    /**
+     * @see org.apache.activeio.Service#start()
+     */
+    public void start() throws IOException {
+        asyncChannel.start();
+    }
+
+    /**
+     * @see org.apache.activeio.Service#stop()
+     */
+    public void stop() throws IOException {
+        asyncChannel.stop();
+    }
+
+    /**
+     * @see org.apache.activeio.packet.async.AsyncChannelListener#onPacket(org.apache.activeio.packet.Packet)
+     */
+    public void onPacket(Packet packet) {
+        try {
+            buffer.put(packet);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }        
+    }
+
+    /**
+     * @see org.apache.activeio.packet.async.AsyncChannelListener#onPacketError(org.apache.activeio.ChannelException)
+     */
+    public void onPacketError(IOException error) {
+        try {
+            buffer.put(error);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }        
+    }
+
+    public Object getAdapter(Class target) {
+        if( target.isAssignableFrom(getClass()) ) {
+            return this;
+        }
+        return asyncChannel.getAdapter(target);
+    }    
+
+    public AsyncChannel getAsyncChannel() {
+        return asyncChannel;
+    }
+    
+    public String toString() {
+        return asyncChannel.toString();
+    }
 }

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelFactory.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelFactory.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelFactory.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelFactory.java Tue Feb 21 15:12:56 2006
@@ -1,65 +1,65 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.activeio.packet.async.AsyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.SyncChannelFactory;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-
-/**
- * @version $Revision$
- */
-final public class AsyncToSyncChannelFactory implements SyncChannelFactory {
-    
-    private AsyncChannelFactory asyncChannelFactory;
-    
-    static public SyncChannelFactory adapt(AsyncChannelFactory channelFactory ) {
-
-        // It might not need adapting
-        if( channelFactory instanceof SyncChannelServer ) {
-            return (SyncChannelFactory) channelFactory;
-        }
-
-        // Can we just just undo the adaptor
-        if( channelFactory.getClass() == SyncToAsyncChannelFactory.class ) {
-            return ((SyncToAsyncChannelFactory)channelFactory).getSyncChannelFactory();
-        }
-        
-        return new AsyncToSyncChannelFactory((AsyncChannelFactory)channelFactory);        
-    }
-    
-    
-    private AsyncToSyncChannelFactory(AsyncChannelFactory asyncChannelFactory) {
-        this.asyncChannelFactory = asyncChannelFactory;
-    }
-        
-    public SyncChannel openSyncChannel(URI location) throws IOException {
-        return AsyncToSyncChannel.adapt( asyncChannelFactory.openAsyncChannel(location) );
-    }
-    
-    public SyncChannelServer bindSyncChannel(URI location) throws IOException {
-        return AsyncToSyncChannelServer.adapt(asyncChannelFactory.bindAsyncChannel(location));
-    }
-    
-    public AsyncChannelFactory getAsyncChannelFactory() {
-        return asyncChannelFactory;
-    }
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.activeio.packet.async.AsyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.SyncChannelFactory;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+
+/**
+ * @version $Revision$
+ */
+final public class AsyncToSyncChannelFactory implements SyncChannelFactory {
+    
+    private AsyncChannelFactory asyncChannelFactory;
+    
+    static public SyncChannelFactory adapt(AsyncChannelFactory channelFactory ) {
+
+        // It might not need adapting
+        if( channelFactory instanceof SyncChannelServer ) {
+            return (SyncChannelFactory) channelFactory;
+        }
+
+        // Can we just just undo the adaptor
+        if( channelFactory.getClass() == SyncToAsyncChannelFactory.class ) {
+            return ((SyncToAsyncChannelFactory)channelFactory).getSyncChannelFactory();
+        }
+        
+        return new AsyncToSyncChannelFactory((AsyncChannelFactory)channelFactory);        
+    }
+    
+    
+    private AsyncToSyncChannelFactory(AsyncChannelFactory asyncChannelFactory) {
+        this.asyncChannelFactory = asyncChannelFactory;
+    }
+        
+    public SyncChannel openSyncChannel(URI location) throws IOException {
+        return AsyncToSyncChannel.adapt( asyncChannelFactory.openAsyncChannel(location) );
+    }
+    
+    public SyncChannelServer bindSyncChannel(URI location) throws IOException {
+        return AsyncToSyncChannelServer.adapt(asyncChannelFactory.bindAsyncChannel(location));
+    }
+    
+    public AsyncChannelFactory getAsyncChannelFactory() {
+        return asyncChannelFactory;
+    }
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelServer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelServer.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelServer.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/AsyncToSyncChannelServer.java Tue Feb 21 15:12:56 2006
@@ -1,176 +1,176 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.URI;
-
-import org.apache.activeio.AcceptListener;
-import org.apache.activeio.Channel;
-import org.apache.activeio.ChannelServer;
-import org.apache.activeio.packet.async.AsyncChannelServer;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-
-import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-
-/**
- * Adapts a {@see org.apache.activeio.AsyncChannelServer} so that it provides an 
- * {@see org.apache.activeio.SynchChannelServer} interface.  
- * 
- * This object buffers asynchronous accepts from the {@see org.apache.activeio.AsyncChannelServer} 
- * abs buffers them in a {@see edu.emory.mathcs.backport.java.util.concurrent.Channel} util the client accepts the 
- * connection.
- * 
- * @version $Revision$
- */
-final public class AsyncToSyncChannelServer implements SyncChannelServer, AcceptListener {
-
-    private final AsyncChannelServer asyncChannelServer;    
-    private final BlockingQueue acceptBuffer;
-    
-    static public SyncChannelServer adapt(ChannelServer channel) {
-        return adapt(channel, new LinkedBlockingQueue());
-    }
-
-    static public SyncChannelServer adapt(ChannelServer channel, BlockingQueue upPacketChannel) {
-
-        // It might not need adapting
-        if( channel instanceof SyncChannelServer ) {
-            return (SyncChannelServer) channel;
-        }
-
-        // Can we just just undo the adaptor
-        if( channel.getClass() == SyncToAsyncChannel.class ) {
-            return ((SyncToAsyncChannelServer)channel).getSynchChannelServer();
-        }
-        
-        return new AsyncToSyncChannelServer((AsyncChannelServer)channel, upPacketChannel);        
-    }
-    
-    /**
-     * @deprecated {@see #adapt(ChannelServer)}
-     */
-    public AsyncToSyncChannelServer(AsyncChannelServer asyncChannelServer) {
-        this(asyncChannelServer,new LinkedBlockingQueue());
-    }
-    
-    /**
-     * @deprecated {@see #adapt(ChannelServer, edu.emory.mathcs.backport.java.util.concurrent.Channel)}
-     */
-    public AsyncToSyncChannelServer(AsyncChannelServer asyncChannelServer, BlockingQueue acceptBuffer) {
-        this.asyncChannelServer = asyncChannelServer;
-        this.acceptBuffer=acceptBuffer;
-        this.asyncChannelServer.setAcceptListener(this);
-    }
-
-    /**
-     * @see org.apache.activeio.packet.sync.SyncChannelServer#accept(long)
-     */
-    public org.apache.activeio.Channel accept(long timeout) throws IOException {
-        try {
-            
-            Object o;
-            if( timeout == NO_WAIT_TIMEOUT ) {
-                o = acceptBuffer.poll(0, TimeUnit.MILLISECONDS);
-            } else if( timeout == WAIT_FOREVER_TIMEOUT ) {
-                o = acceptBuffer.take();            
-            } else {
-                o = acceptBuffer.poll(timeout, TimeUnit.MILLISECONDS);                        
-            }
-            
-            if( o == null )
-                return null;
-            
-            if( o instanceof Channel )
-                return (Channel)o;
-            
-            Throwable e = (Throwable)o;
-            throw (IOException)new IOException("Async error occurred: "+e).initCause(e);
-            
-        } catch (InterruptedException e) {
-            throw new InterruptedIOException(e.getMessage());
-        }
-    }
-    /**
-     * @see org.apache.activeio.Disposable#dispose()
-     */
-    public void dispose() {
-        asyncChannelServer.dispose();
-    }
-
-    /**
-     * @see org.apache.activeio.Service#start()
-     */
-    public void start() throws IOException {
-        asyncChannelServer.start();
-    }
-
-    /**
-     * @see org.apache.activeio.Service#stop()
-     */
-    public void stop() throws IOException {
-        asyncChannelServer.stop();
-    }
-
-    public URI getBindURI() {
-        return asyncChannelServer.getBindURI();
-    }
-
-    public URI getConnectURI() {
-        return asyncChannelServer.getConnectURI();
-    }
-
-    /**
-     * @see org.apache.activeio.AcceptListener#onAccept(org.apache.activeio.Channel)
-     */
-    public void onAccept(org.apache.activeio.Channel channel) {
-        try {
-            acceptBuffer.put(channel);
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-        }        
-    }
-    
-    /**
-     * @see org.apache.activeio.AcceptListener#onAcceptError(java.io.IOException)
-     */
-    public void onAcceptError(IOException error) {
-        try {
-            acceptBuffer.put(error);
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-        }        
-    }
-    
-    public AsyncChannelServer getAsyncChannelServer() {
-        return asyncChannelServer;
-    }
-    
-    public Object getAdapter(Class target) {
-        if( target.isAssignableFrom(getClass()) ) {
-            return this;
-        }
-        return asyncChannelServer.getAdapter(target);
-    }    
-    
-    public String toString() {
-        return asyncChannelServer.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.adapter;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.net.URI;
+
+import org.apache.activeio.AcceptListener;
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelServer;
+import org.apache.activeio.packet.async.AsyncChannelServer;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+
+import edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+
+/**
+ * Adapts a {@see org.apache.activeio.AsyncChannelServer} so that it provides an 
+ * {@see org.apache.activeio.SynchChannelServer} interface.  
+ * 
+ * This object buffers asynchronous accepts from the {@see org.apache.activeio.AsyncChannelServer} 
+ * abs buffers them in a {@see edu.emory.mathcs.backport.java.util.concurrent.Channel} util the client accepts the 
+ * connection.
+ * 
+ * @version $Revision$
+ */
+final public class AsyncToSyncChannelServer implements SyncChannelServer, AcceptListener {
+
+    private final AsyncChannelServer asyncChannelServer;    
+    private final BlockingQueue acceptBuffer;
+    
+    static public SyncChannelServer adapt(ChannelServer channel) {
+        return adapt(channel, new LinkedBlockingQueue());
+    }
+
+    static public SyncChannelServer adapt(ChannelServer channel, BlockingQueue upPacketChannel) {
+
+        // It might not need adapting
+        if( channel instanceof SyncChannelServer ) {
+            return (SyncChannelServer) channel;
+        }
+
+        // Can we just just undo the adaptor
+        if( channel.getClass() == SyncToAsyncChannel.class ) {
+            return ((SyncToAsyncChannelServer)channel).getSynchChannelServer();
+        }
+        
+        return new AsyncToSyncChannelServer((AsyncChannelServer)channel, upPacketChannel);        
+    }
+    
+    /**
+     * @deprecated {@see #adapt(ChannelServer)}
+     */
+    public AsyncToSyncChannelServer(AsyncChannelServer asyncChannelServer) {
+        this(asyncChannelServer,new LinkedBlockingQueue());
+    }
+    
+    /**
+     * @deprecated {@see #adapt(ChannelServer, edu.emory.mathcs.backport.java.util.concurrent.Channel)}
+     */
+    public AsyncToSyncChannelServer(AsyncChannelServer asyncChannelServer, BlockingQueue acceptBuffer) {
+        this.asyncChannelServer = asyncChannelServer;
+        this.acceptBuffer=acceptBuffer;
+        this.asyncChannelServer.setAcceptListener(this);
+    }
+
+    /**
+     * @see org.apache.activeio.packet.sync.SyncChannelServer#accept(long)
+     */
+    public org.apache.activeio.Channel accept(long timeout) throws IOException {
+        try {
+            
+            Object o;
+            if( timeout == NO_WAIT_TIMEOUT ) {
+                o = acceptBuffer.poll(0, TimeUnit.MILLISECONDS);
+            } else if( timeout == WAIT_FOREVER_TIMEOUT ) {
+                o = acceptBuffer.take();            
+            } else {
+                o = acceptBuffer.poll(timeout, TimeUnit.MILLISECONDS);                        
+            }
+            
+            if( o == null )
+                return null;
+            
+            if( o instanceof Channel )
+                return (Channel)o;
+            
+            Throwable e = (Throwable)o;
+            throw (IOException)new IOException("Async error occurred: "+e).initCause(e);
+            
+        } catch (InterruptedException e) {
+            throw new InterruptedIOException(e.getMessage());
+        }
+    }
+    /**
+     * @see org.apache.activeio.Disposable#dispose()
+     */
+    public void dispose() {
+        asyncChannelServer.dispose();
+    }
+
+    /**
+     * @see org.apache.activeio.Service#start()
+     */
+    public void start() throws IOException {
+        asyncChannelServer.start();
+    }
+
+    /**
+     * @see org.apache.activeio.Service#stop()
+     */
+    public void stop() throws IOException {
+        asyncChannelServer.stop();
+    }
+
+    public URI getBindURI() {
+        return asyncChannelServer.getBindURI();
+    }
+
+    public URI getConnectURI() {
+        return asyncChannelServer.getConnectURI();
+    }
+
+    /**
+     * @see org.apache.activeio.AcceptListener#onAccept(org.apache.activeio.Channel)
+     */
+    public void onAccept(org.apache.activeio.Channel channel) {
+        try {
+            acceptBuffer.put(channel);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }        
+    }
+    
+    /**
+     * @see org.apache.activeio.AcceptListener#onAcceptError(java.io.IOException)
+     */
+    public void onAcceptError(IOException error) {
+        try {
+            acceptBuffer.put(error);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }        
+    }
+    
+    public AsyncChannelServer getAsyncChannelServer() {
+        return asyncChannelServer;
+    }
+    
+    public Object getAdapter(Class target) {
+        if( target.isAssignableFrom(getClass()) ) {
+            return this;
+        }
+        return asyncChannelServer.getAdapter(target);
+    }    
+    
+    public String toString() {
+        return asyncChannelServer.toString();
+    }
 }

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketByteArrayOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketByteArrayOutputStream.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketByteArrayOutputStream.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketByteArrayOutputStream.java Tue Feb 21 15:12:56 2006
@@ -1,109 +1,109 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.activeio.packet.AppendedPacket;
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.Packet;
-
-/**
- *
- */
-final public class PacketByteArrayOutputStream extends OutputStream {
-    
-    private Packet result;
-    private Packet current;
-    int nextAllocationSize=0;
-    
-    public PacketByteArrayOutputStream() {
-    	this( 1024 );
-    }
-    
-    public PacketByteArrayOutputStream(int initialSize) {
-    	nextAllocationSize = initialSize;
-        current = allocate();
-    }
-    
-    protected Packet allocate() {
-    	ByteArrayPacket packet = new ByteArrayPacket(new byte[nextAllocationSize]);
-    	nextAllocationSize <<= 3; // x by 8
-        return packet;
-    }
-    
-    public void skip(int size) {
-        while( size > 0 ) {
-            if( !current.hasRemaining() ) {
-                allocatedNext();
-            }
-            
-            int skip = ((size <= current.remaining()) ? size : current.remaining());
-            current.position(current.position()+skip);
-            size -= skip;
-        }
-    }
-    
-    public void write(int b) throws IOException {
-        if( !current.hasRemaining() ) {
-            allocatedNext();
-        }
-        current.write(b);
-    }
-    
-    public void write(byte[] b, int off, int len) throws IOException {
-        while( len > 0 ) {
-	        if( !current.hasRemaining() ) {
-	            allocatedNext();
-	        }
-	        int wrote = current.write(b,off,len);
-	        off+=wrote;
-	        len-=wrote;
-        }
-    }
-    
-    private void allocatedNext() {
-        if( result == null ) {
-            current.flip();
-            result = current;
-        } else {
-            current.flip();
-            result = AppendedPacket.join(result, current);            
-        }
-        current = allocate();
-    }
-    
-    public Packet getPacket() {
-        if( result == null ) {
-            current.flip();
-            return current.slice();
-        } else {
-            current.flip();
-            return AppendedPacket.join(result, current);                
-        }
-    }
-
-    public void reset() {
-        result = null;
-        current.clear();
-    }
-
-    public int position() {
-        return current.position() + (result==null ? 0 : result.remaining());
-    }
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.activeio.packet.AppendedPacket;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.Packet;
+
+/**
+ *
+ */
+final public class PacketByteArrayOutputStream extends OutputStream {
+    
+    private Packet result;
+    private Packet current;
+    int nextAllocationSize=0;
+    
+    public PacketByteArrayOutputStream() {
+    	this( 1024 );
+    }
+    
+    public PacketByteArrayOutputStream(int initialSize) {
+    	nextAllocationSize = initialSize;
+        current = allocate();
+    }
+    
+    protected Packet allocate() {
+    	ByteArrayPacket packet = new ByteArrayPacket(new byte[nextAllocationSize]);
+    	nextAllocationSize <<= 3; // x by 8
+        return packet;
+    }
+    
+    public void skip(int size) {
+        while( size > 0 ) {
+            if( !current.hasRemaining() ) {
+                allocatedNext();
+            }
+            
+            int skip = ((size <= current.remaining()) ? size : current.remaining());
+            current.position(current.position()+skip);
+            size -= skip;
+        }
+    }
+    
+    public void write(int b) throws IOException {
+        if( !current.hasRemaining() ) {
+            allocatedNext();
+        }
+        current.write(b);
+    }
+    
+    public void write(byte[] b, int off, int len) throws IOException {
+        while( len > 0 ) {
+	        if( !current.hasRemaining() ) {
+	            allocatedNext();
+	        }
+	        int wrote = current.write(b,off,len);
+	        off+=wrote;
+	        len-=wrote;
+        }
+    }
+    
+    private void allocatedNext() {
+        if( result == null ) {
+            current.flip();
+            result = current;
+        } else {
+            current.flip();
+            result = AppendedPacket.join(result, current);            
+        }
+        current = allocate();
+    }
+    
+    public Packet getPacket() {
+        if( result == null ) {
+            current.flip();
+            return current.slice();
+        } else {
+            current.flip();
+            return AppendedPacket.join(result, current);                
+        }
+    }
+
+    public void reset() {
+        result = null;
+        current.clear();
+    }
+
+    public int position() {
+        return current.position() + (result==null ? 0 : result.remaining());
+    }
+}

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

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketOutputStream.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketOutputStream.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketOutputStream.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.adapter;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.activeio.packet.Packet;
-
-/**
- * Provides an OutputStream for a given Packet.
- *  
- * @version $Revision$
- */
-public class PacketOutputStream extends OutputStream {
-    
-    final Packet packet;
-    
-    public PacketOutputStream(Packet packet) {
-        this.packet = packet;
-    }
-
-    public void write(int b) throws IOException {
-        if( !packet.write(b) )
-            throw new IOException("Packet does not have any remaining space to write to.");
-    }
-    
-    public void write(byte[] b, int off, int len) throws IOException {
-        if( packet.write(b, off, len)!=len )
-            throw new IOException("Packet does not have "+len+" byte(s) left to write to.");
-    }
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.activeio.packet.Packet;
+
+/**
+ * Provides an OutputStream for a given Packet.
+ *  
+ * @version $Revision$
+ */
+public class PacketOutputStream extends OutputStream {
+    
+    final Packet packet;
+    
+    public PacketOutputStream(Packet packet) {
+        this.packet = packet;
+    }
+
+    public void write(int b) throws IOException {
+        if( !packet.write(b) )
+            throw new IOException("Packet does not have any remaining space to write to.");
+    }
+    
+    public void write(byte[] b, int off, int len) throws IOException {
+        if( packet.write(b, off, len)!=len )
+            throw new IOException("Packet does not have "+len+" byte(s) left to write to.");
+    }
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketToInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketToInputStream.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketToInputStream.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/PacketToInputStream.java Tue Feb 21 15:12:56 2006
@@ -1,54 +1,54 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.activeio.packet.Packet;
-
-/**
- * Provides an InputStream for a given Packet.
- *  
- * @version $Revision$
- */
-public class PacketToInputStream extends InputStream {
-    
-    final Packet packet;
-    
-    /**
-     * @param packet
-     */
-    public PacketToInputStream(Packet packet) {
-        this.packet = packet;
-    }
-    
-    /**
-     * @see java.io.InputStream#read()
-     */
-    public int read() throws IOException {
-        return packet.read();
-    }
-
-    /**
-     * @see java.io.InputStream#read(byte[], int, int)
-     */
-    public int read(byte[] b, int off, int len) throws IOException {
-        return packet.read(b, off, len);
-    }
-
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.activeio.packet.Packet;
+
+/**
+ * Provides an InputStream for a given Packet.
+ *  
+ * @version $Revision$
+ */
+public class PacketToInputStream extends InputStream {
+    
+    final Packet packet;
+    
+    /**
+     * @param packet
+     */
+    public PacketToInputStream(Packet packet) {
+        this.packet = packet;
+    }
+    
+    /**
+     * @see java.io.InputStream#read()
+     */
+    public int read() throws IOException {
+        return packet.read();
+    }
+
+    /**
+     * @see java.io.InputStream#read(byte[], int, int)
+     */
+    public int read(byte[] b, int off, int len) throws IOException {
+        return packet.read(b, off, len);
+    }
+
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelServerToServerSocket.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelServerToServerSocket.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelServerToServerSocket.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelServerToServerSocket.java Tue Feb 21 15:12:56 2006
@@ -1,133 +1,133 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.URI;
-import java.nio.channels.ServerSocketChannel;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-
-/**
- */
-public class SyncChannelServerToServerSocket extends ServerSocket {
-
-    private final SyncChannelServer channelServer;
-    private long timeout = Channel.WAIT_FOREVER_TIMEOUT;
-    boolean closed;
-    private InetAddress inetAddress;
-    private int localPort;
-    private SocketAddress localSocketAddress;
-    private int receiveBufferSize;
-    private boolean reuseAddress;
-    
-    /**
-     * @throws IOException
-     */
-    public SyncChannelServerToServerSocket(SyncChannelServer channelServer) throws IOException {
-        this.channelServer = channelServer;
-        URI connectURI = channelServer.getConnectURI();
-        localPort = connectURI.getPort();
-        inetAddress = InetAddress.getByName(connectURI.getHost());
-        localSocketAddress = new InetSocketAddress(inetAddress, localPort);        
-    }
-    
-    public synchronized void setSoTimeout(int timeout) throws SocketException {
-        if( timeout <= 0 )
-            this.timeout = Channel.WAIT_FOREVER_TIMEOUT;
-        else 
-            this.timeout = timeout;
-    }
-    
-    public synchronized int getSoTimeout() throws IOException {
-        if( timeout == Channel.WAIT_FOREVER_TIMEOUT )
-            return 0;
-        return (int) timeout;
-    }
-
-    public Socket accept() throws IOException {
-        Channel channel = channelServer.accept(timeout);
-        if( channel==null )
-            throw new InterruptedIOException();
-        
-        SyncChannel syncChannel = AsyncToSyncChannel.adapt(channel);            
-        syncChannel.start();
-        return new SyncChannelToSocket(syncChannel);
-                    
-    }
-    
-    public void bind(SocketAddress endpoint, int backlog) throws IOException {
-    	if (isClosed())
-    	    throw new SocketException("Socket is closed");
-  	    throw new SocketException("Already bound");
-    }
-    
-    public void bind(SocketAddress endpoint) throws IOException {
-    	if (isClosed())
-    	    throw new SocketException("Socket is closed");
-  	    throw new SocketException("Already bound");
-    }
-    
-    public ServerSocketChannel getChannel() {
-        return null;
-    }
-    
-    public InetAddress getInetAddress() {
-        return inetAddress;
-    }
-    public int getLocalPort() {
-        return localPort;
-    }
-    public SocketAddress getLocalSocketAddress() {
-        return localSocketAddress;
-    }    
-    public synchronized int getReceiveBufferSize() throws SocketException {
-        return receiveBufferSize;
-    }
-    
-    public boolean getReuseAddress() throws SocketException {
-        return reuseAddress;
-    }
-    
-    public boolean isBound() {
-        return true;
-    }
-    
-    public boolean isClosed() {
-        return closed;
-    }
-    
-    public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
-    }
-    
-    public synchronized void setReceiveBufferSize(int size) throws SocketException {
-        this.receiveBufferSize = size;
-    }
-    
-    public void setReuseAddress(boolean on) throws SocketException {
-        reuseAddress = on;
-    }    
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.URI;
+import java.nio.channels.ServerSocketChannel;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+
+/**
+ */
+public class SyncChannelServerToServerSocket extends ServerSocket {
+
+    private final SyncChannelServer channelServer;
+    private long timeout = Channel.WAIT_FOREVER_TIMEOUT;
+    boolean closed;
+    private InetAddress inetAddress;
+    private int localPort;
+    private SocketAddress localSocketAddress;
+    private int receiveBufferSize;
+    private boolean reuseAddress;
+    
+    /**
+     * @throws IOException
+     */
+    public SyncChannelServerToServerSocket(SyncChannelServer channelServer) throws IOException {
+        this.channelServer = channelServer;
+        URI connectURI = channelServer.getConnectURI();
+        localPort = connectURI.getPort();
+        inetAddress = InetAddress.getByName(connectURI.getHost());
+        localSocketAddress = new InetSocketAddress(inetAddress, localPort);        
+    }
+    
+    public synchronized void setSoTimeout(int timeout) throws SocketException {
+        if( timeout <= 0 )
+            this.timeout = Channel.WAIT_FOREVER_TIMEOUT;
+        else 
+            this.timeout = timeout;
+    }
+    
+    public synchronized int getSoTimeout() throws IOException {
+        if( timeout == Channel.WAIT_FOREVER_TIMEOUT )
+            return 0;
+        return (int) timeout;
+    }
+
+    public Socket accept() throws IOException {
+        Channel channel = channelServer.accept(timeout);
+        if( channel==null )
+            throw new InterruptedIOException();
+        
+        SyncChannel syncChannel = AsyncToSyncChannel.adapt(channel);            
+        syncChannel.start();
+        return new SyncChannelToSocket(syncChannel);
+                    
+    }
+    
+    public void bind(SocketAddress endpoint, int backlog) throws IOException {
+    	if (isClosed())
+    	    throw new SocketException("Socket is closed");
+  	    throw new SocketException("Already bound");
+    }
+    
+    public void bind(SocketAddress endpoint) throws IOException {
+    	if (isClosed())
+    	    throw new SocketException("Socket is closed");
+  	    throw new SocketException("Already bound");
+    }
+    
+    public ServerSocketChannel getChannel() {
+        return null;
+    }
+    
+    public InetAddress getInetAddress() {
+        return inetAddress;
+    }
+    public int getLocalPort() {
+        return localPort;
+    }
+    public SocketAddress getLocalSocketAddress() {
+        return localSocketAddress;
+    }    
+    public synchronized int getReceiveBufferSize() throws SocketException {
+        return receiveBufferSize;
+    }
+    
+    public boolean getReuseAddress() throws SocketException {
+        return reuseAddress;
+    }
+    
+    public boolean isBound() {
+        return true;
+    }
+    
+    public boolean isClosed() {
+        return closed;
+    }
+    
+    public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
+    }
+    
+    public synchronized void setReceiveBufferSize(int size) throws SocketException {
+        this.receiveBufferSize = size;
+    }
+    
+    public void setReuseAddress(boolean on) throws SocketException {
+        reuseAddress = on;
+    }    
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToInputStream.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToInputStream.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToInputStream.java Tue Feb 21 15:12:56 2006
@@ -1,114 +1,114 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.packet.EOSPacket;
-import org.apache.activeio.packet.Packet;
-import org.apache.activeio.packet.sync.SyncChannel;
-
-/**
- * Provides an InputStream for a given SynchChannel.
- *  
- * @version $Revision$
- */
-public class SyncChannelToInputStream extends InputStream {
-    
-    private final SyncChannel channel;
-    private Packet lastPacket;
-    private boolean closed;
-    private long timeout = Channel.WAIT_FOREVER_TIMEOUT;
-    
-    /**
-     * @param channel
-     */
-    public SyncChannelToInputStream(final SyncChannel channel) {
-        this.channel = channel;
-    }
-    
-    /**
-     * @see java.io.InputStream#read()
-     */
-    public int read() throws IOException {
-        while( true ) {
-            if( lastPacket==null ) {
-                try {
-                    lastPacket = channel.read(timeout);
-                } catch (IOException e) {
-                    throw (IOException)new IOException("Channel failed: "+e.getMessage()).initCause(e);
-                }
-            }
-            if( lastPacket.hasRemaining() ) {
-                return lastPacket.read();
-            }
-        }
-    }
-
-    /**
-     * @see java.io.InputStream#read(byte[], int, int)
-     */
-    public int read(byte[] b, int off, int len) throws IOException {
-        while( true ) {
-            if( lastPacket==null || !lastPacket.hasRemaining() ) {
-                try {
-                    lastPacket = channel.read(timeout);
-                } catch (IOException e) {
-                    throw (IOException)new IOException("Channel failed: "+e.getMessage()).initCause(e);
-                }
-            }
-            if( lastPacket==EOSPacket.EOS_PACKET ) {
-                return -1;
-            }
-            if( lastPacket!=null && lastPacket.hasRemaining() ) {
-                return lastPacket.read(b, off, len);
-            }
-        }
-    }
- 
-    /**
-     * @see java.io.InputStream#close()
-     */
-    public void close() throws IOException {
-        closed=true;
-        super.close();
-    }
-    
-    public boolean isClosed() {
-        return closed;
-    }
-
-    /**
-     * @param timeout
-     */
-    public void setTimeout(long timeout) {
-        if( timeout <= 0 )
-            timeout = Channel.WAIT_FOREVER_TIMEOUT;
-        this.timeout = timeout;
-    }
-
-    /**
-     * @return
-     */
-    public long getTimeout() {
-        if( timeout == Channel.WAIT_FOREVER_TIMEOUT )
-            return 0;
-        return timeout;
-    }
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.packet.EOSPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.sync.SyncChannel;
+
+/**
+ * Provides an InputStream for a given SynchChannel.
+ *  
+ * @version $Revision$
+ */
+public class SyncChannelToInputStream extends InputStream {
+    
+    private final SyncChannel channel;
+    private Packet lastPacket;
+    private boolean closed;
+    private long timeout = Channel.WAIT_FOREVER_TIMEOUT;
+    
+    /**
+     * @param channel
+     */
+    public SyncChannelToInputStream(final SyncChannel channel) {
+        this.channel = channel;
+    }
+    
+    /**
+     * @see java.io.InputStream#read()
+     */
+    public int read() throws IOException {
+        while( true ) {
+            if( lastPacket==null ) {
+                try {
+                    lastPacket = channel.read(timeout);
+                } catch (IOException e) {
+                    throw (IOException)new IOException("Channel failed: "+e.getMessage()).initCause(e);
+                }
+            }
+            if( lastPacket.hasRemaining() ) {
+                return lastPacket.read();
+            }
+        }
+    }
+
+    /**
+     * @see java.io.InputStream#read(byte[], int, int)
+     */
+    public int read(byte[] b, int off, int len) throws IOException {
+        while( true ) {
+            if( lastPacket==null || !lastPacket.hasRemaining() ) {
+                try {
+                    lastPacket = channel.read(timeout);
+                } catch (IOException e) {
+                    throw (IOException)new IOException("Channel failed: "+e.getMessage()).initCause(e);
+                }
+            }
+            if( lastPacket==EOSPacket.EOS_PACKET ) {
+                return -1;
+            }
+            if( lastPacket!=null && lastPacket.hasRemaining() ) {
+                return lastPacket.read(b, off, len);
+            }
+        }
+    }
+ 
+    /**
+     * @see java.io.InputStream#close()
+     */
+    public void close() throws IOException {
+        closed=true;
+        super.close();
+    }
+    
+    public boolean isClosed() {
+        return closed;
+    }
+
+    /**
+     * @param timeout
+     */
+    public void setTimeout(long timeout) {
+        if( timeout <= 0 )
+            timeout = Channel.WAIT_FOREVER_TIMEOUT;
+        this.timeout = timeout;
+    }
+
+    /**
+     * @return
+     */
+    public long getTimeout() {
+        if( timeout == Channel.WAIT_FOREVER_TIMEOUT )
+            return 0;
+        return timeout;
+    }
+}

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

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToOutputStream.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToOutputStream.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/adapter/SyncChannelToOutputStream.java Tue Feb 21 15:12:56 2006
@@ -1,72 +1,72 @@
-/**
- *
- * 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.adapter;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.BytePacket;
-import org.apache.activeio.packet.sync.SyncChannel;
-
-/**
- */
-public class SyncChannelToOutputStream extends OutputStream {
-
-    private final SyncChannel channel;
-    private boolean closed;
-
-    /**
-     * @param channel
-     */
-    public SyncChannelToOutputStream(SyncChannel channel) {
-        this.channel = channel;
-    }
-
-    /**
-     * @see java.io.OutputStream#write(int)
-     */
-    public void write(int b) throws IOException {
-        channel.write(new BytePacket((byte) b));
-    }
-
-    /**
-     * @see java.io.OutputStream#write(byte[], int, int)
-     */
-    public void write(byte[] b, int off, int len) throws IOException {
-        channel.write(new ByteArrayPacket(b, off, len));
-    }
-    
-    /**
-     * @see java.io.OutputStream#flush()
-     */
-    public void flush() throws IOException {
-        channel.flush();
-    }
-            
-    /**
-     * @see java.io.InputStream#close()
-     */
-    public void close() throws IOException {
-        closed=true;
-        super.close();
-    }
-    
-    public boolean isClosed() {
-        return closed;
-    }    
-}
+/**
+ *
+ * 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.adapter;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.BytePacket;
+import org.apache.activeio.packet.sync.SyncChannel;
+
+/**
+ */
+public class SyncChannelToOutputStream extends OutputStream {
+
+    private final SyncChannel channel;
+    private boolean closed;
+
+    /**
+     * @param channel
+     */
+    public SyncChannelToOutputStream(SyncChannel channel) {
+        this.channel = channel;
+    }
+
+    /**
+     * @see java.io.OutputStream#write(int)
+     */
+    public void write(int b) throws IOException {
+        channel.write(new BytePacket((byte) b));
+    }
+
+    /**
+     * @see java.io.OutputStream#write(byte[], int, int)
+     */
+    public void write(byte[] b, int off, int len) throws IOException {
+        channel.write(new ByteArrayPacket(b, off, len));
+    }
+    
+    /**
+     * @see java.io.OutputStream#flush()
+     */
+    public void flush() throws IOException {
+        channel.flush();
+    }
+            
+    /**
+     * @see java.io.InputStream#close()
+     */
+    public void close() throws IOException {
+        closed=true;
+        super.close();
+    }
+    
+    public boolean isClosed() {
+        return closed;
+    }    
+}

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



Mime
View raw message