Skip to content
Browse files

JBTM-1145 TXFramework Code Tidy Part 2

  • Loading branch information...
1 parent 74b1b7f commit b4747c25fd2e4beda0f8e855da7ffb8cc41c55b9 @paulrobinson paulrobinson committed Dec 17, 2012
Showing with 145 additions and 953 deletions.
  1. +0 −3 txframework/src/main/java/org/jboss/narayana/txframework/api/management/BATxControl.java
  2. +2 −3 txframework/src/main/java/org/jboss/narayana/txframework/impl/Participant.java
  3. +3 −3 txframework/src/main/java/org/jboss/narayana/txframework/impl/ServiceRequestInterceptor.java
  4. +67 −19 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/HandlerFactory.java
  5. +0 −5 ...work/src/main/java/org/jboss/narayana/txframework/impl/handlers/UnsupportedProtocolException.java
  6. +2 −2 ...in/java/org/jboss/narayana/txframework/impl/handlers/restat/client/RestTXRequiredInterceptor.java
  7. +3 −3 ...c/main/java/org/jboss/narayana/txframework/impl/handlers/restat/service/RESTAT2PCParticipant.java
  8. +11 −26 ...work/src/main/java/org/jboss/narayana/txframework/impl/handlers/restat/service/RESTATHandler.java
  9. +5 −6 ...java/org/jboss/narayana/txframework/impl/handlers/restat/service/RestParticipantEndpointImpl.java
  10. +12 −30 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATHandler.java
  11. +0 −72 ...work/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATParticipantRegistry.java
  12. +1 −8 ...k/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATVolatile2PCParticipant.java
  13. +0 −86 ...main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBACoordinatorCompletionHandler.java
  14. +2 −2 .../java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBACoordinatorCompletionParticipant.java
  15. +32 −9 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAHandler.java
  16. +0 −87 ...main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantCompletionHandler.java
  17. +1 −9 .../java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantCompletionParticipant.java
  18. +0 −84 ...work/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantRegistry.java
  19. +1 −11 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBATxControlImpl.java
  20. +0 −140 txframework/src/test/java/org/jboss/narayana/txframework/functional/ATStatefullTest.java
  21. +0 −58 txframework/src/test/java/org/jboss/narayana/txframework/functional/clients/ATStatefullClient.java
  22. +0 −70 txframework/src/test/java/org/jboss/narayana/txframework/functional/common/SimpleHandler.java
  23. +0 −47 txframework/src/test/java/org/jboss/narayana/txframework/functional/interfaces/ATStatefull.java
  24. +0 −3 txframework/src/test/java/org/jboss/narayana/txframework/functional/services/ATBridgeImpl.java
  25. +0 −164 txframework/src/test/java/org/jboss/narayana/txframework/functional/services/ATStatefullService.java
  26. +1 −1 ...c/test/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATVolatile2PCParticipantTest.java
  27. +1 −1 ...a/org/jboss/narayana/txframework/impl/handlers/wsba/WSBACoordinatorCompletionParticipantTest.java
  28. +1 −1 ...a/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantCompletionParticipantTest.java
