[jboss-cvs] JBossAS SVN: r83850 - in projects/jboss-deployers/trunk/deployers-vfs/src: test/java/org/jboss/test/deployers/vfs/deployer/facelets/support and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 4 08:56:52 EST 2009
Author: alesj
Date: 2009-02-04 08:56:52 -0500 (Wed, 04 Feb 2009)
New Revision: 83850
Added:
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/support/SearchDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/FaceletsUnitTestCase.java
projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
Log:
Port real WarStructure.
Mock booking deployment.
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java 2009-02-04 13:35:59 UTC (rev 83849)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java 2009-02-04 13:56:52 UTC (rev 83850)
@@ -22,6 +22,7 @@
package org.jboss.deployers.vfs.plugins.structure.war;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import org.jboss.deployers.spi.DeploymentException;
@@ -35,18 +36,25 @@
/**
* WARStructure.
- *
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 83811 $
*/
public class WARStructure extends AbstractVFSStructureDeployer
{
/** The default filter which allows jars/jar directories */
public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
-
+
/** The web-inf/lib filter */
private VirtualFileFilter webInfLibFilter = DEFAULT_WEB_INF_LIB_FILTER;
+ /** The web-inf/lib/[some-archive]/META-INF filter */
+ private VirtualFileFilter webInfLibMetaDataFilter;
+
+ /** Whether to include web-inf in the classpath */
+ private boolean includeWebInfInClasspath;
+
/**
* Sets the default relative order 1000.
*
@@ -58,7 +66,7 @@
/**
* Get the webInfLibFilter.
- *
+ *
* @return the webInfLibFilter.
*/
public VirtualFileFilter getWebInfLibFilter()
@@ -68,7 +76,7 @@
/**
* Set the webInfLibFilter.
- *
+ *
* @param webInfLibFilter the webInfLibFilter.
* @throws IllegalArgumentException for a null filter
*/
@@ -79,6 +87,36 @@
this.webInfLibFilter = webInfLibFilter;
}
+ /**
+ * Get webInfLibMetaDataFilter
+ *
+ * @return the webInfLibMetaDataFilter
+ */
+ public VirtualFileFilter getWebInfLibMetaDataFilter()
+ {
+ return webInfLibMetaDataFilter;
+ }
+
+ /**
+ * Set the webInfLibMetaDataFilter.
+ *
+ * @param webInfLibMetaDataFilter the webInfLibFilter.
+ */
+ public void setWebInfLibMetaDataFilter(VirtualFileFilter webInfLibMetaDataFilter)
+ {
+ this.webInfLibMetaDataFilter = webInfLibMetaDataFilter;
+ }
+
+ /**
+ * Should we include web-inf in classpath.
+ *
+ * @param includeWebInfInClasspath the include web-inf flag
+ */
+ public void setIncludeWebInfInClasspath(boolean includeWebInfInClasspath)
+ {
+ this.includeWebInfInClasspath = includeWebInfInClasspath;
+ }
+
public boolean determineStructure(StructureContext structureContext) throws DeploymentException
{
ContextInfo context = null;
@@ -87,6 +125,9 @@
{
boolean trace = log.isTraceEnabled();
+ // the WEB-INF
+ VirtualFile webinf = null;
+
if (isLeaf(file) == false)
{
// We require either a WEB-INF or the name ends in .war
@@ -94,8 +135,8 @@
{
try
{
- VirtualFile child = file.getChild("WEB-INF");
- if (child != null)
+ webinf = file.getChild("WEB-INF");
+ if (webinf != null)
{
if (trace)
log.trace("... ok - directory has a WEB-INF subdirectory");
@@ -118,44 +159,76 @@
log.trace("... ok - name ends in .war.");
}
- // Create a context for this war file with WEB-INF as the location for metadata
- // Some wars also might have metadata in WEB-INF/classes/META-INF, e.g. persistence.xml
- context = createContext(structureContext, new String[]{"WEB-INF", "WEB-INF/classes/META-INF"});
+ List<String> metaDataLocations = new ArrayList<String>();
+ metaDataLocations.add("WEB-INF");
- // Add the war manifest classpath entries
- addClassPath(structureContext, file, false, true, context);
+ // Check for WEB-INF/classes
+ VirtualFile classes = null;
try
{
- // The classpath is WEB-INF/classes
- VirtualFile classes = file.getChild("WEB-INF/classes");
- // Add the war manifest classpath entries
+ // The classpath contains WEB-INF/classes
+ classes = file.getChild("WEB-INF/classes");
+
+ // Check for a META-INF for metadata
if (classes != null)
- addClassPath(structureContext, classes, true, false, context);
- else if (trace)
- log.trace("No WEB-INF/classes for: " + file.getPathName());
+ metaDataLocations.add("WEB-INF/classes/META-INF");
}
catch(IOException e)
{
log.warn("Exception while looking for classes, " + file.getPathName() + ", " + e);
}
- // and the top level jars in WEB-INF/lib
+
+ // Check for jars in WEB-INF/lib
+ List<VirtualFile> archives = null;
try
{
VirtualFile webinfLib = file.getChild("WEB-INF/lib");
if (webinfLib != null)
{
- List<VirtualFile> archives = webinfLib.getChildren(webInfLibFilter);
+ archives = webinfLib.getChildren(webInfLibFilter);
+ // Add the jars' META-INF for metadata
for (VirtualFile jar : archives)
- addClassPath(structureContext, jar, true, true, context);
+ {
+ // either same as plain lib filter, null or accepts the jar
+ if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
+ metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
+ }
}
- else if (trace)
- log.trace("No WEB-INF/lib for: " + file.getPathName());
}
catch (IOException e)
{
log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
}
+ // Create a context for this war file and all its metadata locations
+ context = createContext(structureContext, metaDataLocations.toArray(new String[metaDataLocations.size()]));
+
+ // Add the war manifest classpath entries
+ addClassPath(structureContext, file, false, true, context);
+
+ // Add WEB-INF/classes if present
+ if (classes != null)
+ addClassPath(structureContext, classes, true, false, context);
+ else if (trace)
+ log.trace("No WEB-INF/classes for: " + file.getPathName());
+
+ // and the top level jars in WEB-INF/lib
+ if (archives != null)
+ {
+ for (VirtualFile jar : archives)
+ addClassPath(structureContext, jar, true, true, context);
+ }
+ else if (trace)
+ {
+ log.trace("No WEB-INF/lib for: " + file.getPathName());
+ }
+
+ // do we include WEB-INF in classpath
+ if (includeWebInfInClasspath && webinf != null)
+ {
+ addClassPath(structureContext, webinf, true, false, context);
+ }
+
// There are no subdeployments for wars
return true;
}
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/support/SearchDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/support/SearchDeployer.java 2009-02-04 13:35:59 UTC (rev 83849)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/support/SearchDeployer.java 2009-02-04 13:56:52 UTC (rev 83850)
@@ -23,10 +23,13 @@
import java.io.IOException;
import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
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.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.DeploymentUnit;
/**
@@ -42,7 +45,7 @@
private String prefix;
private String suffix;
- private URL[] urls;
+ private Set<URL> urls = new HashSet<URL>();
public SearchDeployer(String prefix, String suffix)
{
@@ -60,7 +63,11 @@
{
try
{
- urls = Classpath.search(unit.getClassLoader(), prefix, suffix);
+ URL[] foundUrls = Classpath.search(unit.getClassLoader(), prefix, suffix);
+ if (foundUrls != null)
+ {
+ urls.addAll(Arrays.asList(foundUrls));
+ }
}
catch (IOException e)
{
@@ -73,7 +80,7 @@
urls = null;
}
- public URL[] getUrls()
+ public Set<URL> getUrls()
{
return urls;
}
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java (from rev 83617, projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/FaceletsUnitTestCase.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java 2009-02-04 13:56:52 UTC (rev 83850)
@@ -0,0 +1,155 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.deployers.vfs.deployer.facelets.test;
+
+import java.net.URL;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer;
+import org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer;
+import org.jboss.deployers.structure.spi.StructureBuilder;
+import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer;
+import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+import org.jboss.deployers.vfs.plugins.structure.modify.ModificationTypeStructureProcessor;
+import org.jboss.deployers.vfs.plugins.structure.modify.TempTopModificationTypeMatcher;
+import org.jboss.deployers.vfs.plugins.structure.war.WARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.test.deployers.vfs.deployer.AbstractDeployerUnitTest;
+import org.jboss.test.deployers.vfs.deployer.facelets.support.SearchDeployer;
+import org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.plugins.cache.IterableTimedVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCacheFactory;
+
+/**
+ * BookingUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BookingUnitTest extends AbstractDeployerUnitTest
+{
+ private SearchDeployer deployer = new SearchDeployer("META-INF/", ".taglib.xml");
+
+ public BookingUnitTest(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ // Uncomment this to test VFS nested jar copy handling
+ System.setProperty(VFSUtils.FORCE_COPY_KEY, "true");
+
+ VFSCache cache = new IterableTimedVFSCache();
+ cache.start();
+ VFSCacheFactory.setInstance(cache);
+
+ addStructureDeployer(main, new WARStructure());
+ addStructureDeployer(main, new MockEarStructureDeployer());
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ VFSCacheFactory.setInstance(null);
+ super.tearDown();
+ }
+
+ protected void addDeployers(Kernel kernel)
+ {
+ ClassLoadingDefaultDeployer cldd = new ClassLoadingDefaultDeployer();
+ ClassLoadingMetaData clmd = new ClassLoadingMetaData();
+ cldd.setDefaultMetaData(clmd);
+
+ VFSClassLoaderClassPathDeployer vfscp = new VFSClassLoaderClassPathDeployer();
+ VFSClassLoaderDescribeDeployer vfsdd = new VFSClassLoaderDescribeDeployer();
+ ClassLoading classLoading = new ClassLoading();
+ KernelController controller = kernel.getController();
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("ClassLoading", ClassLoading.class.getName());
+ builder.addMethodInstallCallback("addModule");
+ builder.addMethodUninstallCallback("removeModule");
+ try
+ {
+ controller.install(builder.getBeanMetaData(), classLoading);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ vfsdd.setClassLoading(classLoading);
+
+ ClassLoaderSystem system = new DefaultClassLoaderSystem();
+ system.getDefaultDomain().setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY);
+
+ AbstractLevelClassLoaderSystemDeployer clsd = new AbstractLevelClassLoaderSystemDeployer();
+ clsd.setClassLoading(classLoading);
+ clsd.setSystem(system);
+
+ addDeployer(main, cldd);
+ addDeployer(main, vfsdd);
+ addDeployer(main, vfscp);
+ addDeployer(main, clsd);
+ addDeployer(main, deployer);
+ }
+
+ @Override
+ protected StructureBuilder createStructureBuilder()
+ {
+ VFSStructureBuilder structureBuilder = (VFSStructureBuilder)super.createStructureBuilder();
+ ModificationTypeStructureProcessor sp = new ModificationTypeStructureProcessor();
+ sp.addMatcher(new TempTopModificationTypeMatcher("META-INF/components.xml"));
+ structureBuilder.setStructureProcessor(sp);
+ return structureBuilder;
+ }
+
+ protected void testFacelets(String name, int size) throws Throwable
+ {
+ VFSDeployment context = createDeployment("/facelets", name);
+ assertDeploy(context);
+ try
+ {
+ Set<URL> urls = deployer.getUrls();
+ assertNotNull(urls);
+ assertEquals(size, urls.size());
+ }
+ finally
+ {
+ assertUndeploy(context);
+ }
+ }
+
+ public void testBooking() throws Throwable
+ {
+ testFacelets("booking.ear", 11);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/FaceletsUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/FaceletsUnitTestCase.java 2009-02-04 13:35:59 UTC (rev 83849)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/FaceletsUnitTestCase.java 2009-02-04 13:56:52 UTC (rev 83850)
@@ -22,6 +22,7 @@
package org.jboss.test.deployers.vfs.deployer.facelets.test;
import java.net.URL;
+import java.util.Set;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -112,9 +113,9 @@
assertDeploy(context);
try
{
- URL[] urls = deployer.getUrls();
+ Set<URL> urls = deployer.getUrls();
assertNotNull(urls);
- assertEquals(size, urls.length);
+ assertEquals(size, urls.size());
}
finally
{
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java 2009-02-04 13:35:59 UTC (rev 83849)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java 2009-02-04 13:56:52 UTC (rev 83850)
@@ -300,6 +300,7 @@
VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml");
VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml");
VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml");
+ //VirtualFile seamXml = getMetaDataFile(archive, "META-INF/components.xml");
if (clientXml != null)
{
@@ -318,7 +319,7 @@
determineType(context, archive);
}
}
- else if (ejbXml != null || jbossXml != null)
+ else if (ejbXml != null || jbossXml != null) // || seamXml != null)
{
type = J2eeModuleMetaData.EJB;
}
More information about the jboss-cvs-commits
mailing list