[jboss-svn-commits] JBL Code SVN: r13126 - in labs/jbosstm/workspace/maciej.machulak/code/bridge: org/jboss/txbridge/ba and 13 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 5 19:40:21 EDT 2007


Author: maciej.machulak
Date: 2007-07-05 19:40:21 -0400 (Thu, 05 Jul 2007)
New Revision: 13126

Added:
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensationMethod.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/DummyCompensationManager.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/Testable.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestIdentifierFactory.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestUidGetter.java
Modified:
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/BATransactionManager.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/SingleTransactionManager.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensatedBy.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/aspect/JaxWSBAProcessingAspect.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManager.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManagerImpl.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationData.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationDataReturn.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescription.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescriptionImpl.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/TaskDescription.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/BAServiceVisitor.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/CompensationManagement.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/ServiceInformationManager.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/IdentifierFactory.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/UidGetter.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA1.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/Participant.java
   labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/ParticipantCompletionParticipantBA.java
Log:
Significant changes. Finally the code works smoothly after refactoring:)

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/BATransactionManager.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/BATransactionManager.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/BATransactionManager.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -4,7 +4,6 @@
 import org.jboss.txbridge.ba.data.MethodInformation;
 import org.jboss.txbridge.ba.data.ServiceDescription;
 import org.jboss.txbridge.ba.data.TaskDescription;
-import org.jboss.txbridge.ba.data.IdentificationType;
 import org.jboss.txbridge.ba.compensation.CompensationService;
 import org.jboss.txbridge.ba.id.IdentifierFactory;
 import org.jboss.txbridge.ba.id.UidIdentifierFactory;
@@ -94,10 +93,10 @@
      * @param method is the method which is being invoked.
      * @return the task identifier for this method.
      */
