[seam-commits] Seam SVN: r10597 - in examples/trunk: servlet-booking and 14 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Apr 22 18:55:22 EDT 2009


Author: dan.j.allen
Date: 2009-04-22 18:55:22 -0400 (Wed, 22 Apr 2009)
New Revision: 10597

Added:
   examples/trunk/servlet-booking/
   examples/trunk/servlet-booking/pom.xml
   examples/trunk/servlet-booking/src/
   examples/trunk/servlet-booking/src/main/
   examples/trunk/servlet-booking/src/main/java/
   examples/trunk/servlet-booking/src/main/java/org/
   examples/trunk/servlet-booking/src/main/java/org/jboss/
   examples/trunk/servlet-booking/src/main/java/org/jboss/seam/
   examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/
   examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/
   examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/BeanLookup.java
   examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/HelloWorld.java
   examples/trunk/servlet-booking/src/main/java/org/jboss/webbeans/
   examples/trunk/servlet-booking/src/main/java/org/jboss/webbeans/resources/
   examples/trunk/servlet-booking/src/main/java/org/jboss/webbeans/resources/ManagerReferenceFactory.java
   examples/trunk/servlet-booking/src/main/resources/
   examples/trunk/servlet-booking/src/main/webapp/
   examples/trunk/servlet-booking/src/main/webapp/META-INF/
   examples/trunk/servlet-booking/src/main/webapp/META-INF/context.xml
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/beans.xml
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/faces-config.xml
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/jetty-env.xml
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/layout/
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/layout/template.xhtml
   examples/trunk/servlet-booking/src/main/webapp/WEB-INF/web.xml
   examples/trunk/servlet-booking/src/main/webapp/home.xhtml
   examples/trunk/servlet-booking/src/main/webapp/index.html
Log:
Skeleton of the booking example for servlet containers. Works for both Tomcat and Jetty.



Property changes on: examples/trunk/servlet-booking
___________________________________________________________________
Name: svn:ignore
   + target


Added: examples/trunk/servlet-booking/pom.xml
===================================================================
--- examples/trunk/servlet-booking/pom.xml	                        (rev 0)
+++ examples/trunk/servlet-booking/pom.xml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <parent>
+      <groupId>org.jboss.seam.examples</groupId>
+      <artifactId>parent</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>seam-servlet-booking</artifactId>
+   <packaging>war</packaging>
+   <name>Seam Booking Example (Servlet Container)</name>
+
+   <build>
+      <defaultGoal>package</defaultGoal>
+      <finalName>${project.artifactId}</finalName>
+      <plugins>
+
+         <plugin>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>maven-jetty-plugin</artifactId>
+            <version>6.1.16</version>
+            <configuration>
+               <connectors>
+                  <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+                     <port>${jetty.run.port}</port>
+                     <maxIdleTime>3600000</maxIdleTime>
+                  </connector>
+               </connectors>
+               <scanIntervalSeconds>10</scanIntervalSeconds>
+               <webAppConfig>
+                  <contextPath>/${project.build.finalName}</contextPath>
+               </webAppConfig>
+            </configuration>
+            <dependencies/>
+         </plugin>
+
+      </plugins>
+   </build>
+
+   <properties>
+      <jetty.run.port>9090</jetty.run.port>
+      <jetty.debug.port>9190</jetty.debug.port>
+   </properties>
+
+   <dependencies>
+
+      <dependency>
+         <groupId>org.testng</groupId>
+         <artifactId>testng</artifactId>
+         <scope>test</scope>
+         <classifier>jdk15</classifier>
+      </dependency>
+
+      <!-- disable after upgrading to JSF 2 -->
+      <dependency>
+         <groupId>com.sun.facelets</groupId>
+         <artifactId>jsf-facelets</artifactId>
+         <scope>runtime</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>javax.annotation</groupId>
+         <artifactId>jsr250-api</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>javax.faces</groupId>
+         <artifactId>jsf-api</artifactId>
+         <version>1.2_12</version>
+      </dependency>
+
+      <dependency>
+         <groupId>javax.faces</groupId>
+         <artifactId>jsf-impl</artifactId>
+         <scope>runtime</scope>
+         <version>1.2_12</version>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.webbeans</groupId>
+         <artifactId>jsr299-api</artifactId>
+         <scope>provided</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.webbeans.servlet</groupId>
+         <artifactId>webbeans-servlet</artifactId>
+         <scope>compile</scope> <!-- change to runtime after removing ManagerReference -->
+      </dependency>
+
+   </dependencies>
+
+</project>

