Author: rmannibucau
Date: Thu Oct  2 12:26:00 2014
New Revision: 1628957

URL: http://svn.apache.org/r1628957
Log:
TOMEE-1371 if using kahadb or leveldb or any persistence adapter force broker 
to be persistent

Modified:
    
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java

Modified: 
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
URL: 
http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java?rev=1628957&r1=1628956&r2=1628957&view=diff
==============================================================================
--- 
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
 (original)
+++ 
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
 Thu Oct  2 12:26:00 2014
@@ -22,6 +22,7 @@ import org.apache.activemq.broker.Broker
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.ra.ActiveMQResourceAdapter;
 import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.PersistenceAdapterFactory;
 import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
 import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
@@ -36,6 +37,7 @@ import org.apache.xbean.propertyeditor.P
 import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.sql.DataSource;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -89,6 +91,8 @@ public class ActiveMQ5Factory implements
 
             if (persistenceAdapter != null) {
                 broker.setPersistenceAdapter(persistenceAdapter);
+                // if user didn't set persistent to true then 
setPersistenceAdapter() alone is ignored so forcing it with the factory
+                broker.setPersistenceFactory(new 
ProvidedPersistenceAdapterPersistenceAdapterFactory(persistenceAdapter));
                 broker.setPersistent(true);
                 tomeeConfig(broker);
             } else {
@@ -316,4 +320,17 @@ public class ActiveMQ5Factory implements
     public Collection<BrokerService> getBrokers() {
         return brokers.values();
     }
+
+    private static class ProvidedPersistenceAdapterPersistenceAdapterFactory 
implements PersistenceAdapterFactory {
+        private final PersistenceAdapter instance;
+
+        public ProvidedPersistenceAdapterPersistenceAdapterFactory(final 
PersistenceAdapter persistenceAdapter) {
+            this.instance = persistenceAdapter;
+        }
+
+        @Override
+        public PersistenceAdapter createPersistenceAdapter() throws 
IOException {
+            return instance;
+        }
+    }
 }


Reply via email to