[seam-commits] Seam SVN: r12007 - in modules/remoting/trunk/src: main/java/org/jboss/seam/remoting and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Feb 4 03:30:12 EST 2010


Author: shane.bryzak at jboss.com
Date: 2010-02-04 03:30:12 -0500 (Thu, 04 Feb 2010)
New Revision: 12007

Added:
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/NonInjectionRemoting.java
Removed:
   modules/remoting/trunk/src/test/
Modified:
   modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
Log:
added servlet that doesn't rely on dependency injection


Added: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/NonInjectionRemoting.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/NonInjectionRemoting.java	                        (rev 0)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/NonInjectionRemoting.java	2010-02-04 08:30:12 UTC (rev 12007)
@@ -0,0 +1,65 @@
+package org.jboss.seam.remoting;
+
+import static org.jboss.weld.logging.messages.ServletMessage.BEAN_DEPLOYMENT_ARCHIVE_MISSING;
+import static org.jboss.weld.logging.messages.ServletMessage.BEAN_MANAGER_FOR_ARCHIVE_NOT_FOUND;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.servlet.ServletContext;
+
+import org.jboss.seam.remoting.ExecutionHandler;
+import org.jboss.seam.remoting.InterfaceGenerator;
+import org.jboss.seam.remoting.Remoting;
+import org.jboss.seam.remoting.model.ModelHandler;
+import org.jboss.weld.Container;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.exceptions.ForbiddenStateException;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.servlet.api.ServletServices;
+
+public class NonInjectionRemoting extends Remoting
+{
+   private static final long serialVersionUID = -8985912269669096603L;
+     
+   private static BeanManagerImpl getBeanManager(ServletContext ctx)
+   {
+      BeanDeploymentArchive war = Container.instance().services().get(ServletServices.class).getBeanDeploymentArchive(ctx);
+      if (war == null)
+      {
+         throw new ForbiddenStateException(BEAN_DEPLOYMENT_ARCHIVE_MISSING, ctx);
+      }
+      BeanManagerImpl beanManager = Container.instance().beanDeploymentArchives().get(war);
+      if (beanManager == null)
+      {
+         throw new ForbiddenStateException(BEAN_MANAGER_FOR_ARCHIVE_NOT_FOUND, ctx, war);
+      }
+      return beanManager;
+   }
+   
+   @Override
+   protected ExecutionHandler getExecutionHandler()
+   {
+      BeanManager beanManager = getBeanManager(getServletConfig().getServletContext());
+      Bean<ExecutionHandler> bean = (Bean<ExecutionHandler>) beanManager.getBeans(
+            ExecutionHandler.class).iterator().next();
+      return bean.create(beanManager.createCreationalContext(bean));
+   }
+   
+   @Override
+   protected InterfaceGenerator getInterfaceHandler()
+   {
+      BeanManager beanManager = getBeanManager(getServletConfig().getServletContext());
+      Bean<InterfaceGenerator> bean = (Bean<InterfaceGenerator>) beanManager.getBeans(
+            InterfaceGenerator.class).iterator().next();
+      return bean.create(beanManager.createCreationalContext(bean));
+   }
+   
+   @Override
+   protected ModelHandler getModelHandler()
+   {
+      BeanManager beanManager = getBeanManager(getServletConfig().getServletContext());
+      Bean<ModelHandler> bean = (Bean<ModelHandler>) beanManager.getBeans(
+            ModelHandler.class).iterator().next();
+      return bean.create(beanManager.createCreationalContext(bean));
+   }
+}
\ No newline at end of file

Modified: modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java
===================================================================
--- modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java	2010-02-03 09:50:09 UTC (rev 12006)
+++ modules/remoting/trunk/src/main/java/org/jboss/seam/remoting/model/ModelHandler.java	2010-02-04 08:30:12 UTC (rev 12007)
@@ -77,7 +77,9 @@
       try
       {         
          // Initialize the conversation context
-         conversationContext = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();
+         // TODO - this is non-portable, we should at least use the new ConversationManager API once Nik has
+         // written it, and non-portable code should be abstracted out
+         conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversationContext();
          
          if (ctx.getConversationId() != null && !ctx.getConversationId().isEmpty())
          { 



More information about the seam-commits mailing list