usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/2] incubator-usergrid git commit: hacked spring impl, need to improve
Date Wed, 01 Jul 2015 22:02:55 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/isolate-app-infos 107989544 -> c61d69f0f


hacked spring impl, need to improve


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

Branch: refs/heads/isolate-app-infos
Commit: 24726af8de5265086453cd2f8ef345fe2222b74d
Parents: 1079895
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Jul 1 15:30:24 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Jul 1 15:30:24 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/GuiceFactory.java  | 15 ++++-
 .../usergrid/corepersistence/ServiceModule.java | 29 ++++++++
 .../management/AppInfoMigrationPlugin.java      | 16 ++++-
 .../usergrid/services/guice/ServiceModule.java  | 71 --------------------
 .../services/guice/ServiceModuleImpl.java       | 60 +++++++++++++++++
 .../resources/usergrid-services-context.xml     |  5 +-
 .../org/apache/usergrid/ServiceITSetup.java     |  1 -
 7 files changed, 121 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/24726af8/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
index 6a87005..aadb479 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
@@ -20,10 +20,15 @@
 package org.apache.usergrid.corepersistence;
 
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 
 import javax.inject.Named;
 
+import com.google.inject.AbstractModule;
+import com.google.inject.Module;
+import org.apache.usergrid.persistence.collection.service.impl.ServiceModule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.FactoryBean;
@@ -126,9 +131,15 @@ public class GuiceFactory implements FactoryBean<Injector> {
             throw new RuntimeException( "Fatal error loading configuration.", e );
         }
 
-
+        List<Module> moduleList = new ArrayList<>();
+        if(applicationContext.containsBean("serviceModule")){
+            Module serviceModule =(Module)applicationContext.getBean("serviceModule");
+            moduleList.add( serviceModule);
+        }
+        moduleList.add(new CoreModule());
+        moduleList.add(new PersistenceModule(applicationContext));
         //we have to inject a couple of spring beans into our Guice.  Wire it with PersistenceModule
-        injector = Guice.createInjector( new CoreModule(), new PersistenceModule( applicationContext
) );
+        injector = Guice.createInjector( moduleList );
 
         return injector;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/24726af8/stack/core/src/main/java/org/apache/usergrid/corepersistence/ServiceModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ServiceModule.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ServiceModule.java
