aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1341251 - in /aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction: Activator.java TransactionManagerService.java
Date Mon, 21 May 2012 22:58:39 GMT
Author: gnodet
Date: Mon May 21 22:58:38 2012
New Revision: 1341251

URL: http://svn.apache.org/viewvc?rev=1341251&view=rev
Log:
[ARIES-809] Allow the transaction manager to be created when there's no specific configuration


Conflicts:

	transaction/transaction-manager/src/main/java/org/apache/aries/transaction/Activator.java

Modified:
    aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/Activator.java
    aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/TransactionManagerService.java

Modified: aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/Activator.java?rev=1341251&r1=1341250&r2=1341251&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/Activator.java
(original)
+++ aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/Activator.java
Mon May 21 22:58:38 2012
@@ -18,82 +18,56 @@ package org.apache.aries.transaction;
 
 import java.util.Dictionary;
 import java.util.Hashtable;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.HashMap;
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
-import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  */
-public class Activator implements BundleActivator, ManagedServiceFactory {
+public class Activator implements BundleActivator, ManagedService {
 
-    private static final Logger log = LoggerFactory.getLogger("org.apache.aries.transaction");
+    public static final String PID = "org.apache.aries.transaction";
+
+    private static final Logger log = LoggerFactory.getLogger(PID);
 
     private BundleContext bundleContext;
-    private Map managers = new HashMap<String, TransactionManagerService>();
+    private TransactionManagerService manager;
 
     public void start(BundleContext bundleContext) throws Exception {
         this.bundleContext = bundleContext;
         Hashtable props = new Hashtable();
-        props.put(Constants.SERVICE_PID, getName());
-        bundleContext.registerService(ManagedServiceFactory.class.getName(), this, props);
-
-        Hashtable ht = new Hashtable();
-        updated("initial", ht);
-    }
-
-    private void set(Hashtable ht, String key) {
-        String o = bundleContext.getProperty(key);
-        if (o == null) {
-            o = System.getenv(key.toUpperCase().replaceAll(".", "_"));
-            if (o == null) {
-                return;
-            }
-        }
-        ht.put(key, o);
+        props.put(Constants.SERVICE_PID, PID);
+        bundleContext.registerService(ManagedService.class.getName(), this, props);
+        updated(props);
     }
 
     public void stop(BundleContext context) throws Exception {
-        for (Iterator w = managers.values().iterator(); w.hasNext();) {
-            try {
-                TransactionManagerService mgr = (TransactionManagerService) w.next();
-                w.remove();
-                mgr.close();
-            } catch (Exception e) {
-                // Ignore
-            }
-        }
-    }
-
-    public String getName() {
-        return "org.apache.aries.transaction";
+        deleted();
     }
 
-    public void updated(String pid, Dictionary properties) throws ConfigurationException
{
-        deleted(pid);
-        TransactionManagerService mgr = new TransactionManagerService(pid, properties, bundleContext);
-        managers.put(pid, mgr);
+    public synchronized void updated(Dictionary properties) throws ConfigurationException
{
+        deleted();
+        manager = new TransactionManagerService(PID, properties, bundleContext);
         try {
-            mgr.start();
+            manager.start();
         } catch (Exception e) {
             log.error(NLS.MESSAGES.getMessage("exception.tx.manager.start"), e);
         }
     }
 
-    public void deleted(String pid) {
-        TransactionManagerService mgr = (TransactionManagerService) managers.remove(pid);
-        if (mgr != null) {
+    public synchronized void deleted() {
+        if (manager != null) {
             try {
-                mgr.close();
+                manager.close();
             } catch (Exception e) {
                 log.error(NLS.MESSAGES.getMessage("exception.tx.manager.stop"), e);
+            } finally {
+                manager = null;
             }
         }
     }

Modified: aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/TransactionManagerService.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/TransactionManagerService.java?rev=1341251&r1=1341250&r2=1341251&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/TransactionManagerService.java
(original)
+++ aries/trunk/transaction/transaction-manager/src/main/java/org/apache/aries/transaction/TransactionManagerService.java
Mon May 21 22:58:38 2012
@@ -83,8 +83,8 @@ public class TransactionManagerService {
         if (transactionTimeout <= 0) {
             throw new ConfigurationException(TRANSACTION_TIMEOUT, NLS.MESSAGES.getMessage("tx.timeout.greaterthan.zero"));
         }
-        // XID factory
-        XidFactory xidFactory = new XidFactoryImpl(pid.getBytes());
+        // the max length of the factory should be 64
+        XidFactory xidFactory = new XidFactoryImpl(pid.substring(0, Math.min(pid.length(),
64)).getBytes());
         // Transaction log
         if (getBool(RECOVERABLE, DEFAULT_RECOVERABLE)) {
             String bufferClassName = getString(HOWL_BUFFER_CLASS_NAME, "org.objectweb.howl.log.BlockLogBuffer");



Mime
View raw message