[jboss-cvs] JBoss Messaging SVN: r5219 - in branches/amqp_integration: src/main/org/jboss/messaging/amq/impl and 10 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 30 10:53:57 EDT 2008


Author: jmesnil
Date: 2008-10-30 10:53:57 -0400 (Thu, 30 Oct 2008)
New Revision: 5219

Added:
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosBodyImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosOkBodyImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowBodyImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowOkBodyImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareBodyImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareOkBodyImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPBufferHandlerImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreServerMapper.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreSessionMapper.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreServerMapperImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreSessionMapperImpl.java
Modified:
   branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/MethodRegistry_0_9.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/impl/AMQMessageImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/protocol/AMQConstant.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingConnectionImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingServiceImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPGlobalFrameHandler.java
   branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPSessionPacketHandler.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientBrowserImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/Channel.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ChannelHandler.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ConnectionRegistry.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingService.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/MessagingServer.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/ServerSession.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/AMQPMessageDeliveryRunnableFactory.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessageDeliveryRunnableFactory.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerMessageDeliveryRunnableFactory.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
   branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
   branches/amqp_integration/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
Log:
AMQP integration

refactoring to introduce AMQPToCoreXXXMapper which handles AMQP frames and maps them to JBM Core API

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosBodyImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosBodyImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosBodyImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,150 @@
+
+
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
+ * Supported AMQP version:
+ *   0-9
+ */
+ 
+ 
+package org.jboss.messaging.amq.framing.amqp_0_9;
+
+import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
+import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQMethodBodyInstanceFactory;
+import org.jboss.messaging.amq.framing.BasicQosBody;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+public class BasicQosBodyImpl extends AMQMethodBody_0_9 implements BasicQosBody
+{
+    private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory()
+    {
+        public AMQMethodBody newInstance(MessagingBuffer in, long size) throws AMQFrameDecodingException
+        {
+            return new BasicQosBodyImpl(in);
+        }
+		
+ 
+    };
+    
+	
+    public static AMQMethodBodyInstanceFactory getFactory()
+    {
+        return FACTORY_INSTANCE;
+    }
+
+	public static int CLASS_ID =  60; 
+    
+    public static int METHOD_ID = 10; 
+    
+
+	
+    // Fields declared in specification
+    private final long _prefetchSize; // [prefetchSize]
+    private final int _prefetchCount; // [prefetchCount]
+    private final byte _bitfield0; // [global]
+
+    
+    // Constructor
+
+    public BasicQosBodyImpl(MessagingBuffer buffer) throws AMQFrameDecodingException
+    {
+        _prefetchSize = readUnsignedInteger( buffer );
+        _prefetchCount = readUnsignedShort( buffer );
+        _bitfield0 = readBitfield( buffer );
+	}
+	
+    public BasicQosBodyImpl(
+                                long prefetchSize,
+                                int prefetchCount,
+                                boolean global
+                            )
+    {
+        _prefetchSize = prefetchSize;
+        _prefetchCount = prefetchCount;
+        byte bitfield0 = (byte)0;
+        if( global )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 0));
+		}
+        _bitfield0 = bitfield0; 
+    }
+    
+    public int getClazz() 
+    { 
+        return CLASS_ID; 
+    }
+    
+    public int getMethod() 
+    { 
+        return METHOD_ID; 
+    }
+
+    
+    public final long getPrefetchSize()
+    {
+        return _prefetchSize;
+    }
+    public final int getPrefetchCount()
+    {
+        return _prefetchCount;
+    }
+    public final boolean getGlobal()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 0)) != 0;
+    }
+
+    protected int getBodySize()
+    {      
+	    int size = 7;
+        return size;        
+    }
+
+    public void writeMethodPayload(MessagingBuffer buffer)
+    {
+        writeUnsignedInteger( buffer, _prefetchSize );
+        writeUnsignedShort( buffer, _prefetchCount );
+        writeBitfield( buffer, _bitfield0 );
+    }
+	
+	
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder("[BasicQosBodyImpl: ");
+        buf.append( "prefetchSize=" );
+		buf.append( getPrefetchSize() );
+		buf.append( ", " );		
+        buf.append( "prefetchCount=" );
+		buf.append( getPrefetchCount() );
+		buf.append( ", " );		
+        buf.append( "global=" );
+		buf.append( getGlobal() );
+        buf.append("]");
+        return buf.toString();
+    }
+
+
+}

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosOkBodyImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosOkBodyImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/BasicQosOkBodyImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,110 @@
+
+
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
+ * Supported AMQP version:
+ *   0-9
+ */
+ 
+ 
+package org.jboss.messaging.amq.framing.amqp_0_9;
+
+import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
+import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQMethodBodyInstanceFactory;
+import org.jboss.messaging.amq.framing.BasicQosOkBody;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+public class BasicQosOkBodyImpl extends AMQMethodBody_0_9 implements BasicQosOkBody
+{
+    private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory()
+    {
+        public AMQMethodBody newInstance(MessagingBuffer in, long size) throws AMQFrameDecodingException
+        {
+            return new BasicQosOkBodyImpl(in);
+        }
+		
+ 
+    };
+    
+	
+    public static AMQMethodBodyInstanceFactory getFactory()
+    {
+        return FACTORY_INSTANCE;
+    }
+
+	public static int CLASS_ID =  60; 
+    
+    public static int METHOD_ID = 11; 
+    
+
+	
+    // Fields declared in specification
+
+    
+    // Constructor
+
+    public BasicQosOkBodyImpl(MessagingBuffer buffer) throws AMQFrameDecodingException
+    {
+	}
+	
+    public BasicQosOkBodyImpl(
+                            )
+    {
+    }
+    
+    public int getClazz() 
+    { 
+        return CLASS_ID; 
+    }
+    
+    public int getMethod() 
+    { 
+        return METHOD_ID; 
+    }
+
+    
+
+    protected int getBodySize()
+    {      
+	    int size = 0;
+        return size;        
+    }
+
+    public void writeMethodPayload(MessagingBuffer buffer)
+    {
+    }
+
+	
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder("[BasicQosOkBodyImpl: ");
+        buf.append("]");
+        return buf.toString();
+    }
+
+
+}

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowBodyImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowBodyImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowBodyImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,125 @@
+
+
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
+ * Supported AMQP version:
+ *   0-9
+ */
+ 
+ 
+package org.jboss.messaging.amq.framing.amqp_0_9;
+
+import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
+import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQMethodBodyInstanceFactory;
+import org.jboss.messaging.amq.framing.ChannelFlowBody;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+public class ChannelFlowBodyImpl extends AMQMethodBody_0_9 implements ChannelFlowBody
+{
+    private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory()
+    {
+        public AMQMethodBody newInstance(MessagingBuffer in, long size) throws AMQFrameDecodingException
+        {
+            return new ChannelFlowBodyImpl(in);
+        }
+		
+ 
+    };
+    
+	
+    public static AMQMethodBodyInstanceFactory getFactory()
+    {
+        return FACTORY_INSTANCE;
+    }
+
+	public static int CLASS_ID =  20; 
+    
+    public static int METHOD_ID = 20; 
+    
+
+	
+    // Fields declared in specification
+    private final byte _bitfield0; // [active]
+
+    
+    // Constructor
+
+    public ChannelFlowBodyImpl(MessagingBuffer buffer) throws AMQFrameDecodingException
+    {
+        _bitfield0 = readBitfield( buffer );
+	}
+	
+    public ChannelFlowBodyImpl(
+                                boolean active
+                            )
+    {
+        byte bitfield0 = (byte)0;
+        if( active )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 0));
+		}
+        _bitfield0 = bitfield0; 
+    }
+    
+    public int getClazz() 
+    { 
+        return CLASS_ID; 
+    }
+    
+    public int getMethod() 
+    { 
+        return METHOD_ID; 
+    }
+
+    
+    public final boolean getActive()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 0)) != 0;
+    }
+
+    protected int getBodySize()
+    {      
+	    int size = 1;
+        return size;        
+    }
+
+    public void writeMethodPayload(MessagingBuffer buffer)
+    {
+        writeBitfield( buffer, _bitfield0 );
+    }
+	
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder("[ChannelFlowBodyImpl: ");
+        buf.append( "active=" );
+		buf.append( getActive() );
+        buf.append("]");
+        return buf.toString();
+    }
+
+
+}

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowOkBodyImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowOkBodyImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ChannelFlowOkBodyImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,126 @@
+
+
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
+ * Supported AMQP version:
+ *   0-9
+ */
+ 
+ 
+package org.jboss.messaging.amq.framing.amqp_0_9;
+
+import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
+import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQMethodBodyInstanceFactory;
+import org.jboss.messaging.amq.framing.ChannelFlowOkBody;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+public class ChannelFlowOkBodyImpl extends AMQMethodBody_0_9 implements ChannelFlowOkBody
+{
+    private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory()
+    {
+        public AMQMethodBody newInstance(MessagingBuffer in, long size) throws AMQFrameDecodingException
+        {
+            return new ChannelFlowOkBodyImpl(in);
+        }
+		
+ 
+    };
+    
+	
+    public static AMQMethodBodyInstanceFactory getFactory()
+    {
+        return FACTORY_INSTANCE;
+    }
+
+	public static int CLASS_ID =  20; 
+    
+    public static int METHOD_ID = 21; 
+    
+
+	
+    // Fields declared in specification
+    private final byte _bitfield0; // [active]
+
+    
+    // Constructor
+
+    public ChannelFlowOkBodyImpl(MessagingBuffer buffer) throws AMQFrameDecodingException
+    {
+        _bitfield0 = readBitfield( buffer );
+	}
+	
+    public ChannelFlowOkBodyImpl(
+                                boolean active
+                            )
+    {
+        byte bitfield0 = (byte)0;
+        if( active )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 0));
+		}
+        _bitfield0 = bitfield0; 
+    }
+    
+    public int getClazz() 
+    { 
+        return CLASS_ID; 
+    }
+    
+    public int getMethod() 
+    { 
+        return METHOD_ID; 
+    }
+
+    
+    public final boolean getActive()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 0)) != 0;
+    }
+
+    protected int getBodySize()
+    {      
+	    int size = 1;
+        return size;        
+    }
+
+    public void writeMethodPayload(MessagingBuffer buffer)
+    {
+        writeBitfield( buffer, _bitfield0 );
+    }
+	
+	
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder("[ChannelFlowOkBodyImpl: ");
+        buf.append( "active=" );
+		buf.append( getActive() );
+        buf.append("]");
+        return buf.toString();
+    }
+
+
+}

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareBodyImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareBodyImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareBodyImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,231 @@
+
+
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
+ * Supported AMQP version:
+ *   0-9
+ */
+ 
+ 
+package org.jboss.messaging.amq.framing.amqp_0_9;
+
+import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
+import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQMethodBodyInstanceFactory;
+import org.jboss.messaging.amq.framing.AMQShortString;
+import org.jboss.messaging.amq.framing.ExchangeDeclareBody;
+import org.jboss.messaging.amq.framing.FieldTable;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+public class ExchangeDeclareBodyImpl extends AMQMethodBody_0_9 implements ExchangeDeclareBody
+{
+    private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory()
+    {
+        public AMQMethodBody newInstance(MessagingBuffer in, long size) throws AMQFrameDecodingException
+        {
+            return new ExchangeDeclareBodyImpl(in);
+        }
+		
+ 
+    };
+    
+	
+    public static AMQMethodBodyInstanceFactory getFactory()
+    {
+        return FACTORY_INSTANCE;
+    }
+
+	public static int CLASS_ID =  40; 
+    
+    public static int METHOD_ID = 10; 
+    
+
+	
+    // Fields declared in specification
+    private final int _ticket; // [ticket]
+    private final AMQShortString _exchange; // [exchange]
+    private final AMQShortString _type; // [type]
+    private final byte _bitfield0; // [passive, durable, autoDelete, internal, nowait]
+    private final FieldTable _arguments; // [arguments]
+
+    
+    // Constructor
+
+    public ExchangeDeclareBodyImpl(MessagingBuffer buffer) throws AMQFrameDecodingException
+    {
+        _ticket = readUnsignedShort( buffer );
+        _exchange = readAMQShortString( buffer );
+        _type = readAMQShortString( buffer );
+        _bitfield0 = readBitfield( buffer );
+        _arguments = readFieldTable( buffer );
+	}
+	
+    public ExchangeDeclareBodyImpl(
+                                int ticket,
+                                AMQShortString exchange,
+                                AMQShortString type,
+                                boolean passive,
+                                boolean durable,
+                                boolean autoDelete,
+                                boolean internal,
+                                boolean nowait,
+                                FieldTable arguments
+                            )
+    {
+        _ticket = ticket;
+        _exchange = exchange;
+        _type = type;
+        byte bitfield0 = (byte)0;
+        if( passive )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 0));
+		}
+ 
+        if( durable )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 1));
+		}
+ 
+        if( autoDelete )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 2));
+		}
+ 
+        if( internal )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 3));
+		}
+ 
+        if( nowait )
+		{		    
+            bitfield0 = (byte) (((int) bitfield0) | (1 << 4));
+		}
+ 
+        _bitfield0 = bitfield0; 
+        _arguments = arguments;
+    }
+    
+    public int getClazz() 
+    { 
+        return CLASS_ID; 
+    }
+    
+    public int getMethod() 
+    { 
+        return METHOD_ID; 
+    }
+
+    
+    public final int getTicket()
+    {
+        return _ticket;
+    }
+    public final AMQShortString getExchange()
+    {
+        return _exchange;
+    }
+    public final AMQShortString getType()
+    {
+        return _type;
+    }
+    public final boolean getPassive()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 0)) != 0;
+    }
+    public final boolean getDurable()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 1)) != 0;
+    }
+    public final boolean getAutoDelete()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 2)) != 0;
+    }
+    public final boolean getInternal()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 3)) != 0;
+    }
+    public final boolean getNowait()
+    {
+        return (((int)(_bitfield0)) & ( 1 << 4)) != 0;
+    }
+    public final FieldTable getArguments()
+    {
+        return _arguments;
+    }
+
+    protected int getBodySize()
+    {      
+	    int size = 3;
+        size += getSizeOf( _exchange );
+        size += getSizeOf( _type );
+        size += getSizeOf( _arguments );
+        return size;        
+    }
+
+    public void writeMethodPayload(MessagingBuffer buffer)
+    {
+        writeUnsignedShort( buffer, _ticket );
+        writeAMQShortString( buffer, _exchange );
+        writeAMQShortString( buffer, _type );
+        writeBitfield( buffer, _bitfield0 );
+        writeFieldTable( buffer, _arguments );
+    }	
+	
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder("[ExchangeDeclareBodyImpl: ");
+        buf.append( "ticket=" );
+		buf.append( getTicket() );
+		buf.append( ", " );		
+        buf.append( "exchange=" );
+		buf.append( getExchange() );
+		buf.append( ", " );		
+        buf.append( "type=" );
+		buf.append( getType() );
+		buf.append( ", " );		
+        buf.append( "passive=" );
+		buf.append( getPassive() );
+		buf.append( ", " );		
+        buf.append( "durable=" );
+		buf.append( getDurable() );
+		buf.append( ", " );		
+        buf.append( "autoDelete=" );
+		buf.append( getAutoDelete() );
+		buf.append( ", " );		
+        buf.append( "internal=" );
+		buf.append( getInternal() );
+		buf.append( ", " );		
+        buf.append( "nowait=" );
+		buf.append( getNowait() );
+		buf.append( ", " );		
+        buf.append( "arguments=" );
+		buf.append( getArguments() );
+        buf.append("]");
+        return buf.toString();
+    }
+
+
+}

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareOkBodyImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareOkBodyImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/ExchangeDeclareOkBodyImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,110 @@
+
+
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * This file is auto-generated by Qpid Gentools v.0.1 - do not modify.
+ * Supported AMQP version:
+ *   0-9
+ */
+ 
+ 
+package org.jboss.messaging.amq.framing.amqp_0_9;
+
+import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
+import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQMethodBodyInstanceFactory;
+import org.jboss.messaging.amq.framing.ExchangeDeclareOkBody;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+public class ExchangeDeclareOkBodyImpl extends AMQMethodBody_0_9 implements ExchangeDeclareOkBody
+{
+    private static final AMQMethodBodyInstanceFactory FACTORY_INSTANCE = new AMQMethodBodyInstanceFactory()
+    {
+        public AMQMethodBody newInstance(MessagingBuffer in, long size) throws AMQFrameDecodingException
+        {
+            return new ExchangeDeclareOkBodyImpl(in);
+        }
+		
+ 
+    };
+    
+	
+    public static AMQMethodBodyInstanceFactory getFactory()
+    {
+        return FACTORY_INSTANCE;
+    }
+
+	public static int CLASS_ID =  40; 
+    
+    public static int METHOD_ID = 11; 
+    
+
+	
+    // Fields declared in specification
+
+    
+    // Constructor
+
+    public ExchangeDeclareOkBodyImpl(MessagingBuffer buffer) throws AMQFrameDecodingException
+    {
+	}
+	
+    public ExchangeDeclareOkBodyImpl(
+                            )
+    {
+    }
+    
+    public int getClazz() 
+    { 
+        return CLASS_ID; 
+    }
+    
+    public int getMethod() 
+    { 
+        return METHOD_ID; 
+    }
+
+    
+
+    protected int getBodySize()
+    {      
+	    int size = 0;
+        return size;        
+    }
+
+    public void writeMethodPayload(MessagingBuffer buffer)
+    {
+    }
+
+	
+    public String toString()
+    {
+        StringBuilder buf = new StringBuilder("[ExchangeDeclareOkBodyImpl: ");
+        buf.append("]");
+        return buf.toString();
+    }
+
+
+}

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/MethodRegistry_0_9.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/MethodRegistry_0_9.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/framing/amqp_0_9/MethodRegistry_0_9.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -33,8 +33,10 @@
 import org.jboss.messaging.amq.framing.AMQShortString;
 import org.jboss.messaging.amq.framing.BasicConsumeOkBody;
 import org.jboss.messaging.amq.framing.BasicDeliverBody;
