[jboss-cvs] JBossAS SVN: r77188 - in projects/jboss-seam-int/trunk: jbossas and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 19 07:13:03 EDT 2008


Author: alesj
Date: 2008-08-19 07:13:03 -0400 (Tue, 19 Aug 2008)
New Revision: 77188

Added:
   projects/jboss-seam-int/trunk/jbossas/src/main/org/jboss/seam/integration/jbossas/servlet/
   projects/jboss-seam-int/trunk/jbossas/src/main/org/jboss/seam/integration/jbossas/servlet/JBossSeamListener.java
Modified:
   projects/jboss-seam-int/trunk/build/pom.xml
   projects/jboss-seam-int/trunk/jbossas/pom.xml
Log:
Initial MC+Seam init code.

Modified: projects/jboss-seam-int/trunk/build/pom.xml
===================================================================
--- projects/jboss-seam-int/trunk/build/pom.xml	2008-08-19 11:09:39 UTC (rev 77187)
+++ projects/jboss-seam-int/trunk/build/pom.xml	2008-08-19 11:13:03 UTC (rev 77188)
@@ -29,6 +29,7 @@
     <version.jboss.vfs>2.0.0.Beta21</version.jboss.vfs>
     <version.jboss.metadata>1.0.0.Beta35</version.jboss.metadata>
     <version.jbossxb>2.0.0.CR8</version.jbossxb>
+    <version.servlet.api>2.5</version.servlet.api>
     <version.org.jboss.test>1.1.0.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
   </properties>
@@ -309,7 +310,14 @@
         <version>${version.jboss.seam}</version>
       </dependency>
 
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>servlet-api</artifactId>
+        <version>${version.servlet.api}</version>
+      </dependency>
+
       <!-- test dependencies -->
+
       <dependency>
         <groupId>org.jboss.test</groupId>
         <artifactId>jboss-test</artifactId>

Modified: projects/jboss-seam-int/trunk/jbossas/pom.xml
===================================================================
--- projects/jboss-seam-int/trunk/jbossas/pom.xml	2008-08-19 11:09:39 UTC (rev 77187)
+++ projects/jboss-seam-int/trunk/jbossas/pom.xml	2008-08-19 11:13:03 UTC (rev 77188)
@@ -38,6 +38,11 @@
     </dependency>
     
     <dependency>
+      <groupId>org.jboss.deployers</groupId>
+      <artifactId>jboss-deployers-vfs-spi</artifactId>
+    </dependency>
+
+    <dependency>
       <groupId>org.jboss.microcontainer</groupId>
       <artifactId>jboss-dependency</artifactId>
       <exclusions>
@@ -161,18 +166,22 @@
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.jboss.seam</groupId>
-      <artifactId>jboss-seam</artifactId>
-    </dependency>
-    
-    <dependency>
-     <groupId>org.jboss</groupId>
-     <artifactId>jboss-vfs</artifactId>
-   </dependency>
+    </dependency>
     
+    <dependency>
+      <groupId>org.jboss.seam</groupId>
+      <artifactId>jboss-seam</artifactId>
+    </dependency>
     
+    <dependency>
+     <groupId>org.jboss</groupId>
+     <artifactId>jboss-vfs</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+    </dependency>
+
   </dependencies>  
 </project>
\ No newline at end of file

Added: projects/jboss-seam-int/trunk/jbossas/src/main/org/jboss/seam/integration/jbossas/servlet/JBossSeamListener.java
===================================================================
--- projects/jboss-seam-int/trunk/jbossas/src/main/org/jboss/seam/integration/jbossas/servlet/JBossSeamListener.java	                        (rev 0)
+++ projects/jboss-seam-int/trunk/jbossas/src/main/org/jboss/seam/integration/jbossas/servlet/JBossSeamListener.java	2008-08-19 11:13:03 UTC (rev 77188)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY 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 along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.seam.integration.jbossas.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.kernel.Kernel;
+import org.jboss.seam.servlet.SeamListener;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+
+/**
+ * Servlet context listener integrated with underlying Microcontainer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JBossSeamListener extends SeamListener
+{
+   private static final LogProvider log = Logging.getLogProvider(ServletContextListener.class);
+
+   public void contextInitialized(ServletContextEvent event)
+   {
+      // TODO - enable some MC scanning notion in Seam
+      super.contextInitialized(event);
+      
+      ServletContext context = event.getServletContext();
+      Kernel kernel = getAttribute(context, Kernel.class.getName(), Kernel.class);
+      DeploymentUnit unit = getAttribute(context, DeploymentUnit.class.getName(), DeploymentUnit.class);
+      if (kernel != null && unit != null)
+      {
+         // apply kernel and deployment unit to Seam init
+      }
+      else
+      {
+         log.info("No Kernel or DeploymentUnit as ServletContext attribute.");
+      }
+   }
+
+   /**
+    * Get the attribute.
+    *
+    * @param context the servlet context
+    * @param name the attribute name
+    * @param expectedType the expected attribute type
+    * @return null if no such attribute or found attribute instance
+    */
+   protected <T> T getAttribute(ServletContext context, String name, Class<T> expectedType)
+   {
+      Object attribute = context.getAttribute(name);
+      if (attribute == null)
+         return null;
+      if (expectedType.isInstance(attribute) == false)
+         throw new IllegalArgumentException("Illegal attribute type, expected: " + expectedType + ", actual: " + attribute);
+      return expectedType.cast(attribute);
+   }
+}




More information about the jboss-cvs-commits mailing list