-    public synchronized TaskDescription handleTransaction(Method method)
+    public synchronized TaskDescription handleInvocation(Method method)
     {
-        log.info("handleTransaction()");
-        String txId = null;
+        log.info("handleInvocation()");
+        String txId = null; // Transaction identifier
         try
         {
             // Get the transaction identifier
@@ -115,17 +114,19 @@
             if (!serviceManager.knowsAboutByName(className+methodName))
             {
                 log.info("Service unknown... processing...");
-                ServiceDescription sd = BAServiceVisitor.processMethod(method);
-                serviceManager.storeServiceDescription(sd);
+                serviceManager.storeServiceDescription(BAServiceVisitor.processMethod(method));
             }
             else
             {
                 log.info("Service already known...");
             }
+
+            // Get the service identifier
             log.info("Getting service ID.");
             String serviceId = serviceManager.getServiceId(className+methodName);
             log.info("Service ID: " + serviceId);
 
+            // Get a new task identifier
             log.info("Getting new task identifier...");
             IdentifierFactory idf = new UidIdentifierFactory();
             String taskId = idf.getIdentifier();
@@ -135,9 +136,9 @@
             SingleTransactionManager stm = singleTransactionManagers.get(txId);
             if (stm == null)
             {
-                log.info("Transaction unknown...");
+                log.info("This is a new transaction...");
 
-                // Create a new single transaction manager
+                // Create a new single transaction manager for this transaction
                 stm = new SingleTransactionManager(txId);
 
                 // Remember it
@@ -180,6 +181,45 @@
         singleTransactionManager.compensate();
     }
 
+    /**
+     * This method completes the invocation of a service within a scope of a transaction. It is responsible
+     * for remembering necessary arguments that were passed to this service and a return object (those objects
+     * may be used later if compensation action is being invoked).
+     *
+     * @param taskDesc describes the task.
+     * @param arguments is the list of the arguments for this service.
+     * @param returnObject is the return object of this service.
+     */
+    public synchronized void completeInvocation(TaskDescription taskDesc, Object[] arguments, Object returnObject)
+    {
+        log.info("completeInvocation()");
+
+        // Get reference to the single transaction manager
+        SingleTransactionManager stm = singleTransactionManagers.get(taskDesc.getTxId());
+        if (stm == null)
+        {
+            return;
+        }
+        
+        try
+        {
+            stm.completeInvocation(taskDesc,arguments,returnObject);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+
+
+
+
+
+
     public synchronized void handleTheTransaction(MethodInformation methodInformation,String taskId)
     {
         log.info("handleTheTransaction()");
@@ -279,39 +319,8 @@
         }
     }
 
-    public synchronized void completeTransaction(TaskDescription taskDesc, Object[] arguments, Object returnObject)
-    {
-        log.info("completeTransaction()");
 
-        // Get the service description
-        ServiceDescription sd = serviceManager.getServiceById(taskDesc.getServiceId());
 
-        // Remember necessary additional data (annotated with @BAParam and @BAResult)
-
-        // 1) Get reference to the participant
-        String taskId = taskDesc.getTaskId();
-        Participant participant = taskDesc.getParticipant();
-
-        // 2) Get the annotation values
-        Object[] annotations = sd.getOriginalParameterAnnotation();
-
-        // 3) Remember parameters
-        for (int i = 0; i < annotations.length ; i++)
-        {
-            if (annotations[i] != null)
-            {
-                participant.put(taskId,annotations[i],arguments[i]);
-            }
-        }
-
-        // 4) Remember the return object if necessary
-        Object returnId = sd.getOriginalReturnId();
-        if (returnId != null)
-        {
-            participant.put(taskId,returnId,returnObject);
-        }
-    }
-
     public synchronized void completeTheTransaction()
     {
         log.info("completeTheTransaction()");

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/SingleTransactionManager.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/SingleTransactionManager.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/SingleTransactionManager.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -8,10 +8,12 @@
 import java.util.*;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentHashMap;
+import java.io.Serializable;
 
 import org.jboss.txbridge.ba.data.MethodInformation;
 import org.jboss.txbridge.ba.data.CompensationDataReturn;
 import org.jboss.txbridge.ba.data.TaskDescription;
+import org.jboss.txbridge.ba.data.ServiceDescription;
 import org.jboss.txbridge.ba.participant.ParticipantCompletionParticipantBA;
 import org.jboss.txbridge.ba.participant.CoordinatorCompletionParticipantBA;
 import org.jboss.txbridge.ba.participant.Participant;
@@ -20,12 +22,13 @@
 import org.jboss.txbridge.ba.compensation.CompensationService;
 import org.jboss.txbridge.ba.helper.ServiceInformationManager;
 import org.jboss.txbridge.ba.exception.TaskAssociationFailedException;
+import org.jboss.txbridge.ba.annotation.BAServiceType;
 import org.apache.log4j.Logger;
 
 /**
  * Author: Maciej Machulak
  */
-public class SingleTransactionManager
+public class SingleTransactionManager implements Serializable
 {
     // Logger
     Logger log = Logger.getLogger(SingleTransactionManager.class);
@@ -34,7 +37,7 @@
     BusinessActivityManager businessActivityManager;
 
     // Service information manager
-    private ServiceInformationManager serviceManager;
+    ServiceInformationManager serviceInformationManager;
 
     // Transaction identifier
     private String txId;
@@ -88,7 +91,7 @@
         businessActivityManager = BusinessActivityManager.getBusinessActivityManager();
 
         // Get reference to the service information manager
-        serviceManager = ServiceInformationManager.getSingletonInstance();
+        serviceInformationManager = ServiceInformationManager.getSingletonInstance();
 
         // Initialise the list of tasks for this transaction
         taskList = new Stack<String>();
@@ -104,7 +107,7 @@
 
 
 
-        
+
         methodIdList = new HashMap<String,String>();
         methodList = new HashMap<String, MethodInformation>();
         participant2List = new HashMap<String, ParticipantCompletionParticipantBA>();
@@ -153,20 +156,24 @@
         Participant participant = serviceParticipantMapping.get(serviceId);
         if ( participant == null )
         {
-            log.info("Participant unknown. Creating new one.");
+            log.info("Participant unknown.");
 
             // Create a new participant
+            log.info("Creating new participant...");
             participant = new ParticipantCompletionParticipantBA1(txId,serviceId);
 
             // Remember the participant
+            log.info("Storing reference to the participant...");
             serviceParticipantMapping.put(serviceId,participant);
 
             // Enlist the participant
             try
             {
+                log.info("Enlisting participant...");
                 BAParticipantManager participantManager = businessActivityManager.enlistForBusinessAgreementWithParticipantCompletion((BusinessAgreementWithParticipantCompletionParticipant)participant,new Uid().toString());
 
                 // Remember the participant manager for this specific participant
+                log.info("Storing reference to the participant manager...");
                 participantManagerMapping.put(participant,participantManager);
             }
             catch (Exception e)
@@ -184,11 +191,62 @@
         {
             e.printStackTrace();
         }
-        
+
         return participant;
 
     }
 
+    public void completeInvocation(TaskDescription taskDesc, Object[] arguments, Object returnObject) throws SystemException, UnknownTransactionException, WrongStateException {
+        log.info("completeInvocation()");
+
+        // Get the service description
+        ServiceDescription sd = serviceInformationManager.getServiceById(taskDesc.getServiceId());
+        if (sd == null)
+        {
+            return;
+        }
+
+        // Remember necessary additional data (annotated with @BAParam and @BAResult)
+
+        // 1) Get reference to the participant
+        String taskId = taskDesc.getTaskId();
+        Participant participant = taskDesc.getParticipant();
+
+        // 2) Get the annotation values
+        Object[] annotations = sd.getOriginalParameterAnnotation();
+
+        // 3) Remember parameters
+        for (int i = 0; i < annotations.length ; i++)
+        {
+            if (annotations[i] != null)
+            {
+                participant.put(taskId,annotations[i],arguments[i]);
+            }
+        }
+
+        // 4) Remember the return object if necessary
+        Object returnId = sd.getOriginalReturnId();
+        if (returnId != null)
+        {
+            participant.put(taskId,returnId,returnObject);
+        }
+
+        // Get reference to the BA Participant Manager
+        log.info("Checking for BA Participant Manager");
+        BAParticipantManager baParticipantManager = participantManagerMapping.get(participant);
+        if ( baParticipantManager != null )
+        {
+            if (sd.getServiceType().equals(BAServiceType.MODIFY))
+            {
+                baParticipantManager.completed();
+            }
+            if (sd.getServiceType().equals(BAServiceType.READONLY))
+            {
+                baParticipantManager.exit();
+            }
+        }
+    }
+
     /**
      * This method executes compensation for all tasks that are associated with this transaction.
      * Compensation happens in reverse order.
@@ -219,8 +277,8 @@
                 }
             }
         }
-        
-        
+
+
     }
 
     public void start(MethodInformation methodInfo,String taskId)

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensatedBy.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensatedBy.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensatedBy.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -13,7 +13,9 @@
 {
     public String value();
     public String methodClass() default "";
-    public String url() default "";
-    public String port() default "";
+    public String wsdl() default "";
+    public String address() default "";
+    public String namespace() default "";
+    public String serviceName() default "";
     public BACompensationType type() default BACompensationType.RETURN_VALUE;
 }
\ No newline at end of file

Added: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensationMethod.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensationMethod.java	                        (rev 0)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/annotation/BACompensationMethod.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -0,0 +1,13 @@
+package org.jboss.txbridge.ba.annotation;
+
+/**
+ * Author: Maciej Machulak
+ */
+public enum BACompensationMethod
+{
+    LOCAL,
+    UDII,
+    CDII,
+    RMI,
+    CORBA
+}

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/aspect/JaxWSBAProcessingAspect.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/aspect/JaxWSBAProcessingAspect.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/aspect/JaxWSBAProcessingAspect.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -2,9 +2,11 @@
 
 import org.apache.log4j.Logger;
 import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.joinpoint.FieldReadInvocation;
+import org.jboss.aop.joinpoint.FieldWriteInvocation;
 import org.jboss.txbridge.ba.BATransactionManager;
-import org.jboss.txbridge.ba.annotation.BAAgreementType;
-import org.jboss.txbridge.ba.data.ServiceDescription;
+import org.jboss.txbridge.ba.compensation.CompensationManager;
+import org.jboss.txbridge.ba.compensation.DummyCompensationManager;
 import org.jboss.txbridge.ba.data.TaskDescription;
 import org.jboss.txbridge.ba.helper.ServiceInformationManager;
 import org.jboss.txbridge.ba.helper.CompensationManagement;
@@ -22,48 +24,61 @@
     // BA Transaction Manager
     private static BATransactionManager baTransactionManager = BATransactionManager.getSingletonInstance();
 
-    // Service information manager
-    private static ServiceInformationManager serviceManager = ServiceInformationManager.getSingletonInstance();
+    // Dummy Compensation Manager
+    private static CompensationManager dummyCompensationManager = new DummyCompensationManager();
 
+    /**
+     * Advice that processes methods execution according to the BA management.
+     *
+     * @param invocation is the method's invocation.
+     * @return the object returned by the method.
+     * @throws Throwable ...
+     */
     public Object process(MethodInvocation invocation) throws Throwable
     {
 
         log.info("process()");
 
         // #### IMPLEMENTATION SPECIFIC PART - BEGIN
-        // 1) Method
-        // 2) Arguments
-        // 3) Target Object
         Method method = invocation.getMethod();
+        log.info("Method: " + method.getName());
         Object[] arguments = invocation.getArguments();
+        log.info("No of arguments: " + arguments.length);
         Object targetObject = invocation.getTargetObject();
         // #### IMPLEMENTATION SPECIFIC PART - END
 
 
 
-        // Handle the transaction
-        TaskDescription taskDesc = baTransactionManager.handleTransaction(method,arguments);
+        // Handle the invocation
+        log.info("Handling invocation...");
+        TaskDescription taskDesc = baTransactionManager.handleInvocation(method);
 
         // Inject the compensation manager
         targetObject = CompensationManagement.injectCompensationManager(targetObject,taskDesc);
 
-
-
-
         // #### IMPLEMENTATION SPECIFIC PART - BEGIN
         // Invoke the service
         invocation.setTargetObject(targetObject);
         Object returnObject = invocation.invokeNext();
         // #### IMPLEMENTATION SPECIFIC PART - END
 
-
-
         log.info("No exception... proceeding...");
 
         // Complete the execution within this transaction
-        baTransactionManager.completeTransaction(taskDesc,returnObject);
+        baTransactionManager.completeInvocation(taskDesc,arguments,returnObject);
 
         return returnObject;
     }
 
+    public Object access(FieldReadInvocation invocation) throws Throwable
+    {
+       return dummyCompensationManager;
+    }
+
+    public Object access(FieldWriteInvocation invocation) throws Throwable
+    {
+       throw new RuntimeException("Setting a @BACompensationManagement variable is illegal.");
+    }
+
+
 }

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManager.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManager.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManager.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -7,4 +7,7 @@
  */
 public interface CompensationManager
 {
+    public void put(Object objectId, Object object);
+
+    public Object get(Object objectId);
 }

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManagerImpl.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManagerImpl.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/CompensationManagerImpl.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -13,7 +13,7 @@
  * data is stored and retrieved. An object of this class is injected into the business logic so
  * that the programmer does not have to worry about anything.
  */
-public class CompensationManagerImpl
+public class CompensationManagerImpl implements CompensationManager
 {
     // Logger
     private static Logger log = Logger.getLogger(CompensationManagerImpl.class);

Added: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/DummyCompensationManager.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/DummyCompensationManager.java	                        (rev 0)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/compensation/DummyCompensationManager.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -0,0 +1,29 @@
+package org.jboss.txbridge.ba.compensation;
+
+/**
+ * @author: Maciej P. Machulak
+ * @date: Jul 5, 2007
+ */
+public class DummyCompensationManager implements CompensationManager
+{
+    /**
+     * This is a dummy method that... does nothing.
+     *
+     * @param objectId is the ID of the object.
+     * @param object is the object itself.
+     */
+    public void put(Object objectId, Object object)
+    {       
+    }
+
+    /**
+     * This method does nothing - simply returns null.
+     *
+     * @param objectId is the object id.
+     * @return returns always null.
+     */
+    public Object get(Object objectId)
+    {
+        return null;
+    }
+}

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationData.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationData.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationData.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -5,11 +5,12 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentHashMap;
+import java.io.Serializable;
 
 /**
  * Author: Maciej Machulak
  */
-public abstract class CompensationData
+public abstract class CompensationData implements Serializable
 {
     ConcurrentMap<Object,Object> compensationData;
 

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationDataReturn.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationDataReturn.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/CompensationDataReturn.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -13,20 +13,11 @@
     // Logger
     private static Logger log = Logger.getLogger(CompensationDataReturn.class);
 
-    // Return object + mapping
-    private String returnName;
     private Object returnObject;
 
-    private Object[] parameterObjects;
-
-    // Primary compensation objects - parameters
-    private Map<String,Object> primaryObjects;
-
-    // Secondary compensation objects - temporary objects
-    private Map<String,Object> secondaryObjects;
-
     public CompensationDataReturn()
     {
+        super();
         primaryObjects = new HashMap<String,Object>();
         secondaryObjects = new HashMap<String,Object>();
         parameterObjects = null;

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescription.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescription.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescription.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -3,6 +3,7 @@
 import org.jboss.txbridge.ba.annotation.BAServiceType;
 import org.jboss.txbridge.ba.annotation.BAAgreementType;
 import org.jboss.txbridge.ba.annotation.BACompensationType;
+import org.jboss.txbridge.ba.annotation.BACompensationMethod;
 
 import java.util.Map;
 import java.io.Serializable;
@@ -24,6 +25,10 @@
 
     void setCompensationType(BACompensationType compensationType);
 
+    public BACompensationMethod getCompensationMethod();
+
+    public void setCompensationMethod(BACompensationMethod compensationMethod);
+
     Class getOriginalClass();
 
     void setOriginalClass(Class originalClass);

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescriptionImpl.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescriptionImpl.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/ServiceDescriptionImpl.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -3,6 +3,7 @@
 import org.jboss.txbridge.ba.annotation.BAServiceType;
 import org.jboss.txbridge.ba.annotation.BAAgreementType;
 import org.jboss.txbridge.ba.annotation.BACompensationType;
+import org.jboss.txbridge.ba.annotation.BACompensationMethod;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -31,6 +32,7 @@
     private BAServiceType serviceType;
     private BAAgreementType agreementType;
     private BACompensationType compensationType;
+    private BACompensationMethod compensationMethod;
     private IdentificationType identificationType;
 
     /**
@@ -90,6 +92,16 @@
         return originalClass;
     }
 
+    public BACompensationMethod getCompensationMethod()
+    {
+        return compensationMethod;
+    }
+
+    public void setCompensationMethod(BACompensationMethod compensationMethod)
+    {
+        this.compensationMethod = compensationMethod;
+    }
+
     public void setOriginalClass(Class originalClass)
     {
         this.originalClass = originalClass;
@@ -165,7 +177,6 @@
         this.compensationReturnType = compensationReturnType;
     }
 
-
     public Class[] getOriginalParameterTypes()
     {
         return originalParameterTypes;
@@ -226,4 +237,5 @@
     {
         this.originalParameterAnnotation = originalParameterAnnotation;
     }
+
 }
\ No newline at end of file

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/TaskDescription.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/TaskDescription.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/data/TaskDescription.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -44,6 +44,21 @@
     }
 
 
+    @Override
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        sb.append("TxID: ");
+        sb.append(txId);
+        sb.append(" TaskID: ");
+        sb.append(taskId);
+        sb.append(" ServiceID: ");
+        sb.append(serviceId);
+        sb.append(" Participant ref: ");
+        sb.append(participant);
+        return sb.toString();
+    }
+
     public boolean equals(Object o)
     {
         if (this == o)

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/BAServiceVisitor.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/BAServiceVisitor.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/BAServiceVisitor.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -138,6 +138,9 @@
         BACompensatedBy baComp = method.getAnnotation(BACompensatedBy.class);
         if (baComp != null)
         {
+            // TODO: TEMPORARY
+            serviceDescription.setCompensationMethod(BACompensationMethod.LOCAL);
+
             log.info("BACompensatedBy annotation present!");
             String compensationMethodName = baComp.value();
             log.info("Compensation method: " + compensationMethodName);
@@ -283,7 +286,7 @@
                         throw new MethodIncorrectlyAnnotatedException("BAResult annotation uses text identifier.");
                     }
                     log.info("Return identifier: " + returnName);
-                    serviceDescription.setOriginalReturnName(returnName);
+                    serviceDescription.setOriginalReturnId(returnName);
                 }
             }
             else

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/CompensationManagement.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/CompensationManagement.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/CompensationManagement.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -2,6 +2,7 @@
 
 import org.jboss.txbridge.ba.annotation.BACompensationManagement;
 import org.jboss.txbridge.ba.compensation.CompensationManagerImpl;
+import org.jboss.txbridge.ba.compensation.CompensationManager;
 import org.jboss.txbridge.ba.data.TaskDescription;
 import org.apache.log4j.Logger;
 
@@ -19,6 +20,8 @@
     public static synchronized Object injectCompensationManager(Object targetObject, TaskDescription taskDesc)
     {
         // Inject the transaction identifier
+        log.info("injectCompensationManager()");
+        log.info(taskDesc);
         try
         {
             Class clazz = targetObject.getClass();
@@ -29,12 +32,16 @@
                 BACompensationManagement cm = singleField.getAnnotation(BACompensationManagement.class);
                 if (cm != null)
                 {
-                    log.info("CompensationManager found...");
-                    log.info("Creating new one...");
-                    log.info("taskId: " + taskDesc.getTaskId());
-                    singleField.setAccessible(true);
-                    singleField.set(targetObject,new CompensationManagerImpl(taskDesc));
-                    return targetObject;
+                    if (singleField.getType().equals(CompensationManager.class))
+                    {
+                        log.info("CompensationManager object found...");
+                        log.info("Setting field...");
+                        singleField.setAccessible(true);
+                        log.info("Injecting...");
+                        singleField.set(targetObject,new CompensationManagerImpl(taskDesc));
+                        log.info("Returning...");
+                        return targetObject;
+                    }
                 }
             }
         }

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/ServiceInformationManager.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/ServiceInformationManager.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/helper/ServiceInformationManager.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -4,6 +4,7 @@
 import org.jboss.txbridge.ba.data.ServiceDescription;
 import org.jboss.txbridge.ba.id.IdentifierFactory;
 import org.jboss.txbridge.ba.id.RandomIdentifierFactory;
+import org.jboss.txbridge.ba.id.UidIdentifierFactory;
 
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -36,7 +37,7 @@
     private ServiceInformationManager()
     {
         log.info("constructor()");
-        idf = new RandomIdentifierFactory();
+        idf = new UidIdentifierFactory();
         methodServiceIdMapping = new ConcurrentHashMap<String,String>();
         serviceDescriptions = new ConcurrentHashMap<String,ServiceDescription>();
     }
@@ -88,7 +89,7 @@
     {
         log.info("storeServiceDescription()");
         methodServiceIdMapping.putIfAbsent(completeMethodName,serviceId);
-        serviceDescriptions.putIfAbsent(completeMethodName,serviceDescription);
+        serviceDescriptions.putIfAbsent(serviceId,serviceDescription);
     }
 
     /**

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/IdentifierFactory.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/IdentifierFactory.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/IdentifierFactory.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -1,5 +1,7 @@
 package org.jboss.txbridge.ba.id;
 
+import test.Testable;
+
 /**
  * @author: Maciej Machulak
  * @date:
@@ -10,12 +12,12 @@
 {
     UniqueValueGetter uvg;
 
+    @Testable
     protected IdentifierFactory()
     {
     }
 
-
-
+    @Testable
     public String getIdentifier()
     {
         return uvg.getUniqueValue();

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/UidGetter.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/UidGetter.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/id/UidGetter.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -1,6 +1,7 @@
 package org.jboss.txbridge.ba.id;
 
 import com.arjuna.ats.arjuna.common.Uid;
+import test.Testable;
 
 /**
  * @author: Maciej P. Machulak
@@ -8,6 +9,7 @@
  */
 public class UidGetter implements UniqueValueGetter
 {
+    @Testable
     public String getUniqueValue()
     {
         return new Uid().toString();

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -7,6 +7,15 @@
  */
 public class CoordinatorCompletionParticipantBA extends Participant implements BusinessAgreementWithCoordinatorCompletionParticipant
 {
+    /**
+     * Constructor.
+     *
+     * @param txId      is the transaction identifier.
+     * @param serviceId is the service identifier.
+     */
+    public CoordinatorCompletionParticipantBA(String txId, String serviceId) {
+        super(txId, serviceId);
+    }
 
     public void close() throws WrongStateException, SystemException
     {

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA1.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA1.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/CoordinatorCompletionParticipantBA1.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -7,6 +7,15 @@
  */
 public class CoordinatorCompletionParticipantBA1 extends Participant implements BusinessAgreementWithCoordinatorCompletionParticipant
 {
+    /**
+     * Constructor.
+     *
+     * @param txId      is the transaction identifier.
+     * @param serviceId is the service identifier.
+     */
+    public CoordinatorCompletionParticipantBA1(String txId, String serviceId) {
+        super(txId, serviceId);
+    }
 
     public void close() throws WrongStateException, SystemException
     {

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/Participant.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/Participant.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/Participant.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -10,6 +10,7 @@
 import org.jboss.txbridge.ba.exception.CompensationActionUnsuccessfulException;
 import org.jboss.txbridge.ba.exception.TaskAssociationFailedException;
 import org.jboss.txbridge.ba.BATransactionManager;
+import org.jboss.txbridge.ba.annotation.BACompensationMethod;
 
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -27,31 +28,40 @@
 public abstract class Participant
 {
     // Service Information Manager
-    private ServiceInformationManager sim = null;
+    protected ServiceInformationManager sim = null;
 
     // ServiceExecutor
     protected ServiceExecutor se = null;
 
     // BA Manager
-    static BATransactionManager baTransactionManager = null;
+    protected static BATransactionManager baTransactionManager = null;
 
     // Transaction identifier
-    String txId = null;
+    protected String txId = null;
 
     // Service identifier
-    String serviceId = null;
+    protected String serviceId = null;
 
     // List of all tasks
-    private List<String> taskList = null;
+    protected List<String> taskList = null;
 
     // Mapping (taskId,compensation_data)
-    private ConcurrentMap<String,CompensationData> compensationData = null;
+    protected ConcurrentMap<String,CompensationData> compensationData = null;
 
     /**
-     * Main constructor.
+     * Constructor.
+     *
+     * @param txId is the transaction identifier.
+     * @param serviceId is the service identifier.
      */
-    public Participant()
+    public Participant(String txId,String serviceId)
     {
+        // Remember transaction identifier
+        this.txId = txId;
+
+        // Remember the service identifier
+        this.serviceId = serviceId;
+
         // Get reference to the service information manager
         sim = ServiceInformationManager.getSingletonInstance();
 
@@ -63,22 +73,7 @@
 
         // Get reference to the BA Transaction Manager
         baTransactionManager = BATransactionManager.getSingletonInstance();
-    }
 
-    /**
-     * Constructor.
-     *
-     * @param txId is the transaction identifier.
-     * @param serviceId is the service identifier.
-     */
-    public Participant(String txId,String serviceId)
-    {
-        // Remember transaction identifier
-        this.txId = txId;
-
-        // Remember the service identifier
-        this.serviceId = serviceId;
-
     }
 
     /**
@@ -136,6 +131,9 @@
      */
     public CompensationData associateTask(String taskId) throws TaskAssociationFailedException
     {
+
+        System.out.println("associateTask()");
+
         // Check correctness of parameters
         if (taskList.contains(taskId))
         {
@@ -179,7 +177,7 @@
 
         // If the compensation is remote than use remote executor. Otherwise
         // use the local one.
-        if (serviceDescription.getOriginalClass() != null)
+        if (serviceDescription.getCompensationMethod().equals(BACompensationMethod.UDII))
         {
             // Use the remote executor.
             se = new RemoteServiceExecutor(txId,taskId);

Modified: labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/ParticipantCompletionParticipantBA.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/ParticipantCompletionParticipantBA.java	2007-07-05 23:01:56 UTC (rev 13125)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/org/jboss/txbridge/ba/participant/ParticipantCompletionParticipantBA.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -40,6 +40,7 @@
 
     public ParticipantCompletionParticipantBA(String txId,String taskId, MethodInformation method)
     {
+        super("1","1");
         log.info("constructor()");
         log.info("txId: " + txId);
         log.info("taskId: " + taskId);

Added: labs/jbosstm/workspace/maciej.machulak/code/bridge/test/Testable.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/test/Testable.java	                        (rev 0)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/test/Testable.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -0,0 +1,17 @@
+package test;
+
+import java.lang.annotation.*;
+
+/**
+ * Created Thu Jul 05 23:01:13 BST 2007 <br/>
+ *
+ * @author JUnit 4 Synchronizer
+ * @version $Revision: $ <br/> $Date: $ <br/> $Author: $
+ */
+ at Retention(value = RetentionPolicy.SOURCE)
+ at Target( { ElementType.CONSTRUCTOR, ElementType.METHOD } )
+public @interface Testable {
+
+    String value() default "";
+
+} // Testable annotation type

Added: labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestIdentifierFactory.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestIdentifierFactory.java	                        (rev 0)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestIdentifierFactory.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -0,0 +1,41 @@
+package test.org.jboss.txbridge.ba.id;
+
+import org.jboss.txbridge.ba.id.IdentifierFactory;
+        import org.junit.*;
+        import static org.junit.Assert.*;
+
+/**
+ * @author: Maciej P. Machulak
+ * @date: Jul 5, 2007
+ */
+public class TestIdentifierFactory {
+
+    public TestIdentifierFactory() {
+    } // constructor
+
+    @BeforeClass
+    public static void unitSetup() {
+    } // unitSetup()
+
+    @AfterClass
+    public static void unitCleanup() {
+    } // unitCleanup()
+
+    @Before
+    public void methodSetup() {
+    } // methodSetup()
+
+    @After
+    public void methodCleanup() {
+    } // methodCleanup()
+
+    @Test
+    public void testIdentifierFactory() {
+        fail(); // @todo - implement
+    } // testIdentifierFactory()
+
+    @Test
+    public void testGetIdentifier() {
+        fail(); // @todo - implement
+    } // testGetIdentifier()
+}

Added: labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestUidGetter.java
===================================================================
--- labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestUidGetter.java	                        (rev 0)
+++ labs/jbosstm/workspace/maciej.machulak/code/bridge/test/org/jboss/txbridge/ba/id/TestUidGetter.java	2007-07-05 23:40:21 UTC (rev 13126)
@@ -0,0 +1,42 @@
+package test.org.jboss.txbridge.ba.id;
+
+import org.jboss.txbridge.ba.id.UidGetter;
+        import org.junit.*;
+        import static org.junit.Assert.*;
+
+/**
+ * @author: Maciej P. Machulak
+ * @date: Jul 5, 2007
+ */
+public class TestUidGetter 
+{
+    public TestUidGetter()
+    {
+    } // constructor
+
+    @BeforeClass
+    public static void unitSetup()
+    {
+    } // unitSetup()
+
+    @AfterClass
+    public static void unitCleanup()
+    {
+    } // unitCleanup()
+
+    @Before
+    public void methodSetup()
+    {
+    } // methodSetup()
+
+    @After
+    public void methodCleanup()
+    {
+    } // methodCleanup()
+
+    @Test
+    public void testGetUniqueValue()
+    {
+        fail(); // @todo - implement
+    } // testGetUniqueValue()
+}




More information about the jboss-svn-commits mailing list