Quantcast

[mule-scm] [mule][25318] branches/mule-3.x: MULE-6701 - adding user persistent store

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[mule-scm] [mule][25318] branches/mule-3.x: MULE-6701 - adding user persistent store

pablo.lagreca
[mule][25318] branches/mule-3.x: MULE-6701 - adding user persistent store

Diff

Modified: branches/mule-3.x/core/src/main/java/org/mule/api/config/MuleProperties.java (25317 => 25318)


--- branches/mule-3.x/core/src/main/java/org/mule/api/config/MuleProperties.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/main/java/org/mule/api/config/MuleProperties.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -133,6 +133,7 @@
     public static final String QUEUE_STORE_DEFAULT_IN_MEMORY_NAME = "_defaultInMemoryQueueStore";
     public static final String QUEUE_STORE_DEFAULT_PERSISTENT_NAME = "_defaultPersistentQueueStore";
     public static final String DEFAULT_USER_OBJECT_STORE_NAME = "_defaultUserObjectStore";
+    public static final String DEFAULT_USER_PERSISTENT_OBJECT_STORE_NAME = "_defaultPersistentUserObjectStore";
     public static final String OBJECT_STORE_MANAGER = "_muleObjectStoreManager";
     public static final String OBJECT_STORE_SIMPLE_MEMORY_NAME = "_simpleMemoryQueueStore";
     public static final String OBJECT_STORE_FILE_NAME = "_fileQueueStore";

Modified: branches/mule-3.x/core/src/main/java/org/mule/config/builders/DefaultsConfigurationBuilder.java (25317 => 25318)


--- branches/mule-3.x/core/src/main/java/org/mule/config/builders/DefaultsConfigurationBuilder.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/main/java/org/mule/config/builders/DefaultsConfigurationBuilder.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -75,6 +75,7 @@
         registry.registerObject(MuleProperties.QUEUE_STORE_DEFAULT_IN_MEMORY_NAME, DefaultObjectStoreFactoryBean.createDefaultInMemoryQueueStore());
         registry.registerObject(MuleProperties.QUEUE_STORE_DEFAULT_PERSISTENT_NAME, DefaultObjectStoreFactoryBean.createDefaultPersistentQueueStore());
         registry.registerObject(MuleProperties.DEFAULT_USER_OBJECT_STORE_NAME, DefaultObjectStoreFactoryBean.createDefaultUserObjectStore());
+        registry.registerObject(MuleProperties.DEFAULT_USER_PERSISTENT_OBJECT_STORE_NAME, DefaultObjectStoreFactoryBean.createDefaultUserPersistentObjectStore());
         registry.registerObject(MuleProperties.OBJECT_STORE_MANAGER, new MuleObjectStoreManager());
         registry.registerObject(MuleProperties.OBJECT_DEFAULT_MESSAGE_PROCESSING_MANAGER, new MuleMessageProcessingManager());
 

Modified: branches/mule-3.x/core/src/main/java/org/mule/util/store/DefaultObjectStoreFactory.java (25317 => 25318)


--- branches/mule-3.x/core/src/main/java/org/mule/util/store/DefaultObjectStoreFactory.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/main/java/org/mule/util/store/DefaultObjectStoreFactory.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -28,4 +28,6 @@
     QueueStore<Serializable> createDefaultPersistentQueueStore();
 
     ObjectStore<Serializable> createDefaultUserObjectStore();
+
+    ObjectStore<Serializable> createDefaultUserPersistentObjectStore();
 }

Modified: branches/mule-3.x/core/src/main/java/org/mule/util/store/DefaultObjectStoreFactoryBean.java (25317 => 25318)