Added: examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/BeanLookup.java
===================================================================
--- examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/BeanLookup.java	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/BeanLookup.java	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,27 @@
+package org.jboss.seam.examples.booking;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+//import javax.faces.ManagedBean;
+//import javax.faces.RequestScoped;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+//@ManagedBean
+//@RequestScoped
+public class BeanLookup {
+   public void lookupManager() {
+      try {
+         InitialContext ic = new InitialContext();
+         Manager manager = (Manager) ic.lookup("java:comp/env/jcdi/Manager");
+         if (manager != null) {
+            Logger logger = Logger.getLogger(BeanLookup.class.getName());
+            logger.log(Level.INFO, "JCDI manager: " + manager.toString());
+            logger.log(Level.INFO, "helloWorld bean: " + String.valueOf(manager.getInstanceByName("helloWorld")));
+         }
+      } catch (NamingException ex) {
+         Logger.getLogger(BeanLookup.class.getName()).log(Level.SEVERE, null, ex);
+      }
+   }
+}

Added: examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/HelloWorld.java
===================================================================
--- examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/HelloWorld.java	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/java/org/jboss/seam/examples/booking/HelloWorld.java	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,18 @@
+package org.jboss.seam.examples.booking;
+
+import javax.annotation.Named;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.context.RequestScoped;
+
+ at Named
+ at RequestScoped
+public class HelloWorld {
+
+   private @Current Manager manager;
+
+   public void sayHello() {
+       System.out.println("Hello! Here is the manager that I found: " + manager);
+   }
+
+}

Added: examples/trunk/servlet-booking/src/main/java/org/jboss/webbeans/resources/ManagerReferenceFactory.java
===================================================================
--- examples/trunk/servlet-booking/src/main/java/org/jboss/webbeans/resources/ManagerReferenceFactory.java	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/java/org/jboss/webbeans/resources/ManagerReferenceFactory.java	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,37 @@
+package org.jboss.webbeans.resources;
+
+import java.util.Hashtable;
+import javax.inject.manager.Manager;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import org.jboss.webbeans.CurrentManager;
+
+/**
+ * A JNDI object factory which will return the current {@link javax.inject.manager.Manager}
+ * when the JNDI name under which this factory is registered gets resolved.
+ *
+ * @author Dan Allen
+ */
+public class ManagerReferenceFactory extends Reference implements ObjectFactory
+{
+   public ManagerReferenceFactory()
+   {
+      super(Manager.class.getName(), ManagerReferenceFactory.class.getName(), null);
+   }
+
+   /**
+    * Called by the JNDI container when the JNDI name under which this factory is registered gets resolved.
+    *
+    * @param ref the Reference
+    * @param name not used
+    * @param ctx not used
+    * @param env not used
+    *
+    * @return The current JCDI root manager instance
+    */
+   public Object getObjectInstance(Object ref, Name name, Context ctx, Hashtable<?, ?> env) throws Exception {
+      return CurrentManager.rootManager().getCurrent();
+   }
+}

Added: examples/trunk/servlet-booking/src/main/webapp/META-INF/context.xml
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/META-INF/context.xml	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/META-INF/context.xml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+   <Resource name="jcdi/Manager"
+      auth="Container"
+      type="javax.inject.manager.Manager"
+      factory="org.jboss.webbeans.resources.ManagerReferenceFactory"/>
+</Context>

Added: examples/trunk/servlet-booking/src/main/webapp/WEB-INF/beans.xml
===================================================================

Added: examples/trunk/servlet-booking/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/WEB-INF/faces-config.xml	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/WEB-INF/faces-config.xml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+   version="2.0">
+    
+   <application>
+      <!-- disable after upgrading to JSF 2 -->
+      <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+   </application>
+
+   <managed-bean>
+      <managed-bean-name>beanLookup</managed-bean-name>
+	  <managed-bean-class>org.jboss.seam.examples.booking.BeanLookup</managed-bean-class>
+	  <managed-bean-scope>request</managed-bean-scope>
+   </managed-bean>
+
+</faces-config>

