openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r922654 - in /openwebbeans/trunk/samples/tomcat-sample: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/webbeans/ src/main/java/org/apache/webbeans/samples/ src/main/java/org/apache/web...
Date Sat, 13 Mar 2010 19:23:02 GMT
Author: gerdogdu
Date: Sat Mar 13 19:23:01 2010
New Revision: 922654

URL: http://svn.apache.org/viewvc?rev=922654&view=rev
Log:
[OWB-324] Add Tomcat Plugin

Added:
    openwebbeans/trunk/samples/tomcat-sample/pom.xml   (with props)
    openwebbeans/trunk/samples/tomcat-sample/src/
    openwebbeans/trunk/samples/tomcat-sample/src/main/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/CurrentDateProvider.java
  (with props)
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
  (with props)
    openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
  (with props)
    openwebbeans/trunk/samples/tomcat-sample/src/main/resources/
    openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/
    openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/beans.xml   (with
props)
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/MANIFEST.MF
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/beans.xml   (with props)
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/lib/
    openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml   (with props)
Modified:
    openwebbeans/trunk/samples/tomcat-sample/   (props changed)

Propchange: openwebbeans/trunk/samples/tomcat-sample/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Mar 13 19:23:01 2010
@@ -0,0 +1,4 @@
+.classpath
+.settings
+target
+.project

Added: openwebbeans/trunk/samples/tomcat-sample/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/pom.xml?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/pom.xml (added)
+++ openwebbeans/trunk/samples/tomcat-sample/pom.xml Sat Mar 13 19:23:01 2010
@@ -0,0 +1,96 @@
+	<!--
+
+		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.
+	-->
+<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>
+	<description>Sample JSF2 Application</description>
+	<parent>
+		<artifactId>samples</artifactId>
+		<groupId>org.apache.openwebbeans</groupId>
+		<version>1.0.0-SNAPSHOT</version>
+	</parent>	
+	
+	<groupId>org.apache.openwebbeans.samples</groupId>
+	<artifactId>tomcat-sample</artifactId>
+	<packaging>war</packaging>
+	<name>Apache OpenWebBeans :: Tomcat Sample</name>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-impl</artifactId>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-interceptor_1.1_spec</artifactId>
+		</dependency>
+
+				
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-web</artifactId>
+			<version>${project.version}</version>
+		</dependency>		
+				
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-servlet_2.5_spec</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-ee-common</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jcdi_1.0_spec</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		
+		<dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        
+		<dependency>
+			<groupId>org.apache.openwebbeans</groupId>
+			<artifactId>openwebbeans-spi</artifactId>
+			<version>${project.version}</version>
+			<scope>provided</scope>
+		</dependency>			
+
+	</dependencies>
+	
+	<build>
+		<finalName>tomcat-sample</finalName>
+		<plugins>
+			<plugin>
+			        <groupId>org.codehaus.mojo</groupId>
+			        <artifactId>tomcat-maven-plugin</artifactId>
+					<configuration>
+                		<url>http://localhost:8080/manager</url>
+        			</configuration>			        
+			</plugin>
+		</plugins>
+	</build>
+	
+</project>

