From: Juergen H. <jho...@us...> - 2008-07-30 21:18:11
|
Update of /cvsroot/springframework/spring/src/org/springframework/jms/connection In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5638/src/org/springframework/jms/connection Modified Files: ConnectionFactoryUtils.java SessionProxy.java Log Message: added "ConnectionFactoryUtils.getTargetSession(Session)" convenience method Index: SessionProxy.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jms/connection/SessionProxy.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SessionProxy.java 18 Mar 2007 16:42:43 -0000 1.1 --- SessionProxy.java 30 Jul 2008 21:18:08 -0000 1.2 *************** *** 1,4 **** /* ! * Copyright 2002-2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 26,29 **** --- 26,31 ---- * @since 2.0.4 * @see TransactionAwareConnectionFactoryProxy + * @see CachingConnectionFactory + * @see ConnectionFactoryUtils#getTargetSession(javax.jms.Session) */ public interface SessionProxy extends Session { Index: ConnectionFactoryUtils.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jms/connection/ConnectionFactoryUtils.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ConnectionFactoryUtils.java 6 May 2008 09:16:47 -0000 1.9 --- ConnectionFactoryUtils.java 30 Jul 2008 21:18:08 -0000 1.10 *************** *** 87,90 **** --- 87,108 ---- /** + * Return the innermost target Session of the given Session. If the given + * Session is a proxy, it will be unwrapped until a non-proxy Session is + * found. Otherwise, the passed-in Session will be returned as-is. + * @param session the Session proxy to unwrap + * @return the innermost target Session, or the passed-in one if no proxy + * @see SessionProxy#getTargetSession() + */ + public static Session getTargetSession(Session session) { + Session sessionToUse = session; + while (sessionToUse instanceof SessionProxy) { + sessionToUse = ((SessionProxy) sessionToUse).getTargetSession(); + } + return sessionToUse; + } + + + + /** * Determine whether the given JMS Session is transactional, that is, * bound to the current thread by Spring's transaction facilities. |