usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [07/35] usergrid git commit: Fix new lock manager wiring issues in services layer.
Date Mon, 25 Jan 2016 21:17:59 GMT
Fix new lock manager wiring issues in services layer.


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

Branch: refs/heads/USERGRID-1047
Commit: 8ddc7d98841ffd8ee3d225c1ce07f92f82f64810
Parents: 71f3274
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Thu Jan 14 13:28:52 2016 -0800
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Thu Jan 14 13:28:52 2016 -0800

----------------------------------------------------------------------
 .../org/apache/usergrid/CoreITSetupImpl.java    |   4 +
 .../cassandra/ManagementServiceImpl.java        |  36 ++---
 .../services/guice/ServiceModuleImpl.java       |   3 +
 .../resources/usergrid-services-context.xml     | 131 ++++++++++---------
 4 files changed, 87 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/8ddc7d98/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
index 6f9b384..64b001c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
@@ -20,6 +20,8 @@ package org.apache.usergrid;
 import com.google.inject.Injector;
 import org.apache.usergrid.cassandra.SpringResource;
 import org.apache.usergrid.corepersistence.service.ApplicationService;
+import org.apache.usergrid.locking.Lock;
+import org.apache.usergrid.locking.LockManager;
 import org.apache.usergrid.mq.QueueManagerFactory;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManagerFactory;
