From 5fbfcb0795ad20e6831164d9d8d826e51faf50a3 Mon Sep 17 00:00:00 2001 From: markpollack Date: Wed, 16 Jul 2008 18:15:40 +0000 Subject: [PATCH] simple code cleanup --- .../Nms/Connections/NmsResourceHolder.cs | 22 ++++++------------- .../AbstractMessageListenerContainer.cs | 16 ++++++++++++++ .../SimpleMessageListenerContainer.cs | 7 ++++++ .../Messaging/Nms/NmsTemplate.cs | 4 ++-- .../Destinations/NmsDestinationAccessor.cs | 7 ++++++ 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsResourceHolder.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsResourceHolder.cs index 868f6305..adb83d62 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsResourceHolder.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Connections/NmsResourceHolder.cs @@ -164,28 +164,20 @@ namespace Spring.Messaging.Nms.IConnections //return (ISession)CollectionUtils.FindValueOfType(sessions, sessionType); } + /// + /// Commits all sessions. + /// public virtual void CommitAll() { foreach (ISession session in sessions) { session.Commit(); - - // TODO are these exceptions valid? -// try -// { -// session.Commit(); -// } -// catch (TransactionInProgressException ex) -// { -// // Ignore -> can only happen in case of a distributed transaction. -// } -// catch (IllegalStateException ex) -// { -// // Ignore -> can only happen in case of a distributed transaction. -// } } } - + + /// + /// Closes all sessions then stops and closes all connections, in that order. + /// public virtual void CloseAll() { foreach (ISession session in sessions) diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs index 37a539f1..238372e4 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/AbstractMessageListenerContainer.cs @@ -372,11 +372,27 @@ namespace Spring.Messaging.Nms.Listener } } + /// + /// Invoke the specified listener as standard JMS MessageListener. + /// + /// Default implementation performs a plain invocation of the + /// OnMessage methods + /// The listener to invoke. + /// The received message. + /// if thronw by the underlying NMS APIs protected virtual void DoInvokeListener(IMessageListener listener, IMessage message) { listener.OnMessage(message); } + /// + /// Invoke the specified listener as Spring SessionAwareMessageListener, + /// exposing a new NMS Session (potentially with its own transaction) + /// to the listener if demanded. + /// + /// The Spring ISessionAwareMessageListener to invoke. + /// The session to operate on. + /// The received message. protected virtual void DoInvokeListener(ISessionAwareMessageListener listener, ISession session, IMessage message) { IConnection conToClose = null; diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs index d3a67a61..e3214354 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Listener/SimpleMessageListenerContainer.cs @@ -62,6 +62,10 @@ namespace Spring.Messaging.Nms.Listener return consumer; } + /// + /// Close the message consumers and sessions. + /// + /// NMSException if destruction failed protected override void DestroyListener() { logger.Debug("Closing NMS IMessageConsumers"); @@ -76,6 +80,9 @@ namespace Spring.Messaging.Nms.Listener } } + /// + /// Afters the properties set. + /// public override void AfterPropertiesSet() { if (this.concurrentConsumers <= 0) diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/NmsTemplate.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/NmsTemplate.cs index 05cacfd2..33b7c917 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/NmsTemplate.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/NmsTemplate.cs @@ -87,9 +87,9 @@ namespace Spring.Messaging.Nms /// Create a new NmsTemplate. /// - ///

Note: The IConnectionFactory has to be set before using the instance. + /// Note: The IConnectionFactory has to be set before using the instance. /// This constructor can be used to prepare a NmsTemplate via an ObjectFactory, - /// typically setting the IConnectionFactory.

+ /// typically setting the IConnectionFactory. ///
public NmsTemplate() { diff --git a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Destinations/NmsDestinationAccessor.cs b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Destinations/NmsDestinationAccessor.cs index 08e75221..83d65c89 100644 --- a/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Destinations/NmsDestinationAccessor.cs +++ b/src/Spring/Spring.Messaging.Nms/Messaging/Nms/Support/Destinations/NmsDestinationAccessor.cs @@ -95,6 +95,13 @@ namespace Spring.Messaging.Nms.Support.IDestinations #endregion + /// + /// Resolves the given destination name to a NMS destination. + /// + /// The current session. + /// Name of the destination. + /// The located IDestination + /// If resolution failed. public virtual IDestination ResolveDestinationName(ISession session, System.String destinationName) { return DestinationResolver.ResolveDestinationName(session, destinationName, PubSubDomain);