You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by st...@apache.org on 2006/11/25 23:04:50 UTC

svn commit: r479211 [7/15] - in /incubator/qpid/trunk/qpid/dotnet: ./ Qpid.Buffer/ Qpid.Buffer/Properties/ Qpid.Client.Tests/ Qpid.Client.Tests/Common/ Qpid.Client.Tests/HeadersExchange/ Qpid.Client.Tests/MultiConsumer/ Qpid.Client.Tests/Properties/ Qp...

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AMQProtocolProvider.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AMQProtocolProvider.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AMQProtocolProvider.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AMQProtocolProvider.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.
+ *
+ */
+using Qpid.Codec;
+using Qpid.Codec.Demux;
+using Qpid.Framing;
+
+namespace Qpid.Client.Transport
+{
+    public class AMQProtocolProvider
+    {
+        private DemuxingProtocolCodecFactory _factory;
+
+        public AMQProtocolProvider()
+        {
+            _factory = new DemuxingProtocolCodecFactory();
+            _factory.Register(new AMQDataBlockEncoder());
+            _factory.Register(new AMQDataBlockDecoder());
+            _factory.Register(new ProtocolInitiation.Decoder());
+        }
+
+        public IProtocolCodecFactory CodecFactory
+        {
+            get
+            {
+                return _factory;
+            }
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AMQProtocolProvider.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AmqpChannel.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AmqpChannel.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AmqpChannel.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AmqpChannel.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Collections;
+using log4net;
+using Qpid.Buffer;
+using Qpid.Codec;
+using Qpid.Codec.Support;
+using Qpid.Framing;
+
+namespace Qpid.Client.Transport
+{
+    public class AmqpChannel : IProtocolChannel
+    {
+        // Warning: don't use this log for regular logging.
+        static readonly ILog _protocolTraceLog = LogManager.GetLogger("Qpid.Client.ProtocolChannel.Tracing");
+        
+        IByteChannel byteChannel;
+        IProtocolEncoder encoder;
+        IProtocolDecoder decoder;
+
+        public AmqpChannel(IByteChannel byteChannel)
+        {
+            this.byteChannel = byteChannel;    
+            
+            AMQProtocolProvider protocolProvider = new AMQProtocolProvider();
+            IProtocolCodecFactory factory = protocolProvider.CodecFactory;
+            encoder = factory.Encoder;
+            decoder = factory.Decoder;
+        }
+
+        public Queue Read()
+        {
+            ByteBuffer buffer = byteChannel.Read();
+
+            Queue frames = Decode(buffer);
+            
+            // TODO: Refactor to decorator.
+            if (_protocolTraceLog.IsDebugEnabled)
+            {
+                foreach (object o in frames)
+                {
+                    _protocolTraceLog.Debug(String.Format("READ {0}", o));
+                }
+            }
+
+            return frames;
+        }
+
+        public void Write(IDataBlock o)
+        {
+            // TODO: Refactor to decorator.
+            if (_protocolTraceLog.IsDebugEnabled)
+            {
+                _protocolTraceLog.Debug(String.Format("WRITE {0}", o));
+            }
+
+            byteChannel.Write(Encode(o));
+        }
+
+        private ByteBuffer Encode(object o)
+        {
+            SingleProtocolEncoderOutput output = new SingleProtocolEncoderOutput();
+            encoder.Encode(o, output);
+            return output.buffer;
+        }
+
+        private Queue Decode(ByteBuffer byteBuffer)
+        {
+            SimpleProtocolDecoderOutput outx = new SimpleProtocolDecoderOutput();
+            decoder.Decode(byteBuffer, outx);
+            return outx.MessageQueue;
+        }
+    }
+}
+

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/AmqpChannel.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IByteChannel.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IByteChannel.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IByteChannel.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IByteChannel.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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.
+ *
+ */
+using Qpid.Buffer;
+
+namespace Qpid.Client.Transport
+{
+    public interface IByteChannel
+    {
+        ByteBuffer Read();
+        void Write(ByteBuffer buffer);
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IByteChannel.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolChannel.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolChannel.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolChannel.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolChannel.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System.Collections;
+
+namespace Qpid.Client.Transport
+{
+    public interface IProtocolChannel : IProtocolWriter
+    {
+        Queue Read();
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolChannel.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolWriter.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolWriter.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolWriter.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolWriter.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.
+ *
+ */
+using Qpid.Framing;
+
+namespace Qpid.Client.Transport
+{
+    public interface IProtocolWriter
+    {
+        void Write(IDataBlock o);
+    }
+}
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/IProtocolWriter.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/ITransport.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/ITransport.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/ITransport.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/ITransport.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.
+ *
+ */
+using Qpid.Client.Protocol;
+
+namespace Qpid.Client.Transport
+{
+    public interface ITransport : IConnectionCloser
+    {
+        void Open();
+        string getLocalEndPoint();
+        IProtocolWriter ProtocolWriter { get; }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/ITransport.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/SingleProtocolEncoderOutput.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/SingleProtocolEncoderOutput.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/SingleProtocolEncoderOutput.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/SingleProtocolEncoderOutput.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using Qpid.Buffer;
+using Qpid.Codec;
+
+namespace Qpid.Client.Transport
+{
+    public class SingleProtocolEncoderOutput : IProtocolEncoderOutput
+    {
+        public ByteBuffer buffer;
+
+        public void Write(ByteBuffer buf)
+        {
+            if (buffer != null)
+            {
+                throw new InvalidOperationException("{0} does not allow the writing of more than one buffer");
+            }
+            buffer = buf;
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Client/Transport/SingleProtocolEncoderOutput.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Properties/AssemblyInfo.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Properties/AssemblyInfo.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Properties/AssemblyInfo.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System.Reflection;
+using System.Runtime.InteropServices;
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Qpid.Client")]
+[assembly: AssemblyDescription("Qpid Client API implementation")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Qpid")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("Copyright (c) 2006 The Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("380cb124-07a8-40c2-b67d-69a0d94cb620")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers 
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("0.5.*")]

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Properties/AssemblyInfo.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Qpid.Client.csproj
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Qpid.Client.csproj?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Qpid.Client.csproj (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Qpid.Client.csproj Sat Nov 25 14:04:39 2006
@@ -0,0 +1,133 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{68987C05-3768-452C-A6FC-6BA1D372852F}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Qpid.Client</RootNamespace>
+    <AssemblyName>Qpid.Client</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="log4net, Version=1.2.0.30714, Culture=neutral, PublicKeyToken=500ffcafb14f92df">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Qpid.Common\lib\log4net\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Client\AmqBrokerInfo.cs" />
+    <Compile Include="Client\AMQConnection.cs" />
+    <Compile Include="Client\AMQConnectionException.cs" />
+    <Compile Include="Client\AMQDestination.cs" />
+    <Compile Include="Client\AmqChannel.cs" />
+    <Compile Include="Client\QpidConnectionInfo.cs" />
+    <Compile Include="Client\BasicMessageConsumer.cs" />
+    <Compile Include="Client\BasicMessageProducer.cs" />
+    <Compile Include="Client\Closeable.cs" />
+    <Compile Include="Client\ConnectionTuneParameters.cs" />
+    <Compile Include="Client\Failover\FailoverException.cs" />
+    <Compile Include="Client\Failover\FailoverHandler.cs" />
+    <Compile Include="Client\Failover\FailoverState.cs" />
+    <Compile Include="Client\Failover\FailoverSupport.cs" />
+    <Compile Include="Client\Handler\BasicDeliverMethodHandler.cs" />
+    <Compile Include="Client\Handler\BasicReturnMethodHandler.cs" />
+    <Compile Include="Client\Handler\ChannelCloseMethodHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionCloseMethodHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionCloseOkHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionOpenOkMethodHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionRedirectMethodHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionSecureMethodHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionStartMethodHandler.cs" />
+    <Compile Include="Client\Handler\ConnectionTuneMethodHandler.cs" />
+    <Compile Include="Client\Message\AbstractQmsMessage.cs" />
+    <Compile Include="Client\Message\AMQMessage.cs" />
+    <Compile Include="Client\Message\AMQMessageFactory.cs" />
+    <Compile Include="Client\Message\IMessageFactory.cs" />
+    <Compile Include="Client\Message\MessageFactoryRegistry.cs" />
+    <Compile Include="Client\Message\UnexpectedBodyReceivedException.cs" />
+    <Compile Include="Client\Message\UnprocessedMessage.cs" />
+    <Compile Include="Client\Message\QpidBytesMessage.cs" />
+    <Compile Include="Client\Message\QpidBytesMessageFactory.cs" />
+    <Compile Include="Client\Message\QpidTextMessage.cs" />
+    <Compile Include="Client\Message\QpidTextMessageFactory.cs" />
+    <Compile Include="Client\Protocol\AMQMethodEvent.cs" />
+    <Compile Include="Client\Protocol\AMQProtocolListener.cs" />
+    <Compile Include="Client\Protocol\AMQProtocolSession.cs" />
+    <Compile Include="Client\Protocol\Listener\BlockingMethodFrameListener.cs" />
+    <Compile Include="Client\Protocol\Listener\IAMQMethodListener.cs" />
+    <Compile Include="Client\Protocol\IConnectionCloser.cs" />
+    <Compile Include="Client\Protocol\ProtocolWriter.cs" />
+    <Compile Include="Client\Protocol\IProtocolListener.cs" />
+    <Compile Include="Client\State\AMQState.cs" />
+    <Compile Include="Client\State\AMQStateChangedEvent.cs" />
+    <Compile Include="Client\State\AMQStateManager.cs" />
+    <Compile Include="Client\State\IAMQStateListener.cs" />
+    <Compile Include="Client\State\IllegalStateTransitionException.cs" />
+    <Compile Include="Client\State\IStateAwareMethodListener.cs" />
+    <Compile Include="Client\State\IStateListener.cs" />
+    <Compile Include="Client\Protocol\Listener\SpecificMethodFrameListener.cs" />
+    <Compile Include="Client\State\StateWaiter.cs" />
+    <Compile Include="Client\Transport\AmqpChannel.cs" />
+    <Compile Include="Client\Transport\AMQProtocolProvider.cs" />
+    <Compile Include="Client\Transport\IByteChannel.cs" />
+    <Compile Include="Client\Transport\IProtocolChannel.cs" />
+    <Compile Include="Client\Transport\IProtocolWriter.cs" />
+    <Compile Include="Client\Transport\ITransport.cs" />
+    <Compile Include="Client\Transport\SingleProtocolEncoderOutput.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="qms\BrokerInfo.cs" />
+    <Compile Include="qms\ConnectionInfo.cs" />
+    <Compile Include="qms\FailoverPolicy.cs" />
+    <Compile Include="qms\failover\FailoverMethod.cs" />
+    <Compile Include="qms\failover\FailoverRoundRobin.cs" />
+    <Compile Include="qms\failover\FailoverSingleServer.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Qpid.Codec\Qpid.Codec.csproj">
+      <Project>{22D0D0C2-77AF-4DE3-B456-7FF3893F9F88}</Project>
+      <Name>Qpid.Codec</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Qpid.Buffer\Qpid.Buffer.csproj">
+      <Project>{44384DF2-B0A4-4580-BDBC-EE4BAA87D995}</Project>
+      <Name>Qpid.Buffer</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Qpid.Messaging\Qpid.Messaging.csproj">
+      <Project>{6688F826-C58E-4C1B-AA1F-22AFAB4B7D07}</Project>
+      <Name>Qpid.Messaging</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Qpid.Common\Qpid.Common.csproj">
+      <Project>{77064C42-24D2-4CEB-9EA2-0EF481A43205}</Project>
+      <Name>Qpid.Common</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/Qpid.Client.csproj
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/default.build
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/default.build?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/default.build (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/default.build Sat Nov 25 14:04:39 2006
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<project name="XMS.AMQ.Client" default="build">
+    <property name="nant.settings.currentframework" value="net-1.0" />
+    <property name="basename" value="XMSClient"/>
+    <property name="debug" value="true"/>
+    <property name="CommonCollectionsDir" value="../CommonCollections"/>
+    <property name="MINADir" value="../minadotnet"/>
+    <property name="XMSCommonDir" value="../xmscommon"/>
+
+    <if test="${debug}">
+        <property name="targetdir" value="bin/${nant.settings.currentframework}/Debug"/>
+    </if>
+    <ifnot test="${debug}">
+        <property name="targetdir" value="bin/${nant.settings.currentframework}/Release"/>
+    </ifnot>
+
+    <target name="clean">
+        <delete>
+            <fileset>
+                <include name="${targetdir}/${basename}.dll"/>
+                <include name="${targetdir}/${basename}.pdb"/>
+            </fileset>
+        </delete>
+    </target>
+
+    <target name="init">
+        <mkdir dir="${targetdir}"/>
+    </target>
+
+    <target name="build" depends="init">
+        <csc target="library" output="${targetdir}/${basename}.dll" debug="${debug}">
+            <sources>
+                <include name="**/*.cs"/>
+                <exclude name="Properties/Settings.Designer.cs" />
+            </sources>
+            <references>
+                <lib>
+                    <include name="${CommonCollectionsDir}/${targetdir}" />
+                    <include name="${MINADir}/${targetdir}" />
+                    <include name="${XMSCommonDir}/${targetdir}" />
+                    <include name="${XMSCommonDir}/lib/**" />
+                    <include name="lib/**" />
+                </lib>
+                <include name="CommonCollections.dll" />
+                <include name="log4net.dll" />
+                <include name="MINA.dll" />
+                <include name="IBM.XMS.dll" />
+                <include name="XMSCommon.dll" />
+            </references>
+        </csc>
+    </target>
+</project>
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/default.build
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/BrokerInfo.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/BrokerInfo.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/BrokerInfo.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/BrokerInfo.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+
+namespace Qpid.Client.qms
+{
+    /// <summary>
+    /// Know URL option names.
+    /// <seealso cref="ConnectionInfo"/>
+    /// </summary>
+    public class BrokerDetailsConstants
+    {
+        public const String OPTIONS_RETRY = "retries";
+        public const String OPTIONS_SSL = ConnectionUrlConstants.OPTIONS_SSL;
+        public const String OPTIONS_CONNECT_TIMEOUT = "connecttimeout";
+        public const int DEFAULT_PORT = 5672;
+        public const String DEFAULT_TRANSPORT = "tcp";
+
+        public readonly string URL_FORMAT_EXAMPLE =
+                "<transport>://<hostname>[:<port Default=\"" + DEFAULT_PORT + "\">][?<option>='<value>'[,<option>='<value>']]";
+
+        public const long DEFAULT_CONNECT_TIMEOUT = 30000L;
+    }
+    
+    public interface BrokerInfo
+    {
+        String getHost();
+        void setHost(string host);
+
+        int getPort();
+        void setPort(int port);
+
+        String getTransport();
+        void setTransport(string transport);
+
+        bool useSSL();
+        void useSSL(bool ssl);
+
+        String getOption(string key);
+        void setOption(string key, string value);
+
+        long getTimeout();
+        void setTimeout(long timeout);
+    }
+}
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/BrokerInfo.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/ConnectionInfo.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/ConnectionInfo.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/ConnectionInfo.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/ConnectionInfo.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System.Collections;
+
+namespace Qpid.Client.qms
+{
+    class ConnectionUrlConstants 
+    {
+        public const string AMQ_PROTOCOL = "amqp";
+        public const string OPTIONS_BROKERLIST = "brokerlist";
+        public const string OPTIONS_FAILOVER = "failover";
+        public const string OPTIONS_FAILOVER_CYCLE = "cyclecount";
+        public const string OPTIONS_SSL = "ssl";
+    }
+
+    /**
+     Connection URL format
+     amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\'&option=\'value\';vm://:3/virtualpath?option=\'value\''&failover='method?option=\'value\'&option='value''"
+     Options are of course optional except for requiring a single broker in the broker list.
+     The option seperator is defined to be either '&' or ','
+      */
+    public interface ConnectionInfo
+    {
+        string asUrl();
+
+        string getFailoverMethod();
+
+        string getFailoverOption(string key);
+
+        int getBrokerCount();
+
+        BrokerInfo GetBrokerDetails(int index);
+
+        void AddBrokerInfo(BrokerInfo broker);
+
+        IList GetAllBrokerInfos();
+
+        string GetClientName();
+
+        void SetClientName(string clientName);
+
+        string getUsername();
+
+        void setUsername(string username);
+
+        string getPassword();
+
+        void setPassword(string password);
+
+        string getVirtualHost();
+
+        void setVirtualHost(string virtualHost);
+
+        string getOption(string key);
+
+        void setOption(string key, string value);
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/ConnectionInfo.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/FailoverPolicy.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/FailoverPolicy.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/FailoverPolicy.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/FailoverPolicy.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,315 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Text;
+using log4net;
+using Qpid.Client.qms.failover;
+
+namespace Qpid.Client.qms
+{
+    public class FailoverPolicy
+    {
+        private static readonly ILog _logger = LogManager.GetLogger(typeof(FailoverPolicy));
+
+        private const long MINUTE = 60000L;
+
+        private const long DEFAULT_METHOD_TIMEOUT = 1 * MINUTE;
+        private const long DEFAULT_FAILOVER_TIMEOUT = 4 * MINUTE;
+
+        private FailoverMethod[] _methods = new FailoverMethod[1];
+
+        private int _currentMethod;
+
+        private int _methodsRetries;
+
+        private int _currentRetry;
+
+        private bool _timing;
+
+        private long _lastMethodTime;
+        private long _lastFailTime;
+
+        public FailoverPolicy(ConnectionInfo connectionInfo)
+        {
+            FailoverMethod method;
+
+            //todo This should be integrated in to the connection url when it supports
+            // multiple strategies.
+
+            _methodsRetries = 0;
+
+            if (connectionInfo.getFailoverMethod() == null)
+            {
+                if (connectionInfo.getBrokerCount() > 1)
+                {
+                    method = new FailoverRoundRobin(connectionInfo);
+                }
+                else
+                {
+                    method = new FailoverSingleServer(connectionInfo);
+                }
+            }
+            else
+            {
+                string failoverMethod = connectionInfo.getFailoverMethod();
+
+    /*
+                if (failoverMethod.equals(FailoverMethod.RANDOM))
+                {
+                    //todo write a random connection Failover
+                }
+    */
+                if (failoverMethod.Equals(FailoverMethodConstants.ROUND_ROBIN))
+                {
+                    method = new FailoverRoundRobin(connectionInfo);
+                }
+                else
+                {
+                    throw new NotImplementedException("Dynamic loading of FailoverMethods not yet implemented.");
+//                    try
+//                    {
+//                        Type[] constructorSpec = {ConnectionInfo.class};
+//                        Object [] params = {connectionInfo};
+//
+//                        method = (FailoverMethod) ClassLoader.getSystemClassLoader().
+//                                loadClass(failoverMethod).
+//                                getConstructor(constructorSpec).newInstance(params);
+//                    }
+//                    catch (Exception cnfe)
+//                    {
+//                        throw new IllegalArgumentException("Unknown failover method:" + failoverMethod);
+//                    }
+                }
+            }
+
+            if (method == null)
+            {
+                throw new ArgumentException("Unknown failover method specified.");
+            }
+
+            reset();
+
+            _methods[_currentMethod] = method;
+        }
+
+        public FailoverPolicy(FailoverMethod method) : this(method, 0)
+        {
+        }
+
+        public FailoverPolicy(FailoverMethod method, int retries)
+        {
+            _methodsRetries = retries;
+
+            reset();
+
+            _methods[_currentMethod] = method;
+        }
+
+        private void reset()
+        {
+            _currentMethod = 0;
+            _currentRetry = 0;
+            _timing = false;
+
+        }
+
+        public bool FailoverAllowed()
+        {
+            bool failoverAllowed;
+
+            if (_timing)
+            {
+                long now = CurrentTimeMilliseconds();
+
+                if ((now - _lastMethodTime) >= DEFAULT_METHOD_TIMEOUT)
+                {
+                    _logger.Info("Failover method timeout");
+                    _lastMethodTime = now;
+
+                    if (!nextMethod())
+                    {
+                        return false;
+                    }
+
+
+                }
+                else if ((now - _lastFailTime) >= DEFAULT_FAILOVER_TIMEOUT)
+                {
+                    _logger.Info("Failover timeout");
+                    return false;
+                }
+                else
+                {
+                    _lastMethodTime = now;
+                }
+            }
+            else
+            {
+                _timing = true;
+                _lastMethodTime = CurrentTimeMilliseconds();
+                _lastFailTime = _lastMethodTime;
+            }
+
+
+            if (_methods[_currentMethod].failoverAllowed())
+            {
+                failoverAllowed = true;
+            }
+            else
+            {
+                if (_currentMethod < (_methods.Length - 1))
+                {
+                    nextMethod();
+                    _logger.Info("Changing method to " + _methods[_currentMethod].methodName());
+                    return FailoverAllowed();
+                }
+                else
+                {
+                    return cycleMethods();
+                }
+            }
+
+            return failoverAllowed;
+        }
+
+        private static long CurrentTimeMilliseconds()
+        {
+            return DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
+        }
+
+        private bool nextMethod()
+        {
+            if (_currentMethod < (_methods.Length - 1))
+            {
+                _currentMethod++;
+                _methods[_currentMethod].reset();
+                return true;
+            }
+            else
+            {
+                return cycleMethods();
+            }
+        }
+
+        private bool cycleMethods()
+        {
+            if (_currentRetry < _methodsRetries)
+            {
+                _currentRetry++;
+
+                _currentMethod = 0;
+
+                _logger.Info("Retrying methods starting with " + _methods[_currentMethod].methodName());
+                _methods[_currentMethod].reset();
+                return FailoverAllowed();
+            }
+            else
+            {
+                _logger.Debug("All failover methods exhausted");
+                return false;
+            }
+        }
+
+        /**
+         * Notification that connection was successful.
+         */
+        public void attainedConnection()
+        {
+            _currentRetry = 0;
+
+            _methods[_currentMethod].attainedConnection();
+
+            _timing = false;
+        }
+
+        public BrokerInfo GetCurrentBrokerInfo()
+        {
+            return _methods[_currentMethod].GetCurrentBrokerInfo();
+        }
+
+        public BrokerInfo GetNextBrokerInfo()
+        {
+            return _methods[_currentMethod].getNextBrokerDetails();
+        }
+
+        public void setBroker(BrokerInfo broker)
+        {
+            _methods[_currentMethod].setBroker(broker);
+        }
+
+        public void addMethod(FailoverMethod method)
+        {
+            int len = _methods.Length + 1;
+            FailoverMethod[] newMethods = new FailoverMethod[len];
+            _methods.CopyTo(newMethods, 0);
+//            System.arraycopy(_methods, 0, newMethods, 0, _methods.length);
+            int index = len - 1;
+            newMethods[index] = method;
+            _methods = newMethods;
+        }
+
+        public void setMethodRetries(int retries)
+        {
+            _methodsRetries = retries;
+        }
+
+        public FailoverMethod getCurrentMethod()
+        {
+            if (_currentMethod >= 0 && _currentMethod < (_methods.Length - 1))
+            {
+                return _methods[_currentMethod];
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        public String toString()
+        {
+            StringBuilder sb = new StringBuilder();
+
+            sb.Append("Failover Policy:\n");
+
+            if (FailoverAllowed())
+            {
+                sb.Append("Failover allowed\n");
+            }
+            else
+            {
+                sb.Append("Failover not allowed\n");
+            }
+
+            sb.Append("Failover policy methods\n");
+            for (int i = 0; i < _methods.Length; i++)
+            {
+
+                if (i == _currentMethod)
+                {
+                    sb.Append(">");
+                }
+                sb.Append(_methods[i].ToString());
+            }
+
+            return sb.ToString();
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/FailoverPolicy.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+
+namespace Qpid.Client.qms.failover
+{
+    public class FailoverMethodConstants
+    {
+        public const String ROUND_ROBIN = "roundrobin";
+        public const String RANDOM = "random";
+    }
+
+    public interface FailoverMethod
+    {
+        /**
+         * Reset the Failover to initial conditions
+         */
+        void reset();
+
+        /**
+         *  Check if failover is possible for this method
+         *
+         * @return true if failover is allowed
+         */
+        bool failoverAllowed();
+
+        /**
+         * Notification to the Failover method that a connection has been attained.
+         */
+        void attainedConnection();
+
+        /**
+         * If there is no current BrokerInfo the null will be returned.
+         * @return The current BrokerDetail value to use
+         */
+        BrokerInfo GetCurrentBrokerInfo();
+
+        /**
+         *  Move to the next BrokerInfo if one is available.
+         * @return the next BrokerDetail or null if there is none.
+         */
+        BrokerInfo getNextBrokerDetails();
+
+        /**
+         * Set the currently active broker to be the new value.
+         * @param broker The new BrokerDetail value
+         */
+        void setBroker(BrokerInfo broker);
+
+        /**
+         * Set the retries for this method
+         * @param maxRetries the maximum number of time to retry this Method
+         */
+        void setRetries(int maxRetries);
+
+        /**
+         * @return The name of this method for display purposes.
+         */
+        String methodName();
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverMethod.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,255 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Text;
+using log4net;
+
+namespace Qpid.Client.qms.failover
+{
+    public class FailoverRoundRobin : FailoverMethod
+    {
+        private static readonly ILog _logger = LogManager.GetLogger(typeof(FailoverRoundRobin));
+
+        /** The default number of times to cycle through all servers */
+        public const int DEFAULT_CYCLE_RETRIES = 0;
+        /** The default number of times to retry each server */
+        public const int DEFAULT_SERVER_RETRIES = 0;
+
+        /**
+         * The index into the hostDetails array of the broker to which we are connected
+         */
+        private int _currentBrokerIndex = -1;
+
+        /**
+         * The number of times to retry connecting for each server
+         */
+        private int _serverRetries;
+
+        /**
+         * The current number of retry attempts made
+         */
+        private int _currentServerRetry;
+
+        /**
+         *  The number of times to cycle through the servers
+         */
+        private int _cycleRetries;
+
+        /**
+         * The current number of cycles performed.
+         */
+        private int _currentCycleRetries;
+
+        /**
+         * Array of BrokerDetail used to make connections.
+         */
+        private ConnectionInfo _connectionDetails;
+
+        public FailoverRoundRobin(ConnectionInfo connectionDetails)
+        {
+            if (!(connectionDetails.getBrokerCount() > 0))
+            {
+                throw new ArgumentException("At least one broker details must be specified.");
+            }
+
+            _connectionDetails = connectionDetails;
+
+            //There is no current broker at startup so set it to -1.
+            _currentBrokerIndex = -1;
+
+            String cycleRetries = _connectionDetails.getFailoverOption(ConnectionUrlConstants.OPTIONS_FAILOVER_CYCLE);
+
+            if (cycleRetries != null)
+            {
+                try
+                {
+                    _cycleRetries = int.Parse(cycleRetries);
+                }
+                catch (FormatException)
+                {
+                    _cycleRetries = DEFAULT_CYCLE_RETRIES;
+                }
+            }
+
+            _currentCycleRetries = 0;
+
+            _serverRetries = 0;
+            _currentServerRetry = -1;
+        }
+
+        public void reset()
+        {
+            _currentBrokerIndex = 0;
+            _currentCycleRetries = 0;
+            _currentServerRetry = -1;
+        }
+
+        public bool failoverAllowed()
+        {
+            return ((_currentCycleRetries < _cycleRetries)
+                   || (_currentServerRetry < _serverRetries)
+                   || (_currentBrokerIndex < (_connectionDetails.getBrokerCount() - 1)));
+        }
+
+        public void attainedConnection()
+        {
+            _currentCycleRetries = 0;
+            _currentServerRetry = -1;
+        }
+
+        public BrokerInfo GetCurrentBrokerInfo()
+        {
+            if (_currentBrokerIndex == -1)
+            {
+                return null;
+            }
+
+            return _connectionDetails.GetBrokerDetails(_currentBrokerIndex);
+        }
+
+        public BrokerInfo getNextBrokerDetails()
+        {
+            if (_currentBrokerIndex == (_connectionDetails.getBrokerCount() - 1))
+            {
+                if (_currentServerRetry < _serverRetries)
+                {
+                    if (_currentBrokerIndex == -1)
+                    {
+                        _currentBrokerIndex = 0;
+
+                        setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+
+                        _logger.Info("First Run using " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+                    }
+                    else
+                    {
+                        _logger.Info("Retrying " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+                    }
+
+                    _currentServerRetry++;
+                }
+                else
+                {
+                    _currentCycleRetries++;
+                    //failed to connect to first broker
+                    _currentBrokerIndex = 0;
+
+                    setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+
+                    // This is zero rather than -1 as we are already retrieving the details.
+                    _currentServerRetry = 0;
+                }
+                //else - should force client to stop as max retries has been reached.
+            }
+            else
+            {
+                if (_currentServerRetry < _serverRetries)
+                {
+                    if (_currentBrokerIndex == -1)
+                    {
+                        _currentBrokerIndex = 0;
+
+                        setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+
+                        _logger.Info("First Run using " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+                    }
+                    else
+                    {
+                        _logger.Info("Retrying " + _connectionDetails.GetBrokerDetails(_currentBrokerIndex));
+                    }
+                    _currentServerRetry++;
+                }
+                else
+                {
+                    _currentBrokerIndex++;
+
+                     setBroker(_connectionDetails.GetBrokerDetails(_currentBrokerIndex ));
+                    // This is zero rather than -1 as we are already retrieving the details.
+                    _currentServerRetry = 0;
+                }
+            }
+
+            return _connectionDetails.GetBrokerDetails(_currentBrokerIndex);
+        }
+
+        public void setBroker(BrokerInfo broker)
+        {
+            _connectionDetails.AddBrokerInfo(broker);
+
+            int index = _connectionDetails.GetAllBrokerInfos().IndexOf(broker);
+
+            String serverRetries = broker.getOption(BrokerDetailsConstants.OPTIONS_RETRY);
+
+            if (serverRetries != null)
+            {
+                try
+                {
+                    _serverRetries = int.Parse(serverRetries);
+                }
+                catch (FormatException)
+                {
+                    _serverRetries = DEFAULT_SERVER_RETRIES;
+                }
+            }
+
+            _currentServerRetry = -1;
+            _currentBrokerIndex = index;
+        }
+
+        public void setRetries(int maxRetries)
+        {
+            _cycleRetries = maxRetries;
+        }
+
+        public String methodName()
+        {
+            return "Cycle Servers";
+        }
+
+        public override string ToString()
+        {
+            StringBuilder sb = new StringBuilder();
+
+            sb.Append(GetType().Name).Append("\n");
+
+            sb.Append("Broker count: ").Append(_connectionDetails.getBrokerCount());
+            sb.Append("\ncurrent broker index: ").Append(_currentBrokerIndex);
+
+            sb.Append("\nCycle Retries: ").Append(_cycleRetries);
+            sb.Append("\nCurrent Cycle:").Append(_currentCycleRetries);
+            sb.Append("\nServer Retries:").Append(_serverRetries);
+            sb.Append("\nCurrent Retry:").Append(_currentServerRetry);
+            sb.Append("\n");
+
+            for(int i=0; i < _connectionDetails.getBrokerCount() ; i++)
+            {
+                if (i == _currentBrokerIndex)
+                {
+                    sb.Append(">");
+                }
+                sb.Append(_connectionDetails.GetBrokerDetails(i));
+                sb.Append("\n");
+            }
+
+            return sb.ToString();
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverRoundRobin.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,147 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+
+namespace Qpid.Client.qms.failover
+{
+    public class FailoverSingleServer : FailoverMethod
+    {
+        /** The default number of times to rety a conection to this server */
+        public const int DEFAULT_SERVER_RETRIES = 1;
+
+        /**
+         * The details of the Single Server
+         */
+        private BrokerInfo _brokerDetail;
+
+        /**
+         * The number of times to retry connecting to the sever
+         */
+        private int _retries;
+
+        /**
+         * The current number of attempts made to the server
+         */
+        private int _currentRetries;
+
+
+        public FailoverSingleServer(ConnectionInfo connectionDetails)
+        {
+            if (connectionDetails.getBrokerCount() > 0)
+            {
+                setBroker(connectionDetails.GetBrokerDetails(0));
+            }
+            else
+            {
+                throw new ArgumentException("BrokerInfo details required for connection.");
+            }
+        }
+
+        public FailoverSingleServer(BrokerInfo brokerDetail)
+        {
+            setBroker(brokerDetail);
+        }
+
+        public void reset()
+        {
+            _currentRetries = -1;
+        }
+
+        public bool failoverAllowed()
+        {
+            return _currentRetries < _retries;
+        }
+
+        public void attainedConnection()
+        {
+            reset();
+        }
+
+        public BrokerInfo GetCurrentBrokerInfo()
+        {
+           return _brokerDetail;
+        }
+
+        public BrokerInfo getNextBrokerDetails()
+        {
+            if (_currentRetries == _retries)
+            {
+                return null;
+            }
+            else
+            {
+                if (_currentRetries < _retries)
+                {
+                    _currentRetries ++;
+                }
+
+                return _brokerDetail;
+            }
+        }
+
+        public void setBroker(BrokerInfo broker)
+        {
+            if (broker == null)
+            {
+                throw new ArgumentException("BrokerInfo details cannot be null");
+            }
+            _brokerDetail = broker;
+
+            String retries = broker.getOption(BrokerDetailsConstants.OPTIONS_RETRY);
+            if (retries != null)
+            {
+                try
+                {
+                    _retries = int.Parse(retries);
+                }
+                catch (FormatException nfe)
+                {
+                    _retries = DEFAULT_SERVER_RETRIES;
+                }
+            }
+            else
+            {
+                _retries = DEFAULT_SERVER_RETRIES;
+            }
+
+            reset();
+        }
+
+        public void setRetries(int retries)
+        {
+            _retries = retries;
+        }
+
+        public String methodName()
+        {
+            return "Single Server";
+        }
+
+        public String toString()
+        {
+            return "SingleServer:\n"+
+                    "Max Retries:"+_retries+
+                    "\nCurrent Retry:"+_currentRetries+
+                    "\n"+_brokerDetail+"\n";
+        }
+
+    }
+}
\ No newline at end of file

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Client/qms/failover/FailoverSingleServer.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using Qpid.Buffer;
+
+namespace Qpid.Codec
+{
+    public abstract class CumulativeProtocolDecoder : IProtocolDecoder
+    {
+        ByteBuffer _remaining;
+
+        /// <summary>
+        /// Creates a new instance with the 65535 bytes initial capacity of
+        /// cumulative buffer.
+        /// Note that capacity is currently fixed as the .NET ByteBuffers does not implement auto-expansion.
+        /// </summary>
+        protected CumulativeProtocolDecoder()
+        {
+            // Needs to be as large as the largest frame to be decoded.
+            _remaining = ByteBuffer.Allocate(65535); // FIXME: Probably should not be fixed.
+        }
+
+        /// <summary>
+        /// Cumulates content of <tt>in</tt> into internal buffer and forwards
+        /// decoding request to {@link #doDecode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
+        /// <tt>doDecode()</tt> is invoked repeatedly until it returns <tt>false</tt>
+        /// and the cumulative buffer is compacted after decoding ends.
+        /// </summary>
+        /// <exception cref="Exception">
+        /// if your <tt>doDecode()</tt> returned <tt>true</tt> not consuming the cumulative buffer.
+        /// </exception>
+        public void Decode(ByteBuffer input, IProtocolDecoderOutput output)
+        {
+            if (_remaining.Position != 0) // If there were remaining undecoded bytes
+            {
+                DecodeRemainingAndInput(input, output);
+            }
+            else
+            {
+                DecodeInput(input, output);
+            }
+        }
+
+        private void DecodeInput(ByteBuffer input, IProtocolDecoderOutput output)
+        {
+            // Just decode the input buffer and remember any remaining undecoded bytes.
+            try
+            {
+                DecodeAll(input, output);
+            }
+            finally
+            {
+                if (input.HasRemaining())
+                {
+                    _remaining.Put(input);
+                }
+            }
+        }
+
+        private void DecodeRemainingAndInput(ByteBuffer input, IProtocolDecoderOutput output)
+        {
+            // Concatenate input buffer with left-over bytes.
+            _remaining.Put(input);
+            _remaining.Flip();
+
+            try
+            {
+                DecodeAll(_remaining, output);
+            }
+            finally
+            {
+                _remaining.Compact();
+            }
+        }
+
+        private void DecodeAll(ByteBuffer buf, IProtocolDecoderOutput output)
+        {
+            for (;;)
+            {
+                int oldPos = buf.Position;                    
+                bool decoded = DoDecode(buf, output);
+                if (decoded)
+                {                        
+                    if (buf.Position == oldPos)
+                    {
+                        throw new Exception(
+                            "doDecode() can't return true when buffer is not consumed.");
+                    }
+
+                    if (!buf.HasRemaining())
+                    {
+                        break;
+                    }
+                }
+                else
+                {
+                    break;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Implement this method to consume the specified cumulative buffer and
+        /// decode its content into message(s). 
+        /// </summary>
+        /// <param name="input">the cumulative buffer</param>
+        /// <param name="output">decoder output</param>
+        /// <returns>
+        /// <tt>true</tt> if and only if there's more to decode in the buffer
+        /// and you want to have <tt>doDecode</tt> method invoked again.
+        /// Return <tt>false</tt> if remaining data is not enough to decode,
+        /// then this method will be invoked again when more data is cumulated.
+        /// </returns>
+        /// <exception cref="Exception">If cannot decode</exception>
+        protected abstract bool DoDecode(ByteBuffer input, IProtocolDecoderOutput output);
+
+        public void Dispose()
+        {
+            _remaining = null;
+        }
+    }
+}

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/CumulativeProtocolDecoder.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,385 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Collections;
+using Qpid.Buffer;
+
+namespace Qpid.Codec.Demux
+{
+    public class DemuxingProtocolCodecFactory : IProtocolCodecFactory
+    {
+        private ArrayList _decoderFactories = new ArrayList();
+        private ArrayList _encoderFactories = new ArrayList();
+        
+        public void Register(Type encoderOrDecoderClass)
+        {
+            if (encoderOrDecoderClass == null)
+            {
+                throw new ArgumentNullException("encoderOrDecoderClass");
+            }
+
+            bool registered = false;
+            if (typeof(IMessageEncoder).IsAssignableFrom(encoderOrDecoderClass))
+            {
+                Register(new DefaultConstructorMessageEncoderFactory(encoderOrDecoderClass));
+                registered = true;
+            }
+            
+            if (typeof(IMessageDecoder).IsAssignableFrom(encoderOrDecoderClass))
+            {
+                Register(new DefaultConstructorMessageDecoderFactory(encoderOrDecoderClass));
+                registered = true;
+            }
+            
+            if (!registered)
+            {
+                throw new ArgumentException("Unregisterable type: " + encoderOrDecoderClass);
+            }
+        }
+        
+        public void Register(IMessageEncoder encoder)
+        {
+            Register(new SingletonMessageEncoderFactory(encoder));
+        }
+        
+        public void Register(IMessageEncoderFactory factory)
+        {
+            if (factory == null)
+            {
+                throw new ArgumentNullException("factory");
+            }
+
+            _encoderFactories.Add(factory);
+        }
+        
+        public void Register(IMessageDecoder decoder)
+        {
+            Register(new SingletonMessageDecoderFactory(decoder));
+        }
+        
+        public void Register(IMessageDecoderFactory factory)
+        {
+            if (factory == null)
+            {
+                throw new ArgumentNullException("factory");
+            }
+            _decoderFactories.Add(factory);
+        }
+        
+        public IProtocolEncoder Encoder
+        {
+            get
+            {
+                return new ProtocolEncoderImpl(this);
+            }
+        }
+        
+        public IProtocolDecoder Decoder
+        {
+            get
+            {
+                return new ProtocolDecoderImpl(this);
+            }            
+        }
+        
+        protected void DisposeCodecResources()
+        {
+            // Do nothing by default
+        }
+
+        private class ProtocolEncoderImpl : IProtocolEncoder
+        {
+            private readonly Hashtable _encoders = new Hashtable();
+
+            private DemuxingProtocolCodecFactory _enclosing;
+
+            public ProtocolEncoderImpl(DemuxingProtocolCodecFactory enclosing)
+            {
+                _enclosing = enclosing;
+                ArrayList encoderFactories = enclosing._encoderFactories;
+                for (int i = encoderFactories.Count - 1; i >= 0; i--)
+                {
+                    IMessageEncoder encoder = ((IMessageEncoderFactory)encoderFactories[i]).NewEncoder();
+                    foreach (Type type in encoder.MessageTypes.Keys)
+                    {
+                        _encoders[type] = encoder;
+                    }
+                }
+            }
+
+            public void Encode(object message, IProtocolEncoderOutput output)
+            {
+                Type type = message.GetType();
+                IMessageEncoder encoder = FindEncoder(type);
+                if (encoder == null)
+                {
+                    throw new ProtocolEncoderException("Unexpected message type: " + type);
+                }
+
+                encoder.Encode(message, output);
+            }
+
+            private IMessageEncoder FindEncoder(Type type)
+            {
+                IMessageEncoder encoder = (IMessageEncoder)_encoders[type];
+                if (encoder == null)
+                {
+                    encoder = FindEncoder(type, new Hashtable());
+                }
+
+                return encoder;
+            }
+
+            private IMessageEncoder FindEncoder(Type type, Hashtable triedClasses)
+            {
+                IMessageEncoder encoder;
+
+                if (triedClasses.Contains(type))
+                {
+                    return null;
+                }
+                triedClasses[type] = 1;
+
+                encoder = (IMessageEncoder)_encoders[type];
+                if (encoder == null)
+                {
+                    encoder = FindEncoder(type, triedClasses);
+                    if (encoder != null)
+                    {
+                        return encoder;
+                    }
+
+                    Type[] interfaces = type.GetInterfaces();
+                    for (int i = 0; i < interfaces.Length; i++)
+                    {
+                        encoder = FindEncoder(interfaces[i], triedClasses);
+                        if (encoder != null)
+                        {
+                            return encoder;
+                        }
+                    }
+
+                    return null;
+                }
+                else
+                    return encoder;
+            }
+
+            public void Dispose()
+            {
+                _enclosing.DisposeCodecResources();
+            }
+        }
+        
+        private class ProtocolDecoderImpl : CumulativeProtocolDecoder
+        {
+            private readonly IMessageDecoder[] _decoders;
+            private IMessageDecoder _currentDecoder;
+            private DemuxingProtocolCodecFactory _enclosing;
+            
+            public ProtocolDecoderImpl(DemuxingProtocolCodecFactory enclosing)
+            {
+                _enclosing = enclosing;
+                ArrayList decoderFactories = _enclosing._decoderFactories;
+                _decoders = new IMessageDecoder[decoderFactories.Count];
+                for (int i = decoderFactories.Count - 1; i >= 0; i--)
+                {
+                    _decoders[i] = ((IMessageDecoderFactory) decoderFactories[i]).NewDecoder();
+                }
+            }
+
+            protected override bool DoDecode(ByteBuffer input, IProtocolDecoderOutput output)
+            {
+                MessageDecoderResult result;
+                if (_currentDecoder == null)
+                {
+                    IMessageDecoder[] decoders = _decoders;
+                    int undecodables = 0;
+                
+                    for (int i = decoders.Length - 1; i >= 0; i --) 
+                    {
+                        IMessageDecoder decoder = decoders[i];
+                        int limit = input.Limit;
+                        int pos = input.Position;
+                        
+                        try
+                        {
+                            result = decoder.Decodable(input);
+                        }
+                        finally
+                        {
+                            input.Position = pos;
+                            input.Limit = limit;
+                        }
+                        
+                        if (result == MessageDecoderResult.OK)
+                        {
+                            _currentDecoder = decoder;
+                            break;
+                        }
+                        else if(result == MessageDecoderResult.NOT_OK)
+                        {
+                            undecodables ++;
+                        }
+                        else if (result != MessageDecoderResult.NEED_DATA)
+                        {
+                            throw new Exception("Unexpected decode result (see your decodable()): " + result);
+                        }
+                    }
+                    
+                    if (undecodables == _decoders.Length)
+                    {
+                        // Throw an exception if all decoders cannot decode data.
+                        input.Position = input.Limit; // Skip data
+                        throw new ProtocolDecoderException(
+                            "No appropriate message decoder: " + input.HexDump);
+                    }
+                    
+                    if (_currentDecoder == null)
+                    {
+                        // Decoder is not determined yet (i.e. we need more data)
+                        return false;
+                    }
+                }
+                
+                result = _currentDecoder.Decode(input, output);
+                if (result == MessageDecoderResult.OK)
+                {
+                    _currentDecoder = null;
+                    return true;
+                }
+                else if (result == MessageDecoderResult.NEED_DATA)
+                {
+                    return false;
+                }
+                else if (result == MessageDecoderResult.NOT_OK) 
+                {
+                    throw new ProtocolDecoderException("Message decoder returned NOT_OK.");
+                }
+                else
+                {
+                    throw new Exception("Unexpected decode result (see your decode()): " + result);
+                }
+            }
+        }
+        
+        private class SingletonMessageEncoderFactory : IMessageEncoderFactory
+        {
+            private readonly IMessageEncoder _encoder;
+            
+            public SingletonMessageEncoderFactory(IMessageEncoder encoder)
+            {
+                if (encoder == null)
+                {
+                    throw new ArgumentNullException("encoder");
+                }
+                _encoder = encoder;
+            }
+
+            public IMessageEncoder NewEncoder()
+            {
+                return _encoder;
+            }
+        }
+        
+        private class SingletonMessageDecoderFactory : IMessageDecoderFactory
+        {
+            private readonly IMessageDecoder _decoder;
+            
+            public SingletonMessageDecoderFactory(IMessageDecoder decoder)
+            {
+                if (decoder == null)
+                {
+                    throw new ArgumentNullException("decoder");
+                }
+                _decoder = decoder;
+            }
+
+            public IMessageDecoder NewDecoder()
+            {
+                return _decoder;
+            }
+        }
+        
+        private class DefaultConstructorMessageEncoderFactory : IMessageEncoderFactory
+        {
+            private readonly Type _encoderClass;
+            
+            public DefaultConstructorMessageEncoderFactory(Type encoderClass)
+            {
+                if (encoderClass == null)
+                {
+                    throw new ArgumentNullException("encoderClass");
+                }
+                
+                if(!typeof(IMessageEncoder).IsAssignableFrom(encoderClass))
+                {
+                    throw new ArgumentException("encoderClass is not assignable to MessageEncoder");
+                }
+                _encoderClass = encoderClass;
+            }
+
+            public IMessageEncoder NewEncoder()
+            {
+                try
+                {
+                    return (IMessageEncoder) Activator.CreateInstance(_encoderClass);
+                }
+                catch (Exception e)
+                {
+                    throw new Exception( "Failed to create a new instance of " + _encoderClass, e);
+                }
+            }
+        }
+
+        private class DefaultConstructorMessageDecoderFactory : IMessageDecoderFactory
+        {
+            private readonly Type _decoderClass;
+            
+            public DefaultConstructorMessageDecoderFactory(Type decoderClass)
+            {
+                if (decoderClass == null)
+                {
+                    throw new ArgumentNullException("decoderClass");
+                }
+                
+                if(!typeof(IMessageDecoder).IsAssignableFrom(decoderClass))
+                {
+                    throw new ArgumentException("decoderClass is not assignable to MessageDecoder");
+                }
+                _decoderClass = decoderClass;
+            }
+
+            public IMessageDecoder NewDecoder()
+            {
+                try
+                {
+                    return (IMessageDecoder) Activator.CreateInstance(_decoderClass);
+                }
+                catch (Exception e)
+                {
+                    throw new Exception("Failed to create a new instance of " + _decoderClass, e);
+                }
+            }
+        }
+    }
+}
+

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/DemuxingProtocolCodecFactory.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoder.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoder.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using Qpid.Buffer;
+
+namespace Qpid.Codec.Demux
+{
+    public interface IMessageDecoder
+    {
+        /// <summary>
+        /// Checks the specified buffer is decodable by this decoder.
+        /// </summary>
+        /// <param name="buffer">The buffer to read data from.</param>
+        /// <returns>
+        /// OK if this decoder can decode the specified buffer.
+        /// NOT_OK if this decoder cannot decode the specified buffer.
+        /// if more data is required to determine if the
+        /// specified buffer is decodable ({@link #OK}) or not decodable
+        /// {@link #NOT_OK}.</returns>             
+        MessageDecoderResult Decodable(ByteBuffer buffer);
+
+        /// <summary>
+        /// Decodes binary or protocol-specific content into higher-level message objects.
+        /// MINA invokes {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}
+        /// method with read data, and then the decoder implementation puts decoded
+        /// messages into {@link ProtocolDecoderOutput}.
+        /// </summary>
+        /// <returns>
+        /// {@link #OK} if you finished decoding messages successfully.
+        /// {@link #NEED_DATA} if you need more data to finish decoding current message.
+        /// {@link #NOT_OK} if you cannot decode current message due to protocol specification violation.
+        /// </returns>
+        /// <exception cref="Exception">if the read data violated protocol specification </exception>     
+        MessageDecoderResult Decode(ByteBuffer buffer, IProtocolDecoderOutput output);
+    }
+}
+

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoder.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoderFactory.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoderFactory.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoderFactory.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoderFactory.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.
+ *
+ */
+namespace Qpid.Codec.Demux
+{
+    public interface IMessageDecoderFactory
+    {
+        /// <summary>
+        /// Creates a new message decoder.
+        /// </summary>
+        IMessageDecoder NewDecoder();
+    }
+}
+

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageDecoderFactory.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageEncoder.cs
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageEncoder.cs?view=auto&rev=479211
==============================================================================
--- incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageEncoder.cs (added)
+++ incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageEncoder.cs Sat Nov 25 14:04:39 2006
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.
+ *
+ */
+using System;
+using System.Collections;
+
+namespace Qpid.Codec.Demux
+{
+    public interface IMessageEncoder
+    {
+        /// <summary>
+        /// Returns the set of message classes this encoder can encode.
+        /// </summary>
+        Hashtable MessageTypes
+        {
+            get;
+        }
+
+        /// <summary>
+        /// Encodes higher-level message objects into binary or protocol-specific data.
+        /// MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
+        /// method with message which is popped from the session write queue, and then
+        /// the encoder implementation puts encoded {@link ByteBuffer}s into
+        /// {@link ProtocolEncoderOutput}.
+        /// </summary>
+        /// <exception cref="Exception">if the message violated protocol specification</exception>
+        void Encode(Object message, IProtocolEncoderOutput output);
+    }
+}
+

Propchange: incubator/qpid/trunk/qpid/dotnet/Qpid.Codec/Demux/IMessageEncoder.cs
------------------------------------------------------------------------------
    svn:eol-style = native