--- branches/mule-3.x/core/src/main/java/org/mule/util/store/DefaultObjectStoreFactoryBean.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/main/java/org/mule/util/store/DefaultObjectStoreFactoryBean.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -39,6 +39,7 @@
      * - {@link org.mule.api.config.MuleProperties#OBJECT_STORE_DEFAULT_IN_MEMORY_NAME}
      * - {@link org.mule.api.config.MuleProperties#OBJECT_STORE_DEFAULT_PERSISTENT_NAME}
      * - {@link org.mule.api.config.MuleProperties#DEFAULT_USER_OBJECT_STORE_NAME}
+     * - {@link org.mule.api.config.MuleProperties#DEFAULT_USER_PERSISTENT_OBJECT_STORE_NAME}
      * - {@link org.mule.api.config.MuleProperties#QUEUE_STORE_DEFAULT_IN_MEMORY_NAME}
      * - {@link org.mule.api.config.MuleProperties#QUEUE_STORE_DEFAULT_PERSISTENT_NAME}
      * @param factory
@@ -77,4 +78,9 @@
     {
         return delegate.createDefaultUserObjectStore();
     }
+
+    public static ObjectStore<Serializable> createDefaultUserPersistentObjectStore()
+    {
+        return delegate.createDefaultUserPersistentObjectStore();
+    }
 }

Modified: branches/mule-3.x/core/src/main/java/org/mule/util/store/MuleDefaultObjectStoreFactory.java (25317 => 25318)


--- branches/mule-3.x/core/src/main/java/org/mule/util/store/MuleDefaultObjectStoreFactory.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/main/java/org/mule/util/store/MuleDefaultObjectStoreFactory.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -47,4 +47,10 @@
     {
         return new SimpleMemoryObjectStore<Serializable>();
     }
+
+    @Override
+    public ObjectStore<Serializable> createDefaultUserPersistentObjectStore()
+    {
+        return new PartitionedPersistentObjectStore<Serializable>();
+    }
 }

Modified: branches/mule-3.x/core/src/main/java/org/mule/util/store/MuleObjectStoreManager.java (25317 => 25318)


--- branches/mule-3.x/core/src/main/java/org/mule/util/store/MuleObjectStoreManager.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/main/java/org/mule/util/store/MuleObjectStoreManager.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -61,6 +61,17 @@
         return internalCreateStore(getBaseStore(isPersistent), name, maxEntries, entryTTL, expirationInterval);
     }
 
+    public <T extends ObjectStore<? extends Serializable>> T getUserObjectStore(String name, boolean isPersistent)
+    {
+        return internalCreateStore(getBaseUserStore(isPersistent), name, 0, 0, 0);
+    }
+
+    public <T extends ObjectStore<? extends Serializable>> T getUserObjectStore(String name, boolean isPersistent, int maxEntries, int entryTTL, int expirationInterval)
+    {
+        return internalCreateStore(getBaseUserStore(isPersistent), name, maxEntries, entryTTL, expirationInterval);
+    }
+
+
     @SuppressWarnings({"unchecked"})
     synchronized public <T extends ObjectStore<? extends Serializable>> T internalCreateStore(ListableObjectStore<? extends Serializable> baseStore, String name,
                                                                                               int maxEntries,
@@ -74,7 +85,7 @@
         T store= null;
         try
         {
-            store = this.<T>getPartitionFromBaseObjectStore(baseStore,name);
+            store = this.getPartitionFromBaseObjectStore(baseStore,name);
         }
         catch (ObjectStoreException e)
         {
@@ -91,6 +102,22 @@
         }
     }
 
+    private <T extends ListableObjectStore<? extends Serializable>> T getBaseUserStore(boolean persistent)
+    {
+        T baseStore;
+        if (persistent)
+        {
+            baseStore = (T) muleContext.getRegistry().lookupObject(
+                    MuleProperties.DEFAULT_USER_PERSISTENT_OBJECT_STORE_NAME);
+        }
+        else
+        {
+            baseStore = (T) muleContext.getRegistry().lookupObject(
+                    MuleProperties.DEFAULT_USER_OBJECT_STORE_NAME);
+        }
+        return baseStore;
+    }
+
     private <T extends ListableObjectStore<? extends Serializable>> T getBaseStore(boolean persistent)
     {
         T baseStore;

Modified: branches/mule-3.x/core/src/test/java/org/mule/util/store/MuleObjectStoreManagerTestCase.java (25317 => 25318)


--- branches/mule-3.x/core/src/test/java/org/mule/util/store/MuleObjectStoreManagerTestCase.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/core/src/test/java/org/mule/util/store/MuleObjectStoreManagerTestCase.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -1,12 +1,3 @@
-/*
- * $Id$
- * --------------------------------------------------------------------------------------
- * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
- *
- * The software in this package is published under the terms of the CPAL v1.0
- * license, a copy of which has been included with this distribution in the
- * LICENSE.txt file.
- */
 package org.mule.util.store;
 
 import static org.hamcrest.core.Is.is;
@@ -37,6 +28,8 @@
     public static final String OBJECT_KEY_VALUE_2 = "anotherValue";
     private final ObjectStoreFactory objectStoreFactory;
 
+    private enum ObjectStoreType {DEFAULT,USER};
+
     public MuleObjectStoreManagerTestCase(ObjectStoreFactory objectStoreFactory)
     {
         this.objectStoreFactory = objectStoreFactory;
@@ -46,8 +39,10 @@
     public static Collection<Object[]> parameters()
     {
         return Arrays.asList(new Object[][] {
-                {new ObjectStoreFactory(false)},
-                {new ObjectStoreFactory(true)}
+                /*{new ObjectStoreFactory(false,ObjectStoreType.DEFAULT)},
+                {new ObjectStoreFactory(true,ObjectStoreType.DEFAULT)},
+                {new ObjectStoreFactory(false,ObjectStoreType.USER)},*/
+                {new ObjectStoreFactory(true,ObjectStoreType.USER)}
         });
     }
 
@@ -123,11 +118,13 @@
     private static class ObjectStoreFactory
     {
         private final boolean isPersistent;
+        private final ObjectStoreType objectStoreType;
         private MuleObjectStoreManager muleObjectStoreManager;
 
-        public ObjectStoreFactory(boolean isPersistent)
+        public ObjectStoreFactory(boolean isPersistent, ObjectStoreType objectStoreType)
         {
             this.isPersistent = isPersistent;
+            this.objectStoreType = objectStoreType;
         }
 
         public void setMuleObjectStoreManager(MuleObjectStoreManager muleObjectStoreManager)
@@ -137,12 +134,26 @@
 
         public <T extends ObjectStore<? extends Serializable>> T createObjectStore(String name)
         {
-            return muleObjectStoreManager.getObjectStore(name,isPersistent);
+            if (objectStoreType.equals(ObjectStoreType.USER))
+            {
+                return muleObjectStoreManager.getUserObjectStore(name,isPersistent);
+            }
+            else
+            {
+                return muleObjectStoreManager.getObjectStore(name,isPersistent);
+            }
         }
 
         public <T extends ObjectStore<? extends Serializable>> T createObjectStore(String name, int maxEntries, int entryTTL, int expirationInterval)
         {
-            return muleObjectStoreManager.getObjectStore(name,isPersistent, maxEntries, entryTTL, expirationInterval);
+            if (objectStoreType.equals(ObjectStoreType.USER))
+            {
+                return muleObjectStoreManager.getUserObjectStore(name,isPersistent, maxEntries, entryTTL, expirationInterval);
+            }
+            else
+            {
+                return muleObjectStoreManager.getObjectStore(name,isPersistent, maxEntries, entryTTL, expirationInterval);
+            }
         }
     }
 

Modified: branches/mule-3.x/modules/spring-config/src/main/resources/default-mule-config.xml (25317 => 25318)


--- branches/mule-3.x/modules/spring-config/src/main/resources/default-mule-config.xml	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/modules/spring-config/src/main/resources/default-mule-config.xml	2013-02-27 21:25:03 UTC (rev 25318)
@@ -54,6 +54,8 @@
 
     <bean name="_defaultUserObjectStore" class="org.mule.util.store.DefaultObjectStoreFactoryBean" factory-method="createDefaultUserObjectStore"/>
 
+    <bean name="_defaultPersistentUserObjectStore" class="org.mule.util.store.DefaultObjectStoreFactoryBean" factory-method="createDefaultUserPersistentObjectStore"/>
+
     <bean name="_muleQueueManager" class="org.mule.util.queue.TransactionalQueueManager"/>
     
     <bean name="_muleObjectStoreManager" class="org.mule.util.store.MuleObjectStoreManager"/>

Modified: branches/mule-3.x/tests/integration/src/test/java/org/mule/test/usecases/routing/response/SerializationOnResposeAggregatorTestCase.java (25317 => 25318)


--- branches/mule-3.x/tests/integration/src/test/java/org/mule/test/usecases/routing/response/SerializationOnResposeAggregatorTestCase.java	2013-02-27 20:55:12 UTC (rev 25317)
+++ branches/mule-3.x/tests/integration/src/test/java/org/mule/test/usecases/routing/response/SerializationOnResposeAggregatorTestCase.java	2013-02-27 21:25:03 UTC (rev 25318)
@@ -66,6 +66,7 @@
         {
             return new TestObjectStore<Serializable>();
         }
+
     }
 
     private static class TestObjectStore<T extends Serializable> extends SimpleMemoryObjectStore

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Loading...