[jboss-cvs] JBossAS SVN: r63686 - in projects/microcontainer/trunk: deployers-vfs-spi and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 27 11:59:03 EDT 2007
Author: adrian at jboss.org
Date: 2007-06-27 11:59:02 -0400 (Wed, 27 Jun 2007)
New Revision: 63686
Added:
projects/microcontainer/trunk/deployers-vfs-spi/
projects/microcontainer/trunk/deployers-vfs-spi/.classpath
projects/microcontainer/trunk/deployers-vfs-spi/.project
projects/microcontainer/trunk/deployers-vfs-spi/pom.xml
projects/microcontainer/trunk/deployers-vfs-spi/src/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeployment.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentBuilder.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractSimpleVFSRealDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSRealDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXBDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestMetaData.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SecurityActions.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/StructureDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentResourceLoader.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSStructuralDeployers.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractCandidateStructureVisitor.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/CandidateStructureVisitorFactory.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/DefaultCandidateStructureVisitorFactory.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/SecurityActions.java
projects/microcontainer/trunk/deployers-vfs-spi/src/resources/
Log:
Import refactored deployers code
Added: projects/microcontainer/trunk/deployers-vfs-spi/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/.classpath (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/.classpath 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-vfs/2.0.4.snapshot/jboss-vfs-2.0.4.snapshot.jar" sourcepath="M2_REPO/jboss/jboss-vfs/2.0.4.snapshot/jboss-vfs-2.0.4.snapshot-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.0/jaxb-api-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossxb/2.0.0.CR3/jbossxb-2.0.0.CR3.jar" sourcepath="M2_REPO/jboss/jbossxb/2.0.0.CR3/jbossxb-2.0.0.CR3-sources.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-core-spi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-client-spi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-spi"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-structure-spi"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>
Added: projects/microcontainer/trunk/deployers-vfs-spi/.project
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/.project (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/.project 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jboss-deployers-vfs-spi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/microcontainer/trunk/deployers-vfs-spi/pom.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/pom.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/pom.xml 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,30 @@
+<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>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-microcontainer</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-deployers-vfs-spi</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Deployers VFS SPI</name>
+ <url>http://www.jboss.com/products/jbossmc</url>
+ <description>JBoss Deployers VFS SPI</description>
+ <dependencies>
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-deployers-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-classloader</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeployment.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeployment.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeployment.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.client;
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSDeployment.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface VFSDeployment extends Deployment
+{
+ /**
+ * Get the root of the deployment
+ *
+ * @return the root
+ */
+ VirtualFile getRoot();
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentBuilder.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentBuilder.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentBuilder.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.client;
+
+import java.security.AccessController;
+
+import org.jboss.util.builder.AbstractBuilder;
+
+/**
+ * VFSDeploymentBuilder.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class VFSDeploymentBuilder
+{
+ /** The default attachments builder */
+ private static String DEFAULT_FACTORY = "org.jboss.deployers.vfs.plugins.client.DefaultVFSDeploymentFactory";
+
+ /** The singleton */
+ private static VFSDeploymentFactory singleton;
+
+ /**
+ * Get the instance
+ *
+ * @return the instance
+ */
+ static synchronized VFSDeploymentFactory getInstance()
+ {
+ if (singleton == null)
+ {
+ AbstractBuilder<VFSDeploymentFactory> builder = new AbstractBuilder<VFSDeploymentFactory>(VFSDeploymentFactory.class, DEFAULT_FACTORY);
+ singleton = AccessController.doPrivileged(builder);
+ }
+ return singleton;
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/client/VFSDeploymentFactory.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.client;
+
+import org.jboss.deployers.client.spi.DeploymentFactory;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSDeploymentFactory.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class VFSDeploymentFactory extends DeploymentFactory
+{
+ /**
+ * Get an instance of the factory
+ *
+ * @return the factory
+ */
+ public static VFSDeploymentFactory getInstance()
+ {
+ return VFSDeploymentBuilder.getInstance();
+ }
+
+ /**
+ * Create a new VFS deployment
+ *
+ * @param root the root virtual file
+ * @return the deployment
+ * @throws IllegalArgumentException for a null root
+ */
+ public VFSDeployment createVFSDeployment(VirtualFile root)
+ {
+ return VFSDeploymentBuilder.getInstance().newVFSDeployment(root);
+ }
+
+ /**
+ * Create a new VFS deployment
+ *
+ * @param root the root virtual file
+ * @return the deployment
+ * @throws IllegalArgumentException for a null root
+ */
+ protected abstract VFSDeployment newVFSDeployment(VirtualFile root);
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractSimpleVFSRealDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractSimpleVFSRealDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractSimpleVFSRealDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,88 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * AbstractSimpleVFSRealDeployer.
+ *
+ * @param <T> the input type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSimpleVFSRealDeployer<T> extends AbstractSimpleRealDeployer<T>
+{
+ /**
+ * Create a new AbstractSimpleVFSRealDeployer
+ *
+ * @param input the input type
+ * @throws IllegalArgumentException for a null input
+ */
+ public AbstractSimpleVFSRealDeployer(Class<T> input)
+ {
+ super(input);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, T deployment) throws DeploymentException
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ deploy(vfsDeploymentUnit, deployment);
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, T deployment)
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ undeploy(vfsDeploymentUnit, deployment);
+ }
+
+ /**
+ * Deploy a deployment
+ *
+ * @param unit the unit
+ * @param deployment the attachment
+ * @throws DeploymentException for any error
+ */
+ public abstract void deploy(VFSDeploymentUnit unit, T deployment) throws DeploymentException;
+
+ /**
+ * Undeploy a deployment
+ *
+ * @param unit the unit
+ * @param deployment the attachment
+ */
+ public void undeploy(VFSDeploymentUnit unit, T deployment)
+ {
+ // Nothing
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.deployer;
+
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * AbstractVFSParsingDeployer.
+ *
+ * @param <T> the type of output
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractVFSParsingDeployer<T> extends AbstractParsingDeployerWithOutput<T>
+{
+ /**
+ * Create a new AbstractVFSParsingDeployer.
+ *
+ * @param output the type of output
+ * @throws IllegalArgumentException for null output
+ */
+ public AbstractVFSParsingDeployer(Class<T> output)
+ {
+ super(output);
+ }
+
+ /**
+ * Callback to do prechecking on the deployment
+ *
+ * @param unit the unit
+ * @return true by default
+ * @throws DeploymentException for any error
+ */
+ protected boolean accepts(VFSDeploymentUnit unit) throws DeploymentException
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean accepts(DeploymentUnit unit) throws DeploymentException
+ {
+ // Ignore non-vfs deployments
+ if (unit instanceof VFSDeploymentUnit == false)
+ {
+ log.trace("Not a vfs deployment: " + unit.getName());
+ return false;
+ }
+ return accepts((VFSDeploymentUnit) unit);
+ }
+
+ @Override
+ protected T parse(DeploymentUnit unit, String name, T root) throws Exception
+ {
+ // Try to find the metadata
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+
+ VirtualFile file = vfsDeploymentUnit.getMetaDataFile(name);
+ if (file == null)
+ return null;
+
+ T result = parse(vfsDeploymentUnit, file, root);
+ if (result != null)
+ init(vfsDeploymentUnit, result, file);
+ return result;
+ }
+
+ @Override
+ protected T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception
+ {
+ // Should we include the deployment
+ // The infrastructure will only check leafs anyway so no need to check here
+ if (name == null && isIncludeDeploymentFile())
+ name = unit.getName();
+
+ // Try to find the metadata
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ List<VirtualFile> files = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
+ if (files.size() == 0)
+ return null;
+
+ // TODO remove this limitation
+ if (files.size() > 1)
+ throw new DeploymentException("Only one file is allowed, found=" + files);
+
+ VirtualFile file = files.get(0);
+
+ T result = parse(vfsDeploymentUnit, file, root);
+ if (result != null)
+ init(vfsDeploymentUnit, result, file);
+ return result;
+ }
+
+ /**
+ * Parse a deployment
+ *
+ * @param unit the deployment unit
+ * @param file the metadata file
+ * @param root - possibly null pre-existing root
+ * @return the metadata
+ * @throws Exception for any error
+ */
+ protected abstract T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception;
+
+ /**
+ * Initialise the metadata
+ *
+ * @param unit the unit
+ * @param metaData the metadata
+ * @param file the metadata file
+ * @throws Exception for any error
+ */
+ protected void init(VFSDeploymentUnit unit, T metaData, VirtualFile file) throws Exception
+ {
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSRealDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSRealDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/AbstractVFSRealDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.deployer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+
+/**
+ * AbstractRealDeployer.
+ *
+ * @Deprecated if you've left it until the real deployer to look at the file system then you are lazy
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at Deprecated
+public abstract class AbstractVFSRealDeployer extends AbstractRealDeployer
+{
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ deploy(vfsDeploymentUnit);
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ return;
+
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ undeploy(vfsDeploymentUnit);
+ }
+
+ /**
+ * Deploy a vfs deployment
+ *
+ * @param unit the unit
+ * @throws DeploymentException for any error
+ */
+ public abstract void deploy(VFSDeploymentUnit unit) throws DeploymentException;
+
+ /**
+ * Undeploy a vfs deployment
+ *
+ * @param unit the unit
+ */
+ public void undeploy(VFSDeploymentUnit unit)
+ {
+ // Nothing
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXBDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXBDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXBDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,124 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.xml.sax.InputSource;
+
+/**
+ * JAXBDeployer.
+ *
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class JAXBDeployer<T> extends AbstractVFSParsingDeployer<T>
+{
+ /** The JAXBContext */
+ private JAXBContext context;
+
+ /** The properties */
+ private Map<String, Object> properties;
+
+ /**
+ * Create a new JAXBDeployer.
+ *
+ * @param output the output
+ * @throws IllegalArgumentException for a null output
+ */
+ public JAXBDeployer(Class<T> output)
+ {
+ super(output);
+ }
+
+ /**
+ * Get the properties.
+ *
+ * @return the properties.
+ */
+ public Map<String, Object> getProperties()
+ {
+ return properties;
+ }
+
+ /**
+ * Set the properties.
+ *
+ * @param properties the properties.
+ */
+ public void setProperties(Map<String, Object> properties)
+ {
+ this.properties = properties;
+ }
+
+ /**
+ * Create lifecycle
+ *
+ * @throws Exception for any problem
+ */
+ public void create() throws Exception
+ {
+ if (properties != null)
+ context = JAXBContext.newInstance(new Class[] { getOutput() }, properties);
+ else
+ context = JAXBContext.newInstance(getOutput());
+ }
+
+ /**
+ * Destroy lifecycle
+ */
+ public void destroy()
+ {
+ context = null;
+ }
+
+ @Override
+ protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
+ {
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ InputStream is = file.openStream();
+ try
+ {
+ InputSource source = new InputSource(is);
+ source.setSystemId(file.toURI().toString());
+ Object o = unmarshaller.unmarshal(source);
+ return getOutput().cast(o);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,203 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.virtual.VirtualFile;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * JAXPDeployer is an abstract deployer that overrides parse to run a jaxp
+ * parse of the VirtualFile passed to parse.
+ *
+ * @see #parse(VFSDeploymentUnit, VirtualFile, Object)
+ * @see #doParse(VFSDeploymentUnit, VirtualFile)
+ *
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 60707 $
+ */
+public abstract class JAXPDeployer<T> extends AbstractVFSParsingDeployer<T>
+{
+ /** Use a namespace aware parser */
+ private boolean useNamespaceAwareParser = true;
+
+ /** A flag indicating if deployment descriptors should be validated */
+ private boolean validateDTDs;
+
+ /** The document builder factory */
+ private DocumentBuilderFactory documentBuilderFactory;
+
+ /**
+ * Create a new JAXPDeployer.
+ *
+ * @param output the output
+ * @throws IllegalArgumentException for a null output
+ */
+ public JAXPDeployer(Class<T> output)
+ {
+ super(output);
+ }
+
+ /**
+ * Get the useNamespaceAwareParser.
+ *
+ * @return the useNamespaceAwareParser.
+ */
+ public boolean isUseNamespaceAwareParser()
+ {
+ return useNamespaceAwareParser;
+ }
+
+ /**
+ * Set the useNamespaceAwareParser.
+ *
+ * @param useNamespaceAwareParser the useNamespaceAwareParser.
+ */
+ public void setUseNamespaceAwareParser(boolean useNamespaceAwareParser)
+ {
+ this.useNamespaceAwareParser = useNamespaceAwareParser;
+ }
+
+ /**
+ * Get the validateDTDs.
+ *
+ * @return the validateDTDs.
+ */
+ public boolean isValidateDTDs()
+ {
+ return validateDTDs;
+ }
+
+ /**
+ * Set the validateDTDs.
+ *
+ * @param validateDTDs the validateDTDs.
+ */
+ public void setValidateDTDs(boolean validateDTDs)
+ {
+ this.validateDTDs = validateDTDs;
+ }
+
+ /**
+ * Get the documentBuilderFactory.
+ *
+ * @return the documentBuilderFactory.
+ * @throws IllegalStateException if the create method has not been invoked
+ */
+ protected DocumentBuilderFactory getDocumentBuilderFactory()
+ {
+ if (documentBuilderFactory == null)
+ throw new IllegalStateException("Document builder factory has not been constructed");
+ return documentBuilderFactory;
+ }
+
+ /**
+ * Create lifecycle
+ *
+ * @throws Exception for any problem
+ */
+ public void create() throws Exception
+ {
+ documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(useNamespaceAwareParser);
+ documentBuilderFactory.setValidating(validateDTDs);
+ }
+
+ /**
+ * Destroy lifecycle
+ */
+ public void destroy()
+ {
+ documentBuilderFactory = null;
+ }
+
+ @Override
+ protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
+ {
+ // First look for an existing Document attachment
+ Document document = unit.getAttachment(Document.class);
+ if( document == null )
+ {
+ // Next parse the metadata file
+ document = doParse(unit, file);
+ }
+
+ // Transform the document into a T instance
+ return parse(unit, file, document);
+ }
+
+ /**
+ * Do the parsing
+ *
+ * @param unit the deployment unit
+ * @param file the metadata file
+ * @return the document
+ * @throws Exception for any error
+ */
+ protected Document doParse(VFSDeploymentUnit unit, VirtualFile file) throws Exception
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ log.trace("Parsing: " + file.getName());
+
+ InputStream is = SecurityActions.openStream(file);
+ try
+ {
+ DocumentBuilder parser = getDocumentBuilderFactory().newDocumentBuilder();
+ InputSource source = new InputSource(is);
+ source.setSystemId(file.toURI().toString());
+ parser.setEntityResolver(new JBossEntityResolver());
+ return parser.parse(is);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ }
+
+ /**
+ * Parse a deployment
+ *
+ * @param unit the deployment unit
+ * @param file the metadata file
+ * @param document the document
+ * @return the metadata
+ * @throws Exception for any error
+ */
+ protected abstract T parse(VFSDeploymentUnit unit, VirtualFile file, Document document) throws Exception;
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,82 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import java.io.InputStream;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Parse manifest.mf file.
+ * Prepare metadata from manifest's attributes.
+ *
+ * @param <T> the expected manifest type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class ManifestDeployer<T extends ManifestMetaData> extends AbstractVFSParsingDeployer<T>
+{
+ /**
+ * Create a new ManifestDeployer
+ *
+ * @param output the output
+ * @throws IllegalArgumentException for a null output
+ */
+ protected ManifestDeployer(Class<T> output)
+ {
+ super(output);
+ setName("MANIFEST.MF");
+ }
+
+ /**
+ * Create MetaData
+ *
+ * @param manifest the manifest
+ * @return the metadata
+ * @throws Exception for any error
+ */
+ protected abstract T createMetaData(Manifest manifest) throws Exception;
+
+ @Override
+ protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
+ {
+ // todo - update once we have new vfs snapshot
+ InputStream is = SecurityActions.openStream(file);
+ Manifest manifest;
+ try
+ {
+ manifest = new Manifest(is);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ return createMetaData(manifest);
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestMetaData.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestMetaData.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ManifestMetaData.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,56 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+/**
+ * Manifest meta data model.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ManifestMetaData
+{
+ /**
+ * Get the manifest attribute value.
+ *
+ * @param name the name
+ * @return attribute value or null if attribute doesn't exist
+ */
+ String getMainAttribute(String name);
+
+ /**
+ * Get attribute value from specific attrbiutes.
+ *
+ * @param attributesName attribute group name
+ * @param name string key for accessing specific attribute
+ * @return attribute value or null if attribute doesn't exist
+ */
+ String getAttribute(String attributesName, String name);
+
+ /**
+ * Get attribute value from specific attrbiutes.
+ *
+ * @param entryName entry name
+ * @param name string key for accessing specific attribute
+ * @return attribute value or null if attribute doesn't exist
+ */
+ String getEntry(String entryName, String name);
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/ObjectModelFactoryDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,105 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import java.net.URL;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/**
+ * ObjectModelFactoryDeployer extends the AbstractParsingDeployer to add an
+ * abstract JBossXB ObjectModelFactory accessor that is used from within an
+ * overriden parse(DeploymentUnit unit, VirtualFile file) to unmarshall the xml
+ * document represented by file into an instance of deploymentType T.
+ *
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public abstract class ObjectModelFactoryDeployer<T> extends AbstractVFSParsingDeployer<T>
+{
+ /** Unmarshaller factory */
+ private static final UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+
+ /** Whether the Unmarshaller will use schema validation */
+ private boolean useSchemaValidation = true;
+
+ /**
+ * Create a new SchemaResolverDeployer.
+ *
+ * @param output the output
+ * @throws IllegalArgumentException for a null output
+ */
+ public ObjectModelFactoryDeployer(Class<T> output)
+ {
+ super(output);
+ }
+
+ public boolean isUseSchemaValidation()
+ {
+ return useSchemaValidation;
+ }
+
+ public void setUseSchemaValidation(boolean useSchemaValidation)
+ {
+ this.useSchemaValidation = useSchemaValidation;
+ }
+
+ @Override
+ protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ Unmarshaller unmarshaller = factory.newUnmarshaller();
+ unmarshaller.setSchemaValidation(useSchemaValidation);
+ Object parsed = null;
+ try
+ {
+ ObjectModelFactory factory = getObjectModelFactory(root);
+ URL url = file.toURL();
+ parsed = unmarshaller.unmarshal(url.toString(), factory, root);
+ }
+ catch (Throwable t)
+ {
+ DeploymentException.rethrowAsDeploymentException("Error parsing meta data " + file.getPathName(), t);
+ }
+ if (parsed == null)
+ throw new DeploymentException("The xml " + file.getPathName() + " is not well formed!");
+
+ return getOutput().cast(parsed);
+ }
+
+ /**
+ * Get the object model factory
+ *
+ * @param root - possibly null pre-existing root
+ * @return the object model factory
+ */
+ protected abstract ObjectModelFactory getObjectModelFactory(T root);
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SchemaResolverDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,89 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import java.io.InputStream;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * SchemaResolverDeployer.
+ *
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class SchemaResolverDeployer<T> extends AbstractVFSParsingDeployer<T>
+{
+ /** Unmarshaller factory */
+ private static final UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
+
+ /** The resolver */
+ private static final SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+
+ /**
+ * Create a new SchemaResolverDeployer.
+ *
+ * @param output the output
+ * @throws IllegalArgumentException for a null output
+ */
+ public SchemaResolverDeployer(Class<T> output)
+ {
+ super(output);
+ }
+
+ protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ log.debug("Parsing file: "+file+" for deploymentType: " + getOutput());
+ Unmarshaller unmarshaller = factory.newUnmarshaller();
+ InputStream is = file.openStream();
+ Object parsed = null;
+ try
+ {
+ parsed = unmarshaller.unmarshal(is, resolver);
+ log.debug("Parsed file: "+file+" to: "+parsed);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ if (parsed == null)
+ throw new DeploymentException("The xml " + file.getPathName() + " is not well formed!");
+
+ return getOutput().cast(parsed);
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SecurityActions.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SecurityActions.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/SecurityActions.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.
+ *
+ * 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.deployers.vfs.spi.deployer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 60921 $
+ */
+public class SecurityActions
+{
+ /**
+ * Actions for File access
+ */
+ interface FileActions
+ {
+ FileActions PRIVILEGED = new FileActions()
+ {
+ public InputStream openStream(final VirtualFile f) throws IOException
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>()
+ {
+ public InputStream run() throws Exception
+ {
+ return f.openStream();
+ }
+ });
+ }
+ catch(PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ if( ex instanceof IOException )
+ throw (IOException) ex;
+ else if( ex instanceof RuntimeException )
+ throw (RuntimeException) ex;
+ else
+ throw new UndeclaredThrowableException(ex);
+ }
+ }
+ };
+
+ FileActions NON_PRIVILEGED = new FileActions()
+ {
+ public InputStream openStream(VirtualFile f) throws IOException
+ {
+ return f.openStream();
+ }
+ };
+
+ public InputStream openStream(VirtualFile f) throws IOException;
+ }
+
+ static InputStream openStream(VirtualFile f) throws IOException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if( sm != null )
+ return FileActions.PRIVILEGED.openStream(f);
+ else
+ return FileActions.NON_PRIVILEGED.openStream(f);
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/XSLDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,183 @@
+/*
+* 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.deployers.vfs.spi.deployer;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.util.xml.DOMWriter;
+import org.jboss.util.xml.JBossErrorHandler;
+import org.jboss.virtual.VirtualFile;
+import org.w3c.dom.Document;
+
+/**
+ * SchemaResolverDeployer.
+ *
+ * @param <T> the expected type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class XSLDeployer<T> extends JAXPDeployer<T>
+{
+ /** The xsl resource path */
+ protected String xslPath;
+
+ /** The templates */
+ private Templates templates;
+
+ /**
+ * Create a new XSLDeployer.
+ *
+ * @param deploymentType the deployment type
+ * @throws IllegalArgumentException for a null deployment type
+ */
+ public XSLDeployer(Class<T> deploymentType)
+ {
+ super(deploymentType);
+ }
+
+ /**
+ * Get the xslPath.
+ *
+ * @return the xslPath.
+ */
+ public String getXSLPath()
+ {
+ return xslPath;
+ }
+
+ /**
+ * Set the xslPath.
+ *
+ * @param xslPath the xslPath.
+ */
+ public void setXSLPath(String xslPath)
+ {
+ this.xslPath = xslPath;
+ }
+
+ /**
+ * Get the templates.
+ *
+ * @return the templates.
+ * @throws IllegalStateException if the create method has not been invoked
+ */
+ public Templates getTemplates()
+ {
+ if (templates == null)
+ throw new IllegalStateException("Templates have not been constructed");
+ return templates;
+ }
+
+ /**
+ * Create lifecycle
+ *
+ * @throws Exception for any problem
+ */
+ public void create() throws Exception
+ {
+ super.create();
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(xslPath);
+ try
+ {
+ StreamSource ss = new StreamSource(is);
+ ss.setSystemId(xslPath);
+ templates = tf.newTemplates(ss);
+ log.debug("Created templates: " + templates);
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ }
+
+ /**
+ * Destroy lifecycle
+ */
+ public void destroy()
+ {
+ super.destroy();
+ templates = null;
+ }
+
+ @Override
+ protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ Document document = doParse(unit, file);
+
+ Transformer trans = getTemplates().newTransformer();
+ trans.setErrorListener(new JBossErrorHandler(file.getPathName(), null));
+ Source s = new DOMSource(document);
+ DOMResult r = new DOMResult();
+ setParameters(trans);
+
+ trans.transform(s, r);
+
+ document = (Document) r.getNode();
+ String docStr = DOMWriter.printNode(document, true);
+ log.debug("Transformed " + file.getPathName() + " into " + docStr);
+
+ return parse(unit, file, document);
+ }
+
+ /**
+ * Set parameters for the transformation
+ *
+ * @param trans the transformer
+ * @throws Exception for any problem
+ */
+ protected void setParameters(Transformer trans) throws Exception
+ {
+ // nothing by default
+ }
+
+ /**
+ * Parse a deployment
+ *
+ * @param unit the deployment unit
+ * @param file the metadata file
+ * @param document the document
+ * @return the metadata
+ * @throws Exception for any error
+ */
+ protected abstract T parse(VFSDeploymentUnit unit, VirtualFile file, Document document) throws Exception;
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/StructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/StructureDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/StructureDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.
+ *
+ * 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.deployers.vfs.spi.structure;
+
+import org.jboss.deployers.spi.Ordered;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A StructureDeployer translates a deployment virtual file root into
+ * StructureMetaData representing the deployment contexts.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface StructureDeployer extends Ordered
+{
+ /**
+ * Determine the structure of a deployment
+ *
+ * @param root the root file
+ * @param parent the parent file
+ * @param file the candidate file of the deployment
+ * @param metaData the structure metadata to build
+ * @param deployers the available structure deployers
+ * @return true when it is recognised
+ */
+ boolean determineStructure(VirtualFile root, VirtualFile parent, VirtualFile file, StructureMetaData metaData, VFSStructuralDeployers deployers);
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentContext.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.structure;
+
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSDeploymentContext.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface VFSDeploymentContext extends DeploymentContext
+{
+ /**
+ * Get the root file
+ *
+ * @return the root
+ */
+ VirtualFile getRoot();
+
+ /**
+ * Set the meta data path relative to the root
+ *
+ * @param path the path
+ */
+ void setMetaDataPath(String path);
+
+ /**
+ * Get the meta data location
+ *
+ * @return the meta data location
+ */
+ VirtualFile getMetaDataLocation();
+
+ /**
+ * Set the meta data location
+ *
+ * @param location the meta data location
+ */
+ void setMetaDataLocation(VirtualFile location);
+
+ /**
+ * Gets a metadata file
+ *
+ * @param name the name to exactly match
+ * @return the virtual file or null if not found
+ * @throws IllegalArgumentException for a null name
+ */
+ VirtualFile getMetaDataFile(String name);
+
+ /**
+ * Gets metadata files for this deployment
+ *
+ * @param name the name to exactly match
+ * @param suffix the suffix to partially match
+ * @return the virtual files that match
+ * @throws IllegalArgumentException if both the name and suffix are null
+ */
+ List<VirtualFile> getMetaDataFiles(String name, String suffix);
+
+ /**
+ * Gets a file from this deployment
+ *
+ * @param name the name to exactly match
+ * @return the file or null if not found
+ * @throws IllegalArgumentException if both the name
+ */
+ VirtualFile getFile(String name);
+
+ /**
+ * Get the class path
+ *
+ * @return the class path
+ */
+ List<VirtualFile> getClassPath();
+
+ /**
+ * Set the class path
+ *
+ * @param paths the paths
+ */
+ void setClassPath(List<VirtualFile> paths);
+
+ /**
+ * Get the top level deployment context
+ *
+ * @return the top level deployment context
+ */
+ VFSDeploymentContext getTopLevel();
+
+ /**
+ * Get a resource loader
+ *
+ * @return the resource loader
+ */
+ VFSDeploymentResourceLoader getResourceLoader();
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentResourceLoader.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentResourceLoader.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentResourceLoader.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.structure;
+
+import org.jboss.deployers.structure.spi.DeploymentResourceLoader;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSDeploymentResourceLoader.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface VFSDeploymentResourceLoader extends DeploymentResourceLoader
+{
+ /**
+ * Get a virtual file
+ *
+ * @param path the relative path of the file
+ * @return the virtual file or null if not found
+ */
+ VirtualFile getFile(String path);
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSDeploymentUnit.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.structure;
+
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSDeploymentUnit.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface VFSDeploymentUnit extends DeploymentUnit
+{
+ /**
+ * Gets a metadata file. This is a file located under the deployment metadata
+ * context(s).
+ *
+ * @param name the name to exactly match
+ * @return the virtual file or null if not found
+ * @throws IllegalArgumentException for a null name
+ */
+ VirtualFile getMetaDataFile(String name);
+
+ /**
+ * Gets the metadata files for this deployment unit
+ *
+ * @param name the name to exactly match
+ * @param suffix the suffix to partially match
+ * @return the virtual files that match
+ * @throws IllegalArgumentException if both the name and suffix are null
+ */
+ List<VirtualFile> getMetaDataFiles(String name, String suffix);
+
+ /**
+ * Get a resource loader
+ *
+ * @return the resource loader
+ */
+ VFSDeploymentResourceLoader getResourceLoader();
+
+ /**
+ * Get a virtual file
+ *
+ * @param path the relative path of the file
+ * @return the virtual file or null if not found
+ */
+ VirtualFile getFile(String path);
+
+ /**
+ * Get the root
+ *
+ * @return the root
+ */
+ VirtualFile getRoot();
+
+ /**
+ * Get the class path
+ *
+ * @return the class path
+ */
+ List<VirtualFile> getClassPath();
+
+ /**
+ * Set the classpath
+ *
+ * @param classPath the classpath
+ */
+ void setClassPath(List<VirtualFile> classPath);
+
+ /**
+ * Get the top leve deployment unit
+ *
+ * @return the top level deployment unit
+ */
+ VFSDeploymentUnit getTopLevel();
+
+ /**
+ * Get the parent deployment unit
+ *
+ * @return the parent or null if there is no parent
+ */
+ VFSDeploymentUnit getParent();
+
+ /**
+ * Get the children
+ *
+ * @return the children
+ */
+ List<VFSDeploymentUnit> getVFSChildren();
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSStructuralDeployers.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSStructuralDeployers.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/VFSStructuralDeployers.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers.vfs.spi.structure;
+
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VFSStructuralDeployers.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface VFSStructuralDeployers
+{
+ /**
+ * Determine the structure of a virtual file
+ *
+ * @param root the root file
+ * @param parent the parent file
+ * @param file the virtual file
+ * @param structureMetaData the structure metadata
+ * @return true when recognised, false otherwise
+ */
+ boolean determineStructure(VirtualFile root, VirtualFile parent, VirtualFile file, StructureMetaData structureMetaData);
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractCandidateStructureVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractCandidateStructureVisitor.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractCandidateStructureVisitor.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,183 @@
+/*
+* 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.deployers.vfs.spi.structure.helpers;
+
+import java.io.IOException;
+
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.vfs.helpers.AbstractVirtualFileVisitor;
+
+/**
+ * Visits the structure and creates candidates
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractCandidateStructureVisitor extends AbstractVirtualFileVisitor
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(AbstractCandidateStructureVisitor.class);
+
+ /** The root deployment file */
+ private final VirtualFile root;
+
+ /** The parent deployment file */
+ private final VirtualFile parent;
+
+ /** The meta data */
+ private final StructureMetaData metaData;
+
+ /** The deployers */
+ private final VFSStructuralDeployers deployers;
+
+ /** Ignore directories */
+ private boolean ignoreDirectories;
+
+ /** A filter */
+ private VirtualFileFilter filter;
+
+ /**
+ * Create a new CandidateStructureVisitor.
+ *
+ * @param root the root
+ * @param parent the parent
+ * @param metaData the structure meta data
+ * @param deployers the structure deployers
+ * @throws IllegalArgumentException for a null parent
+ */
+ public AbstractCandidateStructureVisitor(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers)
+ {
+ this(root, parent, metaData, deployers, null);
+ }
+
+ /**
+ * Create a new CandidateStructureVisitor.
+ *
+ * @param root the root
+ * @param parent the parent
+ * @param metaData the structure meta data
+ * @param deployers the structure deployers
+ * @param attributes the attributes
+ * @throws IllegalArgumentException for a null parent
+ */
+ public AbstractCandidateStructureVisitor(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers, VisitorAttributes attributes)
+ {
+ super(attributes);
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent");
+ this.root = root;
+ this.parent = parent;
+ this.metaData = metaData;
+ this.deployers = deployers;
+ }
+
+ /**
+ * Get the parent deployment context
+ *
+ * @return the parent.
+ */
+ public VirtualFile getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Get the ignoreDirectories.
+ *
+ * @return the ignoreDirectories.
+ */
+ public boolean isIgnoreDirectories()
+ {
+ return ignoreDirectories;
+ }
+
+ /**
+ * Get the filter.
+ *
+ * @return the filter.
+ */
+ public VirtualFileFilter getFilter()
+ {
+ return filter;
+ }
+
+ /**
+ * Set the filter.
+ *
+ * @param filter the filter.
+ */
+ public void setFilter(VirtualFileFilter filter)
+ {
+ this.filter = filter;
+ }
+
+ /**
+ * Set the ignoreDirectories.
+ *
+ * @param ignoreDirectories the ignoreDirectories.
+ */
+ public void setIgnoreDirectories(boolean ignoreDirectories)
+ {
+ this.ignoreDirectories = ignoreDirectories;
+ }
+
+ public void visit(VirtualFile file)
+ {
+ String path = AbstractStructureDeployer.getRelativePath(parent, file);
+ ContextInfo context = metaData.getContext(path);
+ if (context == null)
+ {
+ // Ignore directories when asked
+ try
+ {
+ if (ignoreDirectories && SecurityActions.isLeaf(file) == false)
+ return;
+ }
+ catch (IOException e)
+ {
+ log.debug("Ignoring " + file + " reason=" + e);
+ return;
+ }
+
+ // Apply any filter
+ if (filter != null && filter.accepts(file) == false)
+ return;
+
+ try
+ {
+ // Ask the deployers to process this file
+ deployers.determineStructure(root, parent, file, metaData);
+ }
+ catch (Exception e)
+ {
+ log.debug("Ignoring " + file + " reason=" + e);
+ return;
+ }
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,276 @@
+/*
+* 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.deployers.vfs.spi.structure.helpers;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.structure.ClassPathEntry;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.spi.structure.StructureMetaDataFactory;
+import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * AbstractStructureDeployer.<p>
+ *
+ * We don't care about the order by default.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractStructureDeployer implements StructureDeployer
+{
+ /** The log */
+ protected Logger log = Logger.getLogger(getClass());
+
+ /** The relative order */
+ private int relativeOrder = Integer.MAX_VALUE;
+
+ /** The candidate structure visitor factory */
+ private CandidateStructureVisitorFactory candidateStructureVisitorFactory = DefaultCandidateStructureVisitorFactory.INSTANCE;
+
+ /**
+ * Get the relative path between two virtual files
+ *
+ * @param parent the parent
+ * @param child the child
+ * @return the relative path
+ */
+ public static final String getRelativePath(VirtualFile parent, VirtualFile child)
+ {
+ if (child == null)
+ throw new IllegalArgumentException("Null child");
+
+ String childPath = child.getPathName();
+ if (parent != null)
+ {
+ String parentPath = parent.getPathName();
+
+ if (parentPath.length() == childPath.length())
+ return "";
+
+ // Not sure about this? It is obviously not a direct child if it is shorter?
+ if (parentPath.length() < childPath.length())
+ {
+ if (parentPath.endsWith("/") == false)
+ parentPath = parentPath + "/";
+ if (childPath.startsWith(parentPath))
+ return childPath.substring(parentPath.length());
+ }
+ }
+
+ if (childPath.endsWith("/"))
+ childPath = childPath.substring(0, childPath.length()-1);
+
+ return childPath;
+ }
+
+ public int getRelativeOrder()
+ {
+ return relativeOrder;
+ }
+
+ public void setRelativeOrder(int order)
+ {
+ this.relativeOrder = order;
+ }
+
+
+ /**
+ * Get the candidateStructureVisitorFactory.
+ *
+ * @return the candidateStructureVisitorFactory.
+ */
+ public CandidateStructureVisitorFactory getCandidateStructureVisitorFactory()
+ {
+ return candidateStructureVisitorFactory;
+ }
+
+ /**
+ * Set the candidateStructureVisitorFactory.
+ *
+ * @param candidateStructureVisitorFactory the candidateStructureVisitorFactory.
+ * @throws IllegalArgumentException for a null candidate structure
+ */
+ public void setCandidateStructureVisitorFactory(CandidateStructureVisitorFactory candidateStructureVisitorFactory)
+ {
+ if (candidateStructureVisitorFactory == null)
+ throw new IllegalArgumentException("Null candidateStructureVisitorFactory");
+ this.candidateStructureVisitorFactory = candidateStructureVisitorFactory;
+ }
+
+ /**
+ * See if a file corresponds to a top-level deployment.
+ *
+ * @param parent the parent file
+ * @return true when top level
+ */
+ public boolean isTopLevel(VirtualFile parent)
+ {
+ return parent == null;
+ }
+
+ /**
+ * Add an entry to the context classpath.
+ *
+ * @param root - the root file the classpath entry should be relative to
+ * @param entry - the candidate file to add as a classpath entry
+ * @param includeEntry - a flag indicating if the entry should be added to
+ * the classpath
+ * @param includeRootManifestCP - a flag indicating if the entry metainf
+ * manifest classpath should be included.
+ * @param context - the context to populate
+ * @throws IOException on any IO error
+ */
+ protected void addClassPath(VirtualFile root, VirtualFile entry, boolean includeEntry, boolean includeRootManifestCP, ContextInfo context) throws IOException
+ {
+ boolean trace = log.isTraceEnabled();
+
+ List<VirtualFile> paths = new ArrayList<VirtualFile>();
+
+ // The path we have been told to add
+ if (includeEntry)
+ paths.add(entry);
+
+ // Add the manifest locations
+ if (includeRootManifestCP && isLeaf(entry) == false)
+ {
+ try
+ {
+ VFSUtils.addManifestLocations(entry, paths);
+ }
+ catch(Exception e)
+ {
+ if (trace)
+ log.trace("Failed to add manifest locations", e);
+ }
+ }
+
+ // Translate from VirtualFile to relative paths
+ for (VirtualFile vf : paths)
+ {
+ String entryPath = getRelativePath(root, vf);
+ ClassPathEntry cpe = StructureMetaDataFactory.createClassPathEntry(entryPath);
+ context.addClassPathEntry(cpe);
+ if (trace)
+ log.trace("Added classpath entry " + entryPath + " for " + vf.getName() + " from " + root);
+ }
+ }
+
+ /**
+ * Add all children as candidates
+ *
+ * @param root the root context
+ * @param parent the parent context
+ * @param metaData the structure meta data
+ * @param deployers the structure deployers
+ * @throws Exception for any error
+ */
+ protected void addAllChildren(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers) throws Exception
+ {
+ addChildren(root, parent, metaData, deployers, null);
+ }
+
+ /**
+ * Add all children as candidates
+ *
+ * @param root the root context
+ * @param parent the parent context
+ * @param metaData the structure meta data
+ * @param deployers the structure deployers
+ * @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null
+ * @throws Exception for any error
+ */
+ protected void addChildren(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers, VisitorAttributes attributes) throws Exception
+ {
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent");
+
+ VirtualFileVisitor visitor = candidateStructureVisitorFactory.createVisitor(root, parent, metaData, deployers, attributes);
+ parent.visit(visitor);
+ }
+
+ /**
+ * Tests whether the virtual file is a leaf
+ *
+ * @param file the virtual file
+ * @return true when it is a leaf
+ * @throws IOException for any error
+ */
+ protected boolean isLeaf(VirtualFile file) throws IOException
+ {
+ return SecurityActions.isLeaf(file);
+ }
+
+ /**
+ * Create a context
+ *
+ * @param root the root context
+ * @param metaDataPath the metadata path
+ * @param structureMetaData the structure metadata
+ * @return the structure metadata
+ * @throws IllegalArgumentException for a null root or structure metaData
+ */
+ protected ContextInfo createContext(VirtualFile root, String metaDataPath, StructureMetaData structureMetaData)
+ {
+ boolean trace = log.isTraceEnabled();
+
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
+ if (structureMetaData == null)
+ throw new IllegalArgumentException("Null structure metadata");
+
+ // Determine whether the metadata path exists
+ if (metaDataPath != null)
+ {
+ try
+ {
+ root.findChild(metaDataPath);
+ }
+ catch (IOException ignored)
+ {
+ if (trace)
+ log.trace("Not using metadata path " + metaDataPath + " for " + root.getName() + " reason: " + ignored.getMessage());
+ metaDataPath = null;
+ }
+ }
+
+ // Create and link the context
+ ContextInfo result;
+ if (metaDataPath != null)
+ result = StructureMetaDataFactory.createContextInfo("", metaDataPath, null);
+ else
+ result = StructureMetaDataFactory.createContextInfo("", null);
+ structureMetaData.addContext(result);
+ if (trace)
+ log.trace("Added context " + result + " from " + root.getName());
+ return result;
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/CandidateStructureVisitorFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/CandidateStructureVisitorFactory.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/CandidateStructureVisitorFactory.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,50 @@
+/*
+* 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.deployers.vfs.spi.structure.helpers;
+
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * CandidateStructureVisitorFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CandidateStructureVisitorFactory
+{
+ /**
+ * Create the visitor
+ *
+ * @param root the root virtual file
+ * @param parent the parent virtual file
+ * @param metaData the structure metaData
+ * @param deployers the structure deployers
+ * @param attributes the visitor attributes uses {@link VisitorAttributes#DEFAULT} when null
+ * @return the visitor
+ * @throws Exception for any error
+ */
+ VirtualFileVisitor createVisitor(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers, VisitorAttributes attributes) throws Exception;
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,67 @@
+/*
+* 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.deployers.vfs.spi.structure.helpers;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentContextVisitor;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Collects all the classpath elements
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassPathVisitor implements DeploymentContextVisitor
+{
+ /** The full classpath */
+ private Set<VirtualFile> classPath = new LinkedHashSet<VirtualFile>();
+
+ /**
+ * Get the full classpath after the visit
+ *
+ * @return the full classpath
+ */
+ public Set<VirtualFile> getClassPath()
+ {
+ return classPath;
+ }
+
+ public void visit(DeploymentContext context) throws DeploymentException
+ {
+ VFSDeploymentContext vfsContext = (VFSDeploymentContext) context;
+ List<VirtualFile> paths = vfsContext.getClassPath();
+ if (paths != null)
+ classPath.addAll(paths);
+ }
+
+ public void error(DeploymentContext context)
+ {
+ // nothing
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/DefaultCandidateStructureVisitorFactory.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/DefaultCandidateStructureVisitorFactory.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/DefaultCandidateStructureVisitorFactory.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,72 @@
+/*
+* 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.deployers.vfs.spi.structure.helpers;
+
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.vfs.spi.structure.VFSStructuralDeployers;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * DefaultCandidateStructureVisitorFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultCandidateStructureVisitorFactory implements CandidateStructureVisitorFactory
+{
+ /** An instance of the factory */
+ public static final DefaultCandidateStructureVisitorFactory INSTANCE = new DefaultCandidateStructureVisitorFactory();
+
+ /** The filter */
+ private VirtualFileFilter filter;
+
+ /**
+ * Get the filter.
+ *
+ * @return the filter.
+ */
+ public VirtualFileFilter getFilter()
+ {
+ return filter;
+ }
+
+ /**
+ * Set the filter.
+ *
+ * @param filter the filter.
+ */
+ public void setFilter(VirtualFileFilter filter)
+ {
+ this.filter = filter;
+ }
+
+ public VirtualFileVisitor createVisitor(VirtualFile root, VirtualFile parent, StructureMetaData metaData, VFSStructuralDeployers deployers, VisitorAttributes attributes) throws Exception
+ {
+ AbstractCandidateStructureVisitor visitor = new AbstractCandidateStructureVisitor(root, parent, metaData, deployers, attributes);
+ if (filter != null)
+ visitor.setFilter(filter);
+ return visitor;
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/SecurityActions.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/SecurityActions.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/SecurityActions.java 2007-06-27 15:59:02 UTC (rev 63686)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.
+ *
+ * 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.deployers.vfs.spi.structure.helpers;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 60921 $
+ */
+public class SecurityActions
+{
+ /**
+ * Actions for File access
+ */
+ interface FileActions
+ {
+ FileActions PRIVILEGED = new FileActions()
+ {
+ public Boolean isLeaf(final VirtualFile f) throws IOException
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>()
+ {
+ public Boolean run() throws Exception
+ {
+ return f.isLeaf();
+ }
+ });
+ }
+ catch(PrivilegedActionException e)
+ {
+ Exception ex = e.getException();
+ if( ex instanceof IOException )
+ throw (IOException) ex;
+ else if( ex instanceof RuntimeException )
+ throw (RuntimeException) ex;
+ else
+ throw new UndeclaredThrowableException(ex);
+ }
+ }
+ };
+
+ FileActions NON_PRIVILEGED = new FileActions()
+ {
+ public Boolean isLeaf(VirtualFile f) throws IOException
+ {
+ return f.isLeaf();
+ }
+
+ };
+
+ public Boolean isLeaf(VirtualFile f) throws IOException;
+ }
+
+ static boolean isLeaf(VirtualFile f) throws IOException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if( sm != null )
+ return FileActions.PRIVILEGED.isLeaf(f);
+ else
+ return FileActions.NON_PRIVILEGED.isLeaf(f);
+ }
+}
More information about the jboss-cvs-commits
mailing list