A few more refactors.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@383299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-03-05 09:47:04 +00:00
parent 2949d2657a
commit 494e5bdd2a
24 changed files with 165 additions and 179 deletions

View File

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ;
using ActiveMQ.OpenWire;
using ActiveMQ.Commands;
using JMS;
/// <summary>
@ -24,7 +24,7 @@ using ActiveMQ.OpenWire;
namespace ActiveMQ
{
public class BrokerException : OpenWireException
public class BrokerException : JMSException
{
private BrokerError brokerError;

View File

@ -17,12 +17,13 @@
using ActiveMQ.Commands;
using System;
namespace ActiveMQ.OpenWire
/// <summary>
/// Summary description for AbstractCommand.
/// </summary>
namespace ActiveMQ.Commands
{
/// <summary>
/// Summary description for AbstractCommand.
/// </summary>
public abstract class AbstractCommand : Command
public abstract class AbstractCommand : Command
{
private short commandId;
private bool responseRequired;
@ -138,3 +139,4 @@ namespace ActiveMQ.OpenWire
}
}
}

View File

@ -14,9 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ;
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using JMS;
using System;

View File

@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ;
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using JMS;
@ -55,7 +53,7 @@ namespace ActiveMQ.Commands
{
if (Acknowledger == null)
{
throw new OpenWireException("No Acknowledger has been associated with this message: " + this);
throw new JMSException("No Acknowledger has been associated with this message: " + this);
}
else
{

View File

@ -8,7 +8,6 @@
//
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using System;

View File

@ -14,26 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ.Commands;
using System;
using System.Text;
using System.IO;
namespace ActiveMQ.OpenWire
namespace ActiveMQ.Commands
{
public struct StackTraceElement
public struct StackTraceElement
{
public string ClassName;
public string FileName;
public string MethodName;
public int LineNumber;
}
/// <summary>
/// Represents an exception on the broker
/// </summary>
public class BrokerError : AbstractCommand
}
/// <summary>
/// Represents an exception on the broker
/// </summary>
namespace ActiveMQ.Commands
{
public class BrokerError : AbstractCommand
{
private string message;
private string exceptionClass;
@ -64,7 +67,8 @@ namespace ActiveMQ.OpenWire
set { cause = value; }
}
public String StackTrace {
public String StackTrace
{
get {
StringWriter writer = new StringWriter();
PrintStackTrace(writer);
@ -88,3 +92,4 @@ namespace ActiveMQ.OpenWire
}
}
}

View File

@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using ActiveMQ.Commands;
namespace ActiveMQ.OpenWire
/// <summary>
/// An OpenWire command
/// </summary>
namespace ActiveMQ.Commands
{
/// <summary>
/// An OpenWire command
/// </summary>
public interface Command : DataStructure
public interface Command : DataStructure
{
short CommandId
{
@ -37,3 +37,4 @@ namespace ActiveMQ.OpenWire
}
}
}

View File

@ -14,16 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace ActiveMQ.OpenWire
/// <summary>
/// An OpenWire command
/// </summary>
namespace ActiveMQ.Commands
{
/// <summary>
/// An OpenWire command
/// </summary>
public interface DataStructure {
byte GetDataStructureType();
bool IsMarshallAware();
}
public interface DataStructure
{
byte GetDataStructureType();
bool IsMarshallAware();
}
}

View File

@ -1,29 +1,43 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections;
namespace ActiveMQ
{
/// <summary>
/// Represents an OpenWire exception
/// </summary>
public class OpenWireException : Exception {
public OpenWireException(string message) : base(message) {
}
}
}
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ.Commands;
/// <summary>
/// Summary description for DataStructureSupport.
/// </summary>
namespace ActiveMQ.Commands
{
public abstract class DataStructureSupport : DataStructure
{
protected DataStructureSupport()
{
}
public virtual byte GetDataStructureType()
{
return 0;
}
public virtual bool IsMarshallAware()
{
return false;
}
}
}

View File

@ -14,26 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using ActiveMQ.OpenWire;
namespace ActiveMQ.OpenWire
/// <summary>
/// Represents a marshallable entity
/// </summary>
namespace ActiveMQ.Commands
{
/// <summary>
/// Summary description for DataStructureSupport.
/// </summary>
public abstract class DataStructureSupport : DataStructure {
protected DataStructureSupport() {
}
public virtual byte GetDataStructureType() {
return 0;
}
public virtual bool IsMarshallAware() {
return false;
}
}
public interface MarshallAware
{
void BeforeMarshall(OpenWireFormat wireFormat);
void AfterMarshall(OpenWireFormat wireFormat);
void BeforeUnmarshall(OpenWireFormat wireFormat);
void AfterUnmarshall(OpenWireFormat wireFormat);
void SetMarshalledForm(OpenWireFormat wireFormat, byte[] data);
byte[] GetMarshalledForm(OpenWireFormat wireFormat);
}
}

View File

@ -1,5 +1,4 @@
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using ActiveMQ.Transport;
using JMS;
using System;
@ -105,7 +104,7 @@ namespace ActiveMQ
set {
if (connected)
{
throw new OpenWireException("You cannot change the ClientId once the Connection is connected");
throw new JMSException("You cannot change the ClientId once the Connection is connected");
}
info.ClientId = value;
}
@ -145,7 +144,7 @@ namespace ActiveMQ
{
ExceptionResponse exceptionResponse = (ExceptionResponse) response;
// TODO include stack trace
throw new OpenWireException("Request failed: " + exceptionResponse);
throw new JMSException("Request failed: " + exceptionResponse);
}
return response;
}

View File

@ -14,17 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections;
using ActiveMQ.OpenWire;
using JMS;
namespace ActiveMQ
{
/// <summary>
/// Exception thrown when a connection is used that it already closed
/// </summary>
public class ConnectionClosedException : OpenWireException {
public class ConnectionClosedException : JMSException {
public ConnectionClosedException() : base("The connection is already closed!") {
}
}

View File

@ -14,17 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections;
using ActiveMQ.OpenWire;
using JMS;
namespace ActiveMQ
{
/// <summary>
/// Exception thrown when a consumer is used that it already closed
/// </summary>
public class ConsumerClosedException : OpenWireException {
public class ConsumerClosedException : JMSException {
public ConsumerClosedException() : base("The consumer is already closed!") {
}
}

View File

@ -20,25 +20,28 @@ using System;
using System.Collections;
using System.Threading;
namespace ActiveMQ.OpenWire
/// <summary>
/// Handles the multi-threaded dispatching between the transport and the consumers
/// </summary>
namespace ActiveMQ
{
/// <summary>
/// Handles the multi-threaded dispatching between the transport and the consumers
/// </summary>
public class Dispatcher
public class Dispatcher
{
Queue queue = new Queue();
Object semaphore = new Object();
ArrayList messagesToRedeliver = new ArrayList();
/// <summary>
/// Whem we start a transaction we must redeliver any rolled back messages
/// </summary>
public void RedeliverRolledBackMessages() {
public void RedeliverRolledBackMessages()
{
lock (semaphore)
{
Queue replacement = new Queue(queue.Count + messagesToRedeliver.Count);
foreach (ActiveMQMessage element in messagesToRedeliver) {
foreach (ActiveMQMessage element in messagesToRedeliver)
{
replacement.Enqueue(element);
}
messagesToRedeliver.Clear();
@ -58,8 +61,9 @@ namespace ActiveMQ.OpenWire
/// </summary>
public void Redeliver(ActiveMQMessage message)
{
lock (semaphore) {
messagesToRedeliver.Add(message);
lock (semaphore)
{
messagesToRedeliver.Add(message);
}
}
@ -122,3 +126,4 @@ namespace ActiveMQ.OpenWire
}
}

View File

@ -14,9 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace ActiveMQ.OpenWire
namespace ActiveMQ
{
public interface ISynchronization
public interface ISynchronization
{
/// <summary>
/// Called before a commit
@ -34,3 +35,4 @@ namespace ActiveMQ.OpenWire
void AfterRollback();
}
}

View File

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ;
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using JMS;
using System.Threading;

View File

@ -1,36 +0,0 @@
/*
* Copyright 2006 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.IO;
namespace ActiveMQ.OpenWire
{
/// <summary>
/// Represents a marshallable entity
/// </summary>
public interface MarshallAware {
void BeforeMarshall(OpenWireFormat wireFormat);
void AfterMarshall(OpenWireFormat wireFormat);
void BeforeUnmarshall(OpenWireFormat wireFormat);
void AfterUnmarshall(OpenWireFormat wireFormat);
void SetMarshalledForm(OpenWireFormat wireFormat, byte[] data);
byte[] GetMarshalledForm(OpenWireFormat wireFormat);
}
}

View File

@ -219,7 +219,7 @@ namespace ActiveMQ.OpenWire
{
if (! type.IsInstanceOfType(value))
{
throw new OpenWireException("Expected type: " + type.Name + " but was: " + value);
throw new JMSException("Expected type: " + type.Name + " but was: " + value);
}
}
@ -230,7 +230,7 @@ namespace ActiveMQ.OpenWire
Type type = value.GetType();
if (! type.IsPrimitive && !type.IsValueType && !type.IsAssignableFrom(typeof(string)))
{
throw new OpenWireException("Invalid type: " + type.Name + " for value: " + value);
throw new JMSException("Invalid type: " + type.Name + " for value: " + value);
}
}
}

View File

@ -15,13 +15,10 @@
// limitations under the License.
//
using ActiveMQ.Commands;
using System;
using System.Collections;
using System.IO;
using ActiveMQ.OpenWire;
using ActiveMQ.OpenWire.V1;
namespace ActiveMQ.OpenWire.V1
{
//

View File

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using ActiveMQ;
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using System.Collections;

View File

@ -18,12 +18,13 @@ using ActiveMQ.Commands;
using System;
using System.Threading;
namespace ActiveMQ.OpenWire
/// <summary>
/// Handles asynchronous responses
/// </summary>
namespace ActiveMQ.Transport
{
/// <summary>
/// Handles asynchronous responses
/// </summary>
public class FutureResponse : IAsyncResult
public class FutureResponse : IAsyncResult
{
private Response response;
@ -59,13 +60,15 @@ namespace ActiveMQ.OpenWire
get {
while (response == null)
{
try {
lock (semaphore)
{
Monitor.Wait(semaphore, maxWait);
try
{
lock (semaphore)
{
Monitor.Wait(semaphore, maxWait);
}
}
}
catch (Exception e) {
catch (Exception e)
{
Console.WriteLine("Caught while waiting on monitor: " + e);
}
}
@ -82,3 +85,4 @@ namespace ActiveMQ.OpenWire
}
}
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using ActiveMQ.Transport;
using JMS;
using System;

View File

@ -16,6 +16,7 @@
*/
using ActiveMQ.Commands;
using ActiveMQ.OpenWire;
using ActiveMQ.Transport;
using System;
using System.Collections;
using System.IO;

View File

@ -34,6 +34,7 @@
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets"/>
<ItemGroup>
<Compile Include="ActiveMQ\BrokerException.cs"/>
<Compile Include="ActiveMQ\Commands\AbstractCommand.cs"/>
<Compile Include="ActiveMQ\Commands\ActiveMQBytesMessage.cs"/>
<Compile Include="ActiveMQ\Commands\ActiveMQDestination.cs"/>
<Compile Include="ActiveMQ\Commands\ActiveMQMapMessage.cs"/>
@ -47,8 +48,10 @@
<Compile Include="ActiveMQ\Commands\ActiveMQTextMessage.cs"/>
<Compile Include="ActiveMQ\Commands\ActiveMQTopic.cs"/>
<Compile Include="ActiveMQ\Commands\BaseCommand.cs"/>
<Compile Include="ActiveMQ\Commands\BrokerError.cs"/>
<Compile Include="ActiveMQ\Commands\BrokerId.cs"/>
<Compile Include="ActiveMQ\Commands\BrokerInfo.cs"/>
<Compile Include="ActiveMQ\Commands\Command.cs"/>
<Compile Include="ActiveMQ\Commands\ConnectionError.cs"/>
<Compile Include="ActiveMQ\Commands\ConnectionId.cs"/>
<Compile Include="ActiveMQ\Commands\ConnectionInfo.cs"/>
@ -57,6 +60,8 @@
<Compile Include="ActiveMQ\Commands\ControlCommand.cs"/>
<Compile Include="ActiveMQ\Commands\DataArrayResponse.cs"/>
<Compile Include="ActiveMQ\Commands\DataResponse.cs"/>
<Compile Include="ActiveMQ\Commands\DataStructure.cs"/>
<Compile Include="ActiveMQ\Commands\DataStructureSupport.cs"/>
<Compile Include="ActiveMQ\Commands\DestinationInfo.cs"/>
<Compile Include="ActiveMQ\Commands\DiscoveryEvent.cs"/>
<Compile Include="ActiveMQ\Commands\ExceptionResponse.cs"/>
@ -68,6 +73,7 @@
<Compile Include="ActiveMQ\Commands\JournalTransaction.cs"/>
<Compile Include="ActiveMQ\Commands\KeepAliveInfo.cs"/>
<Compile Include="ActiveMQ\Commands\LocalTransactionId.cs"/>
<Compile Include="ActiveMQ\Commands\MarshallAware.cs"/>
<Compile Include="ActiveMQ\Commands\Message.cs"/>
<Compile Include="ActiveMQ\Commands\MessageAck.cs"/>
<Compile Include="ActiveMQ\Commands\MessageDispatch.cs"/>
@ -91,19 +97,12 @@
<Compile Include="ActiveMQ\ConnectionFactory.cs"/>
<Compile Include="ActiveMQ\ConsumerClosedException.cs"/>
<Compile Include="ActiveMQ\DestinationFilter.cs"/>
<Compile Include="ActiveMQ\Dispatcher.cs"/>
<Compile Include="ActiveMQ\ISynchronization.cs"/>
<Compile Include="ActiveMQ\MessageConsumer.cs"/>
<Compile Include="ActiveMQ\MessageProducer.cs"/>
<Compile Include="ActiveMQ\OpenWire\AbstractCommand.cs"/>
<Compile Include="ActiveMQ\OpenWire\BaseDataStreamMarshaller.cs"/>
<Compile Include="ActiveMQ\OpenWire\BooleanStream.cs"/>
<Compile Include="ActiveMQ\OpenWire\BrokerError.cs"/>
<Compile Include="ActiveMQ\OpenWire\Command.cs"/>
<Compile Include="ActiveMQ\OpenWire\DataStructure.cs"/>
<Compile Include="ActiveMQ\OpenWire\DataStructureSupport.cs"/>
<Compile Include="ActiveMQ\OpenWire\Dispatcher.cs"/>
<Compile Include="ActiveMQ\OpenWire\FutureResponse.cs"/>
<Compile Include="ActiveMQ\OpenWire\ISynchronization.cs"/>
<Compile Include="ActiveMQ\OpenWire\MarshallAware.cs"/>
<Compile Include="ActiveMQ\OpenWire\MessagePropertyHelper.cs"/>
<Compile Include="ActiveMQ\OpenWire\OpenWireFormat.cs"/>
<Compile Include="ActiveMQ\OpenWire\PrimitiveMap.cs"/>
@ -161,9 +160,9 @@
<Compile Include="ActiveMQ\OpenWire\V1\TransactionInfoMarshaller.cs"/>
<Compile Include="ActiveMQ\OpenWire\V1\WireFormatInfoMarshaller.cs"/>
<Compile Include="ActiveMQ\OpenWire\V1\XATransactionIdMarshaller.cs"/>
<Compile Include="ActiveMQ\OpenWireException.cs"/>
<Compile Include="ActiveMQ\Session.cs"/>
<Compile Include="ActiveMQ\TransactionContext.cs"/>
<Compile Include="ActiveMQ\Transport\FutureResponse.cs"/>
<Compile Include="ActiveMQ\Transport\ITransport.cs"/>
<Compile Include="ActiveMQ\Transport\SocketTransport.cs"/>
<Compile Include="JMS\IBytesMessage.cs"/>
@ -183,5 +182,7 @@
<Compile Include="JMS\ITemporaryTopic.cs"/>
<Compile Include="JMS\ITextMessage.cs"/>
<Compile Include="JMS\ITopic.cs"/>
<None Include="JMS\JMSConnectionException.cs"/>
<Compile Include="JMS\JMSException.cs"/>
</ItemGroup>
</Project>