+import org.jboss.messaging.amq.framing.BasicQosOkBody;
 import org.jboss.messaging.amq.framing.ChannelCloseBody;
 import org.jboss.messaging.amq.framing.ChannelCloseOkBody;
+import org.jboss.messaging.amq.framing.ChannelFlowOkBody;
 import org.jboss.messaging.amq.framing.ChannelOpenOkBody;
 import org.jboss.messaging.amq.framing.ConnectionCloseBody;
 import org.jboss.messaging.amq.framing.ConnectionOpenBody;
@@ -43,13 +45,13 @@
 import org.jboss.messaging.amq.framing.ConnectionStartOkBody;
 import org.jboss.messaging.amq.framing.ConnectionTuneBody;
 import org.jboss.messaging.amq.framing.ConnectionTuneOkBody;
+import org.jboss.messaging.amq.framing.ExchangeDeclareOkBody;
 import org.jboss.messaging.amq.framing.FieldTable;
 import org.jboss.messaging.amq.framing.MethodRegistry;
 import org.jboss.messaging.amq.framing.ProtocolVersion;
 import org.jboss.messaging.amq.framing.QueueBindOkBody;
 import org.jboss.messaging.amq.framing.QueueDeclareOkBody;
 import org.jboss.messaging.amq.protocol.AMQConstant;
-import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
 
 /**
@@ -60,12 +62,8 @@
 public class MethodRegistry_0_9 extends MethodRegistry
 {
 
-   private static final Logger _log = Logger.getLogger(MethodRegistry_0_9.class);
+   private final AMQMethodBodyInstanceFactory[][] factories = new AMQMethodBodyInstanceFactory[121][];
 
-   // private MethodConverter_0_9 _protocolVersionConverter = new MethodConverter_0_9();
-
-   private final AMQMethodBodyInstanceFactory[][] _factories = new AMQMethodBodyInstanceFactory[121][];
-
    public MethodRegistry_0_9()
    {
       this(new ProtocolVersion((byte)0, (byte)9));
@@ -76,215 +74,157 @@
       super(pv);
 
       // Register method body instance factories for the Connection class.
+      factories[10] = new AMQMethodBodyInstanceFactory[52];
 
-      _factories[10] = new AMQMethodBodyInstanceFactory[52];
+      factories[10][10] = ConnectionStartBodyImpl.getFactory();
+      factories[10][11] = ConnectionStartOkBodyImpl.getFactory();
+      // factories[10][20] = ConnectionSecureBodyImpl.getFactory();
+      // factories[10][21] = ConnectionSecureOkBodyImpl.getFactory();
+      factories[10][30] = ConnectionTuneBodyImpl.getFactory();
+      factories[10][31] = ConnectionTuneOkBodyImpl.getFactory();
+      factories[10][40] = ConnectionOpenBodyImpl.getFactory();
+      factories[10][41] = ConnectionOpenOkBodyImpl.getFactory();
+      // factories[10][42] = ConnectionRedirectBodyImpl.getFactory();
+      factories[10][50] = ConnectionCloseBodyImpl.getFactory();
+      // factories[10][51] = ConnectionCloseOkBodyImpl.getFactory();
+      // Register method body instance factories for the Channel class.
+      factories[20] = new AMQMethodBodyInstanceFactory[81];
 
-      _factories[10][10] = ConnectionStartBodyImpl.getFactory();
-      _factories[10][11] = ConnectionStartOkBodyImpl.getFactory();
-      /*      _factories[10][20] = ConnectionSecureBodyImpl.getFactory(); 
-            _factories[10][21] = ConnectionSecureOkBodyImpl.getFactory(); 
-       */_factories[10][30] = ConnectionTuneBodyImpl.getFactory();
-      _factories[10][31] = ConnectionTuneOkBodyImpl.getFactory();
-      _factories[10][40] = ConnectionOpenBodyImpl.getFactory();
-      _factories[10][41] = ConnectionOpenOkBodyImpl.getFactory();
-      /*     _factories[10][42] = ConnectionRedirectBodyImpl.getFactory(); 
-      */_factories[10][50] = ConnectionCloseBodyImpl.getFactory();
-      /*     _factories[10][51] = ConnectionCloseOkBodyImpl.getFactory(); 
-      	
+      factories[20][10] = ChannelOpenBodyImpl.getFactory();
+      // factories[20][11] = ChannelOpenOkBodyImpl.getFactory();
+      factories[20][20] = ChannelFlowBodyImpl.getFactory();
+      factories[20][21] = ChannelFlowOkBodyImpl.getFactory();
+      factories[20][40] = ChannelCloseBodyImpl.getFactory();
+      factories[20][41] = ChannelCloseOkBodyImpl.getFactory();
+      // factories[20][50] = ChannelResumeBodyImpl.getFactory();
+      // factories[20][60] = ChannelPingBodyImpl.getFactory();
+      // factories[20][70] = ChannelPongBodyImpl.getFactory();
+      // factories[20][80] = ChannelOkBodyImpl.getFactory();
 
-
-
-      	// Register method body instance factories for the Channel class.
-
-      */
-      _factories[20] = new AMQMethodBodyInstanceFactory[81];
-
-      _factories[20][10] = ChannelOpenBodyImpl.getFactory();
-      /*        _factories[20][11] = ChannelOpenOkBodyImpl.getFactory(); 
-              _factories[20][20] = ChannelFlowBodyImpl.getFactory(); 
-              _factories[20][21] = ChannelFlowOkBodyImpl.getFactory(); 
-      */
-      _factories[20][40] = ChannelCloseBodyImpl.getFactory();
-      _factories[20][41] = ChannelCloseOkBodyImpl.getFactory();
-      /*
-      _factories[20][50] = ChannelResumeBodyImpl.getFactory(); 
-      _factories[20][60] = ChannelPingBodyImpl.getFactory(); 
-      _factories[20][70] = ChannelPongBodyImpl.getFactory(); 
-      _factories[20][80] = ChannelOkBodyImpl.getFactory(); 
-      
-
-
-
       // Register method body instance factories for the Access class.
 
-      _factories[30] = new AMQMethodBodyInstanceFactory[12];
-      
-      _factories[30][10] = AccessRequestBodyImpl.getFactory(); 
-      _factories[30][11] = AccessRequestOkBodyImpl.getFactory(); 
-      
+      // factories[30] = new AMQMethodBodyInstanceFactory[12];
 
+      // factories[30][10] = AccessRequestBodyImpl.getFactory();
+      // factories[30][11] = AccessRequestOkBodyImpl.getFactory();
 
-
       // Register method body instance factories for the Exchange class.
+      factories[40] = new AMQMethodBodyInstanceFactory[24];
 
-      _factories[40] = new AMQMethodBodyInstanceFactory[24];
-      
-      _factories[40][10] = ExchangeDeclareBodyImpl.getFactory(); 
-      _factories[40][11] = ExchangeDeclareOkBodyImpl.getFactory(); 
-      _factories[40][20] = ExchangeDeleteBodyImpl.getFactory(); 
-      _factories[40][21] = ExchangeDeleteOkBodyImpl.getFactory(); 
-      _factories[40][22] = ExchangeBoundBodyImpl.getFactory(); 
-      _factories[40][23] = ExchangeBoundOkBodyImpl.getFactory(); 
-      */
+      factories[40][10] = ExchangeDeclareBodyImpl.getFactory();
+      factories[40][11] = ExchangeDeclareOkBodyImpl.getFactory();
+      // factories[40][20] = ExchangeDeleteBodyImpl.getFactory();
+      // factories[40][21] = ExchangeDeleteOkBodyImpl.getFactory();
+      // factories[40][22] = ExchangeBoundBodyImpl.getFactory();
+      // factories[40][23] = ExchangeBoundOkBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Queue class.
+      factories[50] = new AMQMethodBodyInstanceFactory[52];
 
-      _factories[50] = new AMQMethodBodyInstanceFactory[52];
-      
-      _factories[50][10] = QueueDeclareBodyImpl.getFactory(); 
-      _factories[50][11] = QueueDeclareOkBodyImpl.getFactory(); 
-      _factories[50][20] = QueueBindBodyImpl.getFactory(); 
-      /*
-      _factories[50][21] = QueueBindOkBodyImpl.getFactory(); 
-      _factories[50][30] = QueuePurgeBodyImpl.getFactory(); 
-      _factories[50][31] = QueuePurgeOkBodyImpl.getFactory(); 
-      _factories[50][40] = QueueDeleteBodyImpl.getFactory(); 
-      _factories[50][41] = QueueDeleteOkBodyImpl.getFactory(); 
-      _factories[50][50] = QueueUnbindBodyImpl.getFactory(); 
-      _factories[50][51] = QueueUnbindOkBodyImpl.getFactory(); 
-      
+      factories[50][10] = QueueDeclareBodyImpl.getFactory();
+      factories[50][11] = QueueDeclareOkBodyImpl.getFactory();
+      factories[50][20] = QueueBindBodyImpl.getFactory();
+      // factories[50][21] = QueueBindOkBodyImpl.getFactory();
+      // factories[50][30] = QueuePurgeBodyImpl.getFactory();
+      // factories[50][31] = QueuePurgeOkBodyImpl.getFactory();
+      // factories[50][40] = QueueDeleteBodyImpl.getFactory();
+      // factories[50][41] = QueueDeleteOkBodyImpl.getFactory();
+      // factories[50][50] = QueueUnbindBodyImpl.getFactory();
+      // factories[50][51] = QueueUnbindOkBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Basic class.
-      */
-      _factories[60] = new AMQMethodBodyInstanceFactory[103];
-      /*		
-              _factories[60][10] = BasicQosBodyImpl.getFactory(); 
-              _factories[60][11] = BasicQosOkBodyImpl.getFactory();
-              */ 
-              _factories[60][20] = BasicConsumeBodyImpl.getFactory(); 
-               _factories[60][21] = BasicConsumeOkBodyImpl.getFactory(); 
-               /*
-              _factories[60][30] = BasicCancelBodyImpl.getFactory(); 
-              _factories[60][31] = BasicCancelOkBodyImpl.getFactory(); 
-              */
-      _factories[60][40] = BasicPublishBodyImpl.getFactory();
-      /*
-      _factories[60][50] = BasicReturnBodyImpl.getFactory(); 
-      _factories[60][60] = BasicDeliverBodyImpl.getFactory(); 
-      _factories[60][70] = BasicGetBodyImpl.getFactory(); 
-      _factories[60][71] = BasicGetOkBodyImpl.getFactory(); 
-      _factories[60][72] = BasicGetEmptyBodyImpl.getFactory(); 
-      */
-      _factories[60][80] = BasicAckBodyImpl.getFactory(); 
-      /*
-      _factories[60][90] = BasicRejectBodyImpl.getFactory(); 
-      _factories[60][100] = BasicRecoverBodyImpl.getFactory(); 
-      _factories[60][101] = BasicRecoverSyncOkBodyImpl.getFactory(); 
-      _factories[60][102] = BasicRecoverSyncBodyImpl.getFactory(); 
-      
+      factories[60] = new AMQMethodBodyInstanceFactory[103];
 
+      factories[60][10] = BasicQosBodyImpl.getFactory();
+      factories[60][11] = BasicQosOkBodyImpl.getFactory();
+      factories[60][20] = BasicConsumeBodyImpl.getFactory();
+      factories[60][21] = BasicConsumeOkBodyImpl.getFactory();
+      // factories[60][30] = BasicCancelBodyImpl.getFactory();
+      // factories[60][31] = BasicCancelOkBodyImpl.getFactory();
+      factories[60][40] = BasicPublishBodyImpl.getFactory();
+      // factories[60][50] = BasicReturnBodyImpl.getFactory();
+      // factories[60][60] = BasicDeliverBodyImpl.getFactory();
+      // factories[60][70] = BasicGetBodyImpl.getFactory();
+      // factories[60][71] = BasicGetOkBodyImpl.getFactory();
+      // factories[60][72] = BasicGetEmptyBodyImpl.getFactory();
+      factories[60][80] = BasicAckBodyImpl.getFactory();
+      // factories[60][90] = BasicRejectBodyImpl.getFactory();
+      // factories[60][100] = BasicRecoverBodyImpl.getFactory();
+      // factories[60][101] = BasicRecoverSyncOkBodyImpl.getFactory();
+      // factories[60][102] = BasicRecoverSyncBodyImpl.getFactory();
 
-
       // Register method body instance factories for the File class.
+      // factories[70] = new AMQMethodBodyInstanceFactory[101];
 
-      _factories[70] = new AMQMethodBodyInstanceFactory[101];
-      
-      _factories[70][10] = FileQosBodyImpl.getFactory(); 
-      _factories[70][11] = FileQosOkBodyImpl.getFactory(); 
-      _factories[70][20] = FileConsumeBodyImpl.getFactory(); 
-      _factories[70][21] = FileConsumeOkBodyImpl.getFactory(); 
-      _factories[70][30] = FileCancelBodyImpl.getFactory(); 
-      _factories[70][31] = FileCancelOkBodyImpl.getFactory(); 
-      _factories[70][40] = FileOpenBodyImpl.getFactory(); 
-      _factories[70][41] = FileOpenOkBodyImpl.getFactory(); 
-      _factories[70][50] = FileStageBodyImpl.getFactory(); 
-      _factories[70][60] = FilePublishBodyImpl.getFactory(); 
-      _factories[70][70] = FileReturnBodyImpl.getFactory(); 
-      _factories[70][80] = FileDeliverBodyImpl.getFactory(); 
-      _factories[70][90] = FileAckBodyImpl.getFactory(); 
-      _factories[70][100] = FileRejectBodyImpl.getFactory(); 
-      
+      // factories[70][10] = FileQosBodyImpl.getFactory();
+      // factories[70][11] = FileQosOkBodyImpl.getFactory();
+      // factories[70][20] = FileConsumeBodyImpl.getFactory();
+      // factories[70][21] = FileConsumeOkBodyImpl.getFactory();
+      // factories[70][30] = FileCancelBodyImpl.getFactory();
+      // factories[70][31] = FileCancelOkBodyImpl.getFactory();
+      // factories[70][40] = FileOpenBodyImpl.getFactory();
+      // factories[70][41] = FileOpenOkBodyImpl.getFactory();
+      // factories[70][50] = FileStageBodyImpl.getFactory();
+      // factories[70][60] = FilePublishBodyImpl.getFactory();
+      // factories[70][70] = FileReturnBodyImpl.getFactory();
+      // factories[70][80] = FileDeliverBodyImpl.getFactory();
+      // factories[70][90] = FileAckBodyImpl.getFactory();
+      // factories[70][100] = FileRejectBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Stream class.
+      // factories[80] = new AMQMethodBodyInstanceFactory[61];
 
-      _factories[80] = new AMQMethodBodyInstanceFactory[61];
-      
-      _factories[80][10] = StreamQosBodyImpl.getFactory(); 
-      _factories[80][11] = StreamQosOkBodyImpl.getFactory(); 
-      _factories[80][20] = StreamConsumeBodyImpl.getFactory(); 
-      _factories[80][21] = StreamConsumeOkBodyImpl.getFactory(); 
-      _factories[80][30] = StreamCancelBodyImpl.getFactory(); 
-      _factories[80][31] = StreamCancelOkBodyImpl.getFactory(); 
-      _factories[80][40] = StreamPublishBodyImpl.getFactory(); 
-      _factories[80][50] = StreamReturnBodyImpl.getFactory(); 
-      _factories[80][60] = StreamDeliverBodyImpl.getFactory(); 
-      
+      // factories[80][10] = StreamQosBodyImpl.getFactory();
+      // factories[80][11] = StreamQosOkBodyImpl.getFactory();
+      // factories[80][20] = StreamConsumeBodyImpl.getFactory();
+      // factories[80][21] = StreamConsumeOkBodyImpl.getFactory();
+      // factories[80][30] = StreamCancelBodyImpl.getFactory();
+      // factories[80][31] = StreamCancelOkBodyImpl.getFactory();
+      // factories[80][40] = StreamPublishBodyImpl.getFactory();
+      // factories[80][50] = StreamReturnBodyImpl.getFactory();
+      // factories[80][60] = StreamDeliverBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Tx class.
+      // factories[90] = new AMQMethodBodyInstanceFactory[32];
 
-      _factories[90] = new AMQMethodBodyInstanceFactory[32];
-      
-      _factories[90][10] = TxSelectBodyImpl.getFactory(); 
-      _factories[90][11] = TxSelectOkBodyImpl.getFactory(); 
-      _factories[90][20] = TxCommitBodyImpl.getFactory(); 
-      _factories[90][21] = TxCommitOkBodyImpl.getFactory(); 
-      _factories[90][30] = TxRollbackBodyImpl.getFactory(); 
-      _factories[90][31] = TxRollbackOkBodyImpl.getFactory(); 
-      
+      // factories[90][10] = TxSelectBodyImpl.getFactory();
+      // factories[90][11] = TxSelectOkBodyImpl.getFactory();
+      // factories[90][20] = TxCommitBodyImpl.getFactory();
+      // factories[90][21] = TxCommitOkBodyImpl.getFactory();
+      // factories[90][30] = TxRollbackBodyImpl.getFactory();
+      // factories[90][31] = TxRollbackOkBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Dtx class.
+      // factories[100] = new AMQMethodBodyInstanceFactory[22];
 
-      _factories[100] = new AMQMethodBodyInstanceFactory[22];
-      
-      _factories[100][10] = DtxSelectBodyImpl.getFactory(); 
-      _factories[100][11] = DtxSelectOkBodyImpl.getFactory(); 
-      _factories[100][20] = DtxStartBodyImpl.getFactory(); 
-      _factories[100][21] = DtxStartOkBodyImpl.getFactory(); 
-      
+      // factories[100][10] = DtxSelectBodyImpl.getFactory();
+      // factories[100][11] = DtxSelectOkBodyImpl.getFactory();
+      // factories[100][20] = DtxStartBodyImpl.getFactory();
+      // factories[100][21] = DtxStartOkBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Tunnel class.
+      // factories[110] = new AMQMethodBodyInstanceFactory[11];
 
-      _factories[110] = new AMQMethodBodyInstanceFactory[11];
-      
-      _factories[110][10] = TunnelRequestBodyImpl.getFactory(); 
-      
+      // factories[110][10] = TunnelRequestBodyImpl.getFactory();
 
-
-
       // Register method body instance factories for the Message class.
+      // factories[120] = new AMQMethodBodyInstanceFactory[531];
 
-      _factories[120] = new AMQMethodBodyInstanceFactory[531];
-      
-      _factories[120][10] = MessageTransferBodyImpl.getFactory(); 
-      _factories[120][20] = MessageConsumeBodyImpl.getFactory(); 
-      _factories[120][30] = MessageCancelBodyImpl.getFactory(); 
-      _factories[120][40] = MessageGetBodyImpl.getFactory(); 
-      _factories[120][50] = MessageRecoverBodyImpl.getFactory(); 
-      _factories[120][60] = MessageOpenBodyImpl.getFactory(); 
-      _factories[120][70] = MessageCloseBodyImpl.getFactory(); 
-      _factories[120][80] = MessageAppendBodyImpl.getFactory(); 
-      _factories[120][90] = MessageCheckpointBodyImpl.getFactory(); 
-      _factories[120][100] = MessageResumeBodyImpl.getFactory(); 
-      _factories[120][110] = MessageQosBodyImpl.getFactory(); 
-      _factories[120][500] = MessageOkBodyImpl.getFactory(); 
-      _factories[120][510] = MessageEmptyBodyImpl.getFactory(); 
-      _factories[120][520] = MessageRejectBodyImpl.getFactory(); 
-      _factories[120][530] = MessageOffsetBodyImpl.getFactory(); 
-      
-      
-      */
+      // factories[120][10] = MessageTransferBodyImpl.getFactory();
+      // factories[120][20] = MessageConsumeBodyImpl.getFactory();
+      // factories[120][30] = MessageCancelBodyImpl.getFactory();
+      // factories[120][40] = MessageGetBodyImpl.getFactory();
+      // factories[120][50] = MessageRecoverBodyImpl.getFactory();
+      // factories[120][60] = MessageOpenBodyImpl.getFactory();
+      // factories[120][70] = MessageCloseBodyImpl.getFactory();
+      // factories[120][80] = MessageAppendBodyImpl.getFactory();
+      // factories[120][90] = MessageCheckpointBodyImpl.getFactory();
+      // factories[120][100] = MessageResumeBodyImpl.getFactory();
+      // factories[120][110] = MessageQosBodyImpl.getFactory();
+      // factories[120][500] = MessageOkBodyImpl.getFactory();
+      // factories[120][510] = MessageEmptyBodyImpl.getFactory();
+      // factories[120][520] = MessageRejectBodyImpl.getFactory();
+      // factories[120][530] = MessageOffsetBodyImpl.getFactory();
    }
 
    public AMQMethodBody convertToBody(MessagingBuffer in, long size) throws AMQFrameDecodingException