new file mode 100644
index 0000000..1859281
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ServiceModule.java
@@ -0,0 +1,29 @@
+/*
+ *
+ *  * 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.AbstractModule;
+import com.google.inject.Module;
+
+/**
+ * Classy class class.
+ */
+public interface ServiceModule extends Module{
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/24726af8/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
index 2a5346a..6cd487d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
@@ -46,6 +46,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.utils.UUIDUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.BeanFactory;
 import rx.Observable;
 
 import java.util.HashMap;
@@ -84,13 +85,26 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
     final private GraphManagerFactory graphManagerFactory;
     private final ManagementService managementService;
 
-
     @Inject
     public AppInfoMigrationPlugin(
         EntityManagerFactory emf,
         MigrationInfoSerialization migrationInfoSerialization,
         EntityCollectionManagerFactory entityCollectionManagerFactory,
         GraphManagerFactory graphManagerFactory,
+        BeanFactory beanFactory) {
+
+        this.emf = emf;
+        this.migrationInfoSerialization = migrationInfoSerialization;
+        this.entityCollectionManagerFactory = entityCollectionManagerFactory;
+        this.graphManagerFactory = graphManagerFactory;
+        this.managementService = beanFactory.getBean(ManagementService.class);
+    }
+
+    public AppInfoMigrationPlugin(
+        EntityManagerFactory emf,
+        MigrationInfoSerialization migrationInfoSerialization,
+        EntityCollectionManagerFactory entityCollectionManagerFactory,
+        GraphManagerFactory graphManagerFactory,
         ManagementService managementService) {
 
         this.emf = emf;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/24726af8/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModule.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModule.java
b/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModule.java
deleted file mode 100644
index f4296fb..0000000
--- a/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModule.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  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.
- */
-package org.apache.usergrid.services.guice;
-
-
-import org.apache.usergrid.corepersistence.CoreModule;
-import org.apache.usergrid.management.AppInfoMigrationPlugin;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
-import org.apache.usergrid.services.ServiceManager;
-import org.apache.usergrid.services.ServiceManagerFactory;
-import org.apache.usergrid.services.queues.ImportQueueListener;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.multibindings.Multibinder;
-
-
-/**
- * Module that handles all of the guice injects for services.
- */
-
-
-/**
- *   <bean id="notificationsQueueListener" class="org.apache.usergrid.services.notifications.QueueListener"
- scope="singleton">
- <constructor-arg name="emf" ref="entityManagerFactory" />
- <constructor-arg name="metricsService" ref="metricsFactory" />
- <constructor-arg name="props" ref="properties" />
- <constructor-arg name="smf" ref="serviceManagerFactory" />
- </bean>
- */
-
-public class ServiceModule extends AbstractModule {
-    @Override
-    protected void configure() {
-
-        //TODO: why not just make the ImportQueueListener inject the ServiceManager instead?
-        //TODO: I don't know why we need to do the same with emf. We could just inject it
like the CoreModule does.
-
-       // install( new CoreModule() );
-
-
-        //Seems weird, aren't we just binding the factory to the exact same factory when
it goes to look for it?
-        bind( ServiceManagerFactory.class );
-        bind( EntityManagerFactory.class );
-        final Multibinder<MigrationPlugin> plugins = Multibinder.newSetBinder( binder(),
MigrationPlugin.class );
-        plugins.addBinding().to(AppInfoMigrationPlugin.class);
-
-
-
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/24726af8/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
new file mode 100644
index 0000000..1bcc881
--- /dev/null
+++ b/stack/services/src/main/java/org/apache/usergrid/services/guice/ServiceModuleImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  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.
+ */
+package org.apache.usergrid.services.guice;
+
+
+import org.apache.usergrid.corepersistence.CoreModule;
+import org.apache.usergrid.corepersistence.ServiceModule;
+import org.apache.usergrid.management.AppInfoMigrationPlugin;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
+import org.apache.usergrid.services.ServiceManager;
+import org.apache.usergrid.services.ServiceManagerFactory;
+import org.apache.usergrid.services.queues.ImportQueueListener;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.multibindings.Multibinder;
+
+
+/**
+ * Module that handles all of the guice injects for services.
+ */
+
+
+/**
+ *   <bean id="notificationsQueueListener" class="org.apache.usergrid.services.notifications.QueueListener"
+ scope="singleton">
+ <constructor-arg name="emf" ref="entityManagerFactory" />
+ <constructor-arg name="metricsService" ref="metricsFactory" />
+ <constructor-arg name="props" ref="properties" />
+ <constructor-arg name="smf" ref="serviceManagerFactory" />
+ </bean>
+ */
+
+public class ServiceModuleImpl extends AbstractModule implements ServiceModule {
+    @Override
+    protected void configure() {
+
+        //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/incubator-usergrid/blob/24726af8/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 8674b71..74c4de2 100644
--- a/stack/services/src/main/resources/usergrid-services-context.xml
+++ b/stack/services/src/main/resources/usergrid-services-context.xml
@@ -89,7 +89,10 @@
 
   <bean id="exportJob" class="org.apache.usergrid.management.export.ExportJob" />
 
-  <bean id="notificationsQueueListener" class="org.apache.usergrid.services.notifications.QueueListener">
+    <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" />

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/24726af8/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
index 460c471..6cdb0ea 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceITSetup.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid;
 
 
-import org.apache.usergrid.management.AppInfoMigrationPlugin;
 import org.apache.usergrid.management.ApplicationCreator;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.management.export.ExportService;


Mime
View raw message