Author: pete.muir(a)jboss.org
Date: 2009-03-17 13:16:38 -0400 (Tue, 17 Mar 2009)
New Revision: 2073
Added:
extensions/trunk/tomcat/
extensions/trunk/tomcat/int/
extensions/trunk/tomcat/int/pom.xml
extensions/trunk/tomcat/int/src/
extensions/trunk/tomcat/int/src/etc/
extensions/trunk/tomcat/int/src/etc/header.txt
extensions/trunk/tomcat/int/src/main/
extensions/trunk/tomcat/int/src/main/java/
extensions/trunk/tomcat/int/src/main/java/org/
extensions/trunk/tomcat/int/src/main/java/org/jboss/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/
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/discovery/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/AbstractScanner.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/Scanner.java
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/URLScanner.java
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/resources/ReadOnlyNamingContext.java
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java
extensions/trunk/tomcat/int/src/main/resources/
extensions/trunk/tomcat/int/src/test/
extensions/trunk/tomcat/int/src/test/java/
extensions/trunk/tomcat/int/src/test/resources/
extensions/trunk/tomcat/pom.xml
Log:
initial tomcat support
Added: extensions/trunk/tomcat/int/pom.xml
===================================================================
--- extensions/trunk/tomcat/int/pom.xml (rev 0)
+++ extensions/trunk/tomcat/int/pom.xml 2009-03-17 17:16:38 UTC (rev 2073)
@@ -0,0 +1,53 @@
+<?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>
+
+ <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>
+
+ <!-- TODO remove this dependency -->
+ <dependency>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-core</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: extensions/trunk/tomcat/int/src/etc/header.txt
===================================================================
--- extensions/trunk/tomcat/int/src/etc/header.txt (rev 0)
+++ extensions/trunk/tomcat/int/src/etc/header.txt 2009-03-17 17:16:38 UTC (rev 2073)
@@ -0,0 +1,14 @@
+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.
Added:
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
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/ServletListener.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,73 @@
+/*
+ * 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();
+ }
+
+}
Added:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/AbstractScanner.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/AbstractScanner.java
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/AbstractScanner.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,82 @@
+/**
+ * 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.discovery;
+
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Abstract base class for {@link Scanner} providing common functionality
+ *
+ * This class provides file-system orientated scanning
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractScanner implements Scanner
+{
+
+ private static final Logger log = Logger.getLogger(Scanner.class);
+ private final ClassLoader classLoader;
+ private final TomcatWebBeanDiscovery webBeanDiscovery;
+
+ public AbstractScanner(ClassLoader classLoader, TomcatWebBeanDiscovery
webBeanDiscovery)
+ {
+ this.classLoader = classLoader;
+ this.webBeanDiscovery = webBeanDiscovery;
+ }
+
+ protected void handle(String name, URL url)
+ {
+ if (name.endsWith(".class"))
+ {
+ String className = filenameToClassname(name);
+ try
+ {
+ webBeanDiscovery.getWbClasses().add(getClassLoader().loadClass(className));
+ }
+ catch (NoClassDefFoundError e)
+ {
+ log.error("Error loading " + name, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("Error loading " + name, e);
+ }
+ }
+ else if (name.endsWith("beans.xml"))
+ {
+ webBeanDiscovery.getWbUrls().add(url);
+ }
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ /**
+ * Convert a path to a class file to a class name
+ */
+ public static String filenameToClassname(String filename)
+ {
+ return filename.substring( 0, filename.lastIndexOf(".class") )
+ .replace('/', '.').replace('\\', '.');
+ }
+
+}
Added:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/Scanner.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/Scanner.java
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/Scanner.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,47 @@
+/**
+ * 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.discovery;
+
+import java.io.File;
+
+/**
+ * The Scanner is used to find resources to be processed by Seam
+ *
+ * The processing is done by {@link DeploymentHandler}s
+ *
+ * @author Pete Muir
+ *
+ */
+public interface Scanner
+{
+ /**
+ * Recursively scan directories.
+ *
+ * @param directories
+ * An array of the roots of the directory trees to scan
+ */
+ public void scanDirectories(File[] directories);
+
+ /**
+ * Scan for structures which contain any of the given resources in their root
+ *
+ * @param resources
+ * The resources to scan for
+ */
+ public void scanResources(String[] resources);
+
+}
Added:
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
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/TomcatWebBeanDiscovery.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,74 @@
+/**
+ * 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.discovery;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.environment.tomcat.util.Reflections;
+
+/**
+ * The means by which Web Beans are discovered on the classpath. This will only
+ * discover simple web beans - there is no EJB/Servlet/JPA integration.
+ *
+ * @author Peter Royle
+ * @author Pete Muir
+ * @author Ales Justin
+ */
+public abstract class TomcatWebBeanDiscovery implements WebBeanDiscovery
+{
+
+ private final Set<Class<?>> wbClasses;
+ private final Set<URL> wbUrls;
+
+ public TomcatWebBeanDiscovery()
+ {
+ this.wbClasses = new HashSet<Class<?>>();
+ this.wbUrls = new HashSet<URL>();
+ scan();
+ }
+
+ public Iterable<Class<?>> discoverWebBeanClasses()
+ {
+ return Collections.unmodifiableSet(wbClasses);
+ }
+
+ public Iterable<URL> discoverWebBeansXml()
+ {
+ return Collections.unmodifiableSet(wbUrls);
+ }
+
+ public Set<Class<?>> getWbClasses()
+ {
+ return wbClasses;
+ }
+
+ public Set<URL> getWbUrls()
+ {
+ return wbUrls;
+ }
+
+ private void scan()
+ {
+ Scanner scanner = new URLScanner(Reflections.getClassLoader(), this);
+ scanner.scanResources(new String[] { "beans.xml" });
+ }
+
+}
Added:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/URLScanner.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/URLScanner.java
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/discovery/URLScanner.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,198 @@
+/**
+ * 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.discovery;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
+ *
+ * @author Thomas Heute
+ * @author Gavin King
+ * @author Norman Richards
+ * @author Pete Muir
+ *
+ */
+public class URLScanner extends AbstractScanner
+{
+ private static final Logger log = Logger.getLogger(URLScanner.class);
+
+ public URLScanner(ClassLoader classLoader, TomcatWebBeanDiscovery webBeanDiscovery)
+ {
+ super(classLoader, webBeanDiscovery);
+ }
+
+ public void scanDirectories(File[] directories)
+ {
+ for (File directory : directories)
+ {
+ handleDirectory(directory, null);
+ }
+ }
+
+ public void scanResources(String[] resources)
+ {
+ Set<String> paths = new HashSet<String>();
+
+ for (String resourceName : resources)
+ {
+ try
+ {
+ Enumeration<URL> urlEnum =
getClassLoader().getResources(resourceName);
+
+ while (urlEnum.hasMoreElements())
+ {
+ String urlPath = urlEnum.nextElement().getFile();
+ urlPath = URLDecoder.decode(urlPath, "UTF-8");
+
+ if (urlPath.startsWith("file:"))
+ {
+ urlPath = urlPath.substring(5);
+ }
+
+ if (urlPath.indexOf('!') > 0)
+ {
+ urlPath = urlPath.substring(0, urlPath.indexOf('!'));
+ }
+ else
+ {
+ File dirOrArchive = new File(urlPath);
+
+ if ((resourceName != null) &&
(resourceName.lastIndexOf('/') > 0))
+ {
+ // for META-INF/components.xml
+ dirOrArchive = dirOrArchive.getParentFile();
+ }
+
+ urlPath = dirOrArchive.getParent();
+ }
+
+ paths.add(urlPath);
+ }
+ }
+ catch (IOException ioe)
+ {
+ log.warn("could not read: " + resourceName, ioe);
+ }
+ }
+
+ handle(paths);
+ }
+
+ protected void handle(Set<String> paths)
+ {
+ for (String urlPath : paths)
+ {
+ try
+ {
+ log.trace("scanning: " + urlPath);
+
+ File file = new File(urlPath);
+
+ if (file.isDirectory())
+ {
+ handleDirectory(file, null);
+ }
+ else
+ {
+ handleArchiveByFile(file);
+ }
+ }
+ catch (IOException ioe)
+ {
+ log.warn("could not read entries", ioe);
+ }
+ }
+ }
+
+ private void handleArchiveByFile(File file) throws IOException
+ {
+ try
+ {
+ log.trace("archive: " + file);
+
+ ZipFile zip = new ZipFile(file);
+ Enumeration<? extends ZipEntry> entries = zip.entries();
+
+ while (entries.hasMoreElements())
+ {
+ ZipEntry entry = entries.nextElement();
+ String name = entry.getName();
+ handle(name, getClassLoader().getResource(name));
+ }
+ }
+ catch (ZipException e)
+ {
+ throw new RuntimeException("Error handling file " + file, e);
+ }
+ }
+
+ private void handleDirectory(File file, String path)
+ {
+ handleDirectory(file, path, new File[0]);
+ }
+
+ private void handleDirectory(File file, String path, File[] excludedDirectories)
+ {
+ for (File excludedDirectory : excludedDirectories)
+ {
+ if (file.equals(excludedDirectory))
+ {
+ log.trace("skipping excluded directory: " + file);
+
+ return;
+ }
+ }
+
+ log.trace("handling directory: " + file);
+
+ for (File child : file.listFiles())
+ {
+ String newPath = (path == null) ? child.getName() : (path + '/' +
child.getName());
+
+ if (child.isDirectory())
+ {
+ handleDirectory(child, newPath, excludedDirectories);
+ }
+ else
+ {
+ try
+ {
+ handle(newPath, child.toURI().toURL());
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Error loading file " + newPath);
+ }
+ }
+ }
+ }
+
+}
Added:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/resources/ReadOnlyNamingContext.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/resources/ReadOnlyNamingContext.java
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/resources/ReadOnlyNamingContext.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,58 @@
+/*
+ * 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.resources;
+
+import javax.inject.DeploymentException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.webbeans.resources.spi.helpers.AbstractNamingContext;
+
+/**
+ *
+ * @author Pete Muir
+ */
+public class ReadOnlyNamingContext extends AbstractNamingContext
+{
+
+ private final Context context;
+
+ public ReadOnlyNamingContext()
+ {
+ try
+ {
+ context = new InitialContext();
+ }
+ catch (NamingException e)
+ {
+ throw new DeploymentException("Error creating initial context");
+ }
+ }
+
+ public void bind(String name, Object value)
+ {
+ // No-op
+ }
+
+ @Override
+ public Context getContext()
+ {
+ return context;
+ }
+
+}
Added:
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java
===================================================================
---
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java
(rev 0)
+++
extensions/trunk/tomcat/int/src/main/java/org/jboss/webbeans/environment/tomcat/util/Reflections.java 2009-03-17
17:16:38 UTC (rev 2073)
@@ -0,0 +1,62 @@
+/**
+ * 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.util;
+
+/**
+ * Reflection utilities
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class Reflections
+{
+
+ private Reflections()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+ public static <T> T newInstance(String className, Class<T> expectedType)
throws InstantiationException, IllegalAccessException, ClassNotFoundException
+ {
+ return loadClass(className, expectedType).newInstance();
+ }
+
+ public static <T> Class<? extends T> loadClass(String className,
Class<T> expectedType) throws ClassNotFoundException
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ return
Thread.currentThread().getContextClassLoader().loadClass(className).asSubclass(expectedType);
+ }
+ else
+ {
+ return Class.forName(className).asSubclass(expectedType);
+ }
+ }
+
+ public static ClassLoader getClassLoader()
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return Reflections.class.getClassLoader();
+ }
+ }
+
+}
Added: extensions/trunk/tomcat/pom.xml
===================================================================
--- extensions/trunk/tomcat/pom.xml (rev 0)
+++ extensions/trunk/tomcat/pom.xml 2009-03-17 17:16:38 UTC (rev 2073)
@@ -0,0 +1,146 @@
+<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>
+ <groupId>org.jboss.webbeans.tomcat</groupId>
+ <artifactId>webbeans-tomcat</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.jboss.webbeans</groupId>
+ <artifactId>webbeans-version-matrix</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <name>Web Beans Tomcat module</name>
+ <
url>http://www.seamframework.org/WebBeans</url>
+
+ <modules>
+ <module>int</module>
+ </modules>
+
+ <description>
+ Support for Web Beans on Tomcat
+ </description>
+
+ <developers>
+ <developer>
+ <name>Pete Muir</name>
+ <roles>
+ <role>Project Lead</role>
+ </roles>
+ <email>pete.muir(a)jboss.org</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ <url>http://in.relation.to/Bloggers/Pete</url>
+ </developer>
+ </developers>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-8</version>
+ <configuration>
+
<
tagBase>https://svn.jboss.org/repos/webbeans/extensions/tags</tagBa...
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ </plugins>
+ <defaultGoal>package</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>
+ true
+ </addDefaultImplementationEntries>
+ <addDefaultSpecificationEntries>
+ true
+ </addDefaultSpecificationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <profiles>
+
+ </profiles>
+
+ <ciManagement>
+ <system>Hudson</system>
+ <url />
+ </ciManagement>
+
+ <issueManagement>
+ <system>JIRA</system>
+ <
url>http://jira.jboss.org/browse/WBX</url>
+ </issueManagement>
+
+ <inceptionYear>2008</inceptionYear>
+
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <
url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ </license>
+ <license>
+ <name>Lesser Gnu Public License, Version 2.1</name>
+ <
url>http://www.gnu.org/licenses/lgpl-2.1.html</url>
+ </license>
+ </licenses>
+
+ <scm>
+
<
connection>scm:svn:http://anonsvn.jboss.org/repos/webbeans/extensions&...
+
<
developerConnection>scm:svn:https://svn.jboss.org/repos/webbeans/exten...
+ <
url>http://fisheye.jboss.org/browse/WebBeans/extensions</url>
+ </scm>
+
+ <distributionManagement>
+ <repository>
+ <!-- Copy the dist to the local checkout of the JBoss maven2 repo
${maven.repository.root} -->
+ <!-- It is anticipated that ${maven.repository.root} be set in user's
settings.xml -->
+ <!-- todo : replace this with direct svn access once the svnkit providers are
available -->
+ <id>repository.jboss.org</id>
+ <url>file://${maven.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <
url>dav:https://snapshots.jboss.org/maven2</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+</project>