Propchange: openwebbeans/trunk/samples/tomcat-sample/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/CurrentDateProvider.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/CurrentDateProvider.java?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/CurrentDateProvider.java
(added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/CurrentDateProvider.java
Sat Mar 13 19:23:01 2010
@@ -0,0 +1,41 @@
+/*
+ * 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.webbeans.samples.tomcat;
+
+import java.security.Principal;
+import java.util.Date;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class CurrentDateProvider
+{
+    private @Inject Principal principal;
+    
+    @Produces
+    public Date getCurrentDate()
+    {
+        return new Date();
+    }
+    
+    public Principal getPrincipal()
+    {
+        return principal;
+    }
+}

Propchange: openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/CurrentDateProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
(added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
Sat Mar 13 19:23:01 2010
@@ -0,0 +1,62 @@
+/*
+ * 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.webbeans.samples.tomcat;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class InjectorServlet extends HttpServlet
+{
+    private static final long serialVersionUID = 1L;
+
+    private @Inject CurrentDateProvider dateProvider;
+    
+    private @Inject BeanManager beanManager;
+         
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException
+    {
+        PrintWriter writer = resp.getWriter();
+        writer.write("==================Injection of Bean Instance into Servlet=================="
+ "\n\n");
+        writer.write("Caller Principal name injection into DateProvider instance : " + dateProvider.getPrincipal().getName()
+ "\n\n");
+        writer.write("Current Date : " + dateProvider.toString());
+        writer.write("\n");        
+        
+        writer.write("==================Injection of BeanManager into Servlet=================="
+ "\n\n");
+        if(beanManager != null)
+        {
+            writer.write("Injection of @Inject BeanManager into servlet is successfull");
+        }
+        else
+        {
+            writer.write("Injection of @Inject BeanManager into servlet has failed");
+        }
+        
+    }
+    
+    
+
+}

Propchange: openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
(added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
Sat Mar 13 19:23:01 2010
@@ -0,0 +1,70 @@
+/*
+ * 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.webbeans.samples.tomcat;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.webbeans.annotation.DefaultLiteral;
+
+public class MyFilter implements Filter
+{
+    private @Inject BeanManager manager;
+
+    @Override
+    public void destroy()
+    {
+        
+        
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws
IOException, ServletException
+    {
+        Set<Bean<?>> beans = manager.getBeans(CurrentDateProvider.class, new
Annotation[]{new DefaultLiteral()});
+        System.out.println("Total found beans : " + beans.size());
+        Bean<CurrentDateProvider> provider = (Bean<CurrentDateProvider>)beans.iterator().next();
+        CurrentDateProvider instance = (CurrentDateProvider) manager.getReference(provider,
CurrentDateProvider.class, manager.createCreationalContext(provider));
+        
+        System.out.println("Current time is : " + instance.getCurrentDate());
+        
+        arg2.doFilter(arg0, arg1);
+        
+    }
+
+    @Override
+    public void init(FilterConfig arg0) throws ServletException
+    {
+        
+        
+    }
+
+}

Propchange: openwebbeans/trunk/samples/tomcat-sample/src/main/java/org/apache/webbeans/samples/tomcat/MyFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/beans.xml?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/beans.xml (added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/beans.xml Sat Mar
13 19:23:01 2010
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans/>
\ No newline at end of file

Propchange: openwebbeans/trunk/samples/tomcat-sample/src/main/resources/META-INF/beans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/MANIFEST.MF?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/MANIFEST.MF (added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/META-INF/MANIFEST.MF Sat Mar
13 19:23:01 2010
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/beans.xml?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/beans.xml (added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/beans.xml Sat Mar 13
19:23:01 2010
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans/>
\ No newline at end of file

Propchange: openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/beans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml?rev=922654&view=auto
==============================================================================
--- openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml (added)
+++ openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml Sat Mar 13 19:23:01
2010
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	
+	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.
+-->
+<web-app version="2.5" 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">
+ <filter>
+  <filter-name>injectorfilter</filter-name>
+  <filter-class>org.apache.webbeans.samples.tomcat.MyFilter</filter-class>
+ </filter>
+ <filter-mapping>
+  <filter-name>injectorfilter</filter-name>
+  <servlet-name>injector</servlet-name>
+  <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+ <servlet>
+  <servlet-name>injector</servlet-name>
+  <servlet-class>org.apache.webbeans.samples.tomcat.InjectorServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+  <servlet-name>injector</servlet-name>
+  <url-pattern>/injector</url-pattern>
+ </servlet-mapping>
+ <security-constraint>
+  <display-name>injector</display-name>
+  <web-resource-collection>
+   <web-resource-name>injector</web-resource-name>
+   <url-pattern>/injector/*</url-pattern>
+  </web-resource-collection>
+  <auth-constraint>
+   <role-name>manager</role-name>
+  </auth-constraint>
+ </security-constraint>
+ <login-config>
+  <auth-method>BASIC</auth-method>
+  <realm-name>sample</realm-name>
+ </login-config>
+ <security-role>
+  <role-name>manager</role-name>
+ </security-role>
+</web-app>

Propchange: openwebbeans/trunk/samples/tomcat-sample/src/main/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message