View
3 txframework/src/main/java/org/jboss/narayana/txframework/api/management/BATxControl.java
@@ -22,7 +22,6 @@
package org.jboss.narayana.txframework.api.management;
-import org.jboss.narayana.txframework.api.configuration.trigger.BALifecycleEvent;
import org.jboss.narayana.txframework.api.exception.TXControlException;
/**
@@ -31,7 +30,5 @@
*/
public interface BATxControl extends TxControl {
- public void readOnly(BALifecycleEvent event) throws TXControlException;
-
public void completed() throws TXControlException;
}
View
5 txframework/src/main/java/org/jboss/narayana/txframework/impl/Participant.java
@@ -38,7 +38,7 @@
protected Map<Class<? extends Annotation>, Method> lifecycleEventMap = new HashMap<Class<? extends Annotation>, Method>();
protected List<Method> visibleMethods;
- private final Map txDataMap;
+ private Map txDataMap;
public Participant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap) throws ParticipantRegistrationException {
@@ -82,14 +82,13 @@ protected Object invoke(Class<? extends Annotation> lifecycleEvent, Object... ar
try {
method.setAccessible(true);
- //todo: detect parameters better. Maybe have a different participant per interface.
if (lifecycleEvent == ConfirmCompleted.class) {
return method.invoke(serviceInvocationMeta.getProxyInstance(), args);
} else {
return method.invoke(serviceInvocationMeta.getProxyInstance());
}
} catch (Exception e) {
- //todo: Log stacktrace to error and throw a SystemException
+ e.printStackTrace();
throw new RuntimeException("Unable to invoke method '" + method.getName() + "' on '" + serviceInvocationMeta.getServiceClass().getName() + "'", e);
} finally {
suspend();
View
6 txframework/src/main/java/org/jboss/narayana/txframework/impl/ServiceRequestInterceptor.java
@@ -45,7 +45,7 @@ public Object intercept(InvocationContext ic) throws Throwable {
Object serviceImpl = ic.getTarget();
Class serviceClass = getServiceClass(serviceImpl);
- ProtocolHandler protocolHandler = HandlerFactory.createInstance(new ServiceInvocationMeta(serviceImpl, serviceClass, serviceMethod));
+ ProtocolHandler protocolHandler = HandlerFactory.getInstance(new ServiceInvocationMeta(serviceImpl, serviceClass, serviceMethod));
Object result;
try {
@@ -63,8 +63,8 @@ private Class getServiceClass(Object serviceImpl) throws Throwable {
if (serviceImpl instanceof TargetInstanceProxy) //Weld proxy
{
- final BeanInfo bi2 = Introspector.getBeanInfo(serviceImpl.getClass().getSuperclass());
- return bi2.getBeanDescriptor().getBeanClass();
+ final BeanInfo beanInfo = Introspector.getBeanInfo(serviceImpl.getClass().getSuperclass());
+ return beanInfo.getBeanDescriptor().getBeanClass();
} else //EJB Proxy
{
return serviceImpl.getClass();
View
86 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/HandlerFactory.java
@@ -22,45 +22,58 @@
package org.jboss.narayana.txframework.impl.handlers;
+import com.arjuna.mw.wst11.BusinessActivityManager;
+import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
import com.arjuna.mw.wst11.UserTransaction;
import com.arjuna.mw.wst11.UserTransactionFactory;
+import com.arjuna.wst.SystemException;
import org.jboss.narayana.txframework.api.annotation.transaction.Compensatable;
import org.jboss.narayana.txframework.api.annotation.transaction.Transactional;
-import org.jboss.narayana.txframework.api.configuration.transaction.CompletionType;
import org.jboss.narayana.txframework.api.exception.TXFrameworkException;
import org.jboss.narayana.txframework.impl.ServiceInvocationMeta;
import org.jboss.narayana.txframework.impl.handlers.restat.service.RESTATHandler;
import org.jboss.narayana.txframework.impl.handlers.wsat.WSATHandler;
-import org.jboss.narayana.txframework.impl.handlers.wsba.WSBACoordinatorCompletionHandler;
-import org.jboss.narayana.txframework.impl.handlers.wsba.WSBAParticipantCompletionHandler;
+import org.jboss.narayana.txframework.impl.handlers.wsba.WSBAHandler;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
public class HandlerFactory {
- //todo: improve the way transaction type is detected.
- public static ProtocolHandler createInstance(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
-
- Compensatable Compensatable = (Compensatable) serviceInvocationMeta.getServiceClass().getAnnotation(Compensatable.class);
- if (Compensatable != null) {
- CompletionType completionType = Compensatable.completionType();
- if (completionType == CompletionType.PARTICIPANT) {
- return new WSBAParticipantCompletionHandler(serviceInvocationMeta);
- } else if (completionType == CompletionType.COORDINATOR) {
- return new WSBACoordinatorCompletionHandler(serviceInvocationMeta);
- } else {
- throw new UnsupportedProtocolException("Unexpected or null completionType");
- }
+ private static final Map<String, ProtocolHandler> protocolHandlerMap = new HashMap<String, ProtocolHandler>();
+
+ public static ProtocolHandler getInstance(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
+
+ String txid = getCurrentTXID() + ":" + serviceInvocationMeta.getServiceClass();
+ ProtocolHandler protocolHandler = protocolHandlerMap.get(txid);
+
+ if (protocolHandler != null) {
+ return protocolHandler;
+ }
+
+ Compensatable compensatable = (Compensatable) serviceInvocationMeta.getServiceClass().getAnnotation(Compensatable.class);
+ if (compensatable != null) {
+ protocolHandler = new WSBAHandler(serviceInvocationMeta, compensatable.completionType());
}
Transactional Transactional = (Transactional) serviceInvocationMeta.getServiceClass().getAnnotation(Transactional.class);
if (Transactional != null) {
if (isWSATTransactionRunning()) {
- return new WSATHandler(serviceInvocationMeta);
+ protocolHandler = new WSATHandler(serviceInvocationMeta);
} else //assume it must be a REST-AT transaction running.
{
- return new RESTATHandler(serviceInvocationMeta);
+ protocolHandler = new RESTATHandler(serviceInvocationMeta);
}
}
- throw new UnsupportedProtocolException("Expected to find a transaction type annotation on '" + serviceInvocationMeta.getServiceClass().getName() + "'");
+
+ if (protocolHandler == null) {
+ throw new UnsupportedProtocolException("Expected to find a transaction type annotation on '" + serviceInvocationMeta.getServiceClass().getName() + "'");
+ }
+
+ protocolHandlerMap.put(txid, protocolHandler);
+ return protocolHandler;
}
private static boolean isWSATTransactionRunning() {
@@ -69,4 +82,39 @@ private static boolean isWSATTransactionRunning() {
return !ut.transactionIdentifier().equals("Unknown");
}
+ private static String getCurrentTXID() throws TXFrameworkException {
+
+ String txid;
+
+ //Try WS-AT
+ txid = UserTransactionFactory.userTransaction().transactionIdentifier();
+ if (!txid.equals("Unknown")) {
+ return txid;
+ }
+
+ //Try WS-BA
+ try {
+ BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
+
+ if (businessActivityManager.currentTransaction() != null) {
+ txid = businessActivityManager.currentTransaction().toString();
+ if (!txid.equals("Unknown")) {
+ return txid;
+ }
+ }
+ } catch (SystemException e) {
+ throw new TXFrameworkException("Error when looking up Business Activity", e);
+ }
+
+ //Try REST-AT
+ HttpServletRequest req = ResteasyProviderFactory.getContextData(HttpServletRequest.class);
+ String enlistUrl = req.getHeader("enlistURL");
+ if (enlistUrl != null) {
+ String[] parts = enlistUrl.split("/");
+ return parts[parts.length - 1];
+ }
+
+ throw new TXFrameworkException("No Transaction detected");
+ }
+
}
View
5 .../main/java/org/jboss/narayana/txframework/impl/handlers/UnsupportedProtocolException.java
@@ -30,9 +30,4 @@ public UnsupportedProtocolException(String message) {
super(message);
}
-
- public UnsupportedProtocolException(String message, Throwable cause) {
-
- super(message, cause);
- }
}
View
4 ...org/jboss/narayana/txframework/impl/handlers/restat/client/RestTXRequiredInterceptor.java
@@ -28,8 +28,8 @@
/**
* @author paul.robinson@redhat.com 09/04/2012
- * <p/>
- * Quick and dirty implementation of a TX annotation for REST-AT, similar to the EJB tx annotations. Needs doing properly and supporting all variations
+ * <p/>
+ * Quick and dirty implementation of a TX annotation for REST-AT, similar to the EJB tx annotations. Needs doing properly and supporting all variations
*/
@Required
@Interceptor
View
6 ...ava/org/jboss/narayana/txframework/impl/handlers/restat/service/RESTAT2PCParticipant.java
@@ -28,13 +28,13 @@
import org.jboss.narayana.txframework.impl.ServiceInvocationMeta;
import org.jboss.narayana.txframework.impl.handlers.ParticipantRegistrationException;
-import java.util.Map;
+import java.util.HashMap;
public class RESTAT2PCParticipant extends org.jboss.narayana.txframework.impl.Participant {
- public RESTAT2PCParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap) throws ParticipantRegistrationException {
+ public RESTAT2PCParticipant(ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException {
- super(serviceInvocationMeta, txDataMap);
+ super(serviceInvocationMeta, new HashMap());
registerEventsOfInterest(Rollback.class, Commit.class, Prepare.class);
}
View
37 .../main/java/org/jboss/narayana/txframework/impl/handlers/restat/service/RESTATHandler.java
@@ -23,10 +23,9 @@
package org.jboss.narayana.txframework.impl.handlers.restat.service;
import org.jboss.narayana.txframework.api.exception.TXFrameworkException;
+import org.jboss.narayana.txframework.impl.Participant;
import org.jboss.narayana.txframework.impl.ServiceInvocationMeta;
-import org.jboss.narayana.txframework.impl.handlers.ParticipantRegistrationException;
import org.jboss.narayana.txframework.impl.handlers.ProtocolHandler;
-import org.jboss.narayana.txframework.impl.handlers.wsat.WSATParticipantRegistry;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import javax.interceptor.InvocationContext;
@@ -38,49 +37,35 @@
*/
public class RESTATHandler implements ProtocolHandler {
- private ServiceInvocationMeta serviceInvocationMeta;
-
- private static final WSATParticipantRegistry participantRegistry = new WSATParticipantRegistry();
+ private Participant participant;
public RESTATHandler(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
- this.serviceInvocationMeta = serviceInvocationMeta;
+ HttpServletRequest req = ResteasyProviderFactory.getContextData(HttpServletRequest.class);
+ String enlistUrl = req.getHeader("enlistURL");
+ UriInfo info = ResteasyProviderFactory.getContextData(UriInfo.class);
+ String txid = getTransactionId(enlistUrl);
- registerParticipant(serviceInvocationMeta);
+ participant = RestParticipantEndpointImpl.enlistParticipant(txid, info, enlistUrl, serviceInvocationMeta);
}
@Override
public Object proceed(InvocationContext ic) throws Exception {
+ participant.resume();
return ic.proceed();
}
@Override
public void notifySuccess() {
- //do nothing
+
+ Participant.suspend();
}
@Override
public void notifyFailure() {
//Todo: ensure transaction rolled back
- }
-
- private void registerParticipant(ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException {
-
- HttpServletRequest req = ResteasyProviderFactory.getContextData(HttpServletRequest.class);
- String enlistUrl = req.getHeader("enlistURL");
- UriInfo info = ResteasyProviderFactory.getContextData(UriInfo.class);
- String txid = getTransactionId(enlistUrl);
-
- synchronized (participantRegistry) {
-
- //Only create participant if there is not already a participant for this ServiceImpl and this transaction
- if (!participantRegistry.isRegistered(txid, serviceInvocationMeta.getServiceClass())) {
- RestParticipantEndpointImpl.enlistParticipant(txid, info, enlistUrl, serviceInvocationMeta);
- //todo: need to remove this when done.
- participantRegistry.register(txid, serviceInvocationMeta.getServiceClass());
- }
- }
+ Participant.suspend();
}
private static String getTransactionId(String enlistUrl) {
View
11 .../jboss/narayana/txframework/impl/handlers/restat/service/RestParticipantEndpointImpl.java
@@ -24,6 +24,7 @@
import org.jboss.jbossts.star.util.TxStatus;
import org.jboss.jbossts.star.util.TxSupport;
+import org.jboss.narayana.txframework.impl.Participant;
import org.jboss.narayana.txframework.impl.ServiceInvocationMeta;
import org.jboss.narayana.txframework.impl.handlers.ParticipantRegistrationException;
@@ -32,7 +33,6 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.net.HttpURLConnection;
-import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@@ -52,7 +52,7 @@
private static Map<Integer, RESTAT2PCParticipant> participants = new ConcurrentHashMap<Integer, RESTAT2PCParticipant>();
- public static void enlistParticipant(String txid, UriInfo info, String enlistUrl, ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException {
+ public static Participant enlistParticipant(String txid, UriInfo info, String enlistUrl, ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException {
//todo: use a @Notnull annotation.
checkNotNull(info, "txid");
@@ -62,7 +62,7 @@ public static void enlistParticipant(String txid, UriInfo info, String enlistUrl
final int pid = currentParticipantId.getAndIncrement();
- RESTAT2PCParticipant participant = new RESTAT2PCParticipant(serviceInvocationMeta, new HashMap());
+ RESTAT2PCParticipant participant = new RESTAT2PCParticipant(serviceInvocationMeta);
participants.put(pid, participant);
participant.resume();
@@ -75,11 +75,10 @@ public static void enlistParticipant(String txid, UriInfo info, String enlistUrl
*/
String linkHeader = txSupport.makeTwoPhaseAwareParticipantLinkHeader(
info.getAbsolutePath().toString(), txid, String.valueOf(pid));
- System.out.println("Service: Enlisting " + linkHeader);
String recoveryUri = txSupport.enlistParticipant(enlistUrl, linkHeader);
- System.out.println("Service: recoveryURI: " + recoveryUri);
- // TODO the recovery URI should be use by the framework to provide recovery support
+ // TODO the recovery URI should be used by the framework to provide recovery support
+ return participant;
}
private static void checkNotNull(Object object, String name) throws ParticipantRegistrationException {
View
42 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATHandler.java
@@ -24,7 +24,6 @@
import com.arjuna.mw.wst11.TransactionManager;
import com.arjuna.mw.wst11.TransactionManagerFactory;
-import com.arjuna.mw.wst11.UserTransactionFactory;
import com.arjuna.wst.*;
import org.jboss.narayana.txframework.api.exception.TXFrameworkException;
import org.jboss.narayana.txframework.impl.Participant;
@@ -39,39 +38,21 @@
public class WSATHandler implements ProtocolHandler {
- private static final WSATParticipantRegistry participantRegistry = new WSATParticipantRegistry();
-
- private static final Map<String, Participant> durableServiceParticipants = new HashMap<String, Participant>();
+ private Durable2PCParticipant durableParticipant;
public WSATHandler(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
try {
- synchronized (participantRegistry) {
- String txid = UserTransactionFactory.userTransaction().toString();
-
- //Only create participant if there is not already a participant for this ServiceImpl and this transaction
- Participant participantToResume;
- if (!participantRegistry.isRegistered(txid, serviceInvocationMeta.getServiceClass())) {
- Map txDataMap = new HashMap();
- Volatile2PCParticipant volatileParticipant = new WSATVolatile2PCParticipant(serviceInvocationMeta, txDataMap, txid);
- Durable2PCParticipant durableParticipant = new WSATDurable2PCParticipant(serviceInvocationMeta, txDataMap);
-
- TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
- String idPrefix = serviceInvocationMeta.getServiceClass().getName();
- transactionManager.enlistForVolatileTwoPhase(volatileParticipant, idPrefix + UUID.randomUUID());
- transactionManager.enlistForDurableTwoPhase(durableParticipant, idPrefix + UUID.randomUUID());
-
- participantRegistry.register(txid, serviceInvocationMeta.getServiceClass());
-
- synchronized (durableServiceParticipants) {
- participantToResume = (Participant) durableParticipant;
- durableServiceParticipants.put(txid, participantToResume);
- }
- } else {
- participantToResume = durableServiceParticipants.get(txid);
- }
- participantToResume.resume();
- }
+
+ Map txDataMap = new HashMap();
+ Volatile2PCParticipant volatileParticipant = new WSATVolatile2PCParticipant(serviceInvocationMeta, txDataMap);
+ durableParticipant = new WSATDurable2PCParticipant(serviceInvocationMeta, txDataMap);
+
+ TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
+ String idPrefix = serviceInvocationMeta.getServiceClass().getName();
+ transactionManager.enlistForVolatileTwoPhase(volatileParticipant, idPrefix + UUID.randomUUID());
+ transactionManager.enlistForDurableTwoPhase(durableParticipant, idPrefix + UUID.randomUUID());
+
} catch (WrongStateException e) {
throw new ParticipantRegistrationException("Transaction was not in a state in which participants can be registered", e);
} catch (UnknownTransactionException e) {
@@ -84,6 +65,7 @@ public WSATHandler(ServiceInvocationMeta serviceInvocationMeta) throws TXFramewo
@Override
public Object proceed(InvocationContext ic) throws Exception {
+ ((Participant) durableParticipant).resume();
return ic.proceed();
}
View
72 .../main/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATParticipantRegistry.java
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.impl.handlers.wsat;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class WSATParticipantRegistry {
-
- private static final Map<String, List<Class>> participantMap = new HashMap<String, List<Class>>();
-
- public WSATParticipantRegistry() {
-
- }
-
- public void register(String txid, Class participant) {
-
- synchronized (participantMap) {
- if (isRegistered(txid, participant)) {
- return;
- }
-
- List<Class> participantList = participantMap.get(txid);
-
- if (participantList == null) {
- participantList = new ArrayList<Class>();
- participantMap.put(txid, participantList);
- }
-
- if (!participantList.contains(participant)) {
- participantList.add(participant);
- }
- }
- }
-
- public void forget(String txid) {
-
- synchronized (participantMap) {
- participantMap.remove(txid);
- }
- }
-
- public boolean isRegistered(String txid, Class participant) {
-
- synchronized (participantMap) {
- List<Class> participantList = participantMap.get(txid);
- return participantList != null && participantList.contains(participant);
- }
- }
-}
View
9 ...in/java/org/jboss/narayana/txframework/impl/handlers/wsat/WSATVolatile2PCParticipant.java
@@ -32,27 +32,20 @@
public class WSATVolatile2PCParticipant extends org.jboss.narayana.txframework.impl.Participant implements Volatile2PCParticipant {
- protected final WSATParticipantRegistry participantRegistry = new WSATParticipantRegistry();
- private String txid;
-
- public WSATVolatile2PCParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap, String txid) throws ParticipantRegistrationException {
+ public WSATVolatile2PCParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap) throws ParticipantRegistrationException {
super(serviceInvocationMeta, txDataMap);
- this.txid = txid;
-
registerEventsOfInterest(PrePrepare.class, PostCommit.class, Rollback.class, Error.class, Unknown.class);
}
public void commit() throws WrongStateException, SystemException {
invoke(PostCommit.class);
- participantRegistry.forget(txid);
}
public void rollback() throws WrongStateException, SystemException {
invoke(Rollback.class);
- participantRegistry.forget(txid);
}
public void error() throws SystemException {
View
86 ...a/org/jboss/narayana/txframework/impl/handlers/wsba/WSBACoordinatorCompletionHandler.java
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.impl.handlers.wsba;
-
-import com.arjuna.mw.wst11.BusinessActivityManager;
-import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
-import com.arjuna.wst.SystemException;
-import com.arjuna.wst.UnknownTransactionException;
-import com.arjuna.wst.WrongStateException;
-import com.arjuna.wst11.BAParticipantManager;
-import org.jboss.narayana.txframework.api.exception.TXFrameworkException;
-import org.jboss.narayana.txframework.impl.Participant;
-import org.jboss.narayana.txframework.impl.ServiceInvocationMeta;
-import org.jboss.narayana.txframework.impl.handlers.ParticipantRegistrationException;
-
-import java.util.HashMap;
-import java.util.UUID;
-
-public class WSBACoordinatorCompletionHandler extends WSBAHandler {
-
- public WSBACoordinatorCompletionHandler(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
-
- super(serviceInvocationMeta);
- }
-
- @Override
- protected BAParticipantManager registerParticipants(ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException {
-
- try {
- BAParticipantManager baParticipantManager = null;
-
- synchronized (participantRegistry) {
- BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
- String txid = businessActivityManager.currentTransaction().toString();
-
- Participant participantToResume;
-
- //Only create participant if there is not already a participant for this ServiceImpl and this transaction
- if (!participantRegistry.isRegistered(txid, serviceInvocationMeta.getServiceClass())) {
-
- WSBACoordinatorCompletionParticipant coordinatorCompletionParticipant = new WSBACoordinatorCompletionParticipant(serviceInvocationMeta, new HashMap(), txid);
- baParticipantManager = businessActivityManager.enlistForBusinessAgreementWithCoordinatorCompletion(coordinatorCompletionParticipant, serviceInvocationMeta.getServiceClass().getName() + UUID.randomUUID());
-
- participantRegistry.register(txid, serviceInvocationMeta.getServiceClass(), baParticipantManager);
-
- synchronized (durableServiceParticipants) {
- participantToResume = coordinatorCompletionParticipant;
- durableServiceParticipants.put(txid, participantToResume);
- }
- } else {
- baParticipantManager = participantRegistry.lookupBAParticipantManager(txid, serviceInvocationMeta.getServiceClass());
- participantToResume = durableServiceParticipants.get(txid);
- }
- participantToResume.resume();
- }
-
- return baParticipantManager;
- } catch (WrongStateException e) {
- throw new ParticipantRegistrationException("Transaction was not in a state in which participants can be registered", e);
- } catch (UnknownTransactionException e) {
- throw new ParticipantRegistrationException("Can't register a participant as the transaction in unknown", e);
- } catch (SystemException e) {
- throw new ParticipantRegistrationException("A SystemException occurred when attempting to register a participant", e);
- }
- }
-}
View
4 ...g/jboss/narayana/txframework/impl/handlers/wsba/WSBACoordinatorCompletionParticipant.java
@@ -34,9 +34,9 @@
public class WSBACoordinatorCompletionParticipant extends WSBAParticipantCompletionParticipant implements
BusinessAgreementWithCoordinatorCompletionParticipant {
- public WSBACoordinatorCompletionParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap, String txid) throws ParticipantRegistrationException {
+ public WSBACoordinatorCompletionParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap) throws ParticipantRegistrationException {
- super(serviceInvocationMeta, txDataMap, txid);
+ super(serviceInvocationMeta, txDataMap);
registerEventsOfInterest(Complete.class);
}
View
41 txframework/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAHandler.java
@@ -22,11 +22,14 @@
package org.jboss.narayana.txframework.impl.handlers.wsba;
+import com.arjuna.mw.wst11.BusinessActivityManager;
+import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.UnknownTransactionException;
import com.arjuna.wst.WrongStateException;
import com.arjuna.wst11.BAParticipantManager;
import org.jboss.narayana.txframework.api.annotation.lifecycle.ba.Completes;
+import org.jboss.narayana.txframework.api.configuration.transaction.CompletionType;
import org.jboss.narayana.txframework.api.exception.TXFrameworkException;
import org.jboss.narayana.txframework.api.management.WSBATxControl;
import org.jboss.narayana.txframework.impl.Participant;
@@ -37,30 +40,50 @@
import javax.interceptor.InvocationContext;
import java.lang.reflect.Method;
import java.util.HashMap;
-import java.util.Map;
+import java.util.UUID;
-public abstract class WSBAHandler implements ProtocolHandler {
+public class WSBAHandler implements ProtocolHandler {
private ServiceInvocationMeta serviceInvocationMeta;
private BAParticipantManager participantManager;
+ private Participant participant;
+
WSBATxControl wsbaTxControl = new WSBATxControlImpl();
- protected final WSBAParticipantRegistry participantRegistry = new WSBAParticipantRegistry();
+ public WSBAHandler(ServiceInvocationMeta serviceInvocationMeta, CompletionType completionType) throws TXFrameworkException {
- protected static final Map<String, Participant> durableServiceParticipants = new HashMap<String, Participant>();
+ this.serviceInvocationMeta = serviceInvocationMeta;
- public WSBAHandler(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
+ try {
+ BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
+
+ if (completionType == CompletionType.COORDINATOR) {
+ WSBACoordinatorCompletionParticipant coordinatorCompletionParticipant = new WSBACoordinatorCompletionParticipant(serviceInvocationMeta, new HashMap());
+ participantManager = businessActivityManager.enlistForBusinessAgreementWithCoordinatorCompletion(coordinatorCompletionParticipant, serviceInvocationMeta.getServiceClass().getName() + UUID.randomUUID());
+ participant = coordinatorCompletionParticipant;
+ } else {
+ WSBAParticipantCompletionParticipant participantCompletionParticipant = new WSBAParticipantCompletionParticipant(serviceInvocationMeta, new HashMap());
+ participantManager = businessActivityManager.enlistForBusinessAgreementWithParticipantCompletion(participantCompletionParticipant,
+ serviceInvocationMeta.getServiceClass().getName() + UUID.randomUUID());
+ participant = participantCompletionParticipant;
+ }
+
+ } catch (WrongStateException e) {
+ throw new ParticipantRegistrationException("Transaction was not in a state in which participants can be registered", e);
+ } catch (UnknownTransactionException e) {
+ throw new ParticipantRegistrationException("Can't register a participant as the transaction in unknown", e);
+ } catch (SystemException e) {
+ throw new ParticipantRegistrationException("A SystemException occurred when attempting to register a participant", e);
+ }
- this.serviceInvocationMeta = serviceInvocationMeta;
- participantManager = registerParticipants(serviceInvocationMeta);
WSBATxControlImpl.resume(participantManager);
}
- protected abstract BAParticipantManager registerParticipants(ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException;
-
public Object proceed(InvocationContext ic) throws Exception {
+ WSBATxControlImpl.resume(participantManager);
+ participant.resume();
return ic.proceed();
}
View
87 ...a/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantCompletionHandler.java
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.impl.handlers.wsba;
-
-import com.arjuna.mw.wst11.BusinessActivityManager;
-import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
-import com.arjuna.wst.SystemException;
-import com.arjuna.wst.UnknownTransactionException;
-import com.arjuna.wst.WrongStateException;
-import com.arjuna.wst11.BAParticipantManager;
-import org.jboss.narayana.txframework.api.exception.TXFrameworkException;
-import org.jboss.narayana.txframework.impl.Participant;
-import org.jboss.narayana.txframework.impl.ServiceInvocationMeta;
-import org.jboss.narayana.txframework.impl.handlers.ParticipantRegistrationException;
-
-import java.util.HashMap;
-import java.util.UUID;
-
-public class WSBAParticipantCompletionHandler extends WSBAHandler {
-
- public WSBAParticipantCompletionHandler(ServiceInvocationMeta serviceInvocationMeta) throws TXFrameworkException {
-
- super(serviceInvocationMeta);
- }
-
- @Override
- protected BAParticipantManager registerParticipants(ServiceInvocationMeta serviceInvocationMeta) throws ParticipantRegistrationException {
-
- try {
- BAParticipantManager baParticipantManager = null;
-
- synchronized (participantRegistry) {
- BusinessActivityManager businessActivityManager = BusinessActivityManagerFactory.businessActivityManager();
- String txid = businessActivityManager.currentTransaction().toString();
-
-
- Participant participantToResume;
-
- //Only create participant if there is not already a participant for this ServiceImpl and this transaction
- if (!participantRegistry.isRegistered(txid, serviceInvocationMeta.getServiceClass())) {
-
- WSBAParticipantCompletionParticipant participantCompletionParticipant = new WSBAParticipantCompletionParticipant(serviceInvocationMeta, new HashMap(), txid);
- baParticipantManager = businessActivityManager.enlistForBusinessAgreementWithParticipantCompletion(participantCompletionParticipant,
- serviceInvocationMeta.getServiceClass().getName() + UUID.randomUUID());
- participantRegistry.register(txid, serviceInvocationMeta.getServiceClass(), baParticipantManager);
-
- synchronized (durableServiceParticipants) {
- participantToResume = participantCompletionParticipant;
- durableServiceParticipants.put(txid, participantToResume);
- }
- } else {
- baParticipantManager = participantRegistry.lookupBAParticipantManager(txid, serviceInvocationMeta.getServiceClass());
- participantToResume = durableServiceParticipants.get(txid);
- }
- participantToResume.resume();
- }
-
- return baParticipantManager;
- } catch (WrongStateException e) {
- throw new ParticipantRegistrationException("Transaction was not in a state in which participants can be registered", e);
- } catch (UnknownTransactionException e) {
- throw new ParticipantRegistrationException("Can't register a participant as the transaction in unknown", e);
- } catch (SystemException e) {
- throw new ParticipantRegistrationException("A SystemException occurred when attempting to register a participant", e);
- }
- }
-}
View
10 ...g/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantCompletionParticipant.java
@@ -39,14 +39,9 @@
public class WSBAParticipantCompletionParticipant extends Participant implements BusinessAgreementWithParticipantCompletionParticipant,
ConfirmCompletedParticipant, Serializable {
- protected final WSBAParticipantRegistry participantRegistry = new WSBAParticipantRegistry();
- private String txid;
-
- public WSBAParticipantCompletionParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap, String txid) throws ParticipantRegistrationException {
+ public WSBAParticipantCompletionParticipant(ServiceInvocationMeta serviceInvocationMeta, Map txDataMap) throws ParticipantRegistrationException {
super(serviceInvocationMeta, txDataMap);
- this.txid = txid;
-
registerEventsOfInterest(Cancel.class, Close.class, Compensate.class, ConfirmCompleted.class, Error.class, Status.class, Unknown.class);
}
@@ -58,19 +53,16 @@ public void error() throws SystemException {
public void close() throws WrongStateException, SystemException {
invoke(Close.class);
- participantRegistry.forget(txid);
}
public void cancel() throws FaultedException, WrongStateException, SystemException {
invoke(Cancel.class);
- participantRegistry.forget(txid);
}
public void compensate() throws FaultedException, WrongStateException, SystemException {
invoke(Compensate.class);
- participantRegistry.forget(txid);
}
public String status() throws SystemException {
View
84 .../main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBAParticipantRegistry.java
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.impl.handlers.wsba;
-
-import com.arjuna.wst11.BAParticipantManager;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class WSBAParticipantRegistry {
-
- protected static final Map<String, Map<Class, BAParticipantManager>> participantMap = new HashMap<String, Map<Class, BAParticipantManager>>();
-
- public WSBAParticipantRegistry() {
-
- }
-
- public void register(String txid, Class participant, BAParticipantManager baParticipantManager) {
-
- synchronized (participantMap) {
- if (isRegistered(txid, participant)) {
- return;
- }
-
- Map<Class, BAParticipantManager> baParticipantManagerMap = participantMap.get(txid);
-
- if (baParticipantManagerMap == null) {
- baParticipantManagerMap = new HashMap<Class, BAParticipantManager>();
- participantMap.put(txid, baParticipantManagerMap);
- }
-
- if (baParticipantManagerMap.get(participant) == null) {
- baParticipantManagerMap.put(participant, baParticipantManager);
- }
- }
- }
-
- public void forget(String txid) {
-
- synchronized (participantMap) {
- participantMap.remove(txid);
- }
- }
-
- public boolean isRegistered(String txid, Class participant) {
-
- synchronized (participantMap) {
- Map<Class, BAParticipantManager> baParticipantManagerMap = participantMap.get(txid);
- return baParticipantManagerMap != null && baParticipantManagerMap.containsKey(participant);
- }
- }
-
- public BAParticipantManager lookupBAParticipantManager(String txid, Class participantClass) {
-
- synchronized (participantMap) {
- Map<Class, BAParticipantManager> baParticipantManagerMap = participantMap.get(txid);
- if (baParticipantManagerMap != null && baParticipantManagerMap.containsKey(participantClass)) {
- return baParticipantManagerMap.get(participantClass);
- }
- return null;
- }
- }
-}
View
12 ...rk/src/main/java/org/jboss/narayana/txframework/impl/handlers/wsba/WSBATxControlImpl.java
@@ -23,13 +23,12 @@
package org.jboss.narayana.txframework.impl.handlers.wsba;
import com.arjuna.wst11.BAParticipantManager;
-import org.jboss.narayana.txframework.api.configuration.trigger.BALifecycleEvent;
import org.jboss.narayana.txframework.api.exception.TXControlException;
import org.jboss.narayana.txframework.api.management.WSBATxControl;
public class WSBATxControlImpl implements WSBATxControl {
- static final ThreadLocal<BAParticipantManager> baParticipantManagerThreadLocal = new ThreadLocal<BAParticipantManager>();
+ private static final ThreadLocal<BAParticipantManager> baParticipantManagerThreadLocal = new ThreadLocal<BAParticipantManager>();
//todo: Need to hook into lifecycle or record it here.
static final ThreadLocal<Boolean> cannotCompleteThreadLocal = new ThreadLocal<Boolean>();
@@ -69,15 +68,6 @@ public void cannotComplete() throws TXControlException {
}
}
- public void readOnly(BALifecycleEvent event) throws TXControlException {
- //todo: what is the BALifecycleEvent for?
- try {
- baParticipantManagerThreadLocal.get().exit();
- } catch (Exception e) {
- throw new TXControlException("Exception when calling 'exit' on participant manager", e);
- }
- }
-
public void completed() throws TXControlException {
try {
View
140 txframework/src/test/java/org/jboss/narayana/txframework/functional/ATStatefullTest.java
@@ -1,140 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.functional;
-
-import com.arjuna.mw.wst11.UserTransaction;
-import com.arjuna.mw.wst11.UserTransactionFactory;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.narayana.txframework.api.annotation.lifecycle.at.Commit;
-import org.jboss.narayana.txframework.api.annotation.lifecycle.at.Prepare;
-import org.jboss.narayana.txframework.functional.clients.ATStatefullClient;
-import org.jboss.narayana.txframework.functional.interfaces.ATStatefull;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.lang.annotation.Annotation;
-import java.util.Arrays;
-import java.util.List;
-
-@RunWith(Arquillian.class)
-public class ATStatefullTest extends BaseFunctionalTest {
-
- private UserTransaction ut;
- private ATStatefull client;
-
- @Before
- public void setupTest() throws Exception {
-
- ut = UserTransactionFactory.userTransaction();
- client = ATStatefullClient.newInstance();
- }
-
- @After
- public void teardownTest() throws Exception {
-
- assertDataAvailable();
- client.clearLogs();
- rollbackIfActive(ut);
- }
-
- @Test
- public void testSimple() throws Exception {
-
- ut.begin();
- client.invoke1();
- client.invoke2();
- ut.commit();
-
- assertOrder(Prepare.class, Commit.class);
- }
-
- /*@Test
- public void testClientDrivenRollback() throws Exception
- {
- ut.begin();
- client.invoke();
- ut.rollback();
-
- //todo: should rollback be called twice? once for volatile and once for durable
- assertOrder(Rollback.class, Rollback.class);
-
- }
-
- @Test(expected = TransactionRolledBackException.class)
- public void testParticipantDrivenRollback() throws Exception
- {
- try
- {
- ut.begin();
- client.invoke(VOTE_ROLLBACK);
- ut.commit();
- }
- catch (TransactionRolledBackException e)
- {
- //todo: should rollback be called twice? once for volatile and once for durable
- assertOrder(Prepare.class, Rollback.class);
- throw e;
- }
- }
-
- @Test
- public void testApplicationException() throws Exception
- {
- try
- {
- ut.begin();
- client.invoke(THROW_APPLICATION_EXCEPTION);
- Assert.fail("Exception should have been thrown by now");
- }
- catch (SOAPFaultException e)
- {
- //todo: can we pass application exceptions over SOAP when using an EJB exposed as a JAX-WS ws?
- System.out.println("Caught exception");
- }
- finally
- {
- ut.rollback();
- }
- //todo: should this cause Rollback?
- assertOrder(Rollback.class, Rollback.class);
- }
-
-*/
-
- private void assertOrder(Class<? extends Annotation>... expectedOrder) {
-
- Assert.assertEquals(Arrays.asList(expectedOrder), client.getEventLog().getEventLog());
- }
-
- private void assertDataAvailable() {
-
- List<Class<? extends Annotation>> log = client.getEventLog().getDataUnavailableLog();
- if (!log.isEmpty()) {
- Assert.fail("One or more lifecycle methods could not access the managed data: " + log.toString());
- }
- }
-
-}
View
58 ...rk/src/test/java/org/jboss/narayana/txframework/functional/clients/ATStatefullClient.java
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.functional.clients;
-
-import com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor;
-import org.jboss.narayana.txframework.functional.interfaces.ATStatefull;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Service;
-import javax.xml.ws.handler.Handler;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ATStatefullClient {
-
- public static ATStatefull newInstance() throws Exception {
-
- URL wsdlLocation = new URL("http://localhost:8080/test/ATStatefullService/AT?wsdl");
- QName serviceName = new QName("http://www.jboss.com/functional/atstatefull/", "ATStatefullService");
- QName portName = new QName("http://www.jboss.com/functional/atstatefull/", "ATStatefull");
-
- Service service = Service.create(wsdlLocation, serviceName);
- ATStatefull client = service.getPort(portName, ATStatefull.class);
-
- /*
- Add client handler chain
- */
- BindingProvider bindingProvider = (BindingProvider) client;
- List<Handler> handlers = new ArrayList<Handler>(1);
- handlers.add(new JaxWSHeaderContextProcessor());
- bindingProvider.getBinding().setHandlerChain(handlers);
-
- return client;
- }
-}
-
View
70 ...amework/src/test/java/org/jboss/narayana/txframework/functional/common/SimpleHandler.java
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.functional.common;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author paul.robinson@redhat.com, 2012-02-06
- */
-public class SimpleHandler implements SOAPHandler<SOAPMessageContext> {
-
- private static int count = 0;
-
- public Set<QName> getHeaders() {
-
- count++;
- System.out.println("SimpleHandler.getHeaders()");
- return new HashSet<QName>();
- }
-
- public boolean handleMessage(SOAPMessageContext soapMessageContext) {
-
- count++;
- System.out.println("SimpleHandler.handleMessage()");
- return true;
- }
-
- public boolean handleFault(SOAPMessageContext soapMessageContext) {
-
- count++;
- System.out.println("SimpleHandler.handleFault()");
- return true;
- }
-
- public void close(MessageContext messageContext) {
-
- count++;
- System.out.println("SimpleHandler.close()");
- }
-
- public static int getCount() {
-
- return count;
- }
-}
View
47 ...ework/src/test/java/org/jboss/narayana/txframework/functional/interfaces/ATStatefull.java
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.narayana.txframework.functional.interfaces;
-
-import org.jboss.narayana.txframework.functional.common.EventLog;
-import org.jboss.narayana.txframework.functional.common.ServiceCommand;
-import org.jboss.narayana.txframework.functional.common.SomeApplicationException;
-
-import javax.ejb.Remote;
-import javax.jws.WebMethod;
-
-@Remote
-public interface ATStatefull {
-
- @WebMethod
- public void invoke1(ServiceCommand... serviceCommands) throws SomeApplicationException;
-
- @WebMethod
- public void invoke2(ServiceCommand... serviceCommands) throws SomeApplicationException;
-
- @WebMethod
- public EventLog getEventLog();
-
- @WebMethod
- public void clearLogs();
-
-}
View
3 ...mework/src/test/java/org/jboss/narayana/txframework/functional/services/ATBridgeImpl.java
@@ -55,8 +55,6 @@
@WebMethod
public void incrementCounter(int how_many) {
- System.out.println("incrementCounter");
-
SimpleEntity entity = getSimpleEntity();
entity.incrimentCounter(how_many);
em.merge(entity);
@@ -65,7 +63,6 @@ public void incrementCounter(int how_many) {
@WebMethod
public int getCounter() {
- System.out.println("getCounter");
SimpleEntity simpleEntity = getSimpleEntity();
if (simpleEntity == null) {
return -1;
View
164 .../src/test/java/org/jboss/narayana/txframework/functional/services/ATStatefullService.java
@@ -1,164 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat, Inc., and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.narayana.txframework.functional.services;
-
-import org.jboss.narayana.txframework.api.annotation.lifecycle.at.*;
-import org.jboss.narayana.txframework.api.annotation.lifecycle.at.Error;
-import org.jboss.narayana.txframework.api.annotation.service.ServiceRequest;
-import org.jboss.narayana.txframework.api.annotation.transaction.Transactional;
-import org.jboss.narayana.txframework.api.configuration.BridgeType;
-import org.jboss.narayana.txframework.functional.common.EventLog;
-import org.jboss.narayana.txframework.functional.common.ServiceCommand;
-import org.jboss.narayana.txframework.functional.common.SomeApplicationException;
-import org.jboss.narayana.txframework.functional.interfaces.ATStatefull;
-
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.inject.Inject;
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding;
-import java.lang.annotation.Annotation;
-import java.util.Map;
-
-/**
- * @author Paul Robinson (paul.robinson@redhat.com)
- */
-@Remote(ATStatefull.class)
-@Transactional(bridgeType = BridgeType.NONE)
-@Stateless
-@WebService(serviceName = "ATStatefullService", portName = "ATStatefull",
- name = "AT", targetNamespace = "http://www.jboss.com/functional/atstatefull/")
-@SOAPBinding(style = SOAPBinding.Style.RPC)
-public class ATStatefullService implements ATStatefull {
-
- @Inject
- private Map TXDataMap;
- private boolean rollback = false;
- private EventLog eventLog = new EventLog();
-
- @WebMethod
- @ServiceRequest
- public void invoke1(ServiceCommand[] serviceCommands) throws SomeApplicationException {
- //Check data is unavailable
- if (TXDataMap.get("data") != null) {
- throw new RuntimeException("data should be clear when invoke1 is called");
- }
-
- TXDataMap.put("data", "data");
- if (isPresent(ServiceCommand.THROW_APPLICATION_EXCEPTION, serviceCommands)) {
- throw new SomeApplicationException("Intentionally thrown Exception");
- }
-
- if (isPresent(ServiceCommand.VOTE_ROLLBACK, serviceCommands)) {
- rollback = true;
- }
- }
-
- @WebMethod
- @ServiceRequest
- public void invoke2(ServiceCommand[] serviceCommands) throws SomeApplicationException {
- //Check data is available
- if (TXDataMap.get("data") == null) {
- throw new RuntimeException("data set in call to 'invoke' was unavailable in call to 'invoke2'");
- }
- if (isPresent(ServiceCommand.THROW_APPLICATION_EXCEPTION, serviceCommands)) {
- throw new SomeApplicationException("Intentionally thrown Exception");
- }
-
- if (isPresent(ServiceCommand.VOTE_ROLLBACK, serviceCommands)) {
- rollback = true;
- }
- }
-
- @WebMethod
- public EventLog getEventLog() {
-
- return eventLog;
- }
-
- @WebMethod
- public void clearLogs() {
-
- eventLog.clear();
- }
-
- @Commit
- @WebMethod(exclude = true)
- public void commit() {
-
- logEvent(Commit.class);
- }
-
- @Rollback
- @WebMethod(exclude = true)
- public void rollback() {
-
- logEvent(Rollback.class);
- }
-
- @Prepare
- @WebMethod(exclude = true)
- public Boolean prepare() {
-
- logEvent(Prepare.class);
- if (rollback) {
- return false;
- } else {
- return true;
- }
- }
-
- @Unknown
- @WebMethod(exclude = true)
- public void unknown() {
-
- logEvent(Unknown.class);
- }
-
- @Error
- @WebMethod(exclude = true)
- public void error() {
-
- logEvent(Error.class);
- }
-
- private boolean isPresent(ServiceCommand expectedServiceCommand, ServiceCommand... serviceCommands) {
-
- for (ServiceCommand foundServiceCommand : serviceCommands) {
- if (foundServiceCommand == expectedServiceCommand) {
- return true;
- }
- }
- return false;
- }
-
- private void logEvent(Class<? extends Annotation> event) {
- //Check data is available
- if (TXDataMap.get("data") == null) {
- eventLog.addDataUnavailable(event);
- }
-
- eventLog.addEvent(event);
- }
-
-}
View
2 ...ava/org/jboss/narayana/txframework/impl/handlers/wsat/WSATVolatile2PCParticipantTest.java
@@ -44,7 +44,7 @@ public void testCallbacks() throws Exception {
LifecycleImpl lifecycle = new LifecycleImpl();
ServiceInvocationMeta serviceInvocationMeta = new ServiceInvocationMeta(lifecycle, LifecycleImpl.class, null);
- WSATVolatile2PCParticipant participant = new WSATVolatile2PCParticipant(serviceInvocationMeta, new HashMap(), null);
+ WSATVolatile2PCParticipant participant = new WSATVolatile2PCParticipant(serviceInvocationMeta, new HashMap());
participant.prepare();
participant.commit();
View
2 ...oss/narayana/txframework/impl/handlers/wsba/WSBACoordinatorCompletionParticipantTest.java
@@ -42,7 +42,7 @@ public void testCallbacks() throws Exception {
LifecycleImpl lifecycle = new LifecycleImpl();
ServiceInvocationMeta serviceInvocationMeta = new ServiceInvocationMeta(lifecycle, LifecycleImpl.class, null);
- WSBACoordinatorCompletionParticipant participant = new WSBACoordinatorCompletionParticipant(serviceInvocationMeta, new HashMap(), null);
+ WSBACoordinatorCompletionParticipant participant = new WSBACoordinatorCompletionParticipant(serviceInvocationMeta, new HashMap());
participant.cancel();
participant.close();
View
2 ...oss/narayana/txframework/impl/handlers/wsba/WSBAParticipantCompletionParticipantTest.java
@@ -42,7 +42,7 @@ public void testCallbacks() throws Exception {
LifecycleImpl lifecycle = new LifecycleImpl();
ServiceInvocationMeta serviceInvocationMeta = new ServiceInvocationMeta(lifecycle, LifecycleImpl.class, null);
- WSBAParticipantCompletionParticipant participant = new WSBAParticipantCompletionParticipant(serviceInvocationMeta, new HashMap(), null);
+ WSBAParticipantCompletionParticipant participant = new WSBAParticipantCompletionParticipant(serviceInvocationMeta, new HashMap());
participant.cancel();
participant.close();

0 comments on commit b4747c2

Please sign in to comment.
Something went wrong with that request. Please try again.