[jboss-cvs] JBossAS SVN: r111246 - in branches/JBPAPP_5_1: server/src/main/org/jboss/deployment and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 26 04:29:32 EDT 2011
Author: jaikiran
Date: 2011-04-26 04:29:31 -0400 (Tue, 26 Apr 2011)
New Revision: 111246
Added:
branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/JSFDeployment.java
branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingDeployer.java
branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingUtil.java
branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/BaseServlet.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/DummyResource.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFBaseComponent.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInLibJarMetaInf.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInMetaInf.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleJSFManagedBean.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleNonWebComponent.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleServlet.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SomeNonManagedPOJOInLibJar.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/unit/
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/unit/ResourceInjectionOnNonJavaEEComponentsTestCase.java
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/META-INF/
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/META-INF/faces-config.xml
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/faces-config.xml
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/web.xml
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/jar/
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/jar/META-INF/
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/jar/META-INF/faces-config.xml
branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/test-jsf-injection.jsp
Modified:
branches/JBPAPP_5_1/server/src/etc/deployers/metadata-deployer-jboss-beans.xml
branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
branches/JBPAPP_5_1/testsuite/imports/sections/web.xml
branches/JBPAPP_5_1/tomcat/src/resources/war-deployers-jboss-beans.xml
Log:
JBPAPP-6239 Fix scanning of Java EE annotations on non-Java EE components in web application
Modified: branches/JBPAPP_5_1/server/src/etc/deployers/metadata-deployer-jboss-beans.xml
===================================================================
--- branches/JBPAPP_5_1/server/src/etc/deployers/metadata-deployer-jboss-beans.xml 2011-04-25 15:54:49 UTC (rev 111245)
+++ branches/JBPAPP_5_1/server/src/etc/deployers/metadata-deployer-jboss-beans.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -98,6 +98,17 @@
<bean name="AnnotationMetaDataDeployer" class="org.jboss.deployment.OptAnnotationMetaDataDeployer">
<property name="metaDataCompleteIsDefault">false</property>
+ <!--
+ Strict servlet spec compliance implies that only a limited set of classes in a web application will be
+ checked for annotations. The type of classes eligible for such annotation scanning is listed in the Servlet specification.
+ Along with those classes, JSF managed bean classes will be included too.
+ If strict servlet spec compliance is disabled (i.e. the flag is false), then all classes in a web application will
+ be checked for annotations and can lead to side effects like picking up resource injection annotations on non-Java EE
+ components.
+
+ See JBAS-8318 JIRA for more details
+ -->
+ <property name="strictServletSpecCompliance">false</property>
</bean>
<!-- Extract annotations into a standard metadata view
Modified: branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
===================================================================
--- branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2011-04-25 15:54:49 UTC (rev 111245)
+++ branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -24,9 +24,12 @@
import java.io.IOException;
import java.lang.reflect.AnnotatedElement;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -49,6 +52,15 @@
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionListener;
+
/**
* A POST_CLASSLOADER deployer which generates metadata from
* annotations
@@ -64,12 +76,27 @@
private boolean metaDataCompleteIsDefault = false;
+ /**
+ * Strict servlet spec compliance implies that only a limited set of classes in a web application will be
+ * checked for annotations. The type of classes eligible for such annotation scanning is listed in the Servlet specification.
+ * Along with those classes, JSF managed bean classes will be included too.
+ * <p/>
+ * If strict servlet spec compliance is disabled (i.e. the flag is false), then all classes in a web application will
+ * be checked for annotations and can lead to side effects like picking up resource injection annotations on non-Java EE
+ * components.
+ *
+ * @see JBAS-8318 JIRA for details
+ */
+ private boolean strictServletSpecCompliance = false;
+
public AnnotationMetaDataDeployer()
{
setStage(DeploymentStages.POST_CLASSLOADER);
addInput(EjbJarMetaData.class);
addInput(WebMetaData.class);
addInput(ApplicationClientMetaData.class);
+ // we need the JSFDeployment information to know of any JSF managed bean classes within a deployment
+ addInput(JSFDeployment.class);
addOutput(EJB_ANNOTATED_ATTACHMENT_NAME);
addOutput(CLIENT_ANNOTATED_ATTACHMENT_NAME);
addOutput(WEB_ANNOTATED_ATTACHMENT_NAME);
@@ -272,7 +299,20 @@
AnnotationFinder<AnnotatedElement> finder, Collection<Class<?>> classes)
{
Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
- WebMetaData annotationMetaData = creator.create(classes);
+ // initialize resource injection eligible classes to all classes
+ Collection<Class<?>> resourceInjectionEligibleClasses = classes;
+ if (this.strictServletSpecCompliance)
+ {
+ // The spec states that resource injection is eligible only on a certain set of classes, so filter out
+ // the rest of the classes
+ resourceInjectionEligibleClasses = this.getResourceInjectionEligibleWebAppClasses(unit, classes);
+ }
+ if (resourceInjectionEligibleClasses.isEmpty())
+ {
+ log.debug("No Java EE injection eligible classes found in web application: " + unit);
+ return;
+ }
+ WebMetaData annotationMetaData = creator.create(resourceInjectionEligibleClasses);
if(annotationMetaData != null)
unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
}
@@ -323,5 +363,102 @@
file.close();
}
}
+
+ /**
+ * Returns true if the deployer is set to follow strict servlet compliance
+ * during annotation scanning. Else returns false.
+ *
+ * @see #strictServletSpecCompliance
+ * @return
+ */
+ public boolean isStrictServletSpecCompliance()
+ {
+ return this.strictServletSpecCompliance;
+ }
+
+ /**
+ * Sets the strict servlet compliance flag on this deployer. The flag will be used during annotation scanning of
+ * classes and limits the number of classes eligible for annotation scanning, if this flag is set to true.
+ *
+ * @param strictCompliance
+ * @see #strictServletSpecCompliance
+ */
+ public void setStrictServletSpecCompliance(boolean strictCompliance)
+ {
+ this.strictServletSpecCompliance = strictCompliance;
+ }
+
+ /**
+ * Returns a subset of classes which are eligible for annotation scanning in a web application. The type of classes
+ * eligible for annotation scanning in a web application is listed in the Servlet spec. Additionally, this method also
+ * includes JSF managed beans as eligible for annotation scanning.
+ *
+ * @param unit The deployment unit being processed
+ * @param classes Collection of all classes that will be scanned for annotations. This method filters out those
+ * classes based on the limited types of classes which are eligible for annotation scanning.
+ * @return
+ */
+ protected Collection<Class<?>> getResourceInjectionEligibleWebAppClasses(DeploymentUnit unit, Collection<Class<?>> classes)
+ {
+ Set<Class<?>> eligibleClasses = new HashSet<Class<?>>();
+ if (classes == null || classes.isEmpty()) {
+ return eligibleClasses;
+ }
+ Collection<String> jsfManagedBeanClasses = Collections.emptySet();
+ // get the JSFDeployment metadata
+ JSFDeployment jsfDeployment = unit.getAttachment(JSFDeployment.class);
+ if (jsfDeployment != null)
+ {
+ // collection of JSF managed beans
+ jsfManagedBeanClasses = jsfDeployment.getManagedBeans();
+ }
+ for (Class<?> klass : classes)
+ {
+ if (klass == null)
+ {
+ continue;
+ }
+ // javax.servlet.Servlet type classes
+ if (Servlet.class.isAssignableFrom(klass))
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (Filter.class.isAssignableFrom(klass)) // javax.servlet.Filter classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (ServletContextListener.class.isAssignableFrom(klass)) // javax.servlet.ServletContextListener classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (ServletContextAttributeListener.class.isAssignableFrom(klass)) // javax.servlet.ServletContextAttributeListener classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (ServletRequestListener.class.isAssignableFrom(klass)) // javax.servlet.ServletRequestListener classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (ServletRequestAttributeListener.class.isAssignableFrom(klass)) // javax.servlet.ServletRequestAttributeListener classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (HttpSessionListener.class.isAssignableFrom(klass)) // javax.servlet.http.HttpSessionListener classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (HttpSessionAttributeListener.class.isAssignableFrom(klass)) // javax.servlet.http.HttpSessionAttributeListener classes
+ {
+ eligibleClasses.add(klass);
+ }
+ else if (jsfManagedBeanClasses.contains(klass.getName())) // JSF managed bean
+ {
+ eligibleClasses.add(klass);
+ }
+ }
+
+ return eligibleClasses;
+ }
+
}
Added: branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/JSFDeployment.java
===================================================================
--- branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/JSFDeployment.java (rev 0)
+++ branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/JSFDeployment.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.deployment;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * Metadata to hold information about the JSF managed bean classes present in a deployment.
+ *
+ * @author Jaikiran Pai
+ */
+public class JSFDeployment
+{
+ /**
+ * Collection of fully qualified class names of JSF managed beans
+ */
+ private Collection<String> managedBeans = new HashSet<String>();
+
+ /**
+ * Returns a collection of fully qualified classnames of JSF managed beans
+ * belong to this JSF deployment
+ *
+ * @return
+ */
+ public Collection<String> getManagedBeans()
+ {
+ return this.managedBeans;
+ }
+
+ /**
+ * Adds the passed <code>managedBeanClass</code> to the collection of managed bean class names.
+ *
+ * @param managedBeanClass The fully qualified classname of the JSF managed bean.
+ * @throws IllegalArgumentException If the passed <code>managedBeanClass</code> is null or an empty string.
+ */
+ public void addManagedBean(String managedBeanClass)
+ {
+ if (managedBeanClass == null || managedBeanClass.trim().isEmpty())
+ {
+ throw new IllegalArgumentException("Managed bean class cannot be null or empty string");
+ }
+ this.managedBeans.add(managedBeanClass);
+ }
+}
Modified: branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
===================================================================
--- branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java 2011-04-25 15:54:49 UTC (rev 111245)
+++ branches/JBPAPP_5_1/server/src/main/org/jboss/deployment/OptAnnotationMetaDataDeployer.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -94,10 +94,25 @@
protected void processJBossWebMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder)
{
Web25MetaDataCreator creator = new Web25MetaDataCreator(finder);
- Collection<Class<?>> classes = getClasses(unit, creator);
- WebMetaData annotationMetaData = creator.create(classes);
+ final Collection<Class<?>> classes = getClasses(unit, creator);
+ // initialize resource injection eligible classes to all classes
+ Collection<Class<?>> resourceInjectionEligibleClasses = classes;
+ if (this.isStrictServletSpecCompliance())
+ {
+ // The spec states that resource injection is eligible only on a certain set of classes, so filter out
+ // the rest of the classes
+ resourceInjectionEligibleClasses = this.getResourceInjectionEligibleWebAppClasses(unit, classes);
+ }
+ if (resourceInjectionEligibleClasses.isEmpty())
+ {
+ log.debug("No Java EE injection eligible classes found in web application: " + unit);
+ return;
+ }
+ WebMetaData annotationMetaData = creator.create(resourceInjectionEligibleClasses);
if(annotationMetaData != null)
+ {
unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, WebMetaData.class);
+ }
}
/**
Added: branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingDeployer.java
===================================================================
--- branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingDeployer.java (rev 0)
+++ branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingDeployer.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.deployers;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.JSFDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Parses a faces-config.xml file, present in WEB-INF or META-INF folders, for the presence of JSF managed beans and
+ * updates the {@link JSFDeployment} metadata with this information.
+ * <p/>
+ * Note that this deployer is just interested in the presence of any JSF managed beans in the faces configuration files
+ * and doesn't do any real parsing of the faces configuration files. The real and complete parsing of the faces
+ * configuration files is left to the JSF implementation provider.
+ *
+ * @author Jaikiran Pai
+ * @see https://issues.jboss.org/browse/JBAS-8318
+ */
+public class FacesConfigParsingDeployer extends AbstractVFSParsingDeployer<JSFDeployment>
+{
+
+ /**
+ * Logger
+ */
+ private static final Logger logger = Logger.getLogger(FacesConfigParsingDeployer.class);
+
+ /**
+ * Create a new FacesConfigParsingDeployer.
+ */
+ public FacesConfigParsingDeployer()
+ {
+ // we output JSFDeployment
+ super(JSFDeployment.class);
+ // we parse faces-config.xml file
+ this.setName("faces-config.xml");
+ // allow multiple faces-config.xml in the deployment unit
+ this.setAllowMultipleFiles(true);
+ }
+
+ @Override
+ protected boolean allowsReparse()
+ {
+ return true;
+ }
+
+ /**
+ * Finds the files with the passed <code>name</code>, under the metadata locations, in the deployment unit and passes
+ * each such file to {@link #parse(org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit, org.jboss.virtual.VirtualFile, org.jboss.deployment.JSFDeployment)}
+ * method of this deployer.
+ * <p/>
+ * Note that we override this method due to a bug in the parsing deployers, which results in only 1 file with the "name" being picked up
+ * from the metadata locations of the unit, even if there are more than one files with that name.
+ * For example: If a .war had faces-config.xml in .war/WEB-INF and .war/lib/somejar.jar/META-INF folders, then ideally both these
+ * files should have been picked up. But due to a bug in the parsing deployers, only the .war/WEB-INF/faces-config.xml would be picked up.
+ * Hence we override this method to fix the problem, by picking all available faces-config.xml from the metadata locations and parsing
+ * each of those.
+ *
+ * @param unit The deployment unit
+ * @param name The name of the file the deployer is interested in
+ * @param output The metadata output
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected JSFDeployment parse(DeploymentUnit unit, String name, JSFDeployment output) throws Exception
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ {
+ return null;
+ }
+
+ if (ignoreName(unit, name))
+ {
+ return null;
+ }
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ List<VirtualFile> facesConfigXmlFiles = vfsDeploymentUnit.getMetaDataFiles(new FacesConfigXmlFileNameMatchFilter());
+ if (facesConfigXmlFiles == null || facesConfigXmlFiles.isEmpty())
+ {
+ return null;
+ }
+ JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class);
+ for (VirtualFile facesConfigXmlFile : facesConfigXmlFiles)
+ {
+ if (this.ignoreFile(vfsDeploymentUnit, facesConfigXmlFile))
+ {
+ continue;
+ }
+ jsfDeployment = this.parse(vfsDeploymentUnit, facesConfigXmlFile, jsfDeployment);
+ }
+ return jsfDeployment;
+ }
+
+ /**
+ * Parse the passed faces configuration <code>file</code> and update the <code>jsfDeployment</code> with the class names
+ * of the managed beans configured in that file.
+ *
+ * @param unit The deployment unit
+ * @param file The faces configuration file
+ * @param jsfDeployment The {@link JSFDeployment} metadata
+ * @return
+ * @throws Exception
+ */
+ @Override
+ protected JSFDeployment parse(VFSDeploymentUnit unit, VirtualFile file, JSFDeployment jsfDeployment) throws Exception
+ {
+ URL facesConfigURL = file.toURL();
+ if (jsfDeployment == null)
+ {
+ // create the jsf deployment. Note that we don't have to attach it to the deployment unit, since that part
+ // will be done by the AbstractVFSParsingDeployer which will attach the return value of this method to the unit.
+ jsfDeployment = new JSFDeployment();
+ }
+ // parse the xml file and update the jsf deployment
+ FacesConfigParsingUtil.parse(unit, facesConfigURL, jsfDeployment);
+ // return the updated jsf deployment
+ return jsfDeployment;
+ }
+
+ /**
+ * A file name based virtual file filter which accepts only files named faces-config.xml which
+ * are present in a META-INF folder or a WEB-INF folder.
+ */
+ private class FacesConfigXmlFileNameMatchFilter implements VirtualFileFilterWithAttributes
+ {
+
+ public VisitorAttributes getAttributes()
+ {
+ return VisitorAttributes.LEAVES_ONLY;
+ }
+
+ /**
+ * Returns true if the file is named faces-config.xml and is present in META-INF or WEB-INF folder.
+ * Else returns false.
+ *
+ * @param file
+ * @return
+ */
+ public boolean accepts(VirtualFile file)
+ {
+ if (file == null)
+ {
+ return false;
+ }
+ String fileName = file.getName();
+ if (fileName.equals("faces-config.xml"))
+ {
+ // file name matches, now make sure its parent is META-INF or WEB-INF
+ try
+ {
+ VirtualFile parent = file.getParent();
+ if (parent == null)
+ {
+ return false;
+ }
+ String parentName = parent.getName();
+ if (parentName.equals("META-INF") || parentName.equals("WEB-INF"))
+ {
+ // it's a match!
+ return true;
+ }
+ }
+ catch (IOException ioe)
+ {
+ // ignore and just log a debug level message and return false.
+ logger.debug("Ignorning faces-config.xml file: " + file + " because of exception while trying to find its parent", ioe);
+ }
+ }
+ return false;
+ }
+ }
+}
Added: branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingUtil.java
===================================================================
--- branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingUtil.java (rev 0)
+++ branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/FacesConfigParsingUtil.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.deployers;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployment.JSFDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Use the {@link #parse(org.jboss.deployers.structure.spi.DeploymentUnit, java.net.URL, org.jboss.deployment.JSFDeployment)}
+ * method to parse a JSF faces configuration file
+ * <p/>
+ * Note that this class and the parse method just look for the presence of JSF managed beans and on finding such managed beans,
+ * update the {@link JSFDeployment}, passed to the parse method, with the managed bean class name.
+ * This class should <b>not</b> be used as a full fledged faces config file parser. The real and complete parsing of the
+ * faces configuration files is left to the JSF implementation provider.
+ *
+ * @author Jaikiran Pai
+ * @see https://issues.jboss.org/browse/JBAS-8318
+ */
+public class FacesConfigParsingUtil
+{
+ /**
+ * Logger
+ */
+ private static final Logger logger = Logger.getLogger(FacesConfigParsingUtil.class);
+
+ /**
+ * Entity resolver for JSF configuration files
+ */
+ private static final JBossEntityResolver jBossJSFEntityResolver = new JBossEntityResolver();
+
+ static
+ {
+ // JSF 1.0
+ jBossJSFEntityResolver.registerEntity("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN", "web-facesconfig_1_0.dtd");
+ jBossJSFEntityResolver.registerEntity("http://java.sun.com/dtd/web-facesconfig_1_0.dtd", "web-facesconfig_1_0.dtd");
+ // JSF 1.1
+ jBossJSFEntityResolver.registerEntity("-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN", "web-facesconfig_1_1.dtd");
+ jBossJSFEntityResolver.registerEntity("http://java.sun.com/dtd/web-facesconfig_1_1.dtd", "web-facesconfig_1_1.dtd");
+ // JSF 1.2
+ jBossJSFEntityResolver.registerEntity("http://java.sun.com/xml/ns/j2ee/web-facesconfig_1_2.xsd", "web-facesconfig_1_2.xsd");
+
+ }
+
+ /**
+ * Parses the faces configuration file represented by the <code>facesConfigXmlURL</code> and checks for the presence of
+ * any JSF managed beans. On finding any managed beans, this method updates the passed <code>jsfDeployment</code> with the
+ * managed bean class name.
+ *
+ * @param unit The deployment unit
+ * @param facesConfigXmlURL The faces config file URL
+ * @param jsfDeployment The JSFDeployment which will be updated with any managed bean class names, that might be found in the
+ * faces config file.
+ * @throws Exception
+ */
+ public static void parse(final DeploymentUnit unit, final URL facesConfigXmlURL, final JSFDeployment jsfDeployment) throws Exception
+ {
+ logger.debug("Checking for the presence of JSF managed-bean(s) in JSF config file: " + facesConfigXmlURL + " in deployment unit: " + unit);
+ // get the parser factory
+ SAXParserFactory parserFactory = getParserFactory();
+ // create a parser
+ SAXParser saxParser = parserFactory.newSAXParser();
+ InputStream inputStream = null;
+ try
+ {
+ // get the input stream and the input source for the faces config file
+ inputStream = getInputStream(facesConfigXmlURL);
+ InputSource inputSource = new InputSource(getInputStream(facesConfigXmlURL));
+ inputSource.setSystemId(facesConfigXmlURL.toExternalForm());
+
+ // parse it!
+ saxParser.parse(inputSource, new DefaultHandler()
+ {
+ /**
+ * Flag to keep track of managed-bean-class element being processed
+ */
+ private boolean managedBeanClassElementProcessingInProgress;
+
+ /**
+ * Uses the {@link JBossEntityResolver} to resolve the entity. If it cannot be resolved by the {@link JBossEntityResolver}
+ * then this method lets the {@link DefaultHandler} to resolve it.
+ *
+ * @param publicId
+ * @param systemId
+ * @return
+ * @throws IOException
+ * @throws SAXException
+ */
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException
+ {
+ // try resolving it with the JBossEntityResolver
+ InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId);
+ if (source != null)
+ {
+ return source;
+ }
+ // we couldn't resolve, so let the default handler try to resolve it
+ return super.resolveEntity(publicId, systemId);
+ }
+
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
+ {
+ // we are only interested in managed-bean-class element.
+ if (localName.equals("managed-bean-class"))
+ {
+ this.managedBeanClassElementProcessingInProgress = true;
+ }
+ // let the super do its job
+ super.startElement(uri, localName, qName, attributes);
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException
+ {
+ // reset the flag when the managed-bean-class element ends
+ if (localName.equals("managed-bean-class"))
+ {
+ this.managedBeanClassElementProcessingInProgress = false;
+ }
+ // let super do its job
+ super.endElement(uri, localName, qName);
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException
+ {
+ // if we are currently processing the managed-bean-class element, then fetch the managed bean
+ // class name text
+ if (this.managedBeanClassElementProcessingInProgress)
+ {
+ // get the managed bean class name
+ String managedBeanClassName = new String(ch, start, length);
+ if (!managedBeanClassName.trim().isEmpty())
+ {
+ logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit);
+ // add it to the jsf deployment
+ jsfDeployment.addManagedBean(managedBeanClassName);
+ }
+ }
+ // let super do its job now
+ super.characters(ch, start, length);
+ }
+ });
+ }
+ finally
+ {
+ if (inputStream != null)
+ {
+ inputStream.close();
+ }
+ }
+ return;
+
+ }
+
+ /**
+ * Returns a instance of {@link SAXParserFactory}
+ *
+ * @return
+ */
+ private static SAXParserFactory getParserFactory()
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ return factory;
+ }
+
+ /**
+ * Returns the {@link InputStream} for the passed <code>url</code>
+ *
+ * @param url
+ * @return
+ * @throws IOException
+ */
+ private static InputStream getInputStream(URL url) throws IOException
+ {
+ URLConnection conn = url.openConnection();
+ conn.setUseCaches(false);
+ return new BufferedInputStream(conn.getInputStream());
+
+ }
+
+}
Added: branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
===================================================================
--- branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java (rev 0)
+++ branches/JBPAPP_5_1/server/src/main/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.web.deployers;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.JSFDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.ParamValueMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
+import org.jboss.virtual.VirtualFile;
+
+import java.util.List;
+
+/**
+ * Deployer which picks up .war deployments and parses the JSF faces configuration files listed in the
+ * javax.faces.CONFIG_FILES context param of the web.xml of the deployment.
+ * <p/>
+ * Note that this deployer is just interested in the presence of any JSF managed beans in the faces configuration files
+ * listed in the javax.faces.CONFIG_FILES and doesn't do any real parsing of the faces configuration files. The real and
+ * complete parsing of the faces configuration files is left to the JSF implementation provider.
+ *
+ * @author Jaikiran Pai
+ * @see https://issues.jboss.org/browse/JBAS-8318
+ */
+public class WebContextParamFacesConfigParsingDeployer extends AbstractDeployer
+{
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(WebContextParamFacesConfigParsingDeployer.class);
+
+ /**
+ * javax.faces.CONFIG_FILES context param
+ */
+ private static final String JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME = "javax.faces.CONFIG_FILES";
+
+ /**
+ * The default location /WEB-INF/faces-config.xml for an application
+ */
+ private static final String WEB_INF_FACES_CONFIG_XML = "/WEB-INF/faces-config.xml";
+
+ /**
+ *
+ */
+ public WebContextParamFacesConfigParsingDeployer()
+ {
+ // we depend on the parsed web.xml
+ this.setInput(WebMetaData.class);
+ // we output JSFDeployment
+ this.setOutput(JSFDeployment.class);
+ // we run in Parse phase
+ this.setStage(DeploymentStages.PARSE);
+ }
+
+
+ /**
+ * Checks for the presence of {@link WebMetaData} attachment in the deployment unit and then checks for
+ * javax.faces.CONFIG_FILES context param in the web metadata. If found, each of the paths specified in the
+ * context param value are resolved relative to the deployment unit root and the resulting file is parsed as
+ * a faces configuration file, to check for the presence of any JSF managed beans. If any JSF managed beans are found,
+ * those are then registered in a {@link JSFDeployment}, which is then attached to the deployment unit.
+ *
+ * @param unit The deployment unit being processed
+ * @throws DeploymentException
+ */
+ public void deploy(final DeploymentUnit unit) throws DeploymentException
+ {
+ // we require a VFSDeploymentUnit, to be able to pick up context relative
+ // config files
+ if (unit instanceof VFSDeploymentUnit == false)
+ {
+ return;
+ }
+ final VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ // get hold of the parsed web.xml metadata
+ WebMetaData webMetaData = unit.getAttachment(WebMetaData.class);
+ // shouldn't really happen, because we have set WebMetaData as a required input.
+ if (webMetaData == null)
+ {
+ return;
+ }
+ List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
+ if (contextParams == null || contextParams.isEmpty())
+ {
+ return;
+ }
+ JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class);
+ if (jsfDeployment == null)
+ {
+ // create and attach
+ jsfDeployment = new JSFDeployment();
+ vfsDeploymentUnit.addAttachment(JSFDeployment.class, jsfDeployment);
+ }
+ for (ParamValueMetaData contextParam : contextParams)
+ {
+ if (contextParam == null)
+ {
+ continue;
+ }
+ if (JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME.equals(contextParam.getParamName()))
+ {
+ try
+ {
+ logger.debug("Found " + JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME + " param with values: "
+ + contextParam.getParamValue() + " in unit " + vfsDeploymentUnit);
+ // process each of the paths specified in the context param value
+ this.processConfigFilesContextParamValue(vfsDeploymentUnit, jsfDeployment, contextParam.getParamValue());
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Parses the context param value representing the relative paths to faces configuration files. Each of the file
+ * represented by the path, is then parsed using {@link FacesConfigParsingUtil} to check for the presence of JSF
+ * managed beans
+ *
+ * @param vfsDeploymentUnit The deployment unit
+ * @param jsfDeployment The JSF deployment metadata
+ * @param configFilesContextParamValue The javax.faces.CONFIG_FILES context param value
+ * @throws Exception
+ */
+ private void processConfigFilesContextParamValue(final VFSDeploymentUnit vfsDeploymentUnit, final JSFDeployment jsfDeployment, final String configFilesContextParamValue) throws Exception
+ {
+ if (configFilesContextParamValue == null)
+ {
+ return;
+ }
+ // trim the context param value
+ String trimmedConfigParamValues = configFilesContextParamValue.trim();
+ // split the paths which are separated by "," delimiter
+ String[] paths = trimmedConfigParamValues.split(",");
+ for (String path : paths)
+ {
+ // trim each path
+ path = path.trim();
+ if (path.isEmpty())
+ {
+ continue;
+ }
+ // skip this path, since .war/WEB-INF/faces-config.xml is by default parsed
+ // (by a separate deployer)
+ if (WEB_INF_FACES_CONFIG_XML.equals(path))
+ {
+ continue;
+ }
+ // get hold of the file relative to the deployment unit root
+ VirtualFile facesConfigXml = vfsDeploymentUnit.getRoot().getChild(path);
+ // for a file which wasn't found, just log a WARN and move on to the next
+ if (facesConfigXml == null)
+ {
+ logger.warn("Faces config xml not found at relative path: " + path + " in unit " + vfsDeploymentUnit.getRoot());
+ continue;
+ }
+ logger.debug("Found faces config xml with relative path: " + path + " in unit " + vfsDeploymentUnit.getRoot());
+ // parse the faces config file
+ FacesConfigParsingUtil.parse(vfsDeploymentUnit, facesConfigXml.toURL(), jsfDeployment);
+ }
+ }
+}
Modified: branches/JBPAPP_5_1/testsuite/imports/sections/web.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/web.xml 2011-04-25 15:54:49 UTC (rev 111245)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/web.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -920,5 +920,39 @@
</fileset>
</jar>
+ <jar destfile="${build.lib}/jbas-8318-jsf-beans.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/web/jbas8318/JSFManagedBeanInLibJarMetaInf.class"/>
+ </fileset>
+ <fileset dir="${build.resources}/web/jbas-8318/jar">
+ <include name="META-INF/*.xml"/>
+ </fileset>
+ </jar>
+
+ <war destfile="${build.lib}/jbas-8318.war"
+ webxml="${build.resources}/web/jbas-8318/WEB-INF/web.xml">
+
+ <webinf dir="${build.resources}/web/jbas-8318/WEB-INF">
+ <include name="*"/>
+ </webinf>
+
+ <classes dir="${build.classes}">
+ <include name="org/jboss/test/web/jbas8318/*.class"/>
+ </classes>
+
+ <fileset dir="${build.resources}/web/jbas-8318">
+ <include name="**/*.jsp"/>
+ </fileset>
+
+ <fileset dir="${build.resources}/web/jbas-8318">
+ <include name="META-INF/*.xml"/>
+ </fileset>
+
+ <lib dir="${build.lib}">
+ <include name="jbas-8318-jsf-beans.jar"/>
+ </lib>
+
+ </war>
+
</target>
</project>
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/BaseServlet.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/BaseServlet.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/BaseServlet.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServlet;
+import javax.transaction.UserTransaction;
+
+/**
+ * User: jpai
+ */
+public class BaseServlet extends HttpServlet
+{
+ @Resource
+ protected UserTransaction utInServletBase;
+
+ protected String envEntryStringInServletBase;
+
+ @Resource(name="simpleString")
+ public void setSimpleEnvEntry(String envEntry)
+ {
+ this.envEntryStringInServletBase = envEntry;
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/DummyResource.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/DummyResource.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/DummyResource.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import java.io.Serializable;
+
+/**
+ * User: jpai
+ */
+public class DummyResource implements Serializable
+{
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFBaseComponent.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFBaseComponent.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFBaseComponent.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+import javax.transaction.UserTransaction;
+
+/**
+ * User: jpai
+ */
+public class JSFBaseComponent
+{
+ @Resource
+ protected UserTransaction utInBaseClass;
+
+ protected String envEntryStringInBaseClass;
+
+ @Resource(name="simpleString")
+ public void setSimpleEnvEntry(String envEntry)
+ {
+ this.envEntryStringInBaseClass = envEntry;
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInLibJarMetaInf.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInLibJarMetaInf.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInLibJarMetaInf.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+import javax.faces.FacesException;
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+/**
+ * User: jpai
+ */
+public class JSFManagedBeanInLibJarMetaInf
+{
+ @Resource (mappedName = "queue/DLQ")
+ private Queue queue;
+
+ public boolean isQueueInjected()
+ {
+ if (this.queue == null)
+ {
+ throw new FacesException("Queue was not injected in " + this.getClass().getName());
+ }
+ return true;
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInMetaInf.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInMetaInf.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/JSFManagedBeanInMetaInf.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+import javax.faces.FacesException;
+import javax.jms.Queue;
+
+/**
+ * User: jpai
+ */
+public class JSFManagedBeanInMetaInf
+{
+ @Resource (mappedName = "queue/DLQ")
+ private Queue dlq;
+
+ public boolean isQueueInjected()
+ {
+ if (this.dlq == null)
+ {
+ throw new FacesException("Queue is not injected in " + JSFManagedBeanInMetaInf.class.getName());
+ }
+ return true;
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleJSFManagedBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleJSFManagedBean.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleJSFManagedBean.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+import javax.faces.FacesException;
+import javax.jms.Queue;
+import javax.transaction.UserTransaction;
+
+/**
+ * User: jpai
+ */
+public class SimpleJSFManagedBean extends JSFBaseComponent
+{
+
+ @Resource(mappedName = "queue/DLQ")
+ private Queue dlq;
+
+ @Resource(name = "simpleString")
+ private String simpleString;
+
+ @Resource
+ private UserTransaction userTransaction;
+
+ public boolean isSimpleEnvEntryInjected()
+ {
+ if (this.simpleString == null)
+ {
+ throw new FacesException("Simple env entry string was not injected in JSF managed bean");
+ }
+ return true;
+ }
+
+ public boolean isUserTransactionInjected()
+ {
+ if (this.userTransaction == null)
+ {
+ throw new FacesException("UserTransaction was not injected in JSF managed bean");
+ }
+ return true;
+ }
+
+ public boolean isQueueInjected()
+ {
+ if (this.dlq == null)
+ {
+ throw new FacesException("Queue was not injected in JSF managed bean");
+ }
+ return true;
+ }
+
+ public boolean isBaseClassResourcesInjected()
+ {
+ if (this.envEntryStringInBaseClass == null)
+ {
+ throw new FacesException("Simple env-entry string in base class of JSF managed bean was not injected");
+ }
+ if (this.utInBaseClass == null)
+ {
+ throw new FacesException("UserTransaction in base class of JSF managed bean was not injected");
+ }
+ return true;
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleNonWebComponent.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleNonWebComponent.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleNonWebComponent.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+
+/**
+ * User: jpai
+ */
+public class SimpleNonWebComponent
+{
+
+ @Resource
+ private DummyResource dummyResource;
+
+ public DummyResource getDummyResource()
+ {
+ return this.dummyResource;
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleServlet.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleServlet.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SimpleServlet.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+import javax.jms.Queue;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * User: jpai
+ */
+public class SimpleServlet extends BaseServlet
+{
+
+ public static final String SUCCESS_MESSAGE = "Success!";
+
+ @Resource
+ private javax.transaction.UserTransaction userTransaction;
+
+ @Resource (name="simpleString")
+ private String simpleEnvResource;
+
+ @Resource(mappedName = "queue/DLQ")
+ private Queue dlq;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ if (this.userTransaction == null)
+ {
+ throw new ServletException("UserTransaction resource not injected in the servlet");
+ }
+
+ if (this.dlq == null)
+ {
+ throw new ServletException("Queue not injected in the servlet");
+ }
+ if (this.simpleEnvResource == null)
+ {
+ throw new ServletException("Simple string env resource not injected in the servlet");
+ }
+ // check base class injections
+ if (this.utInServletBase == null)
+ {
+ throw new ServletException("UserTransaction in base class of servlet not injected");
+ }
+ if (this.envEntryStringInServletBase == null)
+ {
+ throw new ServletException("Simple env-entry string in base class of servlet not injected");
+ }
+ // everything injected
+ resp.getOutputStream().print(SUCCESS_MESSAGE);
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SomeNonManagedPOJOInLibJar.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SomeNonManagedPOJOInLibJar.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/SomeNonManagedPOJOInLibJar.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318;
+
+import javax.annotation.Resource;
+
+/**
+ * User: jpai
+ */
+public class SomeNonManagedPOJOInLibJar
+{
+
+ @Resource
+ private DummyResource unInjectable;
+
+ public DummyResource getUnInjectable()
+ {
+ return this.unInjectable;
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/unit/ResourceInjectionOnNonJavaEEComponentsTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/unit/ResourceInjectionOnNonJavaEEComponentsTestCase.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/web/jbas8318/unit/ResourceInjectionOnNonJavaEEComponentsTestCase.java 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.web.jbas8318.unit;
+
+import junit.framework.Test;
+import org.apache.commons.httpclient.HttpMethod;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.util.web.HttpUtils;
+import org.jboss.test.web.jbas8318.SimpleServlet;
+
+import java.net.URL;
+
+/**
+ * Tests that Java EE resource injections on non-Java EE components are not processed and don't lead to deployment issues.
+ *
+ * @see https://issues.jboss.org/browse/JBAS-8318 for more details
+ * User: jpai
+ */
+public class ResourceInjectionOnNonJavaEEComponentsTestCase extends JBossTestCase
+{
+ private String baseURL = HttpUtils.getBaseURL();
+
+ private static final org.jboss.logging.Logger logger = org.jboss.logging.Logger.getLogger(ResourceInjectionOnNonJavaEEComponentsTestCase.class);
+
+ public ResourceInjectionOnNonJavaEEComponentsTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(ResourceInjectionOnNonJavaEEComponentsTestCase.class, "jbas-8318.war");
+ }
+
+
+ /**
+ * Test that Java EE resource injection in a servlet works as expected
+ *
+ * @throws Exception
+ */
+ public void testInjectionInServlet() throws Exception
+ {
+ URL url = new URL(baseURL + "jbas-8318/SimpleServlet");
+ HttpMethod request = HttpUtils.accessURL(url);
+ String response = request.getResponseBodyAsString();
+ logger.info("Response for url " + url + " is " + response);
+ assertEquals("Unexpected response from servlet", SimpleServlet.SUCCESS_MESSAGE, response);
+ }
+
+ /**
+ * Tests that Java EE resource injection in a JSF managed bean works as expected
+ *
+ * @throws Exception
+ */
+ public void testInjectionInJSFManagedBean() throws Exception
+ {
+ URL url = new URL(baseURL + "jbas-8318/test-jsf-injection.jsf");
+ HttpMethod request = HttpUtils.accessURL(url);
+ int statusCode = request.getStatusCode();
+ logger.info("Got status code: " + statusCode + " for URL " + url);
+ String response = request.getResponseBodyAsString();
+ logger.info("Response for URL " + url + " is " + response);
+ // no exceptions == injection worked fine and test passed.
+ // TODO: We might want to test for the html output to really make sure of the output.
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/META-INF/faces-config.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/META-INF/faces-config.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/META-INF/faces-config.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+
+ <managed-bean>
+ <description>Another managed bean</description>
+ <managed-bean-name>jsfManagedBeanInMetaInf</managed-bean-name>
+ <managed-bean-class>org.jboss.test.web.jbas8318.JSFManagedBeanInMetaInf</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+</faces-config>
Added: branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/faces-config.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/faces-config.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/faces-config.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+
+ <managed-bean>
+ <description>simple managed bean</description>
+ <managed-bean-name>simpleManagedBean</managed-bean-name>
+ <managed-bean-class>org.jboss.test.web.jbas8318.SimpleJSFManagedBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+</faces-config>
Added: branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/web.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/web.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/WEB-INF/web.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<web-app version="2.5"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+
+ <description>JBAS-8318</description>
+
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>
+ /WEB-INF/faces-config.xml,
+ /META-INF/faces-config.xml
+ ,
+
+ </param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>SimpleServlet</servlet-name>
+ <servlet-class>org.jboss.test.web.jbas8318.SimpleServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>javax.faces.FacesServlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>javax.faces.FacesServlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>SimpleServlet</servlet-name>
+ <url-pattern>/SimpleServlet</url-pattern>
+ </servlet-mapping>
+
+ <env-entry>
+ <env-entry-name>simpleString</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>DummyString</env-entry-value>
+ </env-entry>
+</web-app>
Added: branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/jar/META-INF/faces-config.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/jar/META-INF/faces-config.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/jar/META-INF/faces-config.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,36 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2010, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+
+ <managed-bean>
+ <description>Managed bean in .war/lib/*.jar</description>
+ <managed-bean-name>libJarJSFManagedBean</managed-bean-name>
+ <managed-bean-class>org.jboss.test.web.jbas8318.JSFManagedBeanInLibJarMetaInf</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+</faces-config>
+
Added: branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/test-jsf-injection.jsp
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/test-jsf-injection.jsp (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/web/jbas-8318/test-jsf-injection.jsp 2011-04-26 08:29:31 UTC (rev 111246)
@@ -0,0 +1,32 @@
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@page import="org.jboss.test.web.jbas8318.*" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JBAS-8318 JSF injection test</title>
+ </head>
+ <body>
+ <f:view>
+
+ <h:outputText rendered="#{simpleManagedBean.simpleEnvEntryInjected}" value="Success: Injection of simple env-entry string is ok" />
+ <br/>
+ <h:outputText rendered="#{simpleManagedBean.queueInjected}" value="Success: Injection of Queue is ok" />
+ <br/>
+ <h:outputText rendered="#{simpleManagedBean.userTransactionInjected}" value="Success: Injection of UserTransaction is ok" />
+ <br/>
+ <h:outputText rendered="#{simpleManagedBean.baseClassResourcesInjected}" value="Success: Injection of resources in base class is ok" />
+ <br/>
+
+ <h:outputText rendered="#{jsfManagedBeanInMetaInf.queueInjected}" value="Success: Injection of Queue in JSF managed bean configured in .war/META-INF/faces-config.xml is ok" />
+ <br/>
+
+ <h:outputText rendered="#{libJarJSFManagedBean.queueInjected}" value="Success: Injection of Queue in JSF managed bean configured in .war/lib/*.jar/META-INF/faces-config.xml is ok" />
+ <br/>
+ </f:view>
+ </body>
+</html>
Modified: branches/JBPAPP_5_1/tomcat/src/resources/war-deployers-jboss-beans.xml
===================================================================
--- branches/JBPAPP_5_1/tomcat/src/resources/war-deployers-jboss-beans.xml 2011-04-25 15:54:49 UTC (rev 111245)
+++ branches/JBPAPP_5_1/tomcat/src/resources/war-deployers-jboss-beans.xml 2011-04-26 08:29:31 UTC (rev 111246)
@@ -25,7 +25,11 @@
<bean name="JBossWebAppParsingDeployer" class="org.jboss.deployment.JBossWebAppParsingDeployer">
<property name="relativeOrder">2001</property>
</bean>
+
+ <bean name="FacesConfigParsingDeployer" class="org.jboss.web.deployers.FacesConfigParsingDeployer"/>
+ <bean name="WebContextParamFacesConfigParsingDeployer" class="org.jboss.web.deployers.WebContextParamFacesConfigParsingDeployer"/>
+
<!-- See JBAS-6062 -->
<bean name="WebXmlLessDeployer" class="org.jboss.deployment.LegacyWebXmlLessDeployer"/>
More information about the jboss-cvs-commits
mailing list