You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2008/05/27 23:58:15 UTC

svn commit: r660736 - in /activemq/activemq-dotnet/Apache.NMS.EMS/trunk: src/main/csharp/AtomicBoolean.cs src/main/csharp/Connection.cs vs2005-ems.csproj

Author: jgomes
Date: Tue May 27 14:58:14 2008
New Revision: 660736

URL: http://svn.apache.org/viewvc?rev=660736&view=rev
Log:
Added IsStarted property to IStartable interface.
Fixes [AMQNET-86]. (See https://issues.apache.org/activemq/browse/AMQNET-86)

Added:
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/AtomicBoolean.cs
Modified:
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2005-ems.csproj

Added: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/AtomicBoolean.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/AtomicBoolean.cs?rev=660736&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/AtomicBoolean.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/AtomicBoolean.cs Tue May 27 14:58:14 2008
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+namespace Apache.NMS.EMS
+{
+	public class AtomicBoolean
+	{
+		bool value;
+
+		public bool Value
+		{
+			get
+			{
+				lock (this)
+				{
+					return value;
+				}
+			}
+			set
+			{
+				lock (this)
+				{
+					this.value = value;
+				}
+			}
+		}
+
+		public AtomicBoolean(bool b)
+		{
+			value = b;
+		}
+
+		public bool CompareAndSet(bool expected, bool newValue)
+		{
+			lock(this)
+			{
+				if (value == expected)
+				{
+					value = newValue;
+					return true;
+				}
+				return false;
+			}
+		}
+	}
+}

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs?rev=660736&r1=660735&r2=660736&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/Connection.cs Tue May 27 14:58:14 2008
@@ -26,7 +26,8 @@
     {
     	private Apache.NMS.AcknowledgementMode acknowledgementMode;
     	public readonly TIBCO.EMS.Connection tibcoConnection;
-    	private bool closed = false;
+		private readonly AtomicBoolean started = new AtomicBoolean(false);
+		private bool closed = false;
     	private bool disposed = false;
 
 		public Connection(TIBCO.EMS.Connection cnx)
@@ -47,7 +48,15 @@
         /// </summary>
         public void Start()
         {
-			this.tibcoConnection.Start();
+			if(started.CompareAndSet(false, true))
+			{
+				this.tibcoConnection.Start();
+			}
+		}
+
+		public bool IsStarted
+		{
+			get { return this.started.Value; }
 		}
 
 		#endregion
@@ -59,7 +68,10 @@
         /// </summary>
         public void Stop()
         {
-            this.tibcoConnection.Stop();
+			if(started.CompareAndSet(true, false))
+			{
+	            this.tibcoConnection.Stop();
+			}
 		}
 
 		#endregion

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2005-ems.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2005-ems.csproj?rev=660736&r1=660735&r2=660736&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2005-ems.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2005-ems.csproj Tue May 27 14:58:14 2008
@@ -1,81 +1,82 @@
-<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>{2AF5EBB5-9873-4B35-A8FC-8B6E74242767}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <RootNamespace>Apache.NMS.EMS</RootNamespace>
-    <AssemblyName>Apache.NMS.EMS</AssemblyName>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>build\net-2.0\debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>build\net-2.0\release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>none</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-    <Reference Include="TIBCO.EMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b83db8ff05c64ba">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>lib\TIBCO.EMS.dll</HintPath>
-    </Reference>
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="src\main\csharp\BytesMessage.cs" />
-    <Compile Include="src\main\csharp\CommonAssemblyInfo.cs" />
-    <Compile Include="src\main\csharp\Connection.cs" />
-    <Compile Include="src\main\csharp\ConnectionFactory.cs" />
-    <Compile Include="src\main\csharp\Destination.cs" />
-    <Compile Include="src\main\csharp\Dispatcher.cs" />
-    <Compile Include="src\main\csharp\MapMessage.cs" />
-    <Compile Include="src\main\csharp\Message.cs" />
-    <Compile Include="src\main\csharp\MessageConsumer.cs" />
-    <Compile Include="src\main\csharp\MessageProducer.cs" />
-    <Compile Include="src\main\csharp\MessageProperties.cs" />
-    <Compile Include="src\main\csharp\ObjectMessage.cs" />
-    <Compile Include="src\main\csharp\Queue.cs" />
-    <Compile Include="src\main\csharp\Session.cs" />
-    <Compile Include="src\main\csharp\TemporaryQueue.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="src\main\csharp\TemporaryTopic.cs" />
-    <Compile Include="src\main\csharp\TextMessage.cs" />
-    <Compile Include="src\main\csharp\TibcoUtil.cs" />
-    <Compile Include="src\main\csharp\Topic.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="activemq-dotnet.snk" />
-    <None Include="nmsprovider-ems.config">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="vendor\Apache.NMS\vs2005-nms.csproj">
-      <Project>{300C1716-0674-4D01-8F5D-151E59A504FE}</Project>
-      <Name>vs2005-nms</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+<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>{2AF5EBB5-9873-4B35-A8FC-8B6E74242767}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>Apache.NMS.EMS</RootNamespace>
+    <AssemblyName>Apache.NMS.EMS</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>build\net-2.0\debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>build\net-2.0\release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>none</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="TIBCO.EMS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b83db8ff05c64ba">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>lib\TIBCO.EMS.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="src\main\csharp\AtomicBoolean.cs" />
+    <Compile Include="src\main\csharp\BytesMessage.cs" />
+    <Compile Include="src\main\csharp\CommonAssemblyInfo.cs" />
+    <Compile Include="src\main\csharp\Connection.cs" />
+    <Compile Include="src\main\csharp\ConnectionFactory.cs" />
+    <Compile Include="src\main\csharp\Destination.cs" />
+    <Compile Include="src\main\csharp\Dispatcher.cs" />
+    <Compile Include="src\main\csharp\MapMessage.cs" />
+    <Compile Include="src\main\csharp\Message.cs" />
+    <Compile Include="src\main\csharp\MessageConsumer.cs" />
+    <Compile Include="src\main\csharp\MessageProducer.cs" />
+    <Compile Include="src\main\csharp\MessageProperties.cs" />
+    <Compile Include="src\main\csharp\ObjectMessage.cs" />
+    <Compile Include="src\main\csharp\Queue.cs" />
+    <Compile Include="src\main\csharp\Session.cs" />
+    <Compile Include="src\main\csharp\TemporaryQueue.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="src\main\csharp\TemporaryTopic.cs" />
+    <Compile Include="src\main\csharp\TextMessage.cs" />
+    <Compile Include="src\main\csharp\TibcoUtil.cs" />
+    <Compile Include="src\main\csharp\Topic.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="activemq-dotnet.snk" />
+    <None Include="nmsprovider-ems.config">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="vendor\Apache.NMS\vs2005-nms.csproj">
+      <Project>{300C1716-0674-4D01-8F5D-151E59A504FE}</Project>
+      <Name>vs2005-nms</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