EL container integration; support for contextual objects; removal of deprecated Spring 2.0 functionality; Java 5 code style

This commit is contained in:
Juergen Hoeller
2008-11-20 02:10:53 +00:00
parent 369821dd66
commit 347f34c68a
281 changed files with 6120 additions and 9903 deletions

View File

@@ -258,9 +258,7 @@ public class GenericMessageEndpointManager implements InitializingBean, Lifecycl
getResourceAdapter().endpointActivation(getMessageEndpointFactory(), getActivationSpec());
}
catch (ResourceException ex) {
IllegalStateException wrapped = new IllegalStateException("Could not activate message endpoint");
wrapped.initCause(ex);
throw wrapped;
throw new IllegalStateException("Could not activate message endpoint", ex);
}
this.running = true;
}

View File

@@ -19,13 +19,12 @@ package org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.CollectionFactory;
import org.springframework.core.JdkVersion;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
@@ -55,7 +54,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
* Canonical value held in cache to indicate no transaction attribute was
* found for this method, and we don't need to look again.
*/
private final static Object NULL_TRANSACTION_ATTRIBUTE = new Object();
private final static TransactionAttribute NULL_TRANSACTION_ATTRIBUTE = new DefaultTransactionAttribute();
/**
@@ -70,7 +69,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
* <p>As this base class is not marked Serializable, the cache will be recreated
* after serialization - provided that the concrete subclass is Serializable.
*/
final Map attributeCache = CollectionFactory.createConcurrentMapIfPossible(16);
final Map<Object, TransactionAttribute> attributeCache = new ConcurrentHashMap<Object, TransactionAttribute>();
/**
@@ -139,9 +138,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
// If the target class is null, the method will be unchanged.
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
// If we are dealing with method with generic parameters, find the original method.
if (JdkVersion.isAtLeastJava15()) {
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
}
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
// First try is the method in the target class.
TransactionAttribute txAtt = findTransactionAttribute(specificMethod);

View File

@@ -161,7 +161,7 @@ public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute i
@Override
public String toString() {
StringBuffer result = getDefinitionDescription();
StringBuilder result = getDefinitionDescription();
if (this.rollbackRules != null) {
for (Iterator it = this.rollbackRules.iterator(); it.hasNext();) {
RollbackRuleAttribute rule = (RollbackRuleAttribute) it.next();

View File

@@ -143,7 +143,6 @@ import org.springframework.util.StringUtils;
* @see #setTransactionManagerName
* @see #setTransactionManager
* @see JotmFactoryBean
* @see WebSphereTransactionManagerFactoryBean
* @see WebLogicJtaTransactionManager
*/
public class JtaTransactionManager extends AbstractPlatformTransactionManager

View File