Added: examples/trunk/servlet-booking/src/main/webapp/WEB-INF/jetty-env.xml
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/WEB-INF/jetty-env.xml	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/WEB-INF/jetty-env.xml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
+   "http://jetty.mortbay.org/configure.dtd">
+<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
+   <New id="jdci" class="org.mortbay.jetty.plus.naming.Resource">
+      <Arg><Ref id="webAppCtx"/></Arg> 
+      <Arg>jcdi/Manager</Arg>
+      <Arg>
+         <New class="org.jboss.webbeans.resources.ManagerReferenceFactory"/>
+      </Arg>
+   </New>
+</Configure>

Added: examples/trunk/servlet-booking/src/main/webapp/WEB-INF/layout/template.xhtml
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/WEB-INF/layout/template.xhtml	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/WEB-INF/layout/template.xhtml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<f:view xmlns="http://www.w3.org/1999/xhtml"
+   xmlns:ui="http://java.sun.com/jsf/facelets"
+   xmlns:h="http://java.sun.com/jsf/html"
+   xmlns:f="http://java.sun.com/jsf/core"
+   contentType="text/html">
+<html>
+   <head>
+      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+      <title>Hello World</title>
+   </head>
+   <body>
+      <ui:insert name="content"/>
+   </body>
+</html>
+</f:view>

Added: examples/trunk/servlet-booking/src/main/webapp/WEB-INF/web.xml
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/WEB-INF/web.xml	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/WEB-INF/web.xml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+   version="2.5">
+
+   <display-name>Seam Booking Example (Servlet Container)</display-name>
+   
+   <!-- disable after upgrading to JSF 2 -->
+   <context-param>
+      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+      <param-value>.xhtml</param-value>
+   </context-param>
+   
+   <context-param>
+      <param-name>facelets.DEVELOPMENT</param-name>
+      <param-value>true</param-value>
+   </context-param>
+   
+   <listener>
+      <listener-class>org.jboss.webbeans.environment.servlet.Listener</listener-class>
+   </listener>
+   
+   <servlet>
+      <servlet-name>Faces Servlet</servlet-name>
+      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+      <load-on-startup>1</load-on-startup>
+   </servlet>
+   
+   <servlet-mapping>
+      <servlet-name>Faces Servlet</servlet-name>
+      <url-pattern>*.seam</url-pattern>
+   </servlet-mapping>
+
+   <session-config>
+      <session-timeout>10</session-timeout> 
+   </session-config>   
+
+   <resource-env-ref>
+     <description>Object factory for the JCDI Manager</description>
+     <resource-env-ref-name>jcdi/Manager</resource-env-ref-name>
+     <resource-env-ref-type>javax.inject.manager.Manager</resource-env-ref-type>
+   </resource-env-ref>
+   
+</web-app>

Added: examples/trunk/servlet-booking/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/home.xhtml	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/home.xhtml	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1,19 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+   xmlns:ui="http://java.sun.com/jsf/facelets"
+   xmlns:f="http://java.sun.com/jsf/core"
+   xmlns:h="http://java.sun.com/jsf/html"
+   template="/WEB-INF/layout/template.xhtml">
+
+   <ui:define name="content">
+
+      <h1>Seam 3</h1>
+
+      <h:form>
+         <h:commandButton action="#{beanLookup.lookupManager}" value="Lookup Manager"/>
+      </h:form>
+
+   </ui:define>
+
+</ui:composition>

Added: examples/trunk/servlet-booking/src/main/webapp/index.html
===================================================================
--- examples/trunk/servlet-booking/src/main/webapp/index.html	                        (rev 0)
+++ examples/trunk/servlet-booking/src/main/webapp/index.html	2009-04-22 22:55:22 UTC (rev 10597)
@@ -0,0 +1 @@
+<html><head><meta http-equiv="Refresh" content="0; URL=home.seam"/></head></html>




More information about the seam-commits mailing list