[jboss-svn-commits] JBL Code SVN: r19671 - in labs/jbosslabs/labs-3.0-build: views/admin/src/main/java/org/jboss/labs/admin/action and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Apr 21 09:59:07 EDT 2008
Author: wrzep
Date: 2008-04-21 09:59:07 -0400 (Mon, 21 Apr 2008)
New Revision: 19671
Added:
labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/injection/seam/AdminLabsGuiceModule.java
Removed:
labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/GuiceConfiguration.java
Modified:
labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/Guice.java
labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/LabsSeamInjectionInterceptor.java
labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/ShowRequests.java
labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/WEB-INF/components.xml
Log:
JBLAB-928 @Guice in a separate lib, class loading issue fix (or rather workaround :) )
Modified: labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/Guice.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/Guice.java 2008-04-21 13:03:25 UTC (rev 19670)
+++ labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/Guice.java 2008-04-21 13:59:07 UTC (rev 19671)
@@ -24,7 +24,6 @@
package org.jboss.labs.injection.seam;
import org.jboss.seam.annotations.intercept.Interceptors;
-import org.jboss.labs.injection.seam.LabsSeamInjectionInterceptor;
import static java.lang.annotation.ElementType.TYPE;
import java.lang.annotation.Retention;
@@ -37,5 +36,6 @@
@Target(TYPE)
@Retention(RUNTIME)
@Interceptors(LabsSeamInjectionInterceptor.class)
-public @interface Guice {
+public @interface Guice
+{
}
Deleted: labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/GuiceConfiguration.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/GuiceConfiguration.java 2008-04-21 13:03:25 UTC (rev 19670)
+++ labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/GuiceConfiguration.java 2008-04-21 13:59:07 UTC (rev 19671)
@@ -1,71 +0,0 @@
-/*
-* JBoss Labs. http://labs.jboss.com/jbosslabs
-*
-* Copyright © 2008 Red Hat Middleware, LLC. All rights reserved.
-*
-* This copyrighted material is made available to anyone wishing to use,
-* modify, copy, or redistribute it subject to the terms and conditions
-* of the GNU Lesser General Public License, v. 2.1.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT A WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License, v.2.1 along with this distribution; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-* 02110-1301, USA.
-*
-* Red Hat Author(s): Bob McWhirter, Przemyslaw Dej, Ryszard Kozmik,
-* Tomasz Szymanski, Adam Warski, Pawel Wrzeszcz
-*/
-
-package org.jboss.labs.injection.seam;
-
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.annotations.*;
-import org.jboss.labs.injection.LabsGuiceModule;
-
-import java.io.Serializable;
-
-/**
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- */
- at Name("org.jboss.labs.injection.seam.guiceConfiguration")
- at Scope(ScopeType.APPLICATION)
- at Startup
- at Install(precedence = Install.FRAMEWORK)
-public class GuiceConfiguration implements Serializable {
-
- private Module module;
- private static final long serialVersionUID = -632987093667639748L;
-
- @Logger private Log log;
-
- @Factory(value = "org.jboss.labs.injection.seam.guiceInjector",
- autoCreate = true,
- scope = ScopeType.APPLICATION)
- public Injector getGuiceInjector()
- {
- // TODO null module?
- log.info("Module: " + module);
-
- module = new LabsGuiceModule();
-
- return com.google.inject.Guice.createInjector(module);
- }
-
- public Module getModule()
- {
- return module;
- }
-
- public void setModule(Module module)
- {
- this.module = module;
- }
-}
\ No newline at end of file
Modified: labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/LabsSeamInjectionInterceptor.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/LabsSeamInjectionInterceptor.java 2008-04-21 13:03:25 UTC (rev 19670)
+++ labs/jbosslabs/labs-3.0-build/integration/src/main/java/org/jboss/labs/injection/seam/LabsSeamInjectionInterceptor.java 2008-04-21 13:59:07 UTC (rev 19671)
@@ -24,6 +24,7 @@
package org.jboss.labs.injection.seam;
import com.google.inject.Injector;
+import com.google.inject.Module;
import org.jboss.seam.Component;
import org.jboss.seam.annotations.intercept.AroundInvoke;
import org.jboss.seam.annotations.intercept.Interceptor;
@@ -32,6 +33,8 @@
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
*/
@@ -42,21 +45,49 @@
private static final long serialVersionUID = -6716553117162905303L;
+ private static final ConcurrentHashMap<Class, Injector> INJECTOR_CACHE
+ = new ConcurrentHashMap<Class, Injector>();
+
@AroundInvoke
public Object aroundInvoke(InvocationContext invocationContext) throws Exception
{
+// String moduleBeanName = invocationContext.getMethod().getDeclaringClass().getAnnotation(Guice.class).value();
+//
+// Module module = null;
+//
+// if ((moduleBeanName != null) && (moduleBeanName.length() > 0)) {
+//
+// module = (Module) Component.getInstance(moduleBeanName);
+// log.info("value() " + moduleBeanName);
+// }
+//
+// if (module == null) {
+//
+// Class clazz = invocationContext.getMethod().getDeclaringClass().getAnnotation(Guice.class).module();
+//
+// module = (Module) clazz.newInstance();
+//
+// log.info("module() " + clazz);
+// }
- log.info("Injecting members for: "
- + invocationContext.getTarget().getClass().getName());
+ Module module = (Module) Component.getInstance("org.jboss.labs.injection.seam.guiceModule");
- Injector injector = (Injector) Component.getInstance("org.jboss.labs.injection.seam.guiceInjector");
+ if (module != null)
+ {
- if (injector != null) {
+ log.info("Injecting members for: "
+ + invocationContext.getTarget().getClass().getName()
+ + " using module " + module);
+
+ Injector injector = com.google.inject.Guice.createInjector(module);
injector.injectMembers(invocationContext.getTarget());
- } else {
- log.warn("Null injector.");
}
+ else
+ {
+ log.warn("Guice module not found");
+ }
+
return invocationContext.proceed();
}
}
Modified: labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/ShowRequests.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/ShowRequests.java 2008-04-21 13:03:25 UTC (rev 19670)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/ShowRequests.java 2008-04-21 13:59:07 UTC (rev 19671)
@@ -1,12 +1,10 @@
package org.jboss.labs.admin.action;
-import org.jboss.seam.annotations.Name;
+import org.jboss.labs.admin.Pages;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
import org.jboss.seam.core.Conversation;
-import org.jboss.labs.admin.Pages;
-import org.jboss.labs.core.service.ProjectService;
-import com.google.inject.Inject;
/**
* @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
@@ -16,13 +14,9 @@
@In private Conversation conversation;
- @Inject private ProjectService projectService;
-
@Begin
public String showRequests() {
- System.out.println("PS: " + projectService);
-
conversation.setDescription("Requests");
return Pages.REQUESTS_PAGE;
}
Added: labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/injection/seam/AdminLabsGuiceModule.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/injection/seam/AdminLabsGuiceModule.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/injection/seam/AdminLabsGuiceModule.java 2008-04-21 13:59:07 UTC (rev 19671)
@@ -0,0 +1,6 @@
+package org.jboss.labs.injection.seam;
+
+import org.jboss.labs.injection.LabsGuiceModule;
+
+public class AdminLabsGuiceModule extends LabsGuiceModule {
+}
\ No newline at end of file
Modified: labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/WEB-INF/components.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/WEB-INF/components.xml 2008-04-21 13:03:25 UTC (rev 19670)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/WEB-INF/components.xml 2008-04-21 13:59:07 UTC (rev 19671)
@@ -66,13 +66,8 @@
<factory name="emailReplyTo" value="jboss at o2.pl" scope="APPLICATION"/>
<!-- Guice integration -->
- <component name="labsInjectionModule" class="org.jboss.labs.injection.LabsGuiceModule"
- auto-create="true" scope="APPLICATION"/>
+ <component name="org.jboss.labs.injection.seam.guiceModule"
+ class="org.jboss.labs.injection.seam.AdminLabsGuiceModule"
+ auto-create="true" scope="APPLICATION" startup="true"/>
- <component name="org.jboss.labs.injection.seam.guiceConfiguration">
- <!--<property name="module">-->
- <!--#{labsInjectionModule}-->
- <!--</property>-->
- </component>
-
</components>
More information about the jboss-svn-commits
mailing list