@@ -295,7 +235,7 @@
       AMQMethodBodyInstanceFactory bodyFactory;
       try
       {
-         bodyFactory = _factories[classId][methodId];
+         bodyFactory = factories[classId][methodId];
       }
       catch (NullPointerException e)
       {
@@ -309,7 +249,7 @@
       }
       catch (IndexOutOfBoundsException e)
       {
-         if (classId >= _factories.length)
+         if (classId >= factories.length)
          {
             throw new AMQFrameDecodingException(AMQConstant.COMMAND_INVALID, "Class " + classId +
                                                                              " unknown in AMQP version 0-9" +
@@ -355,7 +295,7 @@
 
    public int getMaxMethodId(int classId)
    {
-      return _factories[classId].length - 1;
+      return factories[classId].length - 1;
    }
 
    public ConnectionStartBody createConnectionStartBody(final short versionMajor,
@@ -427,9 +367,9 @@
                                host,
                                knownHosts
                        );
-   }
-   
+   }   
    */
+
    public ConnectionCloseBody createConnectionCloseBody(final int replyCode,
                                                         final AMQShortString replyText,
                                                         final int classId,
@@ -445,20 +385,19 @@
       return new ConnectionCloseOkBodyImpl(
                        );
    }
-   
-   
+   */
 
-   
+   /*
    public ChannelOpenBody createChannelOpenBody(	
-                               final AMQShortString outOfBand
-                          )
-   {
-      return new ChannelOpenBodyImpl(
-                               outOfBand
-                       );
-   }
-   
-   */
+                                  final AMQShortString outOfBand
+                             )
+      {
+         return new ChannelOpenBodyImpl(
+                                  outOfBand
+                          );
+      }
+      
+      */
    public ChannelOpenOkBody createChannelOpenOkBody(final byte[] channelId)
    {
       return new ChannelOpenOkBodyImpl(channelId);
@@ -474,16 +413,12 @@
                        );
    }
    
-   public ChannelFlowOkBody createChannelFlowOkBody(	
-                               final boolean active
-                          )
+   */
+   public ChannelFlowOkBody createChannelFlowOkBody(final boolean active)
    {
-      return new ChannelFlowOkBodyImpl(
-                               active
-                       );
+      return new ChannelFlowOkBodyImpl(active);
    }
 
-   */
    public ChannelCloseBody createChannelCloseBody(final int replyCode,
                                                   final AMQShortString replyText,
                                                   final int classId,
@@ -496,6 +431,7 @@
    {
       return new ChannelCloseOkBodyImpl();
    }
+
    /*
    public ChannelResumeBody createChannelResumeBody(	
                                final byte[] channelId
@@ -586,13 +522,13 @@
                        );
    }
    
-   public ExchangeDeclareOkBody createExchangeDeclareOkBody(	
-                          )
+   */
+   public ExchangeDeclareOkBody createExchangeDeclareOkBody()
    {
-      return new ExchangeDeclareOkBodyImpl(
-                       );
+      return new ExchangeDeclareOkBodyImpl();
    }
-   
+
+   /*
    public ExchangeDeleteBody createExchangeDeleteBody(	
                                final int ticket,
                                final AMQShortString exchange,
@@ -666,19 +602,13 @@
    }
    
    */
-   public QueueDeclareOkBody createQueueDeclareOkBody(	
-                               final AMQShortString queue,
-                               final long messageCount,
-                               final long consumerCount
-                          )
+   public QueueDeclareOkBody createQueueDeclareOkBody(final AMQShortString queue,
+                                                      final long messageCount,
+                                                      final long consumerCount)
    {
-      return new QueueDeclareOkBodyImpl(
-                               queue,
-                               messageCount,
-                               consumerCount
-                       );
+      return new QueueDeclareOkBodyImpl(queue, messageCount, consumerCount);
    }
-   
+
    /*
    public QueueBindBody createQueueBindBody(	
                                final int ticket,
@@ -700,12 +630,11 @@
    }
    
    */
-   public QueueBindOkBody createQueueBindOkBody(	
-                          )
+   public QueueBindOkBody createQueueBindOkBody()
    {
-      return new QueueBindOkBodyImpl(
-                       );
+      return new QueueBindOkBodyImpl();
    }
+
    /*
    public QueuePurgeBody createQueuePurgeBody(	
                                final int ticket,
@@ -794,14 +723,13 @@
                                global
                        );
    }
-   
-   public BasicQosOkBody createBasicQosOkBody(	
-                          )
+   */
+   public BasicQosOkBody createBasicQosOkBody()
    {
-      return new BasicQosOkBodyImpl(
-                       );
+      return new BasicQosOkBodyImpl();
    }
-   
+
+   /*
    public BasicConsumeBody createBasicConsumeBody(	
                                final int ticket,
                                final AMQShortString queue,
@@ -825,14 +753,11 @@
                        );
    }
    */
-   public BasicConsumeOkBody createBasicConsumeOkBody(	
-                               final AMQShortString consumerTag
-                          )
+   public BasicConsumeOkBody createBasicConsumeOkBody(final AMQShortString consumerTag)
    {
-      return new BasicConsumeOkBodyImpl(
-                               consumerTag
-                       );
+      return new BasicConsumeOkBodyImpl(consumerTag);
    }
+
    /*
    public BasicCancelBody createBasicCancelBody(	
                                final AMQShortString consumerTag,
@@ -887,21 +812,13 @@
    }
    
    */
-   public BasicDeliverBody createBasicDeliverBody(	
-                               final AMQShortString consumerTag,
-                               final long deliveryTag,
-                               final boolean redelivered,
-                               final AMQShortString exchange,
-                               final AMQShortString routingKey
-                          )
+   public BasicDeliverBody createBasicDeliverBody(final AMQShortString consumerTag,
+                                                  final long deliveryTag,
+                                                  final boolean redelivered,
+                                                  final AMQShortString exchange,
+                                                  final AMQShortString routingKey)
    {
-      return new BasicDeliverBodyImpl(
-                               consumerTag,
-                               deliveryTag,
-                               redelivered,
-                               exchange,
-                               routingKey
-                       );
+      return new BasicDeliverBodyImpl(consumerTag, deliveryTag, redelivered, exchange, routingKey);
    }
    /*
    public BasicGetBody createBasicGetBody(	

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/impl/AMQMessageImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/impl/AMQMessageImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/impl/AMQMessageImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -52,13 +52,6 @@
 
    // Static --------------------------------------------------------
 
-   public static AMQMessage fromCoreMessage(ServerMessage serverMessage)
-   {
-
-         return null;
-   }
-
-   
    // Constructors --------------------------------------------------
 
    public AMQMessageImpl(SimpleString exchange, SimpleString routingKey, boolean immediate, boolean mandatory)
@@ -108,7 +101,7 @@
    public boolean addPayload(MessagingBuffer framePayload, int frameSize)
    {
       MessagingBuffer newBuffer = payload.createNewBuffer(currentBodySize + frameSize);
-      
+
       // copy the current payload in the new buffer
       byte[] b = new byte[currentBodySize];
       payload.getBytes(b);

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/protocol/AMQConstant.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/protocol/AMQConstant.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/protocol/AMQConstant.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -48,7 +48,7 @@
 public final class AMQConstant
 {
     /** Defines a map from codes to constants. */
-    private static Map _codeMap = new HashMap();
+    private static Map<Integer, AMQConstant> codeMap = new HashMap<Integer, AMQConstant>();
 
     /** Indicates that the method completed successfully. */
     public static final AMQConstant REPLY_SUCCESS = new AMQConstant(200, "reply success", true);
@@ -183,7 +183,7 @@
         _name = new AMQShortString(name);
         if (map)
         {
-            _codeMap.put(new Integer(code), this);
+            codeMap.put(new Integer(code), this);
         }
     }
 
@@ -197,7 +197,7 @@
      */
     public static AMQConstant getConstant(int code)
     {
-        AMQConstant c = (AMQConstant) _codeMap.get(new Integer(code));
+        AMQConstant c = codeMap.get(new Integer(code));
         if (c == null)
         {
             c = new AMQConstant(code, "unknown code", false);

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPBufferHandlerImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPBufferHandlerImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPBufferHandlerImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,80 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.messaging.amq.remoting.impl;
+
+import static org.jboss.messaging.amq.framing.AMQFrame.FRAME_ATTRIBUTES_LENGTH;
+import static org.jboss.messaging.amq.framing.ProtocolInitiation.PROTOCOL_LENGTH;
+
+import org.jboss.messaging.core.remoting.spi.BufferHandler;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+/**
+ * A AMQPBufferHandler
+ * 
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ */
+public abstract class AMQPBufferHandlerImpl implements BufferHandler
+{
+   // BufferHandler implementation ----------------------------------
+   
+   public int isReadyToHandle(final MessagingBuffer buffer)
+   {
+      if (buffer.remaining() <= 0)
+      {
+         return -1;
+      }
+      if (buffer.getByte(buffer.position()) == (byte)'A')
+      {
+         // protocol initiation
+         if (buffer.remaining() < PROTOCOL_LENGTH)
+         {
+            return -1;
+         }
+         else
+         {
+            return PROTOCOL_LENGTH;
+         }
+      }
+      else
+      {
+         // AMQ frame
+         final int remainingAfterAttributes = buffer.remaining() - FRAME_ATTRIBUTES_LENGTH;
+         if (remainingAfterAttributes < 0)
+         {
+            return -1;
+         }
+
+         buffer.skip(1 + 2);
+         final long bodyLength = buffer.getUnsignedInt();
+
+         if (remainingAfterAttributes < bodyLength)
+         {
+            return -1;
+         }
+         else
+         {
+            return FRAME_ATTRIBUTES_LENGTH + (int)bodyLength;
+         }
+      }
+   }
+}

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingConnectionImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingConnectionImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingConnectionImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -12,9 +12,6 @@
 
 package org.jboss.messaging.amq.remoting.impl;
 
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.PING;
-import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.PONG;
-
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -27,7 +24,6 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -54,11 +50,8 @@
 import org.jboss.messaging.core.remoting.ResponseNotifier;
 import org.jboss.messaging.core.remoting.impl.amqp.AMQDecoder;
 import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
-import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.NullResponseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
-import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
-import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
 import org.jboss.messaging.core.remoting.spi.Connection;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
 import org.jboss.messaging.core.server.ServerSession;
@@ -72,7 +65,7 @@
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * @version <tt>$Revision: 5132 $</tt> $Id: RemotingConnectionImpl.java 5132 2008-10-17 14:57:53Z jmesnil $
  */
-public class AMQPRemotingConnectionImpl extends AMQPBufferHandler implements RemotingConnection
+public class AMQPRemotingConnectionImpl extends AMQPBufferHandler implements RemotingConnection<AMQFrame>
 {
    // Constants
    // ------------------------------------------------------------------------------------
@@ -93,34 +86,14 @@
 
    private final List<FailureListener> failureListeners = new CopyOnWriteArrayList<FailureListener>();
 
-   private final long blockingCallTimeout;
-
    private final ExecutorFactory executorFactory;
 
-   private Runnable pinger;
-
-   private final List<Interceptor> interceptors;
-
    private ScheduledFuture<?> future;
 
-   private boolean firstTime = true;
-
-   private volatile boolean gotPong;
-
    private volatile boolean destroyed;
 
-   private long expirePeriod;
-
-   private volatile boolean stopPinging;
-
    private volatile long expireTime = -1;
 
-   private final Channel pingChannel;
-
-   private final long pingPeriod;
-
-   private final ScheduledExecutorService pingExecutor;
-
    // Channels 0-9 are reserved for the system
    // 0 is for pinging
    // 1 is for session creation and attachment
@@ -134,7 +107,6 @@
    // ---------------------------------------------------------------------------------
 
    public AMQPRemotingConnectionImpl(final Connection transportConnection,
-                                     final long blockingCallTimeout,
                                      final long pingPeriod,
                                      final ExecutorService handlerExecutor,
                                      final ScheduledExecutorService pingExecutor,
@@ -143,8 +115,6 @@
    {
       this.transportConnection = transportConnection;
 
-      this.blockingCallTimeout = blockingCallTimeout;
-
       if (handlerExecutor != null)
       {
          executorFactory = new OrderedExecutorFactory(handlerExecutor);
@@ -154,37 +124,12 @@
          executorFactory = null;
       }
 
-      this.interceptors = interceptors;
+       this.decoder = new AMQDecoder();
 
-      this.pingPeriod = pingPeriod;
-
-      this.pingExecutor = pingExecutor;
-
-      // Channel zero is reserved for pinging
-      pingChannel = getChannel(9, false, -1, false);
-
-      final ChannelHandler ppHandler = new PingPongHandler();
-
-      pingChannel.setHandler(ppHandler);
-
-      this.decoder = new AMQDecoder();
-
    }
 
    public void startPinger()
    {
-      if (pingPeriod != -1)
-      {
-         pinger = new Pinger();
-
-         expirePeriod = (long)(EXPIRE_FACTOR * pingPeriod);
-
-         future = pingExecutor.scheduleWithFixedDelay(pinger, 0, pingPeriod, TimeUnit.MILLISECONDS);
-      }
-      else
-      {
-         pinger = null;
-      }
    }
 
    // RemotingConnection implementation
@@ -195,7 +140,7 @@
       return transportConnection.getID();
    }
 
-   public synchronized Channel getChannel(final long channelID,
+   public synchronized Channel<AMQFrame> getChannel(final long channelID,
                                           final boolean ordered,
                                           final int packetConfirmationBatchSize,
                                           final boolean interruptBlockOnFailure)
@@ -212,7 +157,7 @@
       return channel;
    }
 
-   public ChannelHandler createSessionHandler(ServerSession session, Channel channel, StorageManager storageManager)
+   public ChannelHandler<AMQFrame> createSessionHandler(ServerSession session, Channel channel, StorageManager storageManager)
    {
       return new AMQPSessionPacketHandler(session, channel, storageManager);
    }
@@ -264,7 +209,7 @@
 
          internalClose();
 
-         for (Channel channel : channels.values())
+         for (Channel<AMQFrame> channel : channels.values())
          {
             channel.fail();
          }
@@ -302,7 +247,6 @@
    /* For testing only */
    public void stopPingingAfterOne()
    {
-      stopPinging = true;
    }
 
    public synchronized void syncIDGeneratorSequence(final long id)
@@ -341,12 +285,12 @@
          try
          {
             ProtocolInitiation pi = (ProtocolInitiation)dataBlock;
-
+            System.out.println(pi);
             // Fails if not correct
-            ProtocolVersion pv = pi.checkVersion();
+            pi.checkVersion();
             // This sets the protocol version (and hence framing classes) for this session.
 
-            String mechanisms = "AMQPLAIN";
+            String mechanisms = "PLAIN";
 
             String locales = "en_US";
 
@@ -367,7 +311,6 @@
       else if (dataBlock instanceof AMQFrame)
       {
          AMQFrame frame = (AMQFrame)dataBlock;
-         System.out.println("body frame = " + frame.getBodyFrame());
          synchronized (this)
          {
             Long channelID = (long)frame.getChannel();
@@ -381,17 +324,19 @@
             synchronized (this)
             {
                ChannelImpl channel = channels.get(channelID);
-               System.out.println("channel for " + channelID + "= " + channel);
                if (channel != null)
                {
                   channel.handleFrame(frame);
+               } else
+               {
+                  throw new IllegalStateException("no channel to handle " + frame);
                }
             }
          }
       }
       else
       {
-         throw new IllegalStateException("unsupported datablock");
+         throw new IllegalStateException("unsupported datablock:" + dataBlock);
       }
    }
 
@@ -435,14 +380,12 @@
          future.cancel(false);
       }
 
-      pingChannel.close(false);
-
       destroyed = true;
 
       // We close the underlying transport connection
       transportConnection.close();
 
-      for (Channel channel : channels.values())
+      for (Channel<AMQFrame> channel : channels.values())
       {
          channel.close(false);
       }
@@ -466,13 +409,13 @@
    // --------------------------------------------------------------------------------
 
    // Needs to be static so we can re-assign it to another remotingconnection
-   private static class ChannelImpl implements Channel
+   private static class ChannelImpl implements Channel<AMQFrame>
    {
       private final long id;
 
       private final Executor executor;
 
-      private ChannelHandler handler;
+      private ChannelHandler<AMQFrame> handler;
 
       private Packet response;
 
@@ -486,7 +429,7 @@
 
       private volatile int nextConfirmation;
 
-      private Channel replicatingChannel;
+      private Channel<AMQFrame> replicatingChannel;
 
       private volatile AMQPRemotingConnectionImpl connection;
 
@@ -496,18 +439,12 @@
 
       private Thread blockThread;
 
-      private ResponseNotifier responseNotifier;
-
       private final Lock lock = new ReentrantLock();
 
       private final Condition sendCondition = lock.newCondition();
 
       private final Condition failoverCondition = lock.newCondition();
 
-      private final Object sendLock = new Object();
-
-      private boolean failingOver;
-
       private final Queue<Runnable> responseActions = new ConcurrentLinkedQueue<Runnable>();
 
       private ChannelImpl(final AMQPRemotingConnectionImpl connection,
@@ -574,44 +511,6 @@
          }
       }
 
-      // This must never called by more than one thread concurrently
-      public void send(final Packet packet)
-      {
-         // Must be protected by lock since on session, deliveries can occur at same time as blocking responses
-         synchronized (sendLock)
-         {
-            packet.setChannelID(id);
-
-            lock.lock();
-
-            try
-            {
-               while (failingOver)
-               {
-                  // TODO - don't hardcode this timeout
-                  try
-                  {
-                     failoverCondition.await(10000, TimeUnit.MILLISECONDS);
-                  }
-                  catch (InterruptedException e)
-                  {
-                  }
-               }
-
-               addToCache(packet);
-
-               if (packet.isWriteAlways())
-               {
-                  connection.doWrite(packet);
-               }
-            }
-            finally
-            {
-               lock.unlock();
-            }
-         }
-      }
-
       public void send(AMQFrame frame)
       {
          connection.doWrite(frame);
@@ -624,112 +523,19 @@
          return executor;
       }
 
-      // This must never called by more than one thread concurrently
-      public Packet sendBlocking(final Packet packet) throws MessagingException
+      public AMQFrame sendBlocking(AMQFrame t) throws MessagingException
       {
-         return sendBlocking(packet, null);
+         throw new IllegalStateException("send blocking is not supported for AMQP");
       }
-
-      // This must never called by more than one thread concurrently
-      public Packet sendBlocking(final Packet packet, final ResponseNotifier notifier) throws MessagingException
+      
+      public AMQFrame sendBlocking(AMQFrame t, ResponseNotifier notifier) throws MessagingException
       {
-         packet.setChannelID(id);
-
-         lock.lock();
-
-         try
-         {
-            while (failingOver)
-            {
-               // TODO - don't hardcode this timeout
-               try
-               {
-                  failoverCondition.await(10000, TimeUnit.MILLISECONDS);
-               }
-               catch (InterruptedException e)
-               {
-               }
-            }
-
-            addToCache(packet);
-
-            blockThread = Thread.currentThread();
-
-            responseNotifier = notifier;
-
-            response = null;
-
-            connection.doWrite(packet);
-
-            long toWait = connection.blockingCallTimeout;
-
-            long start = System.currentTimeMillis();
-
-            while (response == null && toWait > 0)
-            {
-               try
-               {
-                  sendCondition.await(toWait, TimeUnit.MILLISECONDS);
-               }
-               catch (final InterruptedException e)
-               {
-                  if (interruptBlockOnFailure)
-                  {
-                     if (connection.destroyed)
-                     {
-                        throw new MessagingException(MessagingException.NOT_CONNECTED, "Connection failed");
-                     }
-                  }
-               }
-
-               final long now = System.currentTimeMillis();
-
-               toWait -= now - start;
-
-               start = now;
-            }
-
-            if (response == null)
-            {
-               throw new MessagingException(MessagingException.CONNECTION_TIMEDOUT,
-                                            "Timed out waiting for response when sending packet " + packet.getType());
-            }
-
-            if (response.getType() == PacketImpl.EXCEPTION)
-            {
-               final MessagingExceptionMessage mem = (MessagingExceptionMessage)response;
-
-               throw mem.getException();
-            }
-            else
-            {
-               return response;
-            }
-         }
-         finally
-         {
-            blockThread = null;
-
-            lock.unlock();
-         }
+         throw new IllegalStateException("send blocking is not supported for AMQP");
       }
-
-      public void replicatePacket(final Packet packet, final Runnable responseAction)
+      
+      public void replicatePacket(AMQFrame t, Runnable responseAction)
       {
-         if (replicatingChannel != null)
-         {
-            // Must be synchronized since can be called by incoming session commands but also by deliveries
-            synchronized (this)
-            {
-               responseActions.add(responseAction);
-
-               replicatingChannel.send(packet);
-            }
-         }
-         else
-         {
-            responseAction.run();
-         }
+         responseAction.run();
       }
 
       public void replicateComplete()
@@ -748,7 +554,7 @@
          action.run();
       }
 
-      public void setHandler(final ChannelHandler handler)
+      public void setHandler(final ChannelHandler<AMQFrame> handler)
       {
          this.handler = handler;
       }
@@ -802,7 +608,7 @@
          }
       }
 
