[webbeans-commits] Webbeans SVN: r2236 - in extensions/trunk/tomcat/int: src/main/java/org/jboss/webbeans/environment/tomcat and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Mar 27 15:09:31 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-03-27 15:09:31 -0400 (Fri, 27 Mar 2009)
New Revision: 2236
Added:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java
Removed:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/ServletListener.java
Modified:
extensions/trunk/tomcat/int/pom.xml
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/TomcatWebBeanDiscovery.java
Log:
fixes
Modified: extensions/trunk/tomcat/int/pom.xml
===================================================================
--- extensions/trunk/tomcat/int/pom.xml 2009-03-27 18:16:09 UTC (rev 2235)
+++ extensions/trunk/tomcat/int/pom.xml 2009-03-27 19:09:31 UTC (rev 2236)
@@ -1,53 +1,43 @@
<?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</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-int</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Web Beans Tomcat Integration</name>
- <url>http://www.seamframework.org/WebBeans</url>
- <build>
- <plugins>
- </plugins>
- </build>
+ <parent>
+ <artifactId>webbeans-tomcat</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-int</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Web Beans Tomcat Integration</name>
+ <url>http://www.seamframework.org/WebBeans</url>
- <dependencies>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- <classifier>jdk15</classifier>
- <exclusions>
- <exclusion>
- <artifactId>junit</artifactId>
- <groupId>junit</groupId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <classifier>jdk15</classifier>
+ <exclusions>
+ <exclusion>
+ <artifactId>junit</artifactId>
+ <groupId>junit</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-spi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
- <dependency>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>webbeans-spi</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- TODO remove this dependency -->
- <dependency>
- <groupId>org.jboss.webbeans</groupId>
- <artifactId>webbeans-core</artifactId>
- </dependency>
-
- </dependencies>
-
</project>
Copied: extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java (from rev 2178, extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/ServletListener.java)
===================================================================
--- extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java (rev 0)
+++ extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/Listener.java 2009-03-27 19:09:31 UTC (rev 2236)
@@ -0,0 +1,91 @@
+/*
+ * 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.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;
+
+ 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)
+ {
+ bootstrap.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();
+ bootstrap.boot();
+ super.contextInitialized(sce);
+ }
+
+ @Override
+ protected ServletListener delegate()
+ {
+ return webBeansListener;
+ }
+
+}
Deleted: extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/ServletListener.java
===================================================================
--- extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/ServletListener.java 2009-03-27 18:16:09 UTC (rev 2235)
+++ extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/ServletListener.java 2009-03-27 19:09:31 UTC (rev 2236)
@@ -1,73 +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 javax.servlet.ServletContextListener;
-
-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.resources.spi.NamingContext;
-import org.jboss.webbeans.servlet.WebBeansListener;
-
-/**
- * @author Pete Muir
- */
-public class ServletListener extends WebBeansListener implements ServletContextListener
-{
-
- private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.webbeans.bootstrap.WebBeansBootstrap";
- private static final String APPLICATION_BEAN_STORE_ATTRIBUTE_NAME = ServletListener.class.getName() + ".applicationBeanStore";
-
- private final transient Bootstrap bootstrap;
-
- public ServletListener()
- {
- 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);
- }
- }
-
- public void contextDestroyed(ServletContextEvent sce)
- {
- bootstrap.shutdown();
- }
-
- public void contextInitialized(ServletContextEvent sce)
- {
- BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
- sce.getServletContext().setAttribute(APPLICATION_BEAN_STORE_ATTRIBUTE_NAME, applicationBeanStore);
- bootstrap.setEnvironment(Environments.SE);
- bootstrap.getServices().add(WebBeanDiscovery.class, new TomcatWebBeanDiscovery() {});
- bootstrap.getServices().add(NamingContext.class, new ReadOnlyNamingContext() {});
- bootstrap.setApplicationContext(applicationBeanStore);
- bootstrap.initialize();
- bootstrap.boot();
- }
-
-}
Modified: extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/TomcatWebBeanDiscovery.java
===================================================================
--- extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/TomcatWebBeanDiscovery.java 2009-03-27 18:16:09 UTC (rev 2235)
+++ extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/TomcatWebBeanDiscovery.java 2009-03-27 19:09:31 UTC (rev 2236)
@@ -16,11 +16,16 @@
*/
package org.jboss.webbeans.environment.tomcat.discovery;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import javax.servlet.ServletContext;
+
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.environment.tomcat.util.Reflections;
@@ -37,11 +42,13 @@
private final Set<Class<?>> wbClasses;
private final Set<URL> wbUrls;
+ private final ServletContext servletContext;
- public TomcatWebBeanDiscovery()
+ public TomcatWebBeanDiscovery(ServletContext servletContext)
{
this.wbClasses = new HashSet<Class<?>>();
this.wbUrls = new HashSet<URL>();
+ this.servletContext = servletContext;
scan();
}
@@ -69,6 +76,22 @@
{
Scanner scanner = new URLScanner(Reflections.getClassLoader(), this);
scanner.scanResources(new String[] { "beans.xml" });
+ try
+ {
+ if (servletContext.getResource("/WEB-INF/beans.xml") != null)
+ {
+ File[] files = {new File(servletContext.getResource("/WEB-INF/classes").toURI())};
+ scanner.scanDirectories(files);
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalStateException("Error loading resources from servlet context ", e);
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IllegalStateException("Error loading resources from servlet context ", e);
+ }
}
}
More information about the weld-commits
mailing list