Upgrade to JMS 2.0 and JCA 1.7

Issue: SPR-13793
This commit is contained in:
Juergen Hoeller
2016-07-05 22:18:19 +02:00
parent bc2c22d51e
commit 355c6f0715
23 changed files with 381 additions and 208 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -37,7 +37,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* JCA 1.5 {@link javax.resource.spi.ResourceAdapter} implementation
* JCA 1.7 {@link javax.resource.spi.ResourceAdapter} implementation
* that loads a Spring {@link org.springframework.context.ApplicationContext},
* starting and stopping Spring-managed beans as part of the ResourceAdapter's
* lifecycle.

View File

@@ -1,5 +1,5 @@
/**
* Integration package that allows for deploying a Spring application context
* as a JCA 1.5 compliant RAR file.
* as a JCA 1.7 compliant RAR file.
*/
package org.springframework.jca.context;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -34,7 +34,7 @@ import org.springframework.transaction.jta.SimpleTransactionFactory;
import org.springframework.transaction.jta.TransactionFactory;
/**
* Abstract base implementation of the JCA 1.5/1.6/1.7
* Abstract base implementation of the JCA 1.7
* {@link javax.resource.spi.endpoint.MessageEndpointFactory} interface,
* providing transaction management capabilities as well as ClassLoader
* exposure for endpoint invocations.
@@ -134,10 +134,20 @@ public abstract class AbstractMessageEndpointFactory implements MessageEndpointF
* returning the bean name as set on this MessageEndpointFactory.
* @see #setBeanName
*/
@Override
public String getActivationName() {
return this.beanName;
}
/**
* Implementation of the JCA 1.7 {@code #getEndpointClass()} method,
* returning {@code} null in order to indicate a synthetic endpoint type.
*/
@Override
public Class<?> getEndpointClass() {
return null;
}
/**
* This implementation returns {@code true} if a transaction manager
* has been specified; {@code false} otherwise.
@@ -166,6 +176,7 @@ public abstract class AbstractMessageEndpointFactory implements MessageEndpointF
* <p>This implementation delegates to {@link #createEndpointInternal()},
* ignoring the specified timeout. It is only here for JCA 1.6 compliance.
*/
@Override
public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) throws UnavailableException {
AbstractMessageEndpoint endpoint = createEndpointInternal();
endpoint.initXAResource(xaResource);
@@ -205,7 +216,7 @@ public abstract class AbstractMessageEndpointFactory implements MessageEndpointF
* This {@code beforeDelivery} implementation starts a transaction,
* if necessary, and exposes the endpoint ClassLoader as current
* thread context ClassLoader.
* <p>Note that the JCA 1.5 specification does not require a ResourceAdapter
* <p>Note that the JCA 1.7 specification does not require a ResourceAdapter
* to call this method before invoking the concrete endpoint. If this method
* has not been called (check {@link #hasBeforeDeliveryBeenCalled()}), the
* concrete endpoint method should call {@code beforeDelivery} and its
@@ -255,7 +266,7 @@ public abstract class AbstractMessageEndpointFactory implements MessageEndpointF
/**
* This {@code afterDelivery} implementation resets the thread context
* ClassLoader and completes the transaction, if any.
* <p>Note that the JCA 1.5 specification does not require a ResourceAdapter
* <p>Note that the JCA 1.7 specification does not require a ResourceAdapter
* to call this method after invoking the concrete endpoint. See the
* explanation in {@link #beforeDelivery}'s javadoc.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -29,7 +29,7 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.util.ReflectionUtils;
/**
* Generic implementation of the JCA 1.5
* Generic implementation of the JCA 1.7
* {@link javax.resource.spi.endpoint.MessageEndpointFactory} interface,
* providing transaction management capabilities for any kind of message
* listener object (e.g. {@link javax.jms.MessageListener} objects or

View File

@@ -26,7 +26,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.SmartLifecycle;
/**
* Generic bean that manages JCA 1.5 message endpoints within a Spring
* Generic bean that manages JCA 1.7 message endpoints within a Spring
* application context, activating and deactivating the endpoint as part
* of the application context's lifecycle.
*

View File

@@ -86,7 +86,7 @@ public class LocalConnectionFactoryBean implements FactoryBean<Object>, Initiali
* by the JCA specification, analogous to a JDBC DataSource and a JPA
* EntityManagerFactory.
* <p>Note that the ManagerConnectionFactory implementation might expect
* a reference to its JCA 1.5 ResourceAdapter, expressed through the
* a reference to its JCA 1.7 ResourceAdapter, expressed through the
* {@link javax.resource.spi.ResourceAdapterAssociation} interface.
* Simply inject the corresponding ResourceAdapter instance into its
* "resourceAdapter" bean property in this case, before passing the

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -30,11 +30,11 @@ import org.springframework.util.Assert;
/**
* {@link org.springframework.beans.factory.FactoryBean} that bootstraps
* the specified JCA 1.5 {@link javax.resource.spi.ResourceAdapter},
* the specified JCA 1.7 {@link javax.resource.spi.ResourceAdapter},
* starting it with a local {@link javax.resource.spi.BootstrapContext}
* and exposing it for bean references. It will also stop the ResourceAdapter
* on context shutdown. This corresponds to 'non-managed' bootstrap in a
* local environment, according to the JCA 1.5 specification.
* local environment, according to the JCA 1.7 specification.
*
* <p>This is essentially an adapter for bean-style bootstrapping of a
* JCA ResourceAdapter, allowing the BootstrapContext or its elements

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -20,10 +20,12 @@ import java.util.Timer;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.UnavailableException;
import javax.resource.spi.XATerminator;
import javax.resource.spi.work.WorkContext;
import javax.resource.spi.work.WorkManager;
import javax.transaction.TransactionSynchronizationRegistry;
/**
* Simple implementation of the JCA 1.5 {@link javax.resource.spi.BootstrapContext}
* Simple implementation of the JCA 1.7 {@link javax.resource.spi.BootstrapContext}
* interface, used for bootstrapping a JCA ResourceAdapter in a local environment.
*
* <p>Delegates to the given WorkManager and XATerminator, if any. Creates simple
@@ -40,6 +42,8 @@ public class SimpleBootstrapContext implements BootstrapContext {
private XATerminator xaTerminator;
private TransactionSynchronizationRegistry transactionSynchronizationRegistry;
/**
* Create a new SimpleBootstrapContext for the given WorkManager,
@@ -60,6 +64,23 @@ public class SimpleBootstrapContext implements BootstrapContext {
this.xaTerminator = xaTerminator;
}
/**
* Create a new SimpleBootstrapContext for the given WorkManager, XATerminator
* and TransactionSynchronizationRegistry.
* @param workManager the JCA WorkManager to use (may be {@code null})
* @param xaTerminator the JCA XATerminator to use (may be {@code null})
* @param transactionSynchronizationRegistry the TransactionSynchronizationRegistry
* to use (may be {@code null})
* @since 5.0
*/
public SimpleBootstrapContext(WorkManager workManager, XATerminator xaTerminator,
TransactionSynchronizationRegistry transactionSynchronizationRegistry) {
this.workManager = workManager;
this.xaTerminator = xaTerminator;
this.transactionSynchronizationRegistry = transactionSynchronizationRegistry;
}
@Override
public WorkManager getWorkManager() {
@@ -79,4 +100,14 @@ public class SimpleBootstrapContext implements BootstrapContext {
return new Timer();
}
@Override
public boolean isContextSupported(Class<? extends WorkContext> workContextClass) {
return false;
}
@Override
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
return this.transactionSynchronizationRegistry;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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.
@@ -35,7 +35,7 @@ import org.springframework.core.task.TaskTimeoutException;
import org.springframework.util.Assert;
/**
* Simple JCA 1.5 {@link javax.resource.spi.work.WorkManager} implementation that
* Simple JCA 1.7 {@link javax.resource.spi.work.WorkManager} implementation that
* delegates to a Spring {@link org.springframework.core.task.TaskExecutor}.
* Provides simple task execution including start timeouts, but without support
* for a JCA ExecutionContext (i.e. without support for imported transactions).

View File

@@ -43,17 +43,17 @@ import org.springframework.util.concurrent.ListenableFutureTask;
/**
* {@link org.springframework.core.task.TaskExecutor} implementation
* that delegates to a JCA 1.5 WorkManager, implementing the
* that delegates to a JCA 1.7 WorkManager, implementing the
* {@link javax.resource.spi.work.WorkManager} interface.
*
* <p>This is mainly intended for use within a JCA ResourceAdapter implementation,
* but may also be used in a standalone environment, delegating to a locally
* embedded WorkManager implementation (such as Geronimo's).
*
* <p>Also implements the JCA 1.5 WorkManager interface itself, delegating all
* <p>Also implements the JCA 1.7 WorkManager interface itself, delegating all
* calls to the target WorkManager. Hence, a caller can choose whether it wants
* to talk to this executor through the Spring TaskExecutor interface or the
* JCA 1.5 WorkManager interface.
* WorkManager interface.
*
* <p>This adapter is also capable of obtaining a JCA WorkManager from JNDI.
* This is for example appropriate on the Geronimo application server, where
@@ -159,7 +159,7 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
}
/**
* Specify a JCA 1.5 WorkListener to apply, if any.
* Specify a JCA WorkListener to apply, if any.
* <p>This shared WorkListener instance will be passed on to the
* WorkManager by all {@link #execute} calls on this TaskExecutor.
*/

View File

@@ -1,5 +1,5 @@
/**
* Convenience classes for scheduling based on the JCA 1.5 WorkManager facility,
* as supported within JCA 1.5 ResourceAdapters.
* Convenience classes for scheduling based on the JCA WorkManager facility,
* as supported within ResourceAdapters.
*/
package org.springframework.jca.work;