usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [38/50] incubator-usergrid git commit: remove circular refs
Date Mon, 13 Apr 2015 17:46:03 GMT
remove circular refs


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5cc3bf6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5cc3bf6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5cc3bf6e

Branch: refs/heads/USERGRID-536
Commit: 5cc3bf6e51bacee599f3ceae671edde1a95435ca
Parents: 7b229d4
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Apr 8 13:46:38 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Apr 8 13:46:38 2015 -0600

----------------------------------------------------------------------
 .../ApplicationIdCacheFactory.java              | 43 ++++++++++++++++++++
 .../corepersistence/ApplicationIdCacheImpl.java | 17 ++++----
 .../usergrid/corepersistence/CoreModule.java    |  2 +-
 .../corepersistence/CpEntityManagerFactory.java |  2 +-
 4 files changed, 52 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5cc3bf6e/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheFactory.java
new file mode 100644
index 0000000..ac8b43b
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheFactory.java
@@ -0,0 +1,43 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  The ASF licenses this file to You
+ *  * under the Apache License, Version 2.0 (the "License"); you may not
+ *  * use this file except in compliance with the License.
+ *  * You may obtain a copy of the License at
+ *  *
+ *  *     http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing, software
+ *  * distributed under the License is distributed on an "AS IS" BASIS,
+ *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  * See the License for the specific language governing permissions and
+ *  * limitations under the License.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.corepersistence;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import org.apache.usergrid.persistence.EntityManager;
+
+/**
+ * returns instances of cache.
+ */
+@Singleton
+public class ApplicationIdCacheFactory {
+    private final ApplicationIdCacheFig fig;
+    private final ManagerCache cache;
+
+    @Inject
+    public ApplicationIdCacheFactory(ApplicationIdCacheFig fig,ManagerCache cache){
+
+        this.fig = fig;
+        this.cache = cache;
+    }
+    public ApplicationIdCache getInstance(EntityManager managementEntityManager){
+        return new ApplicationIdCacheImpl(managementEntityManager,cache,fig);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5cc3bf6e/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
index 2063fb1..ec98e23 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
@@ -51,7 +51,6 @@ import static org.apache.usergrid.persistence.Schema.PROPERTY_APPLICATION_ID;
  * Implements the org app cache for faster runtime lookups.  These values are immutable,
so this LRU cache can stay
  * full for the duration of the execution
  */
-@Singleton
 public class ApplicationIdCacheImpl implements ApplicationIdCache {
     private static final Logger logger = LoggerFactory.getLogger(ApplicationIdCacheImpl.class);
 
@@ -59,17 +58,15 @@ public class ApplicationIdCacheImpl implements ApplicationIdCache {
     /**
      * Cache the pointer to our root entity manager for reference
      */
-    private final EntityManager rootEm;
-    private final CpEntityManagerFactory emf;
 
     private final LoadingCache<String, Optional<UUID>> appCache;
+    private final EntityManager managementEnityManager;
+    private final ManagerCache managerCache;
 
 
-
-    @Inject
-    public ApplicationIdCacheImpl(final EntityManagerFactory emf, ApplicationIdCacheFig fig)
{
-        this.emf = (CpEntityManagerFactory)emf;
-        this.rootEm = emf.getEntityManager(emf.getManagementAppId());
+    public ApplicationIdCacheImpl(final EntityManager managementEnityManager, ManagerCache
managerCache, ApplicationIdCacheFig fig) {
+        this.managementEnityManager = managementEnityManager;
+        this.managerCache = managerCache;
         appCache = CacheBuilder.newBuilder()
             .maximumSize(fig.getCacheSize())
             .expireAfterWrite(fig.getCacheTimeout(), TimeUnit.MILLISECONDS)
@@ -101,12 +98,12 @@ public class ApplicationIdCacheImpl implements ApplicationIdCache {
 
         UUID value = null;
 
-        EntityCollectionManager ecm = emf.getManagerCache().getEntityCollectionManager(
+        EntityCollectionManager ecm = managerCache.getEntityCollectionManager(
             new ApplicationScopeImpl(
                 new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, Schema.TYPE_APPLICATION
) ) );
 
         try {
-            if ( rootEm.getApplication() == null ) {
+            if ( managementEnityManager.getApplication() == null ) {
                 return Optional.empty();
             }
         } catch ( Exception e ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5cc3bf6e/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 8a8a1e0..7859ffc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -110,6 +110,7 @@ public class CoreModule  extends AbstractModule {
        //        install(new QueueModule());
 
         bind(ManagerCache.class).to( CpManagerCache.class );
+        bind(ApplicationIdCacheFactory.class);
 
         Multibinder<EntityDeleted> entityBinder =
             Multibinder.newSetBinder(binder(), EntityDeleted.class);
@@ -143,7 +144,6 @@ public class CoreModule  extends AbstractModule {
         bind(AllApplicationsObservable.class).to(AllApplicationsObservableImpl.class);
 
         install(new GuicyFigModule(ApplicationIdCacheFig.class));
-        bind(ApplicationIdCache.class).to(ApplicationIdCacheImpl.class);
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5cc3bf6e/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index f5ae1c6..642d555 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -118,7 +118,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.entityIndexFactory = injector.getInstance(EntityIndexFactory.class);
         this.managerCache = injector.getInstance( ManagerCache.class );
         this.metricsFactory = injector.getInstance( MetricsFactory.class );
-        this.applicationIdCache = injector.getInstance(ApplicationIdCache.class);
+        this.applicationIdCache = injector.getInstance(ApplicationIdCacheFactory.class).getInstance(getManagementEntityManager());
     }
 
 


Mime
View raw message