[jboss-cvs] JBossAS SVN: r74247 - in projects/jboss-deployers/trunk: deployers-core-spi/src/main/org/jboss/deployers/spi/structure and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jun 6 05:57:38 EDT 2008


Author: alesj
Date: 2008-06-06 05:57:37 -0400 (Fri, 06 Jun 2008)
New Revision: 74247

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ExplodeModificationAction.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationAction.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/TempModificationAction.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/UnpackModificationAction.java
Modified:
   projects/jboss-deployers/trunk/build/pom.xml
   projects/jboss-deployers/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ModificationType.java
   projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java
Log:
Cleaner modification handling.

Modified: projects/jboss-deployers/trunk/build/pom.xml
===================================================================
--- projects/jboss-deployers/trunk/build/pom.xml	2008-06-06 09:37:40 UTC (rev 74246)
+++ projects/jboss-deployers/trunk/build/pom.xml	2008-06-06 09:57:37 UTC (rev 74247)
@@ -30,7 +30,7 @@
     <version.jboss.common.logging.log4j>2.0.4.GA</version.jboss.common.logging.log4j>
     <version.jbossxb>2.0.0.CR8</version.jbossxb>
     <version.jboss.aop>2.0.0.CR8</version.jboss.aop>
-    <version.jboss.vfs>2.0.0.Beta13</version.jboss.vfs>
+    <version.jboss.vfs>2.0.0-SNAPSHOT</version.jboss.vfs>
     <version.org.jboss.test>1.0.5.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
     <version.javassist>3.7.1.GA</version.javassist>

Modified: projects/jboss-deployers/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ModificationType.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ModificationType.java	2008-06-06 09:37:40 UTC (rev 74246)
+++ projects/jboss-deployers/trunk/deployers-core-spi/src/main/org/jboss/deployers/spi/structure/ModificationType.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -32,7 +32,8 @@
 public enum ModificationType
 {
    UNPACK,
-   EXPLODE;
+   EXPLODE,
+   TEMP;
 
    /**
     * Get the modification type.

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java	2008-06-06 09:37:40 UTC (rev 74246)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -35,6 +35,8 @@
 import org.jboss.deployers.structure.spi.helpers.AbstractStructureBuilder;
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.deployers.vfs.plugins.structure.modify.ModificationAction;
+import org.jboss.deployers.vfs.plugins.structure.modify.ModificationActions;
 import org.jboss.logging.Logger;
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
@@ -113,25 +115,23 @@
       ModificationType modificationType = contextInfo.getModificationType();
       if (modificationType != null)
       {
-         boolean trace = log.isTraceEnabled();
-         boolean isSupported = (modificationType == ModificationType.UNPACK || modificationType == ModificationType.EXPLODE);
+         ModificationAction action = ModificationActions.getAction(modificationType);
+         if (action != null)
+         {
+            boolean trace = log.isTraceEnabled();
 
-         if (trace && isSupported)
-            log.trace("Modifying file: " + file + ", modification type: " + modificationType);
+            if (trace)
+               log.trace("Modifying file: " + file + ", modification type: " + modificationType);
 
-         if (ModificationType.UNPACK == modificationType)
-            modified = VFSUtils.unpack(file);
-         else if (ModificationType.EXPLODE == modificationType)
-            modified = VFSUtils.explode(file);
-         else
-            log.warn("Unsupported modification type: " + modificationType);
+            modified = action.modify(file);
 
-         if (trace && isSupported)
-         {
-            if (modified != file)
-               log.trace("Modified file: " + modified);
-            else
-               log.trace("File already modified: " + modified);            
+            if (trace)
+            {
+               if (modified != file)
+                  log.trace("Modified file: " + modified);
+               else
+                  log.trace("File already modified: " + modified);
+            }
          }
       }
       return modified;

Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ExplodeModificationAction.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ExplodeModificationAction.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ExplodeModificationAction.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -0,0 +1,41 @@
+/*
+* 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.plugins.structure.modify;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * Explode modification action.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class ExplodeModificationAction implements ModificationAction
+{
+   public VirtualFile modify(VirtualFile original) throws IOException, URISyntaxException
+   {
+      return VFSUtils.explode(original);
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationAction.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationAction.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationAction.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -0,0 +1,45 @@
+/*
+* 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.plugins.structure.modify;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Execute modification on file.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ModificationAction
+{
+   /**
+    * Modify file.
+    *
+    * @param original the original file
+    * @return modified file, if not already
+    * @throws IOException for any error
+    * @throws URISyntaxException for any URI syntax error
+    */
+   VirtualFile modify(VirtualFile original) throws IOException, URISyntaxException;
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/ModificationActions.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -0,0 +1,54 @@
+/*
+* 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.plugins.structure.modify;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.structure.ModificationType;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ModificationActions
+{
+   private static final Map<ModificationType, ModificationAction> actions;
+
+   static
+   {
+      actions = new HashMap<ModificationType, ModificationAction>();
+      actions.put(ModificationType.UNPACK, new UnpackModificationAction());
+      actions.put(ModificationType.EXPLODE, new ExplodeModificationAction());
+      actions.put(ModificationType.TEMP, new TempModificationAction());
+   }
+
+   /**
+    * Get the modification action.
+    *
+    * @param type the modification type
+    * @return modification action or null if it not supported
+    */
+   public static ModificationAction getAction(ModificationType type)
+   {
+      return actions.get(type);
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/TempModificationAction.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/TempModificationAction.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/TempModificationAction.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -0,0 +1,41 @@
+/*
+* 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.plugins.structure.modify;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * Temp modification action.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class TempModificationAction implements ModificationAction
+{
+   public VirtualFile modify(VirtualFile original) throws IOException, URISyntaxException
+   {
+      return VFSUtils.temp(original);
+   }
+}
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/UnpackModificationAction.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/UnpackModificationAction.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/modify/UnpackModificationAction.java	2008-06-06 09:57:37 UTC (rev 74247)
@@ -0,0 +1,41 @@
+/*
+* 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.plugins.structure.modify;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * Unpack modification action.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class UnpackModificationAction implements ModificationAction
+{
+   public VirtualFile modify(VirtualFile original) throws IOException, URISyntaxException
+   {
+      return VFSUtils.unpack(original);
+   }
+}




More information about the jboss-cvs-commits mailing list