@@ -41,6 +43,7 @@ public class CoreITSetupImpl implements CoreITSetup, TestEntityIndex {
     protected EntityManagerFactory emf;
     protected QueueManagerFactory qmf;
     protected CassandraService cassandraService;
+    protected LockManager lockManager;
 
     protected SpringResource springResource;
 
@@ -52,6 +55,7 @@ public class CoreITSetupImpl implements CoreITSetup, TestEntityIndex {
         emf = springResource.getBean( EntityManagerFactory.class );
         qmf = springResource.getBean( QueueManagerFactory.class );
         injector = springResource.getBean(Injector.class);
+        lockManager = injector.getInstance(LockManager.class);
 
 
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8ddc7d98/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index a4259f7..4111870 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -65,7 +65,6 @@ import org.apache.usergrid.security.shiro.utils.SubjectUtils;
 import org.apache.usergrid.security.tokens.TokenCategory;
 import org.apache.usergrid.security.tokens.TokenInfo;
 import org.apache.usergrid.security.tokens.TokenService;
-import org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl;
 import org.apache.usergrid.security.tokens.exceptions.TokenException;
 import org.apache.usergrid.services.*;
 import org.apache.usergrid.utils.*;
@@ -155,17 +154,25 @@ public class ManagementServiceImpl implements ManagementService {
     @Autowired
     protected MailUtils mailUtils;
 
-    @Autowired
-    protected Injector injector;
-
     protected EncryptionService encryptionService;
 
     protected CacheFactory cacheFactory;
 
+    protected AggregationServiceFactory aggregationServiceFactory;
+
+    protected ApplicationService service;
+
 
 
     /** Must be constructed with a CassandraClientPool. */
-    public ManagementServiceImpl() {
+    public ManagementServiceImpl(Injector injector) {
+
+        // Use the injector to get our guice dependencies
+        this.lockManager = injector.getInstance(LockManager.class);
+        this.cacheFactory = injector.getInstance( CacheFactory.class );
+        this.aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
+        this.service = injector.getInstance(ApplicationService.class);
+
     }
 
     @Autowired
@@ -260,16 +267,6 @@ public class ManagementServiceImpl implements ManagementService {
     }
 
 
-    public LockManager getLockManager() {
-        return lockManager;
-    }
-
-
-    @Autowired
-    public void setLockManager( LockManager lockManager ) {
-        this.lockManager = lockManager;
-    }
-
 
     /** @param encryptionService the encryptionService to set */
     @Autowired
@@ -1664,7 +1661,7 @@ public class ManagementServiceImpl implements ManagementService {
 
         EntityManager em = emf.getEntityManager( smf.getManagementAppId() );
 
-        
+
         if(em.getCollection(organization.getUuid() ,"users",Query.fromQL( "select * where
uuid ="+user.getUuid() ),Level.IDS ).size() >0){
             if(logger.isDebugEnabled()) {
                 logger.debug( "Found value: {} already in collection", user.getName() );
@@ -1757,9 +1754,6 @@ public class ManagementServiceImpl implements ManagementService {
                     + ")</a> created a new application named " + applicationName, null
);
         }
 
-        if ( cacheFactory == null ) {
-            cacheFactory = injector.getInstance( CacheFactory.class );
-        }
         ScopedCache scopedCache = cacheFactory.getScopedCache(
             new CacheScope( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, "application"
)));
         scopedCache.invalidate();
@@ -1830,7 +1824,6 @@ public class ManagementServiceImpl implements ManagementService {
 
     @Override
     public long getApplicationSize(final UUID applicationId) {
-        AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
         AggregationService aggregationService = aggregationServiceFactory.getAggregationService();
         ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId);
         return aggregationService.getApplicationSize(applicationScope);
@@ -1838,7 +1831,6 @@ public class ManagementServiceImpl implements ManagementService {
 
     @Override
     public Map<String,Long> getEachCollectionSize(final UUID applicationId) {
-        AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
         AggregationService aggregationService = aggregationServiceFactory.getAggregationService();
         ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId);
         return aggregationService.getEachCollectionSize(applicationScope);
@@ -1846,7 +1838,6 @@ public class ManagementServiceImpl implements ManagementService {
 
     @Override
     public long getCollectionSize(final UUID applicationId, final String collectionName)
{
-        AggregationServiceFactory aggregationServiceFactory = injector.getInstance(AggregationServiceFactory.class);
         AggregationService aggregationService = aggregationServiceFactory.getAggregationService();
         ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId);
         return aggregationService.getSize(applicationScope,
@@ -3249,7 +3240,6 @@ public class ManagementServiceImpl implements ManagementService {
             throw new IllegalArgumentException("Can't delete from management app");
         }
 
-        ApplicationService service = injector.getInstance(ApplicationService.class);
         return service.deleteAllEntities(CpNamingUtils.getApplicationScope(applicationId),limit);
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8ddc7d98/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
b/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
index 5ce19e0..58b301a 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
@@ -24,6 +24,7 @@ import com.google.inject.TypeLiteral;
 import com.google.inject.multibindings.Multibinder;
 import org.apache.shiro.authc.SimpleAuthenticationInfo;
 import org.apache.usergrid.corepersistence.ServiceModule;
+import org.apache.usergrid.locking.guice.LockModule;
 import org.apache.usergrid.management.AppInfoMigrationPlugin;
 import org.apache.usergrid.persistence.cache.CacheFactory;
 import org.apache.usergrid.persistence.cache.impl.CacheFactoryImpl;
@@ -50,6 +51,8 @@ public class ServiceModuleImpl extends AbstractModule implements ServiceModule
{
     @Override
     protected void configure() {
 
+        install(new LockModule());
+
         //Seems weird, aren't we just binding the factory to the exact same factory when
it goes to look for it?
         final Multibinder<MigrationPlugin> plugins = Multibinder.newSetBinder( binder(),
MigrationPlugin.class );
         plugins.addBinding().to(AppInfoMigrationPlugin.class);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8ddc7d98/stack/services/src/main/resources/usergrid-services-context.xml
----------------------------------------------------------------------
diff --git a/stack/services/src/main/resources/usergrid-services-context.xml b/stack/services/src/main/resources/usergrid-services-context.xml
index 02e01ad..c41080d 100644
--- a/stack/services/src/main/resources/usergrid-services-context.xml
+++ b/stack/services/src/main/resources/usergrid-services-context.xml
@@ -16,115 +16,118 @@
     limitations under the License.
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
-	xsi:schemaLocation="
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
 	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
 	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
 	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
 
-	<context:component-scan base-package="org.apache.usergrid.services"  />
+    <context:component-scan base-package="org.apache.usergrid.services"/>
 
 
-	<import resource="classpath:/usergrid-core-context.xml" />
+    <import resource="classpath:/usergrid-core-context.xml"/>
 
-	<!--  scan for security -->
-	<context:component-scan base-package="org.apache.usergrid.security.crypto"  />
+    <!--  scan for security -->
+    <context:component-scan base-package="org.apache.usergrid.security.crypto"/>
 
     <!--
     <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager"/>
     -->
     <bean id="cacheManager" class="org.apache.usergrid.security.shiro.ShiroCacheManager">
-        <property name="properties" ref="properties" />
+        <property name="properties" ref="properties"/>
     </bean>
 
-	<bean id="realm" class="org.apache.usergrid.security.shiro.Realm">
-        <property name="name" value="realm" />
-        <property name="cacheManager" ref="cacheManager" />
-	</bean>
+    <bean id="realm" class="org.apache.usergrid.security.shiro.Realm">
+        <property name="name" value="realm"/>
+        <property name="cacheManager" ref="cacheManager"/>
+    </bean>
 
-	<bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager">
-		<property name="realm" ref="realm" />
-	</bean>
+    <bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager">
+        <property name="realm" ref="realm"/>
+    </bean>
 
-	<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"
/>
+    <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
 
-	<bean
-		class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-		<property name="staticMethod"
-			value="org.apache.shiro.SecurityUtils.setSecurityManager" />
-		<property name="arguments" ref="securityManager" />
-	</bean>
+    <bean
+        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+        <property name="staticMethod"
+                  value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
+        <property name="arguments" ref="securityManager"/>
+    </bean>
 
-	<bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecutor"/>
+    <bean id="taskExecutor" class="org.springframework.core.task.SyncTaskExecutor"/>
 
-	<bean id="tokenService" class="org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl">
+    <bean id="tokenService" class="org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl">
         <property name="cassandraService" ref="cassandraService"/>
         <property name="entityManagerFactory" ref="entityManagerFactory"/>
-            </bean>
-
-	<bean id="managementService" class="org.apache.usergrid.management.cassandra.ManagementServiceImpl"
>
-		<property name="saltProvider" ref="saltProvider"/>
-	</bean>
-
-	<bean id="saltProvider" class="org.apache.usergrid.security.salt.NoOpSaltProvider" />
+    </bean>
 
     <bean id="injector"
           class="org.apache.usergrid.corepersistence.GuiceFactory">
     </bean>
 
-	<bean id="serviceManagerFactory" class="org.apache.usergrid.services.ServiceManagerFactory">
-		<constructor-arg ref="entityManagerFactory" />
-		<constructor-arg ref="properties" />
-		<constructor-arg ref="schedulerService"/>
+    <bean id="managementService" class="org.apache.usergrid.management.cassandra.ManagementServiceImpl">
+        <property name="saltProvider" ref="saltProvider"/>
+        <constructor-arg ref="injector"/>
+    </bean>
+
+    <bean id="saltProvider" class="org.apache.usergrid.security.salt.NoOpSaltProvider"/>
+
+
+
+    <bean id="serviceManagerFactory" class="org.apache.usergrid.services.ServiceManagerFactory">
+        <constructor-arg ref="entityManagerFactory"/>
+        <constructor-arg ref="properties"/>
+        <constructor-arg ref="schedulerService"/>
         <constructor-arg ref="injector"/>
         <constructor-arg ref="queueManagerFactory"/>
-	</bean>
+    </bean>
 
-	<bean id="applicationCreator"
-		class="org.apache.usergrid.management.cassandra.ApplicationCreatorImpl">
-		<constructor-arg ref="entityManagerFactory" />
-		<constructor-arg ref="managementService" />
-	</bean>
+    <bean id="applicationCreator"
+          class="org.apache.usergrid.management.cassandra.ApplicationCreatorImpl">
+        <constructor-arg ref="entityManagerFactory"/>
+        <constructor-arg ref="managementService"/>
+    </bean>
 
     <bean id="signInProviderFactory" class="org.apache.usergrid.security.providers.SignInProviderFactory">
         <property name="entityManagerFactory" ref="entityManagerFactory"/>
         <property name="managementService" ref="managementService"/>
     </bean>
 
-  <bean id="exportService" class="org.apache.usergrid.management.export.ExportServiceImpl"
>
-    <property name="managementService" ref="managementService"/>
-    <property name="emf" ref="entityManagerFactory"/>
-    <property name="sch" ref="schedulerService"/>
-  </bean>
+    <bean id="exportService" class="org.apache.usergrid.management.export.ExportServiceImpl">
+        <property name="managementService" ref="managementService"/>
+        <property name="emf" ref="entityManagerFactory"/>
+        <property name="sch" ref="schedulerService"/>
+    </bean>
 
-  <bean id="exportJob" class="org.apache.usergrid.management.export.ExportJob" />
+    <bean id="exportJob" class="org.apache.usergrid.management.export.ExportJob"/>
 
-    <bean id="serviceModule" class="org.apache.usergrid.services.guice.ServiceModuleImpl"
/>
+    <bean id="serviceModule" class="org.apache.usergrid.services.guice.ServiceModuleImpl"/>
 
 
     <bean id="notificationsQueueListener" class="org.apache.usergrid.services.notifications.QueueListener">
-    <constructor-arg name="emf" ref="entityManagerFactory" />
-    <constructor-arg name="props" ref="properties" />
-    <constructor-arg name="smf" ref="serviceManagerFactory" />
-  </bean>
+        <constructor-arg name="emf" ref="entityManagerFactory"/>
+        <constructor-arg name="props" ref="properties"/>
+        <constructor-arg name="smf" ref="serviceManagerFactory"/>
+    </bean>
 
-  <bean id="importService" class="org.apache.usergrid.management.importer.ImportServiceImpl"
>
-    <property name="managementService" ref="managementService"/>
-      <property name="emf" ref="entityManagerFactory"/>
-      <property name="sch" ref="schedulerService"/>
-  </bean>
+    <bean id="importService" class="org.apache.usergrid.management.importer.ImportServiceImpl">
+        <property name="managementService" ref="managementService"/>
+        <property name="emf" ref="entityManagerFactory"/>
+        <property name="sch" ref="schedulerService"/>
+    </bean>
 
     <!--<bean id="importQueueListener" class="org.apache.usergrid.services.queues.ImportQueueListener"-->
-          <!--scope="singleton">-->
-        <!--<constructor-arg orgAppName="emf" ref="entityManagerFactory" />-->
-        <!--<constructor-arg orgAppName="metricsService" ref="metricsFactory" />-->
-        <!--<constructor-arg orgAppName="smf" ref="serviceManagerFactory" />-->
-        <!--<constructor-arg orgAppName="props" ref="properties" />-->
+    <!--scope="singleton">-->
+    <!--<constructor-arg orgAppName="emf" ref="entityManagerFactory" />-->
+    <!--<constructor-arg orgAppName="metricsService" ref="metricsFactory" />-->
+    <!--<constructor-arg orgAppName="smf" ref="serviceManagerFactory" />-->
+    <!--<constructor-arg orgAppName="props" ref="properties" />-->
 
     <!--</bean>-->
 
-  <bean id="importJob" class="org.apache.usergrid.management.importer.ImportJob" />
-  <bean id="fileImportJob" class="org.apache.usergrid.management.importer.FileImportJob"
/>
+    <bean id="importJob" class="org.apache.usergrid.management.importer.ImportJob"/>
+    <bean id="fileImportJob" class="org.apache.usergrid.management.importer.FileImportJob"/>
 
 </beans>


Mime
View raw message