@@ -1,117 +0,0 @@
/*
* Copyright 2002-2007 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.transaction.jta;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.transaction.TransactionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.transaction.TransactionSystemException;
/**
* {@link org.springframework.beans.factory.FactoryBean} that retrieves
* the JTA TransactionManager for IBM's WebSphere application servers
* (versions 5.1, 6.0 and 6.1).
*
* <p>Uses WebSphere's static accessor methods to obtain the internal JTA
* TransactionManager. This is known to work reliably on all tested WebSphere
* versions; however, access to the internal TransactionManager facility
* is not officially supported by IBM.
*
* <p>In combination with Spring's JtaTransactionManager, this FactoryBean
* can be used to enable transaction suspension (PROPAGATION_REQUIRES_NEW,
* PROPAGATION_NOT_SUPPORTED) on WebSphere:
*
* <pre>
* &lt;bean id="wsJtaTm" class="org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean"/&gt;
*
* &lt;bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"&gt;
* &lt;property name="transactionManager ref="wsJtaTm"/&gt;
* &lt;/bean&gt;</pre>
*
* Note that Spring's JtaTransactionManager will continue to use the JTA
* UserTransaction for standard transaction demarcation, as defined by
* standard J2EE. It will only use the provided WebSphere TransactionManager
* in case of actual transaction suspension needs. <i>If you do not require
* transaction suspension in the first place, do not bother with this FactoryBean.</i>
*
* <p><b>NOTE: On recent WebSphere 6.0.x and 6.1.x versions, this class has
* been superseded by the {@link WebSphereUowTransactionManager} class, which
* uses IBM's official UOWManager API facility for transaction suspension.</b>
* The WebSphereUowTransactionManager class is a direct replacement for a
* standard JtaTransactionManager definition, without further configuration.
*
* @author Juergen Hoeller
* @since 21.01.2004
* @see JtaTransactionManager#setTransactionManager
* @see com.ibm.ws.Transaction.TransactionManagerFactory#getTransactionManager
* @see WebSphereUowTransactionManager
*/
public class WebSphereTransactionManagerFactoryBean implements FactoryBean {
private static final String FACTORY_CLASS_5_1 = "com.ibm.ws.Transaction.TransactionManagerFactory";
protected final Log logger = LogFactory.getLog(getClass());
private final TransactionManager transactionManager;
/**
* This constructor retrieves the WebSphere TransactionManager factory class,
* so we can get access to the JTA TransactionManager.
*/
public WebSphereTransactionManagerFactoryBean() throws TransactionSystemException {
try {
// Using the thread context class loader for compatibility with the WSAD test server.
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(FACTORY_CLASS_5_1);
Method method = clazz.getMethod("getTransactionManager", (Class[]) null);
this.transactionManager = (TransactionManager) method.invoke(null, (Object[]) null);
}
catch (ClassNotFoundException ex) {
throw new TransactionSystemException(
"Could not find WebSphere 5.1/6.0/6.1 TransactionManager factory class", ex);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
"WebSphere's TransactionManagerFactory.getTransactionManager method failed", ex.getTargetException());
}
catch (Exception ex) {
throw new TransactionSystemException(
"Could not access WebSphere's TransactionManagerFactory.getTransactionManager method", ex);
}
}
public Object getObject() {
return this.transactionManager;
}
public Class getObjectType() {
return this.transactionManager.getClass();
}
public boolean isSingleton() {
return true;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* 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.
@@ -17,7 +17,6 @@
package org.springframework.transaction.jta;
import java.util.List;
import javax.naming.NamingException;
import com.ibm.websphere.uow.UOWSynchronizationRegistry;
@@ -65,12 +64,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
*
* <p>This transaction manager is compatible with WebSphere 7.0 as well as recent
* WebSphere 6.0.x and 6.1.x versions. Check the documentation for your specific
* WebSphere version to find out whether UOWManager support is available. If it
* is not available, consider using Spring's standard {@link JtaTransactionManager}
* class, if necessary specifying the {@link WebSphereTransactionManagerFactoryBean}
* as "transactionManager" through the corresponding bean property. However, note
* that transaction suspension is not officially supported in such a scenario
* (despite it being known to work properly).
* WebSphere version to find out whether UOWManager support is available.
*
* <p>The default JNDI location for the UOWManager is "java:comp/websphere/UOWManager".
* If the location happens to differ according to your WebSphere documentation,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* 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.
@@ -252,20 +252,20 @@ public class DefaultTransactionDefinition implements TransactionDefinition, Seri
* Return an identifying description for this transaction definition.
* <p>Available to subclasses, for inclusion in their <code>toString()</code> result.
*/
protected final StringBuffer getDefinitionDescription() {
StringBuffer desc = new StringBuffer();
desc.append(constants.toCode(new Integer(this.propagationBehavior), PREFIX_PROPAGATION));
desc.append(',');
desc.append(constants.toCode(new Integer(this.isolationLevel), PREFIX_ISOLATION));
protected final StringBuilder getDefinitionDescription() {
StringBuilder result = new StringBuilder();
result.append(constants.toCode(this.propagationBehavior, PREFIX_PROPAGATION));
result.append(',');
result.append(constants.toCode(this.isolationLevel, PREFIX_ISOLATION));
if (this.timeout != TIMEOUT_DEFAULT) {
desc.append(',');
desc.append(PREFIX_TIMEOUT + this.timeout);
result.append(',');
result.append(PREFIX_TIMEOUT).append(this.timeout);
}
if (this.readOnly) {
desc.append(',');
desc.append(READ_ONLY_MARKER);
result.append(',');
result.append(READ_ONLY_MARKER);
}
return desc;
return result;
}
}