-      public Channel getReplicatingChannel()
+      public Channel<AMQFrame> getReplicatingChannel()
       {
          return replicatingChannel;
       }
@@ -861,8 +667,6 @@
       {
          lock.lock();
 
-         failingOver = true;
-
          lock.unlock();
       }
 
@@ -870,8 +674,6 @@
       {
          lock.lock();
 
-         failingOver = false;
-
          failoverCondition.signalAll();
 
          lock.unlock();
@@ -906,7 +708,7 @@
                return;
             }
          }
-         handler.handleFrame(frame);
+         handler.handle(frame);
       }
 
       public boolean channelAwaitingClosure(long channelId)
@@ -916,14 +718,6 @@
          // return _closingChannelsList.contains(channelId);
       }
 
-      private void addToCache(final Packet packet)
-      {
-         if (resendCache != null)
-         {
-            resendCache.add(packet);
-         }
-      }
-
       private void clearUpTo(final int lastReceivedCommandID)
       {
          final int numberToClear = 1 + lastReceivedCommandID - firstStoredCommandID;
@@ -951,65 +745,5 @@
          firstStoredCommandID += numberToClear;
       }
 
-   }
-
-   private class Pinger implements Runnable
-   {
-      public synchronized void run()
-      {
-         if (!firstTime && !gotPong)
-         {
-            // Error - didn't get pong back
-            final MessagingException me = new MessagingException(MessagingException.NOT_CONNECTED,
-                                                                 "Did not receive pong from server");
-
-            fail(me);
-         }
-
-         gotPong = false;
-
-         firstTime = false;
-
-         // Send ping
-         final Packet ping = new Ping(expirePeriod);
-
-         pingChannel.send(ping);
-      }
-   }
-
-   private class PingPongHandler implements ChannelHandler
-   {
-      public void handlePacket(final Packet packet)
-      {
-         final byte type = packet.getType();
-
-         if (type == PONG)
-         {
-            gotPong = true;
-
-            if (stopPinging)
-            {
-               future.cancel(true);
-            }
-         }
-         else if (type == PING)
-         {
-            expireTime = System.currentTimeMillis() + ((Ping)packet).getExpirePeriod();
-
-            // Parameter is placeholder for future
-            final Packet pong = new Pong(-1);
-
-            pingChannel.send(pong);
-         }
-         else
-         {
-            throw new IllegalArgumentException("Invalid packet: " + packet);
-         }
-      }
-
-      public void handleFrame(AMQFrame frame)
-      {
-         // FIXME no ping pong for AMQ
-      }
-   }
+   }  
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingServiceImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingServiceImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/remoting/impl/AMQPRemotingServiceImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -24,6 +24,7 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
+import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.amq.server.impl.AMQPGlobalFrameHandler;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
@@ -34,7 +35,6 @@
 import org.jboss.messaging.core.remoting.Interceptor;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.RemotingService;
-import org.jboss.messaging.core.remoting.impl.AbstractBufferHandler;
 import org.jboss.messaging.core.remoting.spi.Acceptor;
 import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
 import org.jboss.messaging.core.remoting.spi.BufferHandler;
@@ -48,7 +48,7 @@
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * @version <tt>$Revision$</tt>
  */
-public class AMQPRemotingServiceImpl implements RemotingService, ConnectionLifeCycleListener
+public class AMQPRemotingServiceImpl implements RemotingService<AMQFrame>, ConnectionLifeCycleListener
 {
    // Constants -----------------------------------------------------
 
@@ -66,10 +66,8 @@
 
    private final ExecutorService remotingExecutor;
 
-   private final long callTimeout;
+   private final Map<Object, RemotingConnection<AMQFrame>> connections = new ConcurrentHashMap<Object, RemotingConnection<AMQFrame>>();
 
-   private final Map<Object, RemotingConnection> connections = new ConcurrentHashMap<Object, RemotingConnection>();
-
    private final Timer failedConnectionTimer = new Timer(true);
 
    private TimerTask failedConnectionsTask;
@@ -104,8 +102,6 @@
          }
       }
 
-      callTimeout = config.getCallTimeout();
-
       connectionScanPeriod = config.getConnectionScanPeriod();
    }
 
@@ -196,14 +192,14 @@
       return acceptors;
    }
 
-   public RemotingConnection getConnection(final Object remotingConnectionID)
+   public RemotingConnection<AMQFrame> getConnection(final Object remotingConnectionID)
    {
       return connections.get(remotingConnectionID);
    }
 
-   public synchronized Set<RemotingConnection> getConnections()
+   public synchronized Set<RemotingConnection<AMQFrame>> getConnections()
    {
-      return new HashSet<RemotingConnection>(connections.values());
+      return new HashSet<RemotingConnection<AMQFrame>>(connections.values());
    }
 
    public void setMessagingServer(final MessagingServer server)
@@ -225,16 +221,15 @@
          throw new IllegalStateException("Unable to create connection, server hasn't finished starting up");
       }
 
