Author: pete.muir(a)jboss.org
Date: 2009-04-06 15:09:51 -0400 (Mon, 06 Apr 2009)
New Revision: 2323
Added:
extensions/trunk/tomcat/build/.classpath
extensions/trunk/tomcat/build/.project
extensions/trunk/tomcat/build/.settings/
extensions/trunk/tomcat/build/.settings/org.eclipse.jdt.core.prefs
extensions/trunk/tomcat/build/target/
extensions/trunk/tomcat/build/target/dependency-reduced-pom.xml
extensions/trunk/tomcat/build/target/maven-archiver/
extensions/trunk/tomcat/build/target/maven-archiver/pom.properties
extensions/trunk/tomcat/build/target/original-webbeans-tomcat-1.0.0-SNAPSHOT.jar
extensions/trunk/tomcat/build/target/webbeans-tomcat-1.0.0-SNAPSHOT-sources.jar
extensions/trunk/tomcat/build/target/webbeans-tomcat-1.0.0-SNAPSHOT.jar
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/resources/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
Removed:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/resources/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/
Modified:
doc/trunk/reference/en-US/environments.xml
examples/trunk/tomcat/WebContent/META-INF/context.xml
examples/trunk/tomcat/WebContent/WEB-INF/web.xml
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/AbstractScanner.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/Scanner.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/TomcatWebBeanDiscovery.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/URLScanner.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/resources/ReadOnlyNamingContext.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Servlets.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockBootstrap.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java
Log:
WBX-15
Modified: doc/trunk/reference/en-US/environments.xml
===================================================================
--- doc/trunk/reference/en-US/environments.xml 2009-04-06 16:12:49 UTC (rev 2322)
+++ doc/trunk/reference/en-US/environments.xml 2009-04-06 19:09:51 UTC (rev 2323)
@@ -51,14 +51,14 @@
</section>
<section>
- <title>Tomcat</title>
+ <title>Tomcat (or any plain Servlet container)</title>
<para>Web Beans can be used in Tomcat 6.0.</para>
<note>
<para>
Web Beans doesn't support deploying session beans, injection using
- <literal>@EJB</literal>,
<literal>@Resource</literal>, or
+ <literal>@EJB</literal>, or
<literal>@PersistenceContext</literal> or using transactional
events
on Tomcat.
</para>
@@ -122,7 +122,7 @@
</para>
<programlisting><![CDATA[<listener>
-
<listener-class>org.jboss.webbeans.environment.tomcat.Listener</listener-class>
+
<listener-class>org.jboss.webbeans.environment.servlet.Listener</listener-class>
</listener>]]></programlisting>
<para>
Modified: examples/trunk/tomcat/WebContent/META-INF/context.xml
===================================================================
--- examples/trunk/tomcat/WebContent/META-INF/context.xml 2009-04-06 16:12:49 UTC (rev
2322)
+++ examples/trunk/tomcat/WebContent/META-INF/context.xml 2009-04-06 19:09:51 UTC (rev
2323)
@@ -2,4 +2,6 @@
<Resource name="app/Manager" auth="Container"
type="javax.inject.manager.Manager"
factory="org.jboss.webbeans.resources.ManagerObjectFactory"/>
+ <Listener
className="org.jboss.webbeans.environment.tomcat.WebBeansLifecycleListener"
/>
+
</Context>
Modified: examples/trunk/tomcat/WebContent/WEB-INF/web.xml
===================================================================
--- examples/trunk/tomcat/WebContent/WEB-INF/web.xml 2009-04-06 16:12:49 UTC (rev 2322)
+++ examples/trunk/tomcat/WebContent/WEB-INF/web.xml 2009-04-06 19:09:51 UTC (rev 2323)
@@ -30,7 +30,7 @@
</session-config>
<listener>
-
<listener-class>org.jboss.webbeans.environment.tomcat.Listener</listener-class>
+
<listener-class>org.jboss.webbeans.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
Added: extensions/trunk/tomcat/build/.classpath
===================================================================
--- extensions/trunk/tomcat/build/.classpath (rev 0)
+++ extensions/trunk/tomcat/build/.classpath 2009-04-06 19:09:51 UTC (rev 2323)
@@ -0,0 +1,33 @@
+<classpath>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var"
path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"
sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javassist/javassist/3.8.1.GA/javassist-3.8.1.GA.jar"
sourcepath="M2_REPO/javassist/javassist/3.8.1.GA/javassist-3.8.1.GA-sources.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/webbeans/jsr299-api/1.0.0-SNAPSHOT/jsr299-api-1.0.0-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/webbeans/jsr299-api/1.0.0-SNAPSHOT/jsr299-api-1.0.0-SNAPSHOT-sources.jar">
+ <attributes>
+ <attribute
value="jar:file:/Users/pmuir/.m2/repository/org/jboss/webbeans/jsr299-api/1.0.0-SNAPSHOT/jsr299-api-1.0.0-SNAPSHOT-javadoc.jar!/"
name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/webbeans/webbeans-api/1.0.0-SNAPSHOT/webbeans-api-1.0.0-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/webbeans/webbeans-api/1.0.0-SNAPSHOT/webbeans-api-1.0.0-SNAPSHOT-sources.jar">
+ <attributes>
+ <attribute
value="jar:file:/Users/pmuir/.m2/repository/org/jboss/webbeans/webbeans-api/1.0.0-SNAPSHOT/webbeans-api-1.0.0-SNAPSHOT-javadoc.jar!/"
name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/webbeans/webbeans-core/1.0.0-SNAPSHOT/webbeans-core-1.0.0-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/webbeans/webbeans-core/1.0.0-SNAPSHOT/webbeans-core-1.0.0-SNAPSHOT-sources.jar">
+ <attributes>
+ <attribute
value="jar:file:/Users/pmuir/.m2/repository/org/jboss/webbeans/webbeans-core/1.0.0-SNAPSHOT/webbeans-core-1.0.0-SNAPSHOT-javadoc.jar!/"
name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/webbeans/webbeans-logging/1.0.0-SNAPSHOT/webbeans-logging-1.0.0-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/webbeans/webbeans-logging/1.0.0-SNAPSHOT/webbeans-logging-1.0.0-SNAPSHOT-sources.jar">
+ <attributes>
+ <attribute
value="jar:file:/Users/pmuir/.m2/repository/org/jboss/webbeans/webbeans-logging/1.0.0-SNAPSHOT/webbeans-logging-1.0.0-SNAPSHOT-javadoc.jar!/"
name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var"
path="M2_REPO/org/jboss/webbeans/webbeans-spi/1.0.0-SNAPSHOT/webbeans-spi-1.0.0-SNAPSHOT.jar"
sourcepath="M2_REPO/org/jboss/webbeans/webbeans-spi/1.0.0-SNAPSHOT/webbeans-spi-1.0.0-SNAPSHOT-sources.jar">
+ <attributes>
+ <attribute
value="jar:file:/Users/pmuir/.m2/repository/org/jboss/webbeans/webbeans-spi/1.0.0-SNAPSHOT/webbeans-spi-1.0.0-SNAPSHOT-javadoc.jar!/"
name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="/webbeans-tomcat-int"/>
+ <classpathentry kind="var"
path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"
sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
+</classpath>
\ No newline at end of file
Property changes on: extensions/trunk/tomcat/build/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/tomcat/build/.project
===================================================================
--- extensions/trunk/tomcat/build/.project (rev 0)
+++ extensions/trunk/tomcat/build/.project 2009-04-06 19:09:51 UTC (rev 2323)
@@ -0,0 +1,15 @@
+<projectDescription>
+ <name>webbeans-tomcat</name>
+ <comment>Support for Web Beans on Tomcat</comment>
+ <projects>
+ <project>webbeans-tomcat-int</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Property changes on: extensions/trunk/tomcat/build/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/tomcat/build/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- extensions/trunk/tomcat/build/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++ extensions/trunk/tomcat/build/.settings/org.eclipse.jdt.core.prefs 2009-04-06 19:09:51
UTC (rev 2323)
@@ -0,0 +1,5 @@
+#Mon Apr 06 17:56:29 BST 2009
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Property changes on: extensions/trunk/tomcat/build/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/tomcat/build/target/dependency-reduced-pom.xml
===================================================================
--- extensions/trunk/tomcat/build/target/dependency-reduced-pom.xml
(rev 0)
+++ extensions/trunk/tomcat/build/target/dependency-reduced-pom.xml 2009-04-06 19:09:51
UTC (rev 2323)
@@ -0,0 +1,37 @@
+<?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">
+ <parent>
+ <artifactId>webbeans-tomcat-parent</artifactId>
+ <groupId>org.jboss.webbeans.tomcat</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.webbeans.tomcat</groupId>
+ <artifactId>webbeans-tomcat</artifactId>
+ <name>Web Beans Tomcat module</name>
+ <version>1.0.0-SNAPSHOT</version>
+ <
url>http://www.seamframework.org/WebBeans</url>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <artifactSet>
+ <excludes>
+ <exclude>xml-apis:xml-apis</exclude>
+ </excludes>
+ </artifactSet>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
Property changes on: extensions/trunk/tomcat/build/target/dependency-reduced-pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/tomcat/build/target/maven-archiver/pom.properties
===================================================================
--- extensions/trunk/tomcat/build/target/maven-archiver/pom.properties
(rev 0)
+++ extensions/trunk/tomcat/build/target/maven-archiver/pom.properties 2009-04-06 19:09:51
UTC (rev 2323)
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Mon Apr 06 20:03:06 BST 2009
+version=1.0.0-SNAPSHOT
+groupId=org.jboss.webbeans.tomcat
+artifactId=webbeans-tomcat
Property changes on: extensions/trunk/tomcat/build/target/maven-archiver/pom.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: extensions/trunk/tomcat/build/target/original-webbeans-tomcat-1.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on:
extensions/trunk/tomcat/build/target/original-webbeans-tomcat-1.0.0-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: extensions/trunk/tomcat/build/target/webbeans-tomcat-1.0.0-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Property changes on:
extensions/trunk/tomcat/build/target/webbeans-tomcat-1.0.0-SNAPSHOT-sources.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: extensions/trunk/tomcat/build/target/webbeans-tomcat-1.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on:
extensions/trunk/tomcat/build/target/webbeans-tomcat-1.0.0-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Copied:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java
(from rev 2287,
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java)
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/Listener.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.environment.servlet;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletContextEvent;
+
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.bootstrap.api.Environments;
+import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
+import org.jboss.webbeans.environment.servlet.discovery.TomcatWebBeanDiscovery;
+import org.jboss.webbeans.environment.servlet.resources.ReadOnlyNamingContext;
+import org.jboss.webbeans.environment.servlet.util.Reflections;
+import org.jboss.webbeans.manager.api.WebBeansManager;
+import org.jboss.webbeans.resources.spi.NamingContext;
+import org.jboss.webbeans.resources.spi.ResourceServices;
+import org.jboss.webbeans.resources.spi.helpers.AbstractResourceServices;
+import org.jboss.webbeans.servlet.api.ServletListener;
+import org.jboss.webbeans.servlet.api.helpers.ForwardingServletListener;
+
+/**
+ * @author Pete Muir
+ */
+public class Listener extends ForwardingServletListener
+{
+
+ private static final String BOOTSTRAP_IMPL_CLASS_NAME =
"org.jboss.webbeans.bootstrap.WebBeansBootstrap";
+ private static final String WEB_BEANS_LISTENER_CLASS_NAME =
"org.jboss.webbeans.servlet.WebBeansListener";
+ private static final String APPLICATION_BEAN_STORE_ATTRIBUTE_NAME =
Listener.class.getName() + ".applicationBeanStore";
+
+ private final transient Bootstrap bootstrap;
+ private final transient ServletListener webBeansListener;
+ private WebBeansManager manager;
+
+ public Listener()
+ {
+ try
+ {
+ bootstrap = Reflections.newInstance(BOOTSTRAP_IMPL_CLASS_NAME,
Bootstrap.class);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Error loading Web Beans bootstrap, check
that Web Beans is on the classpath", e);
+ }
+ try
+ {
+ webBeansListener = Reflections.newInstance(WEB_BEANS_LISTENER_CLASS_NAME,
ServletListener.class);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Error loading Web Beans listener, check
that Web Beans is on the classpath", e);
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent sce)
+ {
+ manager.shutdown();
+ super.contextDestroyed(sce);
+ }
+
+ public void contextInitialized(ServletContextEvent sce)
+ {
+ BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
+ sce.getServletContext().setAttribute(APPLICATION_BEAN_STORE_ATTRIBUTE_NAME,
applicationBeanStore);
+ bootstrap.setEnvironment(Environments.SERVLET);
+ bootstrap.getServices().add(WebBeanDiscovery.class, new
TomcatWebBeanDiscovery(sce.getServletContext()) {});
+ bootstrap.getServices().add(NamingContext.class, new ReadOnlyNamingContext() {});
+ final Context context;
+ try
+ {
+ context = new InitialContext();
+ }
+ catch (NamingException e)
+ {
+ throw new IllegalStateException("Error creating JNDI context", e);
+ }
+ bootstrap.getServices().add(ResourceServices.class, new AbstractResourceServices()
+ {
+
+ @Override
+ protected Context getContext()
+ {
+ return context;
+ }
+
+ });
+ bootstrap.setApplicationContext(applicationBeanStore);
+ bootstrap.initialize();
+ manager = bootstrap.getManager();
+ bootstrap.boot();
+ super.contextInitialized(sce);
+ }
+
+ @Override
+ protected ServletListener delegate()
+ {
+ return webBeansListener;
+ }
+
+}
Copied:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery
(from rev 2287,
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery)
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/AbstractScanner.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/AbstractScanner.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/AbstractScanner.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.tomcat.discovery;
+package org.jboss.webbeans.environment.servlet.discovery;
import java.net.URL;
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/Scanner.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/Scanner.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/Scanner.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.tomcat.discovery;
+package org.jboss.webbeans.environment.servlet.discovery;
import java.io.File;
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/TomcatWebBeanDiscovery.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/TomcatWebBeanDiscovery.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/TomcatWebBeanDiscovery.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.tomcat.discovery;
+package org.jboss.webbeans.environment.servlet.discovery;
import java.io.File;
import java.net.MalformedURLException;
@@ -26,8 +26,8 @@
import javax.servlet.ServletContext;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
-import org.jboss.webbeans.environment.tomcat.util.Reflections;
-import org.jboss.webbeans.environment.tomcat.util.Servlets;
+import org.jboss.webbeans.environment.servlet.util.Reflections;
+import org.jboss.webbeans.environment.servlet.util.Servlets;
/**
* The means by which Web Beans are discovered on the classpath. This will only
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/URLScanner.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/URLScanner.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/discovery/URLScanner.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.tomcat.discovery;
+package org.jboss.webbeans.environment.servlet.discovery;
import java.io.File;
import java.io.IOException;
Copied:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/resources
(from rev 2287,
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/resources)
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/resources/ReadOnlyNamingContext.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/resources/ReadOnlyNamingContext.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/resources/ReadOnlyNamingContext.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.tomcat.resources;
+package org.jboss.webbeans.environment.servlet.resources;
import javax.inject.DeploymentException;
import javax.naming.Context;
Copied:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util
(from rev 2287,
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util)
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Reflections.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.webbeans.environment.tomcat.util;
+package org.jboss.webbeans.environment.servlet.util;
/**
* Reflection utilities
Modified:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Servlets.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/Servlets.java 2009-03-31
21:49:34 UTC (rev 2287)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/servlet/util/Servlets.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -1,4 +1,4 @@
-package org.jboss.webbeans.environment.tomcat.util;
+package org.jboss.webbeans.environment.servlet.util;
import java.io.File;
import java.net.MalformedURLException;
Deleted:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.environment.tomcat;
-
-import javax.servlet.ServletContextEvent;
-
-import org.jboss.webbeans.bootstrap.api.Bootstrap;
-import org.jboss.webbeans.bootstrap.api.Environments;
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.webbeans.environment.tomcat.discovery.TomcatWebBeanDiscovery;
-import org.jboss.webbeans.environment.tomcat.resources.ReadOnlyNamingContext;
-import org.jboss.webbeans.environment.tomcat.util.Reflections;
-import org.jboss.webbeans.manager.api.WebBeansManager;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.servlet.api.ServletListener;
-import org.jboss.webbeans.servlet.api.helpers.ForwardingServletListener;
-
-/**
- * @author Pete Muir
- */
-public class Listener extends ForwardingServletListener
-{
-
- private static final String BOOTSTRAP_IMPL_CLASS_NAME =
"org.jboss.webbeans.bootstrap.WebBeansBootstrap";
- private static final String WEB_BEANS_LISTENER_CLASS_NAME =
"org.jboss.webbeans.servlet.WebBeansListener";
- private static final String APPLICATION_BEAN_STORE_ATTRIBUTE_NAME =
Listener.class.getName() + ".applicationBeanStore";
-
- private final transient Bootstrap bootstrap;
- private final transient ServletListener webBeansListener;
- private WebBeansManager manager;
-
- public Listener()
- {
- try
- {
- bootstrap = Reflections.newInstance(BOOTSTRAP_IMPL_CLASS_NAME,
Bootstrap.class);
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Error loading Web Beans bootstrap, check
that Web Beans is on the classpath", e);
- }
- try
- {
- webBeansListener = Reflections.newInstance(WEB_BEANS_LISTENER_CLASS_NAME,
ServletListener.class);
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Error loading Web Beans listener, check
that Web Beans is on the classpath", e);
- }
- }
-
- public void contextDestroyed(ServletContextEvent sce)
- {
- manager.shutdown();
- super.contextDestroyed(sce);
- }
-
- public void contextInitialized(ServletContextEvent sce)
- {
- BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
- sce.getServletContext().setAttribute(APPLICATION_BEAN_STORE_ATTRIBUTE_NAME,
applicationBeanStore);
- bootstrap.setEnvironment(Environments.SERVLET);
- bootstrap.getServices().add(WebBeanDiscovery.class, new
TomcatWebBeanDiscovery(sce.getServletContext()) {});
- bootstrap.getServices().add(NamingContext.class, new ReadOnlyNamingContext() {});
- bootstrap.setApplicationContext(applicationBeanStore);
- bootstrap.initialize();
- manager = bootstrap.getManager();
- bootstrap.boot();
- super.contextInitialized(sce);
- }
-
- @Override
- protected ServletListener delegate()
- {
- return webBeansListener;
- }
-
-}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-06
16:12:49 UTC (rev 2322)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -47,6 +47,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
+import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
@@ -258,25 +259,33 @@
*/
protected void injectEjbAndCommonFields(T beanInstance)
{
- if (getManager().getServices().contains(EjbServices.class))
+ EjbServices ejbServices = manager.getServices().get(EjbServices.class);
+ JpaServices jpaServices = manager.getServices().get(JpaServices.class);
+ ResourceServices resourceServices =
manager.getServices().get(ResourceServices.class);
+
+ if (ejbServices != null)
{
- EjbServices ejbServices = manager.getServices().get(EjbServices.class);
- JpaServices jpaServices = manager.getServices().get(JpaServices.class);
for (AnnotatedInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
{
Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
injectionPoint.inject(beanInstance, ejbInstance);
}
-
+ }
+
+ if (jpaServices != null)
+ {
for (AnnotatedInjectionPoint<?, ?> injectionPoint :
persistenceUnitInjectionPoints)
{
Object puInstance = jpaServices.resolvePersistenceContext(injectionPoint);
injectionPoint.inject(beanInstance, puInstance);
}
-
+ }
+
+ if (resourceServices != null)
+ {
for (AnnotatedInjectionPoint<?, ?> injectionPoint :
resourceInjectionPoints)
{
- Object resourceInstance = ejbServices.resolveResource(injectionPoint);
+ Object resourceInstance = resourceServices.resolveResource(injectionPoint);
injectionPoint.inject(beanInstance, resourceInstance);
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -52,6 +52,7 @@
import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.jsf.JSFApiAbstraction;
import org.jboss.webbeans.literal.DeployedLiteral;
import org.jboss.webbeans.literal.InitializedLiteral;
@@ -64,6 +65,7 @@
import org.jboss.webbeans.resources.ManagerObjectFactory;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.servlet.HttpSessionManager;
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -100,8 +102,16 @@
}
if (!getServices().contains(EjbServices.class))
{
- log.info("EJB services not available. Session beans will be simple beans,
injection into non-contextual EJBs, injection of @Resource, @PersistenceContext and @EJB
in simple beans, injection of Java EE resources and JMS resources will not be
available.");
+ log.info("EJB services not available. Session beans will be simple beans,
injection into non-contextual EJBs, injection of @EJB in simple beans, injection of Java
EE resources and JMS resources will not be available.");
}
+ if (!getServices().contains(JpaServices.class))
+ {
+ log.info("JPA services not available. Injection of @PersistenceContext will
not occur. Entity beans will be discovered as simple beans.");
+ }
+ if (!getServices().contains(ResourceServices.class))
+ {
+ log.info("@Resource injection not available.");
+ }
addImplementationServices();
this.manager =
ManagerImpl.newRootManager(ServiceRegistries.unmodifiableServiceRegistry(getServices()));
bindManagerIntoJndi();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-04-06
16:12:49 UTC (rev 2322)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEELifecycle.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -19,6 +19,7 @@
import org.jboss.webbeans.bootstrap.api.Environments;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.jpa.spi.JpaServices;
+import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
public class MockEELifecycle extends MockServletLifecycle
@@ -32,6 +33,7 @@
getBootstrap().getServices().add(TransactionServices.class,
MOCK_TRANSACTION_SERVICES);
getBootstrap().getServices().add(EjbServices.class, new
MockEjBServices(getWebBeanDiscovery()));
getBootstrap().getServices().add(JpaServices.class, new
MockJpaServices(getWebBeanDiscovery()));
+ getBootstrap().getServices().add(ResourceServices.class, new
MockResourceServices());
getBootstrap().setEnvironment(Environments.EE);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-04-06
16:12:49 UTC (rev 2322)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -3,6 +3,7 @@
*/
package org.jboss.webbeans.mock;
+import java.lang.reflect.Field;
import java.util.Collection;
import javax.inject.manager.InjectionPoint;
@@ -27,11 +28,6 @@
return null;
}
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- return null;
- }
-
public void removeEjb(Collection<Object> instance)
{
// No-op
@@ -59,6 +55,12 @@
}
+ public Object getFieldValue(Field field)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
};
}
}
\ No newline at end of file
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.mock;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.resources.spi.ResourceServices;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class MockResourceServices implements ResourceServices
+{
+
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/Environments.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -25,6 +25,7 @@
import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
/**
@@ -39,12 +40,12 @@
/**
* Java EE5 or Java EE6
*/
- EE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class,
TransactionServices.class, NamingContext.class, ResourceLoader.class),
+ EE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class,
ResourceServices.class, TransactionServices.class, NamingContext.class,
ResourceLoader.class),
/**
* Java EE6 Web Profile
*/
- EE_WEB_PROFILE(WebBeanDiscovery.class, EjbServices.class,
JpaServices.class,TransactionServices.class, NamingContext.class, ResourceLoader.class),
+ EE_WEB_PROFILE(WebBeanDiscovery.class, EjbServices.class, JpaServices.class,
ResourceServices.class, TransactionServices.class, NamingContext.class,
ResourceLoader.class),
/**
* Servlet container such as Tomcat
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/BootstrapBean.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -10,6 +10,7 @@
import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
/**
@@ -47,6 +48,16 @@
{
return bootstrap.getServices().get(JpaServices.class);
}
+
+ public ResourceServices getResourceServices()
+ {
+ return bootstrap.getServices().get(ResourceServices.class);
+ }
+
+ public void setResourceServices(ResourceServices resourceServices)
+ {
+ bootstrap.getServices().add(ResourceServices.class, resourceServices);
+ }
public void setWebBeanDiscovery(WebBeanDiscovery webBeanDiscovery)
{
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-04-06
16:12:49 UTC (rev 2322)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/EjbServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -24,7 +24,7 @@
/**
* A container should implement this interface to allow the Web Beans RI to
- * resolve EJBs, Resources and JPA persistence units and discover EJBs
+ * resolve EJB and discover EJBs
*
* @author Pete Muir
*
@@ -48,21 +48,6 @@
public Object resolveEjb(InjectionPoint injectionPoint);
/**
- * Resolve the value for the given @Resource injection point
- *
- * @param injectionPoint
- * the injection point metadata
- * @return an instance of the resource
- * @throws IllegalArgumentException
- * if the injection point is not annotated with @Resource, or, if
- * the injection point is a method that doesn't follow JavaBean
- * conventions
- * @throws IllegalStateException
- * if no resource can be resolved for injection
- */
- public Object resolveResource(InjectionPoint injectionPoint);
-
- /**
* Request a reference to an EJB session object from the container. If the
* EJB being resolved is a stateful session bean, the container should ensure
* the session bean is created before this method returns.
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/spi/helpers/ForwardingEjbServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -46,11 +46,6 @@
{
return delegate().resolveEjb(ejbDescriptor);
}
-
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- return delegate().resolveResource(injectionPoint);
- }
public Iterable<EjbDescriptor<?>> discoverEjbs()
{
Added: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
(rev 0)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.resources.spi;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+
+/**
+ * A container should implement this interface to allow the Web Beans RI to
+ * resolve Resources
+ *
+ * @author Pete Muir
+ *
+ */
+public interface ResourceServices extends Service
+{
+
+ /**
+ * Resolve the value for the given @Resource injection point
+ *
+ * @param injectionPoint
+ * the injection point metadata
+ * @return an instance of the resource
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with @Resource, or, if
+ * the injection point is a method that doesn't follow JavaBean
+ * conventions
+ * @throws IllegalStateException
+ * if no resource can be resolved for injection
+ */
+ public Object resolveResource(InjectionPoint injectionPoint);
+
+}
\ No newline at end of file
Property changes on:
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/ResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
(rev 0)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -0,0 +1,98 @@
+package org.jboss.webbeans.resources.spi.helpers;
+
+import java.beans.Introspector;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javax.annotation.Resource;
+import javax.inject.ExecutionException;
+import javax.inject.manager.InjectionPoint;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.webbeans.resources.spi.ResourceServices;
+
+public abstract class AbstractResourceServices implements ResourceServices
+{
+
+ private static final String RESOURCE_LOOKUP_PREFIX = "java:/comp/env";
+
+ /* (non-Javadoc)
+ * @see
org.jboss.webbeans.resources.spi.helpers.ResourceServices#resolveResource(javax.inject.manager.InjectionPoint)
+ */
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ if (!injectionPoint.isAnnotationPresent(Resource.class))
+ {
+ throw new IllegalArgumentException("No @Resource annotation found on
injection point " + injectionPoint);
+ }
+ if (injectionPoint.getMember() instanceof Method && ((Method)
injectionPoint.getMember()).getParameterTypes().length != 1)
+ {
+ throw new IllegalArgumentException("Injection point represents a method
which doesn't follow JavaBean conventions (must have exactly one parameter) " +
injectionPoint);
+ }
+ String name = getResourceName(injectionPoint);
+ try
+ {
+ return getContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Error looking up " + name + " in
JNDI", e);
+ }
+ }
+
+ protected abstract Context getContext();
+
+ private static String getResourceName(InjectionPoint injectionPoint)
+ {
+ Resource resource = injectionPoint.getAnnotation(Resource.class);
+ String mappedName = resource.mappedName();
+ if (!mappedName.equals(""))
+ {
+ return mappedName;
+ }
+ String name = resource.name();
+ if (!name.equals(""))
+ {
+ return RESOURCE_LOOKUP_PREFIX + "/" + name;
+ }
+ String propertyName;
+ if (injectionPoint.getMember() instanceof Field)
+ {
+ propertyName = injectionPoint.getMember().getName();
+ }
+ else if (injectionPoint.getMember() instanceof Method)
+ {
+ propertyName = getPropertyName((Method) injectionPoint.getMember());
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Injection point represents a method
which doesn't follow JavaBean conventions (unable to determine property name) " +
injectionPoint);
+ }
+ }
+ else
+ {
+ throw new AssertionError("Unable to inject into " + injectionPoint);
+ }
+ String className = injectionPoint.getMember().getDeclaringClass().getName();
+ return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" +
propertyName;
+ }
+
+ public static String getPropertyName(Method method)
+ {
+ String methodName = method.getName();
+ if (methodName.matches("^(get).*") &&
method.getParameterTypes().length == 0)
+ {
+ return Introspector.decapitalize(methodName.substring(3));
+ }
+ else if (methodName.matches("^(is).*") &&
method.getParameterTypes().length == 0)
+ {
+ return Introspector.decapitalize(methodName.substring(2));
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+}
Property changes on:
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/BootstrapTest.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -8,6 +8,7 @@
import org.jboss.webbeans.jpa.spi.JpaServices;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
+import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.testng.annotations.Test;
@@ -36,6 +37,7 @@
bootstrap.getServices().add(TransactionServices.class, new
MockTransactionServices());
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
bootstrap.initialize();
}
@@ -50,6 +52,7 @@
bootstrap.getServices().add(TransactionServices.class, new
MockTransactionServices());
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
bootstrap.initialize();
}
@@ -65,6 +68,7 @@
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
bootstrap.initialize();
}
@@ -80,6 +84,7 @@
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
bootstrap.initialize();
}
@@ -94,9 +99,25 @@
bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.getServices().add(ResourceServices.class, new MockResourceServices());
bootstrap.initialize();
}
+ @Test(expectedExceptions=IllegalStateException.class)
+ public void testMissingResourceServices()
+ {
+ AbstractBootstrap bootstrap = new MockBootstrap();
+ bootstrap.setEnvironment(Environments.EE);
+ bootstrap.getServices().add(NamingContext.class, new MockNamingContext());
+ bootstrap.getServices().add(ResourceLoader.class, new MockResourceLoader());
+ bootstrap.setApplicationContext(new ConcurrentHashMapBeanStore());
+ bootstrap.getServices().add(EjbServices.class, new MockEjbServices());
+ bootstrap.getServices().add(WebBeanDiscovery.class, new MockWebBeanDiscovery());
+ bootstrap.getServices().add(JpaServices.class, new MockJpaServices());
+ bootstrap.getServices().add(TransactionServices.class, new
MockTransactionServices());
+ bootstrap.initialize();
+ }
+
@Test
public void testSEEnv()
{
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockBootstrap.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockBootstrap.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockBootstrap.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -8,13 +8,11 @@
public void boot()
{
- // TODO Auto-generated method stub
}
public WebBeansManager getManager()
{
- // TODO Auto-generated method stub
return null;
}
@@ -25,8 +23,6 @@
public void shutdown()
{
- // TODO Auto-generated method stub
-
}
}
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockEjbServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -11,26 +11,17 @@
public Iterable<EjbDescriptor<?>> discoverEjbs()
{
- // TODO Auto-generated method stub
return null;
}
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor)
{
- // TODO Auto-generated method stub
return null;
}
public Object resolveEjb(InjectionPoint injectionPoint)
{
- // TODO Auto-generated method stub
return null;
}
- public Object resolveResource(InjectionPoint injectionPoint)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
}
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -11,13 +11,11 @@
public Collection<Class<?>> discoverEntities()
{
- // TODO Auto-generated method stub
return null;
}
public Object resolvePersistenceContext(InjectionPoint injectionPoint)
{
- // TODO Auto-generated method stub
return null;
}
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -7,19 +7,15 @@
public void bind(String name, Object value)
{
- // TODO Auto-generated method stub
-
}
public <T> T lookup(String name, Class<? extends T> expectedType)
{
- // TODO Auto-generated method stub
return null;
}
public void unbind(String key)
{
- // TODO Auto-generated method stub
}
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceLoader.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -9,19 +9,16 @@
public Class<?> classForName(String name)
{
- // TODO Auto-generated method stub
return null;
}
public URL getResource(String name)
{
- // TODO Auto-generated method stub
return null;
}
public Iterable<URL> getResources(String name)
{
- // TODO Auto-generated method stub
return null;
}
Added:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
(rev 0)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.bootstrap.api.test;
+
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.resources.spi.ResourceServices;
+
+public class MockResourceServices implements ResourceServices
+{
+
+ public Object resolveResource(InjectionPoint injectionPoint)
+ {
+ return null;
+ }
+
+}
Property changes on:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockResourceServices.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockTransactionServices.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -9,14 +9,11 @@
public boolean isTransactionActive()
{
- // TODO Auto-generated method stub
return false;
}
public void registerSynchronization(Synchronization synchronizedObserver)
{
- // TODO Auto-generated method stub
-
}
}
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java 2009-04-06
16:12:49 UTC (rev 2322)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockWebBeanDiscovery.java 2009-04-06
19:09:51 UTC (rev 2323)
@@ -9,13 +9,11 @@
public Iterable<Class<?>> discoverWebBeanClasses()
{
- // TODO Auto-generated method stub
return null;
}
public Iterable<URL> discoverWebBeansXml()
{
- // TODO Auto-generated method stub
return null;
}