From: Juergen H. <jho...@us...> - 2008-10-15 15:18:58
|
Update of /cvsroot/springframework/spring/src/org/springframework/jms/listener In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20621/src/org/springframework/jms/listener Modified Files: AbstractMessageListenerContainer.java Added Files: SubscriptionNameProvider.java Log Message: introduced SubscriptionNameProvider interface for message listener objects suggesting default subscription names; MessageListenerAdapter uses actual message listener object's class name as default subscription name --- NEW FILE: SubscriptionNameProvider.java --- /* * Copyright 2002-2008 the original author or authors. * * 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. */ package org.springframework.jms.listener; /** * Interface to be implemented by message listener objects that suggest a specific * name for a durable subscription that they might be registered with. Otherwise * the listener class name will be used as a default subscription name. * * <p>Applies to {@link javax.jms.MessageListener} objects as well as to * {@link SessionAwareMessageListener} objects and plain listener methods * (as supported by {@link org.springframework.jms.listener.adapter.MessageListenerAdapter}. * * @author Juergen Hoeller * @since 2.5.6 */ public interface SubscriptionNameProvider { /** * Determine the subscription name for this message listener object. */ String getSubscriptionName(); } Index: AbstractMessageListenerContainer.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jms/listener/AbstractMessageListenerContainer.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** AbstractMessageListenerContainer.java 23 Aug 2008 23:39:38 -0000 1.39 --- AbstractMessageListenerContainer.java 15 Oct 2008 14:42:00 -0000 1.40 *************** *** 239,248 **** this.messageListener = messageListener; if (this.durableSubscriptionName == null) { ! // Use message listener class name as default name for a durable subscription. ! this.durableSubscriptionName = messageListener.getClass().getName(); } } /** * Check the given message listener, throwing an exception * if it does not correspond to a supported listener type. --- 239,254 ---- this.messageListener = messageListener; if (this.durableSubscriptionName == null) { ! this.durableSubscriptionName = getDefaultSubscriptionName(messageListener); } } /** + * Return the message listener object to register. + */ + public Object getMessageListener() { + return this.messageListener; + } + + /** * Check the given message listener, throwing an exception * if it does not correspond to a supported listener type. *************** *** 265,272 **** /** ! * Return the message listener object to register. */ ! public Object getMessageListener() { ! return this.messageListener; } --- 271,286 ---- /** ! * Determine the default subscription name for the given message listener. ! * @param messageListener the message listener object to check ! * @return the default subscription name ! * @see SubscriptionNameProvider */ ! protected String getDefaultSubscriptionName(Object messageListener) { ! if (messageListener instanceof SubscriptionNameProvider) { ! return ((SubscriptionNameProvider) messageListener).getSubscriptionName(); ! } ! else { ! return messageListener.getClass().getName(); ! } } *************** *** 502,509 **** } // Actually invoke the message listener... - if (logger.isDebugEnabled()) { - logger.debug("Invoking listener with message of type [" + message.getClass() + - "] and session [" + sessionToUse + "]"); - } listener.onMessage(message, sessionToUse); // Clean up specially exposed Session, if any. --- 516,519 ---- |