-      RemotingConnection rc = new AMQPRemotingConnectionImpl(connection,
-                                                         callTimeout,
+      RemotingConnection<AMQFrame> rc = new AMQPRemotingConnectionImpl(connection,
                                                          -1,
                                                          remotingExecutor,
                                                          null,
                                                          interceptors);
 
-      Channel channel0 = rc.getChannel(0, false, -1, false);
+      Channel<AMQFrame> channel0 = rc.getChannel(0, false, -1, false);
 
-      ChannelHandler handler = new AMQPGlobalFrameHandler(server, channel0, rc);
+      ChannelHandler<AMQFrame> handler = new AMQPGlobalFrameHandler(server, channel0, rc);
 
       channel0.setHandler(handler);
 
@@ -245,7 +240,7 @@
 
    public void connectionDestroyed(final Object connectionID)
    {
-      RemotingConnection conn = connections.remove(connectionID);
+      RemotingConnection<AMQFrame> conn = connections.remove(connectionID);
 
       if (conn != null)
       {
@@ -255,7 +250,7 @@
 
    public void connectionException(final Object connectionID, final MessagingException me)
    {
-      RemotingConnection rc = connections.remove(connectionID);
+      RemotingConnection<AMQFrame> rc = connections.remove(connectionID);
 
       if (rc != null)
       {
@@ -295,11 +290,11 @@
             return;
          }
 
-         Set<RemotingConnection> failedConnections = new HashSet<RemotingConnection>();
+         Set<RemotingConnection<AMQFrame>> failedConnections = new HashSet<RemotingConnection<AMQFrame>>();
 
          long now = System.currentTimeMillis();
 
-         for (RemotingConnection conn : connections.values())
+         for (RemotingConnection<AMQFrame> conn : connections.values())
          {
             if (conn.isExpired(now))
             {
@@ -307,7 +302,7 @@
             }
          }
 
-         for (RemotingConnection conn : failedConnections)
+         for (RemotingConnection<AMQFrame> conn : failedConnections)
          {
             MessagingException me = new MessagingException(MessagingException.CONNECTION_TIMEDOUT,
                                                            "Did not receive ping on connection. It is likely a client has exited or crashed without " + "closing its connection, or the network between the server and client has failed. The connection will now be closed.");
@@ -330,7 +325,7 @@
    {
       public void bufferReceived(final Object connectionID, final MessagingBuffer buffer)
       {
-         RemotingConnection conn = connections.get(connectionID);
+         RemotingConnection<AMQFrame> conn = connections.get(connectionID);
 
          if (conn != null)
          {

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreServerMapper.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreServerMapper.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreServerMapper.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.amq.server;
+
+import java.util.UUID;
+
+import org.jboss.messaging.amq.framing.AMQShortString;
+import org.jboss.messaging.amq.framing.FieldTable;
+import org.jboss.messaging.amq.server.security.auth.AuthenticationResult;
+
+/**
+ * A AMQToCoreServerMapper
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * Created 30 oct. 2008 10:53:54
+ *
+ *
+ */
+public interface AMQToCoreServerMapper
+{
+   // Channel handlers -------------------------------------------
+
+   UUID handleChannelOpen(AMQShortString outOfBand, long channel) throws Exception;
+
+   // Connection handlers -------------------------------------------
+
+   void handleConnectionOpen(AMQShortString virtualHost, boolean insist, AMQShortString capabilities);
+
+   AuthenticationResult handleConnectionStartOk(AMQShortString mechanism,
+                                                AMQShortString locale,
+                                                byte[] response,
+                                                FieldTable clientProperties);
+
+   void handleConnectionTuneOk(int channelMax, long frameMax, int heartbeat);
+
+}
\ No newline at end of file

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreSessionMapper.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreSessionMapper.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/server/AMQToCoreSessionMapper.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.amq.server;
+
+import org.jboss.messaging.amq.framing.AMQShortString;
+import org.jboss.messaging.amq.framing.ContentHeaderProperties;
+import org.jboss.messaging.amq.framing.FieldTable;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+
+/**
+ * A AMQToCoreSessionMapper
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * Created 30 oct. 2008 11:06:50
+ *
+ *
+ */
+public interface AMQToCoreSessionMapper
+{
+
+   // Basic handlers ------------------------------------------------
+
+   void handleBasicAck(long deliveryTag, boolean multiple) throws Exception;
+
+   void handleBasicConsume(AMQShortString queue,
+                           AMQShortString consumerTag,
+                           int ticket,
+                           boolean noLocal,
+                           boolean noAck,
+                           boolean exclusive,
+                           boolean nowait,
+                           FieldTable arguments) throws Exception;
+
+   void handleBasicPublish(AMQShortString exchange,
+                           AMQShortString routingKey,
+                           boolean immediate,
+                           boolean mandatory,
+                           int ticket);
+
+   void handleBasicQos(boolean global, int prefetchCount, long prefetchSize);
+
+   // Channel handlers ----------------------------------------------
+
+   void handleChannelClose(int classID, int methodID, int replyCode, AMQShortString replyText) throws Exception;
+
+   void handleChannelFlow(boolean active) throws Exception;
+
+   // Content handlers ----------------------------------------------
+
+   void handleContentBody(MessagingBuffer payload, int size) throws Exception;
+
+   void handleContentHeader(ContentHeaderProperties properties, long bodySize) throws Exception;
+
+   // Exchange handlers ---------------------------------------------
+
+   void handleExchangeDeclare(AMQShortString exchange,
+                              AMQShortString type,
+                              int ticket,
+                              boolean durable,
+                              boolean autoDelete,
+                              boolean internal,
+                              boolean nowait,
+                              boolean passive,
+                              FieldTable arguments);
+
+   // Queue handlers ------------------------------------------------
+
+   void handleQueueBind(AMQShortString exchange,
+                        AMQShortString routingKey,
+                        AMQShortString queue,
+                        boolean nowait,
+                        FieldTable arguments);
+
+   void handleQueueDeclare(AMQShortString queueName,
+                           int ticket,
+                           boolean durable,
+                           boolean autoDelete,
+                           boolean exclusive,
+                           boolean noWait,
+                           boolean passive,
+                           FieldTable arguments) throws Exception;
+
+}

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPGlobalFrameHandler.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPGlobalFrameHandler.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPGlobalFrameHandler.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -12,188 +12,149 @@
 
 package org.jboss.messaging.amq.server.impl;
 
+import static org.jboss.messaging.amq.framing.MethodRegistry.registry_0_9;
+
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
-import java.io.IOException;
 import java.util.UUID;
 
-import org.apache.mina.core.buffer.IoBuffer;
 import org.jboss.messaging.amq.framing.AMQBody;
 import org.jboss.messaging.amq.framing.AMQFrame;
-import org.jboss.messaging.amq.framing.AMQFrameDecodingException;
 import org.jboss.messaging.amq.framing.AMQMethodBody;
+import org.jboss.messaging.amq.framing.AMQShortString;
+import org.jboss.messaging.amq.framing.ChannelCloseBody;
 import org.jboss.messaging.amq.framing.ChannelOpenBody;
 import org.jboss.messaging.amq.framing.ChannelOpenOkBody;
 import org.jboss.messaging.amq.framing.ConnectionOpenBody;
 import org.jboss.messaging.amq.framing.ConnectionStartOkBody;
 import org.jboss.messaging.amq.framing.ConnectionTuneBody;
 import org.jboss.messaging.amq.framing.ConnectionTuneOkBody;
-import org.jboss.messaging.amq.framing.FieldTable;
-import org.jboss.messaging.amq.framing.FieldTableFactory;
-import org.jboss.messaging.amq.framing.MethodRegistry;
-import org.jboss.messaging.amq.framing.ProtocolVersion;
-import org.jboss.messaging.amq.framing.amqp_0_9.MethodRegistry_0_9;
+import org.jboss.messaging.amq.framing.HeartbeatBody;
+import org.jboss.messaging.amq.protocol.AMQConstant;
+import org.jboss.messaging.amq.server.AMQToCoreServerMapper;
 import org.jboss.messaging.amq.server.protocol.HeartbeatConfig;
 import org.jboss.messaging.amq.server.security.auth.AuthenticationResult;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.Channel;
 import org.jboss.messaging.core.remoting.ChannelHandler;
-import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.RemotingConnection;
-import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
 import org.jboss.messaging.core.server.MessagingServer;
 
 /**
- * A packet handler for all packets that need to be handled at the server level
- * 
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
  */
-public class AMQPGlobalFrameHandler implements ChannelHandler
+public class AMQPGlobalFrameHandler implements ChannelHandler<AMQFrame>
 {
    private static final Logger log = Logger.getLogger(AMQPGlobalFrameHandler.class);
 
-   private final MessagingServer server;
+   private final Channel<AMQFrame> channel1;
 
-   private final Channel channel1;
+   private final AMQToCoreServerMapper mapper;
 
-   private final RemotingConnection connection;
-
-   private MethodRegistry_0_9 methodRegistry = new MethodRegistry_0_9();
-
    private static final int DEFAULT_FRAME_SIZE = 65536;
 
    public AMQPGlobalFrameHandler(final MessagingServer server,
-                                 final Channel channel1,
-                                 final RemotingConnection connection)
+                                 final Channel<AMQFrame> channel1,
+                                 final RemotingConnection<AMQFrame> connection)
    {
-      this.server = server;
+      this.mapper = new AMQToCoreServerMapperImpl(server, connection);
 
       this.channel1 = channel1;
-
-      this.connection = connection;
    }
 
-   public void handlePacket(final Packet packet)
+   public void handle(AMQFrame frame)
    {
-   }
-
-   public void handleFrame(AMQFrame frame)
-   {
       log.info("handling AMQ frame:" + frame);
       AMQBody b = frame.getBodyFrame();
-      if (b instanceof ConnectionStartOkBody)
+
+      try
       {
-         ConnectionStartOkBody body = (ConnectionStartOkBody)b;
-         byte[] response = body.getResponse();
-         FieldTable ft = null;
-         try
+         if (b instanceof HeartbeatBody)
          {
-            ft = FieldTableFactory.newFieldTable(new IoBufferWrapper(IoBuffer.wrap(response)), response.length);
+            channel1.send(new HeartbeatBody().toFrame());
          }
-         catch (AMQFrameDecodingException e)
+         else if (b instanceof ConnectionStartOkBody)
          {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-         String username = (String)ft.getString("LOGIN");
-         String pwd = (String)ft.getString("PASSWORD");
+            ConnectionStartOkBody body = (ConnectionStartOkBody)b;
+            AuthenticationResult authResult =  mapper.handleConnectionStartOk(body.getMechanism(), body.getLocale(), body.getResponse(), body.getClientProperties());
 
-         AuthenticationResult authResult = null;
-         if (server.getSecurityManager().validateUser(username, pwd))
-         {
-            authResult = new AuthenticationResult(new byte[0], AuthenticationResult.AuthenticationStatus.SUCCESS);
+            switch (authResult.status)
+            {
+               case ERROR:
+                  log.info("Authentication failed");
+                  break;
+
+               case SUCCESS:
+                  log.info("Authentication succeeded");
+                  // _logger.info("Connected as: " + ss.getAuthorizationID());
+                  // session.setAuthorizedID(new UsernamePrincipal(ss.getAuthorizationID()));
+
+                  ConnectionTuneBody tuneBody = registry_0_9.createConnectionTuneBody(0xFFFF,
+                                                                                      DEFAULT_FRAME_SIZE,
+                                                                                      HeartbeatConfig.getInstance()
+                                                                                                     .getDelay());
+                  channel1.send(tuneBody.generateFrame(frame.getChannel()));
+                  break;
+               case CONTINUE:
+                  log.info("Authentication continued");
+
+                  // ConnectionSecureBody secureBody = methodRegistry.createConnectionSecureBody(authResult.challenge);
+                  // session.writeFrame(secureBody.generateFrame(0));
+            }
+
          }
-         else
+         else if (b instanceof ConnectionTuneOkBody)
          {
-            authResult = new AuthenticationResult(new byte[0], AuthenticationResult.AuthenticationStatus.ERROR);
+            ConnectionTuneOkBody body = (ConnectionTuneOkBody)b;
+            mapper.handleConnectionTuneOk(body.getChannelMax(), body.getFrameMax(), body.getHeartbeat());
          }
-         switch (authResult.status)
+         else if (b instanceof ConnectionOpenBody)
          {
-            case ERROR:
-               log.info("Authentication failed");
-               break;
+            ConnectionOpenBody body = (ConnectionOpenBody)b;
+            mapper.handleConnectionOpen(body.getVirtualHost(), body.getInsist(), body.getCapabilities());
+            
+            AMQMethodBody responseBody = registry_0_9.createConnectionOpenOkBody(body.getVirtualHost());
 
-            case SUCCESS:
-               log.info("Authentication succeeded");
-               // _logger.info("Connected as: " + ss.getAuthorizationID());
-               // session.setAuthorizedID(new UsernamePrincipal(ss.getAuthorizationID()));
-
-               ConnectionTuneBody tuneBody = methodRegistry.createConnectionTuneBody(0xFFFF,
-                                                                                     DEFAULT_FRAME_SIZE,
-                                                                                     HeartbeatConfig.getInstance()
-                                                                                                    .getDelay());
-               channel1.send(tuneBody.generateFrame(frame.getChannel()));
-               break;
-            case CONTINUE:
-               log.info("Authentication continued");
-
-               // ConnectionSecureBody secureBody = methodRegistry.createConnectionSecureBody(authResult.challenge);
-               // session.writeFrame(secureBody.generateFrame(0));
+            channel1.send(responseBody.generateFrame(frame.getChannel()));
          }
-
-      }
-      else if (b instanceof ConnectionTuneOkBody)
-      {
-         ConnectionTuneOkBody body = (ConnectionTuneOkBody)b;
-
-      }
-      else if (b instanceof ConnectionOpenBody)
-      {
-         ConnectionOpenBody body = (ConnectionOpenBody)b;
-         AMQMethodBody responseBody = methodRegistry.createConnectionOpenOkBody(body.getVirtualHost());
-
-         channel1.send(responseBody.generateFrame(frame.getChannel()));
-      }
-      else if (b instanceof ChannelOpenBody)
-      {
-         ChannelOpenBody body = (ChannelOpenBody)b;
-         MethodRegistry_0_9 methodRegistry = (MethodRegistry_0_9)MethodRegistry.getMethodRegistry(ProtocolVersion.v0_9);
-         log.info("channel ID = " + frame.getChannel());
-         UUID uuid = UUID.randomUUID();
-         ByteArrayOutputStream output = new ByteArrayOutputStream();
-         DataOutputStream dataOut = new DataOutputStream(output);
-         try
+         else if (b instanceof ChannelOpenBody)
          {
+            ChannelOpenBody body = (ChannelOpenBody)b;
+            log.info("channel ID = " + frame.getChannel());
+            
+            UUID uuid = mapper.handleChannelOpen(body.getOutOfBand(), (long)frame.getChannel());
+
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            DataOutputStream dataOut = new DataOutputStream(output);
             dataOut.writeLong(uuid.getMostSignificantBits());
             dataOut.writeLong(uuid.getLeastSignificantBits());
             dataOut.flush();
             dataOut.close();
+            // should really associate this channelId to the session
+            byte[] channelName = output.toByteArray();
+            ChannelOpenOkBody responseBody = registry_0_9.createChannelOpenOkBody(channelName);
+            channel1.send(responseBody.generateFrame(frame.getChannel()));
          }
-         catch (IOException e)
+         else
          {
-            // This *really* shouldn't happen as we're not doing any I/O
-            throw new RuntimeException("I/O exception when writing to byte array", e);
+            throw new IllegalStateException("unsupported AMQ body: " + b.getClass());
          }
-
-         // should really associate this channelId to the session
-         byte[] channelName = output.toByteArray();
-         ChannelOpenOkBody responseBody = methodRegistry.createChannelOpenOkBody(channelName);
-
-         try
+      }
+      catch (Throwable t)
+      {
+         log.warn("Exception while handling " + frame, t);
+         int classID = -1;
+         int methodID = -1;
+         if (b instanceof AMQMethodBody)
          {
-            server.createSession(uuid.toString(),
-                                 (long)frame.getChannel(),
-                                 null,
-                                 null,
-                                 server.getVersion().getIncrementingVersion(),
-                                 connection,
-                                 true,
-                                 true,
-                                 false);
+            classID = ((AMQMethodBody)b).getClazz();
+            methodID = ((AMQMethodBody)b).getMethod();
          }
-         catch (Exception e)
-         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-         channel1.send(responseBody.generateFrame(frame.getChannel()));
-
+         ChannelCloseBody closeBody = registry_0_9.createChannelCloseBody(AMQConstant.INTERNAL_ERROR.getCode(),
+                                             new AMQShortString(t.getMessage()),
+                                             classID,
+                                             methodID);
+         channel1.send(closeBody.generateFrame(frame.getChannel()));
       }
-      else
-      {
-         throw new IllegalStateException("unsupported AMQ body: " + b.getClass());
-      }
    }
 }
\ No newline at end of file

Modified: branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPSessionPacketHandler.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPSessionPacketHandler.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQPSessionPacketHandler.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -12,11 +12,8 @@
 
 package org.jboss.messaging.amq.server.impl;
 
-import static org.jboss.messaging.amq.StringConverter.toSimpleString;
-import static org.jboss.messaging.amq.exchange.ExchangeDefaults.DEFAULT_EXCHANGE_NAME;
 import static org.jboss.messaging.amq.framing.MethodRegistry.registry_0_9;
 
-import org.jboss.messaging.amq.AMQMessage;
 import org.jboss.messaging.amq.framing.AMQBody;
 import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.amq.framing.AMQMethodBody;
@@ -24,198 +21,199 @@
 import org.jboss.messaging.amq.framing.BasicAckBody;
 import org.jboss.messaging.amq.framing.BasicConsumeBody;
 import org.jboss.messaging.amq.framing.BasicPublishBody;
+import org.jboss.messaging.amq.framing.BasicQosBody;
+import org.jboss.messaging.amq.framing.BasicQosOkBody;
 import org.jboss.messaging.amq.framing.ChannelCloseBody;
 import org.jboss.messaging.amq.framing.ChannelCloseOkBody;
+import org.jboss.messaging.amq.framing.ChannelFlowBody;
+import org.jboss.messaging.amq.framing.ChannelFlowOkBody;
 import org.jboss.messaging.amq.framing.ContentBody;
 import org.jboss.messaging.amq.framing.ContentHeaderBody;
+import org.jboss.messaging.amq.framing.ExchangeDeclareBody;
+import org.jboss.messaging.amq.framing.ExchangeDeclareOkBody;
 import org.jboss.messaging.amq.framing.QueueBindBody;
 import org.jboss.messaging.amq.framing.QueueDeclareBody;
 import org.jboss.messaging.amq.framing.QueueDeclareOkBody;
-import org.jboss.messaging.amq.impl.AMQMessageImpl;
+import org.jboss.messaging.amq.protocol.AMQConstant;
+import org.jboss.messaging.amq.server.AMQToCoreSessionMapper;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.remoting.Channel;
 import org.jboss.messaging.core.remoting.ChannelHandler;
-import org.jboss.messaging.core.remoting.Packet;
-import org.jboss.messaging.core.remoting.WireFormat;
-import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.ServerSession;
-import org.jboss.messaging.util.SimpleString;
 
 /**
  * A AMQPSessionPacketHandler
  *
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  */
-public class AMQPSessionPacketHandler implements ChannelHandler
+public class AMQPSessionPacketHandler implements ChannelHandler<AMQFrame>
 {
    private static final Logger log = Logger.getLogger(AMQPSessionPacketHandler.class);
 
-   private final ServerSession session;
+   private final Channel<AMQFrame> channel;
 
-   private final Channel channel;
+   private AMQToCoreSessionMapper mapper;
 
-   private final StorageManager storageManager;
+   private final long sessionID;
 
-   private AMQMessage currentMessage = null;
-
    public AMQPSessionPacketHandler(final ServerSession session,
-                                     final Channel channel,
-                                     final StorageManager storageManager)
+                                   final Channel<AMQFrame> channel,
+                                   final StorageManager storageManager)
 
    {
-      this.session = session;
+      this.mapper = new AMQToCoreSessionMapperImpl(session);
 
       this.channel = channel;
-
-      this.storageManager = storageManager;
+      
+      this.sessionID = session.getID();
    }
 
    public long getID()
    {
-      return session.getID();
+      return sessionID;
    }
 
-   public void handlePacket(final Packet packet)
+   public void handle(AMQFrame frame)
    {
-   }
-
-   public void handleFrame(AMQFrame frame)
-   {
       log.info("handling frame:" + frame);
       AMQBody b = frame.getBodyFrame();
-      if (b instanceof BasicPublishBody)
+      try
       {
-         BasicPublishBody body = (BasicPublishBody)b;
-         log.info("received basic.publish method " + body);
-         AMQShortString exchangeStr = body.getExchange();
-         SimpleString exchange = (exchangeStr == null) ? toSimpleString(DEFAULT_EXCHANGE_NAME)
-                                                      : toSimpleString(exchangeStr);
-         SimpleString routingKey = toSimpleString(body.getRoutingKey());
-         currentMessage = new AMQMessageImpl(exchange, routingKey, body.getImmediate(), body.getMandatory());
-      }
-      else if (b instanceof ContentHeaderBody)
-      {
-         ContentHeaderBody body = (ContentHeaderBody)b;
-         log.info("received header: " + body.properties);
-         if (currentMessage == null)
+         if (b instanceof ExchangeDeclareBody)
          {
-            throw new IllegalStateException("Content header received before a basic.publish method");
+            ExchangeDeclareBody body = (ExchangeDeclareBody)b;
+            mapper.handleExchangeDeclare(body.getExchange(),
+                                         body.getType(),
+                                         body.getTicket(),
+                                         body.getDurable(),
+                                         body.getAutoDelete(),
+                                         body.getInternal(),
+                                         body.getNowait(),
+                                         body.getPassive(),
+                                         body.getArguments());
+
+            ExchangeDeclareOkBody responseBody = registry_0_9.createExchangeDeclareOkBody();
+            channel.send(responseBody.generateFrame(frame.getChannel()));
          }
-         currentMessage.setHeader(body.properties);
-         currentMessage.setBodySize(body.bodySize);
-         if (body.bodySize == 0)
+         else if (b instanceof ChannelFlowBody)
          {
-            try
-            {
-               session.send(currentMessage.toCoreMessage());
-            }
-            catch (Exception e)
-            {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-            }
-            finally
-            {
-               resetCurrentMessage();
-            }
+            ChannelFlowBody body = (ChannelFlowBody)b;
+            mapper.handleChannelFlow(body.getActive());
+
+            ChannelFlowOkBody responseBody = registry_0_9.createChannelFlowOkBody(body.getActive());
+            channel.send(responseBody.generateFrame(frame.getChannel()));
          }
-      }
-      else if (b instanceof ContentBody)
-      {
-         if (currentMessage == null)
+         else if (b instanceof BasicPublishBody)
          {
-            throw new IllegalStateException("Content body received before a basic.publish method");
+            BasicPublishBody body = (BasicPublishBody)b;
+            log.info("received basic.publish method " + body);
+            mapper.handleBasicPublish(body.getExchange(),
+                                      body.getRoutingKey(),
+                                      body.getImmediate(),
+                                      body.getMandatory(),
+                                      body.getTicket());
          }
-         ContentBody body = (ContentBody)b;
-         log.info("received body: " + body.payload);
-         boolean finalFrame = currentMessage.addPayload(body.payload, body.getSize());
-         if (finalFrame)
+         else if (b instanceof ContentHeaderBody)
          {
-            log.info("received final frame");
-            ServerMessage coreMessage = currentMessage.toCoreMessage();
-            try
-            {
-               session.send(coreMessage);
-               log.info("routed message");
-            }
-            catch (Exception e)
-            {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-            }
-            finally
-            {
-               resetCurrentMessage();
-            }
+            ContentHeaderBody body = (ContentHeaderBody)b;
+            log.info("received header: " + body.properties);
+            mapper.handleContentHeader(body.properties, body.bodySize);
          }
-         else
+         else if (b instanceof ContentBody)
          {
-            log.info("wating for more frame");
+            ContentBody body = (ContentBody)b;
+            log.info("received body: " + body.payload);
+            mapper.handleContentBody(body.payload, body.getSize());
          }
-      }
-      else if (b instanceof QueueDeclareBody)
-      {
-         QueueDeclareBody body = (QueueDeclareBody)b;
-         QueueDeclareOkBody responseBody = registry_0_9.createQueueDeclareOkBody(body.getQueue(), 1, 1);
-         channel.send(responseBody.generateFrame(frame.getChannel()));
-      }
-      else if (b instanceof QueueBindBody)
-      {
-         AMQMethodBody responseBody = registry_0_9.createQueueBindOkBody();
-         channel.send(responseBody.generateFrame(frame.getChannel()));
-      }
-      else if (b instanceof BasicConsumeBody)
-      {
-         BasicConsumeBody body = (BasicConsumeBody)b;
-         try
+         else if (b instanceof QueueDeclareBody)
          {
-            session.createConsumer(toSimpleString(body.getQueue()), null, -1, -1, WireFormat.AMQP);
-            session.setStarted(true);
-            AMQMethodBody responseBody = registry_0_9.createBasicConsumeOkBody(body.getConsumerTag());
+            QueueDeclareBody body = (QueueDeclareBody)b;
+            mapper.handleQueueDeclare(body.getQueue(),
+                                      body.getTicket(),
+                                      body.getDurable(),
+                                      body.getAutoDelete(),
+                                      body.getExclusive(),
+                                      body.getNowait(),
+                                      body.getPassive(),
+                                      body.getArguments());
+
+            QueueDeclareOkBody responseBody = registry_0_9.createQueueDeclareOkBody(body.getQueue(), 1, 1);
             channel.send(responseBody.generateFrame(frame.getChannel()));
          }
-         catch (Exception e)
+         else if (b instanceof QueueBindBody)
          {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            QueueBindBody body = (QueueBindBody)b;
+
+            mapper.handleQueueBind(body.getExchange(),
+                                   body.getRoutingKey(),
+                                   body.getQueue(),
+                                   body.getNowait(),
+                                   body.getArguments());
+            
+            AMQMethodBody responseBody = registry_0_9.createQueueBindOkBody();
+            channel.send(responseBody.generateFrame(frame.getChannel()));
          }
-      }
-      else if (b instanceof BasicAckBody)
-      {
-         BasicAckBody body = (BasicAckBody)b;
-         try
+         else if (b instanceof BasicQosBody)
          {
-            session.commit();
+            BasicQosBody body = (BasicQosBody)b;
+            
+            mapper.handleBasicQos(body.getGlobal(), body.getPrefetchCount(), body.getPrefetchSize());
+
+            BasicQosOkBody responseBody = registry_0_9.createBasicQosOkBody();
+            channel.send(responseBody.generateFrame(frame.getChannel()));
          }
-         catch (Exception e)
+         else if (b instanceof BasicConsumeBody)
          {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            BasicConsumeBody body = (BasicConsumeBody)b;
+
+            mapper.handleBasicConsume(body.getQueue(),
+                                      body.getConsumerTag(),
+                                      body.getTicket(),
+                                      body.getNoLocal(),
+                                      body.getNoAck(),
+                                      body.getExclusive(),
+                                      body.getNowait(),
+                                      body.getArguments());
+
+            AMQMethodBody responseBody = registry_0_9.createBasicConsumeOkBody(body.getConsumerTag());
+            channel.send(responseBody.generateFrame(frame.getChannel()));
+
          }
-      }
-      else if (b instanceof ChannelCloseBody)
-      {
-         ChannelCloseOkBody responseBody = registry_0_9.createChannelCloseOkBody();
-         channel.send(responseBody.generateFrame(frame.getChannel()));
-         try
+         else if (b instanceof BasicAckBody)
          {
-            session.close();
+            BasicAckBody body = (BasicAckBody)b;
+
+            mapper.handleBasicAck(body.getDeliveryTag(), body.getMultiple());
          }
-         catch (Exception e)
+         else if (b instanceof ChannelCloseBody)
          {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            ChannelCloseBody body = (ChannelCloseBody)b;
+            mapper.handleChannelClose(body.getClassId(), body.getMethodId(), body.getReplyCode(), body.getReplyText());
+
+            ChannelCloseOkBody responseBody = registry_0_9.createChannelCloseOkBody();
+            channel.send(responseBody.generateFrame(frame.getChannel()));
          }
+         else
+         {
+            throw new IllegalStateException("Unsupported body:" + frame.getBodyFrame().getClass());
+         }
       }
-      else
+      catch (Throwable t)
       {
-         throw new IllegalStateException("Unsupported body:" + frame.getBodyFrame().getClass());
+         log.warn("Exception while handling " + frame, t);
+         int classID = -1;
+         int methodID = -1;
+         if (b instanceof AMQMethodBody)
+         {
+            classID = ((AMQMethodBody)b).getClazz();
+            methodID = ((AMQMethodBody)b).getMethod();
+         }
+         ChannelCloseBody closeBody = registry_0_9.createChannelCloseBody(AMQConstant.INTERNAL_ERROR.getCode(),
+                                                                          new AMQShortString(t.getMessage()),
+                                                                          classID,
+                                                                          methodID);
+         channel.send(closeBody.generateFrame(frame.getChannel()));
       }
    }
-
-   private void resetCurrentMessage()
-   {
-      currentMessage = null;
-   }
 }

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreServerMapperImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreServerMapperImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreServerMapperImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.amq.server.impl;
+
+import java.util.UUID;
+
+import org.jboss.messaging.amq.framing.AMQFrame;
+import org.jboss.messaging.amq.framing.AMQShortString;
+import org.jboss.messaging.amq.framing.FieldTable;
+import org.jboss.messaging.amq.server.AMQToCoreServerMapper;
+import org.jboss.messaging.amq.server.security.auth.AuthenticationResult;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.ServerSession;
+
+/**
+ * A AMQToCoreServerMapperImpl
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * Created 30 oct. 2008 10:49:13
+ *
+ *
+ */
+public class AMQToCoreServerMapperImpl implements AMQToCoreServerMapper
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final MessagingServer server;
+
+   private final RemotingConnection<AMQFrame> remotingConnection;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public AMQToCoreServerMapperImpl(MessagingServer server, RemotingConnection<AMQFrame> remotingConnection)
+   {
+      this.server = server;
+      this.remotingConnection = remotingConnection;
+   }
+
+   // Public --------------------------------------------------------
+
+   // AMQToCoreServerMapper implementation --------------------------
+
+   public UUID handleChannelOpen(AMQShortString outOfBand, long channelID) throws Exception
+   {
+      UUID sessionID = UUID.randomUUID();
+
+      server.createSession(sessionID.toString(),
+                           channelID,
+                           null,
+                           null,
+                           server.getVersion().getIncrementingVersion(),
+                           remotingConnection,
+                           true,
+                           true,
+                           false);
+      ServerSession session = server.getSession(sessionID.toString());
+      session.setStarted(true);
+      return sessionID;
+   }
+
+   public void handleConnectionOpen(AMQShortString virtualHost, boolean insist, AMQShortString capabilities)
+   {
+   }
+
+   public AuthenticationResult handleConnectionStartOk(AMQShortString mechanism,
+                                                       AMQShortString locale,
+                                                       byte[] response,
+                                                       FieldTable clientProperties)
+   {
+
+      /*
+      FieldTable ft = null;
+      try
+      {
+         ft = FieldTableFactory.newFieldTable(new IoBufferWrapper(IoBuffer.wrap(response)), response.length);
+      }
+      catch (AMQFrameDecodingException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+      String username = (String)ft.getString("LOGIN");
+      String pwd = (String)ft.getString("PASSWORD");
+
+      AuthenticationResult authResult = null;
+      if (server.getSecurityManager().validateUser(username, pwd))
+      {
+         authResult = new AuthenticationResult(new byte[0], AuthenticationResult.AuthenticationStatus.SUCCESS);
+      }
+      else
+      {
+         authResult = new AuthenticationResult(new byte[0], AuthenticationResult.AuthenticationStatus.ERROR);
+      }
+      */
+      AuthenticationResult authResult = new AuthenticationResult(new byte[0],
+                                                                 AuthenticationResult.AuthenticationStatus.SUCCESS);
+      return authResult;
+   }
+
+   public void handleConnectionTuneOk(int channelMax, long frameMax, int heartbeat)
+   {
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreSessionMapperImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreSessionMapperImpl.java	                        (rev 0)
+++ branches/amqp_integration/src/main/org/jboss/messaging/amq/server/impl/AMQToCoreSessionMapperImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.amq.server.impl;
+
+import static org.jboss.messaging.amq.StringConverter.toSimpleString;
+import static org.jboss.messaging.amq.exchange.ExchangeDefaults.DEFAULT_EXCHANGE_NAME;
+
+import org.jboss.messaging.amq.AMQMessage;
+import org.jboss.messaging.amq.framing.AMQShortString;
+import org.jboss.messaging.amq.framing.ContentHeaderProperties;
+import org.jboss.messaging.amq.framing.FieldTable;
+import org.jboss.messaging.amq.impl.AMQMessageImpl;
+import org.jboss.messaging.amq.server.AMQToCoreSessionMapper;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.WireFormat;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.ServerSession;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A AMQToCoreSessionMapperImpl
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * Created 30 oct. 2008 11:07:14
+ *
+ *
+ */
+public class AMQToCoreSessionMapperImpl implements AMQToCoreSessionMapper
+{
+
+   // Constants -----------------------------------------------------
+
+   private static final Logger log = Logger.getLogger(AMQToCoreSessionMapperImpl.class);
+
+   // Attributes ----------------------------------------------------
+
+   private final ServerSession session;
+
+   private AMQMessage currentMessage = null;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public AMQToCoreSessionMapperImpl(ServerSession session)
+   {
+      this.session = session;
+   }
+
+   // Public --------------------------------------------------------
+
+   // AMQToCoreSessionMapper implementation -------------------------
+
+   public void handleBasicAck(long deliveryTag, boolean multiple) throws Exception
+   {
+      session.commit();
+   }
+
+   public void handleBasicConsume(AMQShortString queue,
+                                  AMQShortString consumerTag,
+                                  int ticket,
+                                  boolean noLocal,
+                                  boolean noAck,
+                                  boolean exclusive,
+                                  boolean nowait,
+                                  FieldTable arguments) throws Exception
+   {
+
+      SimpleString squeueName = toSimpleString(queue);
+      session.createConsumer(squeueName, null, -1, -1, WireFormat.AMQP);
+   }
+
+   public void handleBasicPublish(AMQShortString exchange,
+                                  AMQShortString routingKey,
+                                  boolean immediate,
+                                  boolean mandatory,
+                                  int ticket)
+   {
+      SimpleString sExchange = (exchange == null) ? toSimpleString(DEFAULT_EXCHANGE_NAME) : toSimpleString(exchange);
+      SimpleString sRoutingKey = toSimpleString(routingKey);
+
+      currentMessage = new AMQMessageImpl(sExchange, sRoutingKey, immediate, mandatory);
+   }
+
+   public void handleBasicQos(boolean global, int prefetchCount, long prefetchSize)
+   {
+   }
+
+   public void handleChannelClose(int classID, int methodID, int replyCode, AMQShortString replyText) throws Exception
+   {
+      session.close();
+   }
+
+   public void handleChannelFlow(boolean active) throws Exception
+   {
+      session.setStarted(active);
+   }
+
+   public void handleContentBody(MessagingBuffer payload, int size) throws Exception
+   {
+      boolean finalFrame = fillMessageContent(payload, size);
+      if (finalFrame)
+      {
+         if (log.isDebugEnabled())
+         {
+            log.debug("received final frame");
+         }
+         try
+         {
+            session.send(currentMessage.toCoreMessage());
+         }
+         finally
+         {
+            resetCurrentMessage();
+         }
+      }
+      else
+      {
+         if (log.isDebugEnabled())
+         {
+            log.debug("wating for more frame");
+         }
+      }
+   }
+
+   public void handleContentHeader(ContentHeaderProperties properties, long bodySize) throws Exception
+   {
+      fillMessageHeader(properties, bodySize);
+      if (bodySize == 0)
+      {
+         try
+         {
+            session.send(currentMessage.toCoreMessage());
+         }
+         finally
+         {
+            resetCurrentMessage();
+         }
+      }
+   }
+
+   public void handleExchangeDeclare(AMQShortString exchange,
+                                     AMQShortString type,
+                                     int ticket,
+                                     boolean durable,
+                                     boolean autoDelete,
+                                     boolean internal,
+                                     boolean nowait,
+                                     boolean passive,
+                                     FieldTable arguments)
+   {
+   }
+
+   public void handleQueueBind(AMQShortString exchange,
+                               AMQShortString routingKey,
+                               AMQShortString queue,
+                               boolean nowait,
+                               FieldTable arguments)
+   {
+   }
+
+   public void handleQueueDeclare(AMQShortString queueName,
+                                  int ticket,
+                                  boolean durable,
+                                  boolean autoDelete,
+                                  boolean exclusive,
+                                  boolean noWait,
+                                  boolean passive,
+                                  FieldTable arguments) throws Exception
+   {
+      SimpleString squeueName = toSimpleString(queueName);
+      if (!session.isQueueCreated(squeueName))
+      {
+         session.createQueue(squeueName, squeueName, null, durable, false);
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private void resetCurrentMessage()
+   {
+      currentMessage = null;
+   }
+
+   private boolean fillMessageContent(MessagingBuffer payload, int size)
+   {
+      if (currentMessage == null)
+      {
+         throw new IllegalStateException("Content body received before a basic.publish method");
+      }
+      return currentMessage.addPayload(payload, size);
+   }
+
+   private void fillMessageHeader(ContentHeaderProperties properties, long bodySize)
+   {
+      if (currentMessage == null)
+      {
+         throw new IllegalStateException("Content header received before a basic.publish method");
+      }
+      currentMessage.setHeader(properties);
+      currentMessage.setBodySize(bodySize);
+   }
+   // Inner classes -------------------------------------------------
+
+}

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientBrowserImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientBrowserImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientBrowserImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -15,6 +15,7 @@
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowserCloseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionBrowserHasNextMessageMessage;
@@ -39,7 +40,7 @@
 
    private final ClientSessionInternal session;
 
-   private final Channel channel;
+   private final Channel<Packet> channel;
 
    private volatile boolean closed;
 
@@ -47,7 +48,7 @@
 
    // Constructors ---------------------------------------------------------------------------------
 
-   public ClientBrowserImpl(final ClientSessionInternal session, final long id, final Channel channel)
+   public ClientBrowserImpl(final ClientSessionInternal session, final long id, final Channel<Packet> channel)
    {
       this.id = id;
 

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientConsumerImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -21,6 +21,7 @@
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerCloseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
 import org.jboss.messaging.util.Future;
@@ -49,7 +50,7 @@
 
    private final ClientSessionInternal session;
 
-   private final Channel channel;
+   private final Channel<Packet> channel;
 
    private final long id;
 
@@ -83,7 +84,7 @@
                              final int clientWindowSize,
                              final boolean direct,
                              final Executor executor,
-                             final Channel channel)
+                             final Channel<Packet> channel)
    {
       this.id = id;
 

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -18,6 +18,7 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.message.impl.MessageImpl;
 import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionProducerCloseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionScheduledSendMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
@@ -51,7 +52,7 @@
 
    private final ClientSessionInternal session;
 
-   private final Channel channel;
+   private final Channel<Packet> channel;
 
    private volatile boolean closed;
 
@@ -85,7 +86,7 @@
                              final boolean blockOnPersistentSend,
                              final SimpleString autoGroupId,
                              final int initialCredits,
-                             final Channel channel)
+                             final Channel<Packet> channel)
    {
       this.channel = channel;
 

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -429,7 +429,7 @@
       {
          // Need to get it once for each session to ensure ref count in
          // holder is incremented properly
-         RemotingConnection backupConnection = connectionRegistry.getConnection(backupConnectorFactory,
+         RemotingConnection<Packet> backupConnection = connectionRegistry.getConnection(backupConnectorFactory,
                                                                                 backupTransportParams,
                                                                                 pingPeriod,
                                                                                 callTimeout);         
@@ -463,7 +463,7 @@
    {
       Version clientVersion = VersionLoader.load();
 
-      RemotingConnection connection = null;
+      RemotingConnection<Packet> connection = null;
       try
       {
          connection = connectionRegistry.getConnection(connectorFactory, transportParams, pingPeriod, callTimeout);
@@ -490,7 +490,7 @@
                                                    autoCommitSends,
                                                    autoCommitAcks);
 
-         Channel channel1 = connection.getChannel(1, false, -1, true);
+         Channel<Packet> channel1 = connection.getChannel(1, false, -1, true);
 
          try
          {
@@ -517,7 +517,7 @@
 
          int packetConfirmationBatchSize = response.getPacketConfirmationBatchSize();
          
-         Channel sessionChannel = connection.getChannel(sessionChannelID,
+         Channel<Packet> sessionChannel = connection.getChannel(sessionChannelID,
                                                         false,
                                                         packetConfirmationBatchSize,                                               
                                                         !hasBackup);
@@ -537,7 +537,7 @@
 
          sessions.add(session);
 
-         ChannelHandler handler = new ClientSessionPacketHandler(session);
+         ChannelHandler<Packet> handler = new ClientSessionPacketHandler(session);
 
          sessionChannel.setHandler(handler);
 

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -130,7 +130,7 @@
 
    private final Executor executor;
 
-   private volatile RemotingConnection remotingConnection;
+   private volatile RemotingConnection<Packet> remotingConnection;
 
    private final Map<Long, ClientBrowser> browsers = new ConcurrentHashMap<Long, ClientBrowser>();
 
@@ -152,7 +152,7 @@
 
    private final boolean autoGroupId;
 
-   private final Channel channel;
+   private final Channel<Packet> channel;
 
    private final int version;
 
@@ -173,10 +173,10 @@
                             final boolean autoCommitAcks,
                             final boolean blockOnAcknowledge,
                             final boolean autoGroupId,
-                            final RemotingConnection remotingConnection,
+                            final RemotingConnection<Packet> remotingConnection,
                             final ClientSessionFactory connectionFactory,
                             final int version,
-                            final Channel channel) throws MessagingException
+                            final Channel<Packet> channel) throws MessagingException
    {
       this.sessionFactory = sessionFactory;
 
@@ -716,7 +716,7 @@
    }
    
    //Needs to be synchronized to prevent issues with occurring concurrently with close()
-   public synchronized boolean handleFailover(final RemotingConnection backupConnection)
+   public synchronized boolean handleFailover(final RemotingConnection<Packet> backupConnection)
    {
       if (closed)
       {
@@ -737,7 +737,7 @@
 
          Packet request = new ReattachSessionMessage(name, channel.getLastReceivedCommandID());
 
-         Channel channel1 = backupConnection.getChannel(1, false, -1, true);
+         Channel<Packet> channel1 = backupConnection.getChannel(1, false, -1, true);
 
          ReattachSessionResponseMessage response = (ReattachSessionResponseMessage)channel1.sendBlocking(request);
 
@@ -1062,7 +1062,7 @@
       connectionRegistry = registry;
    }
 
-   public RemotingConnection getConnection()
+   public RemotingConnection<Packet> getConnection()
    {
       return remotingConnection;
    }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionInternal.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -19,6 +19,7 @@
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.util.SimpleString;
 
@@ -59,5 +60,5 @@
 
    void handleReceiveMessage(long consumerID, ClientMessage message) throws Exception;
 
-   boolean handleFailover(final RemotingConnection backupConnection);
+   boolean handleFailover(final RemotingConnection<Packet> backupConnection);
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/client/impl/ClientSessionPacketHandler.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -26,7 +26,6 @@
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_RECEIVETOKENS;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_RECEIVE_MSG;
 
-import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.ChannelHandler;
 import org.jboss.messaging.core.remoting.Packet;
@@ -41,7 +40,7 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  *
  */
-public class ClientSessionPacketHandler implements ChannelHandler
+public class ClientSessionPacketHandler implements ChannelHandler<Packet>
 {
    private static final Logger log = Logger.getLogger(ClientSessionPacketHandler.class);
 
@@ -52,7 +51,7 @@
       this.clientSession = clientSesssion;
    }
       
-   public void handlePacket(final Packet packet)
+   public void handle(Packet packet)
    {
       byte type = packet.getType();
        
@@ -97,9 +96,4 @@
          log.error("Failed to handle packet", e);
       }
    }
-   
-   public void handleFrame(AMQFrame frame)
-   {
-      // FIXME no client-side handling for AMQ
-   }
 }
\ No newline at end of file

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/Channel.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/Channel.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/Channel.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -13,37 +13,38 @@
 
 import java.util.concurrent.Executor;
 
-import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.core.exception.MessagingException;
 
 /**
  * A Channel A Channel *does not* support concurrent access by more than one thread!
  * 
+ * <code>T</code> is <code>Packet</code> for JBM Core and <code>AMQFrame</code> for AMQP.
+ * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  */
-public interface Channel
+public interface Channel<T>
 {
    long getID();
 
-   void send(Packet packet);
+   void send(T t);
 
-   Packet sendBlocking(Packet packet) throws MessagingException;
+   T sendBlocking(T t) throws MessagingException;
 
-   Packet sendBlocking(Packet packet, ResponseNotifier notifier) throws MessagingException;
+   T sendBlocking(T t, ResponseNotifier notifier) throws MessagingException;
 
-   void replicatePacket(Packet packet, Runnable responseAction);
+   void replicatePacket(T t, Runnable responseAction);
    
    void replicateComplete();
 
-   void setHandler(ChannelHandler handler);
+   void setHandler(ChannelHandler<T> handler);
 
    void close(boolean onExecutorThread);
 
    void fail();
 
-   Channel getReplicatingChannel();
+   Channel<T> getReplicatingChannel();
 
-   void transferConnection(RemotingConnection newConnection);
+   void transferConnection(RemotingConnection<T> newConnection);
    
    void replayCommands(int lastReceivedCommandID);
 
@@ -57,5 +58,4 @@
 
    void interruptBlocking();
 
-   void send(AMQFrame generateFrame);
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ChannelHandler.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ChannelHandler.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ChannelHandler.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -21,17 +21,16 @@
   */
 package org.jboss.messaging.core.remoting;
 
-import org.jboss.messaging.amq.framing.AMQFrame;
-
 /**
  * A ChannelHandler
  * 
+ * <code>T</code> is <code>Packet</code> for JBM Core and <code>AMQFrame</code> for AMQP.
+ * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  *
  */
-public interface ChannelHandler
+public interface ChannelHandler<T>
 {
-   void handlePacket(Packet packet);
-
-   void handleFrame(AMQFrame frame);
+   void handle(T message);
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ConnectionRegistry.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ConnectionRegistry.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/ConnectionRegistry.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -33,10 +33,10 @@
  */
 public interface ConnectionRegistry
 {
-   RemotingConnection getConnection(ConnectorFactory connectorFactory, Map<String, Object> params,
+   RemotingConnection<Packet> getConnection(ConnectorFactory connectorFactory, Map<String, Object> params,
                                     long pingInterval, long callTimeout);
    
-   RemotingConnection getConnectionNoCache(ConnectorFactory connectorFactory, Map<String, Object> params,
+   RemotingConnection<Packet> getConnectionNoCache(ConnectorFactory connectorFactory, Map<String, Object> params,
                                            long pingInterval, long callTimeout);
    
    void returnConnection(Object connectionID);

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingConnection.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -24,11 +24,11 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  */
-public interface RemotingConnection extends BufferHandler
+public interface RemotingConnection<T> extends BufferHandler
 {
    Object getID();
 
-   Channel getChannel(long channelID, boolean ordered, int packetConfirmationBatchSize, boolean interruptBlockOnFailure);
+   Channel<T> getChannel(long channelID, boolean ordered, int packetConfirmationBatchSize, boolean interruptBlockOnFailure);
 
    long generateChannelID();
 
@@ -52,5 +52,5 @@
    
    void activate();
    
-   ChannelHandler createSessionHandler(ServerSession session, Channel channel, StorageManager storageManager);
+   ChannelHandler<T> createSessionHandler(ServerSession session, Channel<T> channel, StorageManager storageManager);
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingService.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingService.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/RemotingService.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -33,11 +33,11 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @version <tt>$Revision$</tt>
  */
-public interface RemotingService extends MessagingComponent
+public interface RemotingService<T> extends MessagingComponent
 {
-   RemotingConnection getConnection(Object remotingConnectionID);
+   RemotingConnection<T> getConnection(Object remotingConnectionID);
 
-   Set<RemotingConnection> getConnections();
+   Set<RemotingConnection<T>> getConnections();
    
    void setMessagingServer(MessagingServer server);
    

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/ConnectionRegistryImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -26,10 +26,10 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
-import org.jboss.messaging.amq.framing.AMQDataBlock;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.ConnectionRegistry;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.spi.Connection;
 import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
@@ -65,7 +65,7 @@
 
    // ConnectionRegistry implementation -----------------------------
 
-   public synchronized RemotingConnection getConnection(final ConnectorFactory connectorFactory,
+   public synchronized RemotingConnection<Packet> getConnection(final ConnectorFactory connectorFactory,
                                                         final Map<String, Object> params,
                                                         final long pingInterval,
                                                         final long callTimeout)
@@ -78,7 +78,7 @@
       {
          holder.increment();
          
-         RemotingConnection connection = holder.getConnection();
+         RemotingConnection<Packet> connection = holder.getConnection();
 
          return connection;
       }
@@ -97,7 +97,7 @@
             throw new IllegalStateException("Failed to connect");
          }
 
-         RemotingConnection connection = new RemotingConnectionImpl(tc,
+         RemotingConnection<Packet> connection = new RemotingConnectionImpl(tc,
                                                                     callTimeout,
                                                                     pingInterval,
                                                                     null,
@@ -315,7 +315,7 @@
 
    private static class ConnectionHolder
    {
-      private final RemotingConnection connection;
+      private final RemotingConnection<Packet> connection;
 
       private final Connector connector;
 
@@ -323,7 +323,7 @@
       
       private StackTraceElement[] trace;
 
-      public ConnectionHolder(final RemotingConnection connection, final Connector connector)
+      public ConnectionHolder(final RemotingConnection<Packet> connection, final Connector connector)
       {
          assert connector != null;
 
@@ -349,7 +349,7 @@
          return count;
       }
 
-      public RemotingConnection getConnection()
+      public RemotingConnection<Packet> getConnection()
       {
          return connection;
       }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -90,15 +90,6 @@
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.jboss.messaging.amq.AMQException;
-import org.jboss.messaging.amq.framing.AMQDataBlock;
-import org.jboss.messaging.amq.framing.AMQFrame;
-import org.jboss.messaging.amq.framing.AMQMethodBody;
-import org.jboss.messaging.amq.framing.ChannelCloseOkBody;
-import org.jboss.messaging.amq.framing.ChannelOpenBody;
-import org.jboss.messaging.amq.framing.MethodRegistry;
-import org.jboss.messaging.amq.framing.ProtocolInitiation;
-import org.jboss.messaging.amq.framing.ProtocolVersion;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
@@ -109,7 +100,6 @@
 import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.ResponseNotifier;
-import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
@@ -178,7 +168,7 @@
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
  * @version <tt>$Revision$</tt> $Id$
  */
-public class RemotingConnectionImpl extends AbstractBufferHandler implements RemotingConnection
+public class RemotingConnectionImpl extends AbstractBufferHandler implements RemotingConnection<Packet>
 {
    // Constants
    // ------------------------------------------------------------------------------------
@@ -221,9 +211,9 @@
 
    private volatile long expireTime = -1;
 
-   private final Channel pingChannel;
+   private final Channel<Packet> pingChannel;
 
-   private final RemotingConnection replicatingConnection;
+   private final RemotingConnection<Packet> replicatingConnection;
 
    private volatile boolean active;
 
@@ -247,7 +237,7 @@
                                  final ExecutorService handlerExecutor,
                                  final ScheduledExecutorService pingExecutor,
                                  final List<Interceptor> interceptors,
-                                 final RemotingConnection replicatingConnection,
+                                 final RemotingConnection<Packet> replicatingConnection,
                                  final boolean active)
 
    {
@@ -277,7 +267,7 @@
       // Channel zero is reserved for pinging
       pingChannel = getChannel(9, false, -1, false);
 
-      final ChannelHandler ppHandler = new PingPongHandler();
+      final ChannelHandler<Packet> ppHandler = new PingPongHandler();
 
       pingChannel.setHandler(ppHandler);      
    }
@@ -306,7 +296,7 @@
       return transportConnection.getID();
    }
 
-   public synchronized Channel getChannel(final long channelID,
+   public synchronized Channel<Packet> getChannel(final long channelID,
                                           final boolean ordered,
                                           final int packetConfirmationBatchSize,
                                           final boolean interruptBlockOnFailure)
@@ -323,7 +313,7 @@
       return channel;
    }
 
-   public ChannelHandler createSessionHandler(ServerSession session, Channel channel, StorageManager storageManager)
+   public ChannelHandler<Packet> createSessionHandler(ServerSession session, Channel<Packet> channel, StorageManager storageManager)
    {
       return new ServerSessionPacketHandler(session, channel, storageManager);
    }
@@ -375,7 +365,7 @@
 
          internalClose();
 
-         for (Channel channel : channels.values())
+         for (Channel<Packet> channel : channels.values())
          {
             channel.fail();
          }
@@ -504,7 +494,7 @@
          replicatingConnection.destroy();
       }
 
-      for (Channel channel : channels.values())
+      for (Channel<Packet> channel : channels.values())
       {
          channel.close(false);
       }
@@ -519,11 +509,6 @@
       transportConnection.write(buffer);
    }
    
-   public void doWrite(AMQFrame frame)
-   {
-      transportConnection.write(new IoBufferWrapper(frame.toIoBuffer()));
-   }
-
    private Packet decode(final MessagingBuffer in)
    {
       final byte packetType = in.getByte();
@@ -852,13 +837,13 @@
    // --------------------------------------------------------------------------------
 
    // Needs to be static so we can re-assign it to another remotingconnection
-   private static class ChannelImpl implements Channel
+   private static class ChannelImpl implements Channel<Packet>
    {
       private final long id;
 
       private final Executor executor;
 
-      private ChannelHandler handler;
+      private ChannelHandler<Packet> handler;
 
       private Packet response;
 
@@ -872,7 +857,7 @@
 
       private volatile int nextConfirmation;
 
-      private Channel replicatingChannel;
+      private Channel<Packet> replicatingChannel;
 
       private volatile RemotingConnectionImpl connection;
 
@@ -1010,11 +995,6 @@
          }
       }
 
-      public void send(AMQFrame frame)
-      {
-         connection.doWrite(frame);
-      }
-
       private final Object waitLock = new Object();
 
       public Executor getExecutor()
@@ -1111,8 +1091,8 @@
             lock.unlock();
          }
       }
-            
-      public void replicatePacket(final Packet packet, final Runnable responseAction)
+                  
+      public void replicatePacket(Packet packet, Runnable responseAction)
       {
          if (replicatingChannel != null)
          {
@@ -1156,7 +1136,7 @@
          action.run();
       }
 
-      public void setHandler(final ChannelHandler handler)
+      public void setHandler(final ChannelHandler<Packet> handler)
       {
          this.handler = handler;
       }
@@ -1210,7 +1190,7 @@
          }
       }
 
-      public Channel getReplicatingChannel()
+      public Channel<Packet> getReplicatingChannel()
       {
          return replicatingChannel;
       }
@@ -1233,7 +1213,7 @@
          }
       }
 
-      public void transferConnection(final RemotingConnection newConnection)
+      public void transferConnection(final RemotingConnection<Packet> newConnection)
       {
          // Needs to synchronize on the connection to make sure no packets from
          // the old connection get processed after transfer has occurred
@@ -1284,46 +1264,7 @@
 
          lock.unlock();
       }
-
-      private void handleFrame(final AMQFrame frame)
-      {
-         long channelId = frame.getChannel();
-
-         if (log.isInfoEnabled())
-         {
-            log.info("Frame Received on channel " + channelId + ": " + frame);
-         }
-
-         // Check that this channel is not closing
-         if (channelAwaitingClosure(channelId))
-         {
-             if ((frame.getBodyFrame() instanceof ChannelCloseOkBody))
-             {
-                 if (log.isInfoEnabled())
-                 {
-                    log.info("Channel[" + channelId + "] awaiting closure - processing close-ok");
-                 }
-             }
-             else
-             {
-                 if (log.isInfoEnabled())
-                 {
-                    log.info("Channel[" + channelId + "] awaiting closure ignoring");
-                 }
-
-                 return;
-             }
-         }
-         handler.handleFrame(frame);
-      }
       
-      public boolean channelAwaitingClosure(long channelId)
-      {
-         // FIXME
-         return false;
-         //return _closingChannelsList.contains(channelId);
-      }
-      
       private void handlePacket(final Packet packet)
       {
          if (packet.getType() == PACKETS_CONFIRMED)
@@ -1360,7 +1301,7 @@
             }
             else
             {
-               handler.handlePacket(packet);
+               handler.handle(packet);
             }
 
             return;
@@ -1417,7 +1358,7 @@
                {
                   checkConfirmation(packet);
 
-                  handler.handlePacket(packet);
+                  handler.handle(packet);
                }
                else
                {
@@ -1429,7 +1370,7 @@
                         {
                            checkConfirmation(packet);
 
-                           handler.handlePacket(packet);
+                           handler.handle(packet);
                         }
                         catch (Exception e)
                         {
@@ -1500,9 +1441,9 @@
          firstStoredCommandID += numberToClear;
       }
 
-      private class ReplicatedPacketsConfirmedChannelHandler implements ChannelHandler
+      private class ReplicatedPacketsConfirmedChannelHandler implements ChannelHandler<Packet>
       {
-         public void handlePacket(final Packet packet)
+         public void handle(final Packet packet)
          {
             if (packet.getType() == PACKETS_CONFIRMED)
             {
@@ -1517,11 +1458,6 @@
                throw new IllegalArgumentException("Invalid packet " + packet);
             }
          }
-         
-         public void handleFrame(AMQFrame frame)
-         {
-            // FIXME no replication for AMQ
-         }
       }
    }
 
@@ -1549,9 +1485,9 @@
       }
    }
 
-   private class PingPongHandler implements ChannelHandler
+   private class PingPongHandler implements ChannelHandler<Packet>
    {
-      public void handlePacket(final Packet packet)
+      public void handle(final Packet packet)
       {
          final byte type = packet.getType();
 
@@ -1578,10 +1514,5 @@
             throw new IllegalArgumentException("Invalid packet: " + packet);
          }
       }
-      
-      public void handleFrame(AMQFrame frame)
-      {
-         // FIXME no ping pong for AMQ
-      }
    }
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/remoting/impl/RemotingServiceImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -24,7 +24,6 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
-import org.jboss.messaging.amq.framing.AMQDataBlock;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.exception.MessagingException;
@@ -32,6 +31,7 @@
 import org.jboss.messaging.core.remoting.Channel;
 import org.jboss.messaging.core.remoting.ChannelHandler;
 import org.jboss.messaging.core.remoting.Interceptor;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.RemotingService;
 import org.jboss.messaging.core.remoting.spi.Acceptor;
@@ -50,7 +50,7 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @version <tt>$Revision$</tt>
  */
-public class RemotingServiceImpl implements RemotingService, ConnectionLifeCycleListener
+public class RemotingServiceImpl implements RemotingService<Packet>, ConnectionLifeCycleListener
 {
    // Constants -----------------------------------------------------
 
@@ -70,7 +70,7 @@
 
    private final long callTimeout;
 
-   private final Map<Object, RemotingConnection> connections = new ConcurrentHashMap<Object, RemotingConnection>();
+   private final Map<Object, RemotingConnection<Packet>> connections = new ConcurrentHashMap<Object, RemotingConnection<Packet>>();
 
    private final Timer failedConnectionTimer = new Timer(true);
 
@@ -202,14 +202,14 @@
       return acceptors;
    }
 
-   public RemotingConnection getConnection(final Object remotingConnectionID)
+   public RemotingConnection<Packet> getConnection(final Object remotingConnectionID)
    {
       return connections.get(remotingConnectionID);
    }
 
-   public synchronized Set<RemotingConnection> getConnections()
+   public synchronized Set<RemotingConnection<Packet>> getConnections()
    {
-      return new HashSet<RemotingConnection>(connections.values());
+      return new HashSet<RemotingConnection<Packet>>(connections.values());
    }
 
    public void setMessagingServer(final MessagingServer server)
@@ -231,9 +231,9 @@
          throw new IllegalStateException("Unable to create connection, server hasn't finished starting up");
       }
 
-      RemotingConnection replicatingConnection = server.getReplicatingConnection();
+      RemotingConnection<Packet> replicatingConnection = server.getReplicatingConnection();
 
-      RemotingConnection rc = new RemotingConnectionImpl(connection,
+      RemotingConnection<Packet> rc = new RemotingConnectionImpl(connection,
                                                          callTimeout,
                                                          -1,
                                                          remotingExecutor,
@@ -242,9 +242,9 @@
                                                          replicatingConnection,
                                                          !backup);
 
-      Channel channel1 = rc.getChannel(1, false, -1, false);
+      Channel<Packet> channel1 = rc.getChannel(1, false, -1, false);
 
-      ChannelHandler handler = new MessagingServerPacketHandler(server, channel1, rc);
+      ChannelHandler<Packet> handler = new MessagingServerPacketHandler(server, channel1, rc);
 
       channel1.setHandler(handler);
 
@@ -255,7 +255,7 @@
 
    public void connectionDestroyed(final Object connectionID)
    {
-      RemotingConnection conn = connections.remove(connectionID);
+      RemotingConnection<Packet> conn = connections.remove(connectionID);
 
       if (conn != null)
       {
@@ -265,7 +265,7 @@
 
    public void connectionException(final Object connectionID, final MessagingException me)
    {
-      RemotingConnection rc = connections.remove(connectionID);
+      RemotingConnection<Packet> rc = connections.remove(connectionID);
 
       if (rc != null)
       {
@@ -305,11 +305,11 @@
             return;
          }
 
-         Set<RemotingConnection> failedConnections = new HashSet<RemotingConnection>();
+         Set<RemotingConnection<Packet>> failedConnections = new HashSet<RemotingConnection<Packet>>();
 
          long now = System.currentTimeMillis();
 
-         for (RemotingConnection conn : connections.values())
+         for (RemotingConnection<Packet> conn : connections.values())
          {
             if (conn.isExpired(now))
             {
@@ -317,7 +317,7 @@
             }
          }
 
-         for (RemotingConnection conn : failedConnections)
+         for (RemotingConnection<Packet> conn : failedConnections)
          {
             MessagingException me = new MessagingException(MessagingException.CONNECTION_TIMEDOUT,
                                                            "Did not receive ping on connection. It is likely a client has exited or crashed without " + "closing its connection, or the network between the server and client has failed. The connection will now be closed.");
@@ -340,7 +340,7 @@
    {
       public void bufferReceived(final Object connectionID, final MessagingBuffer buffer)
       {
-         RemotingConnection conn = connections.get(connectionID);
+         RemotingConnection<Packet> conn = connections.get(connectionID);
 
          if (conn != null)
          {

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -14,11 +14,13 @@
 
 import java.util.Set;
 
+import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.management.MessagingServerControlMBean;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.RemotingService;
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
@@ -43,13 +45,13 @@
 
    Configuration getConfiguration();
 
-   void setRemotingService(RemotingService remotingService);
+   void setRemotingService(RemotingService<Packet> remotingService);
 
-   RemotingService getRemotingService();
+   RemotingService<Packet> getRemotingService();
 
-   void setAMQPRemotingService(RemotingService remotingService);
+   void setAMQPRemotingService(RemotingService<AMQFrame> remotingService);
 
-   RemotingService getAMQPRemotingService();
+   RemotingService<AMQFrame> getAMQPRemotingService();
    
    void setStorageManager(StorageManager storageManager);
 
@@ -65,7 +67,7 @@
 
    Version getVersion();
 
-   ReattachSessionResponseMessage reattachSession(RemotingConnection connection, String name, int lastReceivedCommandID) throws Exception;
+   ReattachSessionResponseMessage reattachSession(RemotingConnection<Packet> connection, String name, int lastReceivedCommandID) throws Exception;
 
    CreateSessionResponseMessage createSession(String name,
                                               long channelID,
@@ -77,6 +79,8 @@
                                               boolean autoCommitAcks,
                                               boolean xa) throws Exception;
 
+   ServerSession getSession(String name);
+
    void removeSession(String name) throws Exception;
 
    boolean isStarted();
@@ -92,4 +96,5 @@
    PostOffice getPostOffice();
 
    RemotingConnection getReplicatingConnection();
+
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/ServerSession.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/ServerSession.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/ServerSession.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -103,6 +103,8 @@
 
    void removeDestination(SimpleString address, boolean durable) throws Exception;
 
+   boolean isQueueCreated(SimpleString queueName) throws Exception;
+
    void createQueue(SimpleString address,
                     SimpleString queueName,
                     SimpleString filterString,
@@ -153,4 +155,5 @@
    void failedOver() throws Exception;
    
    void handleReplicatedDelivery(long consumerID, long messageID) throws Exception;
+
 }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/AMQPMessageDeliveryRunnableFactory.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/AMQPMessageDeliveryRunnableFactory.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/AMQPMessageDeliveryRunnableFactory.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -28,6 +28,7 @@
 import java.util.Queue;
 
 import org.jboss.messaging.amq.exchange.ExchangeDefaults;
+import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.amq.framing.AMQShortString;
 import org.jboss.messaging.amq.framing.BasicContentHeaderProperties;
 import org.jboss.messaging.amq.framing.BasicDeliverBody;
@@ -49,7 +50,7 @@
  *
  *
  */
-public class AMQPMessageDeliveryRunnableFactory implements MessageDeliveryRunnableFactory
+public class AMQPMessageDeliveryRunnableFactory implements MessageDeliveryRunnableFactory<AMQFrame>
 {
 
    // Constants -----------------------------------------------------
@@ -66,7 +67,7 @@
 
    public Runnable createRunnable(final long consumerID,
                                   final ServerSession session,
-                                  final Channel channel,
+                                  final Channel<AMQFrame> channel,
                                   final Queue<MessageReference> deliveringRefs,
                                   final MessageReference ref)
    {
@@ -108,6 +109,11 @@
       };
    }
 
+   public AMQFrame createReplicateMessage(long consumerID, long messageID)
+   {
+      return null;
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessageDeliveryRunnableFactory.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessageDeliveryRunnableFactory.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessageDeliveryRunnableFactory.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -37,13 +37,15 @@
  *
  *
  */
-public interface MessageDeliveryRunnableFactory
+public interface MessageDeliveryRunnableFactory<T>
 {
 
    Runnable createRunnable(final long consumerID,
                            final ServerSession session,
-                           final Channel channel,
+                           final Channel<T> channel,
                            final Queue<MessageReference> deliveringRefs,
                            final MessageReference ref);
 
+   T createReplicateMessage(long consumerID, long messageID);
+
 }
\ No newline at end of file

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -518,6 +518,11 @@
    {
       sessions.remove(name);
    }
+   
+   public ServerSession getSession(final String name)
+   {
+      return sessions.get(name);
+   }
 
    public RemotingConnection getReplicatingConnection()
    {

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -15,7 +15,6 @@
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATESESSION;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.REATTACH_SESSION;
 
-import org.jboss.messaging.amq.framing.AMQFrame;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.remoting.Channel;
@@ -34,19 +33,19 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
  */
-public class MessagingServerPacketHandler implements ChannelHandler
+public class MessagingServerPacketHandler implements ChannelHandler<Packet>
 {
    private static final Logger log = Logger.getLogger(MessagingServerPacketHandler.class);
 
    private final MessagingServer server;
 
-   private final Channel channel1;
+   private final Channel<Packet> channel1;
 
-   private final RemotingConnection connection;
+   private final RemotingConnection<Packet> connection;
 
    public MessagingServerPacketHandler(final MessagingServer server,
-                                       final Channel channel1,
-                                       final RemotingConnection connection)
+                                       final Channel<Packet> channel1,
+                                       final RemotingConnection<Packet> connection)
    {
       this.server = server;
 
@@ -55,8 +54,8 @@
       this.connection = connection;
    }
 
-   public void handlePacket(final Packet packet)
-   {            
+   public void handle(final Packet packet)
+   {           
       channel1.replicatePacket(packet, new Runnable()
       {
          public void run()
@@ -133,8 +132,4 @@
       
       channel1.replicateComplete();
    }
-
-   public void handleFrame(AMQFrame frame)
-   {
-   }
 }
\ No newline at end of file

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -30,7 +30,7 @@
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.remoting.Channel;
-import org.jboss.messaging.core.remoting.WireFormat;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
 import org.jboss.messaging.core.server.HandleStatus;
 import org.jboss.messaging.core.server.MessageReference;
@@ -185,8 +185,8 @@
          }
          
          Runnable run = factory.createRunnable(id, session, channel, deliveringRefs, ref);
-         
-         channel.replicatePacket(new SessionReplicateDeliveryMessage(id, message.getMessageID()), run);
+         Object t = factory.createReplicateMessage(id, message.getMessageID());
+         channel.replicatePacket(t, run);
         
          return HandleStatus.HANDLED;
       }

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerMessageDeliveryRunnableFactory.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerMessageDeliveryRunnableFactory.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerMessageDeliveryRunnableFactory.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -25,7 +25,9 @@
 import java.util.Queue;
 
 import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.Packet;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionReplicateDeliveryMessage;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.ServerSession;
@@ -39,7 +41,7 @@
  *
  *
  */
-public class ServerMessageDeliveryRunnableFactory implements MessageDeliveryRunnableFactory
+public class ServerMessageDeliveryRunnableFactory implements MessageDeliveryRunnableFactory<Packet>
 {
 
    // Constants -----------------------------------------------------
@@ -56,7 +58,7 @@
 
    public Runnable createRunnable(final long consumerID,
                                   final ServerSession session,
-                                  final Channel channel,
+                                  final Channel<Packet> channel,
                                   final Queue<MessageReference> deliveringRefs,
                                   final MessageReference ref)
    {
@@ -75,6 +77,11 @@
       };
 
    }
+   
+   public Packet createReplicateMessage(long consumerID, long messageID)
+   {
+      return new SessionReplicateDeliveryMessage(consumerID, messageID);
+   }
 
    // Package protected ---------------------------------------------
 

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -827,6 +827,11 @@
       }
    }
 
+   public boolean isQueueCreated(final SimpleString queueName) throws Exception
+   {
+      return (postOffice.getBinding(queueName) != null);      
+   }
+   
    public void createQueue(final SimpleString address,
                            final SimpleString queueName,
                            final SimpleString filterString,

Modified: branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -12,9 +12,6 @@
 
 package org.jboss.messaging.core.server.impl;
 
-import static org.jboss.messaging.amq.StringConverter.toSimpleString;
-import static org.jboss.messaging.amq.exchange.ExchangeDefaults.DEFAULT_EXCHANGE_NAME;
-import static org.jboss.messaging.amq.framing.MethodRegistry.registry_0_9;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_ADD_DESTINATION;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BINDINGQUERY;
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_BROWSER_CLOSE;
@@ -59,22 +56,6 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.amq.AMQMessage;
-import org.jboss.messaging.amq.framing.AMQBody;
-import org.jboss.messaging.amq.framing.AMQFrame;
-import org.jboss.messaging.amq.framing.AMQMethodBody;
-import org.jboss.messaging.amq.framing.AMQShortString;
-import org.jboss.messaging.amq.framing.BasicAckBody;
-import org.jboss.messaging.amq.framing.BasicConsumeBody;
-import org.jboss.messaging.amq.framing.BasicPublishBody;
-import org.jboss.messaging.amq.framing.ChannelCloseBody;
-import org.jboss.messaging.amq.framing.ChannelCloseOkBody;
-import org.jboss.messaging.amq.framing.ContentBody;
-import org.jboss.messaging.amq.framing.ContentHeaderBody;
-import org.jboss.messaging.amq.framing.QueueBindBody;
-import org.jboss.messaging.amq.framing.QueueDeclareBody;
-import org.jboss.messaging.amq.framing.QueueDeclareOkBody;
-import org.jboss.messaging.amq.impl.AMQMessageImpl;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
@@ -121,7 +102,6 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.ServerSession;
-import org.jboss.messaging.util.SimpleString;
 
 /**
  * A ServerSessionPacketHandler
@@ -130,7 +110,7 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:andy.taylor at jboss.org>Andy Taylor</a>
  */
-public class ServerSessionPacketHandler implements ChannelHandler
+public class ServerSessionPacketHandler implements ChannelHandler<Packet>
 {
    private static final Logger log = Logger.getLogger(ServerSessionPacketHandler.class);
 
@@ -140,8 +120,6 @@
 
    private final StorageManager storageManager;
 
-   private AMQMessage currentMessage = null;
-
    public ServerSessionPacketHandler(final ServerSession session,
                                      final Channel channel,
                                      final StorageManager storageManager)
@@ -159,7 +137,7 @@
       return session.getID();
    }
 
-   public void handlePacket(final Packet packet)
+   public void handle(final Packet packet)
    {
       byte type = packet.getType();
 
@@ -494,143 +472,4 @@
 
       channel.replicateComplete();
    }
-
-   public void handleFrame(AMQFrame frame)
-   {
-      log.info("handling frame:" + frame);
-      AMQBody b = frame.getBodyFrame();
-      if (b instanceof BasicPublishBody)
-      {
-         BasicPublishBody body = (BasicPublishBody)b;
-         log.info("received basic.publish method " + body);
-         AMQShortString exchangeStr = body.getExchange();
-         SimpleString exchange = (exchangeStr == null) ? toSimpleString(DEFAULT_EXCHANGE_NAME)
-                                                      : toSimpleString(exchangeStr);
-         SimpleString routingKey = toSimpleString(body.getRoutingKey());
-         currentMessage = new AMQMessageImpl(exchange, routingKey, body.getImmediate(), body.getMandatory());
-      }
-      else if (b instanceof ContentHeaderBody)
-      {
-         ContentHeaderBody body = (ContentHeaderBody)b;
-         log.info("received header: " + body.properties);
-         if (currentMessage == null)
-         {
-            throw new IllegalStateException("Content header received before a basic.publish method");
-         }
-         currentMessage.setHeader(body.properties);
-         currentMessage.setBodySize(body.bodySize);
-         if (body.bodySize == 0)
-         {
-            try
-            {
-               session.send(currentMessage.toCoreMessage());
-            }
-            catch (Exception e)
-            {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-            }
-            finally
-            {
-               resetCurrentMessage();
-            }
-         }
-      }
-      else if (b instanceof ContentBody)
-      {
-         if (currentMessage == null)
-         {
-            throw new IllegalStateException("Content body received before a basic.publish method");
-         }
-         ContentBody body = (ContentBody)b;
-         log.info("received body: " + body.payload);
-         boolean finalFrame = currentMessage.addPayload(body.payload, body.getSize());
-         if (finalFrame)
-         {
-            log.info("received final frame");
-            ServerMessage coreMessage = currentMessage.toCoreMessage();
-            try
-            {
-               session.send(coreMessage);
-               log.info("routed message");
-            }
-            catch (Exception e)
-            {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
-            }
-            finally
-            {
-               resetCurrentMessage();
-            }
-         }
-         else
-         {
-            log.info("wating for more frame");
-         }
-      }
-      else if (b instanceof QueueDeclareBody)
-      {
-         QueueDeclareBody body = (QueueDeclareBody)b;
-         QueueDeclareOkBody responseBody = registry_0_9.createQueueDeclareOkBody(body.getQueue(), 1, 1);
-         channel.send(responseBody.generateFrame(frame.getChannel()));
-      }
-      else if (b instanceof QueueBindBody)
-      {
-         AMQMethodBody responseBody = registry_0_9.createQueueBindOkBody();
-         channel.send(responseBody.generateFrame(frame.getChannel()));
-      }
-      else if (b instanceof BasicConsumeBody)
-      {
-         BasicConsumeBody body = (BasicConsumeBody)b;
-         try
-         {
-            session.createConsumer(toSimpleString(body.getQueue()), null, -1, -1, WireFormat.AMQP);
-            session.setStarted(true);
-            AMQMethodBody responseBody = registry_0_9.createBasicConsumeOkBody(body.getConsumerTag());
-            channel.send(responseBody.generateFrame(frame.getChannel()));
-         }
-         catch (Exception e)
-         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-      }
-      else if (b instanceof BasicAckBody)
-      {
-         BasicAckBody body = (BasicAckBody)b;
-         try
-         {
-            session.commit();
-         }
-         catch (Exception e)
-         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-      }
-      else if (b instanceof ChannelCloseBody)
-      {
-         ChannelCloseOkBody responseBody = registry_0_9.createChannelCloseOkBody();
-         channel.send(responseBody.generateFrame(frame.getChannel()));
-         try
-         {
-            session.close();
-         }
-         catch (Exception e)
-         {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-         }
-      }
-      else
-      {
-         throw new IllegalStateException("Unsupported body:" + frame.getBodyFrame().getClass());
-      }
-   }
-
-   private void resetCurrentMessage()
-   {
-      currentMessage = null;
-   }
 }

Modified: branches/amqp_integration/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- branches/amqp_integration/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java	2008-10-30 07:58:15 UTC (rev 5218)
+++ branches/amqp_integration/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java	2008-10-30 14:53:57 UTC (rev 5219)
@@ -121,7 +121,7 @@
       RemotingConnection serverConn = null;
       while (serverConn == null)
       {
-         Set<RemotingConnection> conns = messagingService.getServer().getRemotingService().getConnections();
+         Set<RemotingConnection<Packet>> conns = messagingService.getServer().getRemotingService().getConnections();
          
          if (!conns.isEmpty())
          {            
@@ -173,7 +173,7 @@
       RemotingConnection serverConn = null;
       while (serverConn == null)
       {
-         Set<RemotingConnection> conns = messagingService.getServer().getRemotingService().getConnections();
+         Set<RemotingConnection<Packet>> conns = messagingService.getServer().getRemotingService().getConnections();
          
          if (!conns.isEmpty())
          {            
@@ -228,7 +228,7 @@
       
       while (serverConn == null)
       {
-         Set<RemotingConnection> conns = messagingService.getServer().getRemotingService().getConnections();
+         Set<RemotingConnection<Packet>> conns = messagingService.getServer().getRemotingService().getConnections();
          
          if (!conns.isEmpty())
          {            
@@ -304,7 +304,7 @@
      RemotingConnection serverConn = null;
      while (serverConn == null)
      {
-        Set<RemotingConnection> conns = messagingService.getServer().getRemotingService().getConnections();
+        Set<RemotingConnection<Packet>> conns = messagingService.getServer().getRemotingService().getConnections();
         
         if (!conns.isEmpty())
         {            




More information about the jboss-cvs-commits mailing list