[jboss-cvs] JBossAS SVN: r83405 - in projects/jboss-deployers/trunk: deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 26 07:17:39 EST 2009
Author: alesj
Date: 2009-01-26 07:17:39 -0500 (Mon, 26 Jan 2009)
New Revision: 83405
Added:
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/StructureProcessor.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureProcessor.java
Removed:
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/RootModificationTypeMatcher.java
Modified:
projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/StructureContext.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/FileModificationTypeMatcher.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeMatcher.java
projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/TempTopModificationTypeMatcher.java
Log:
[JBDEPLOY-154]; redesign the modification kick-in.
Copied: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/StructureProcessor.java (from rev 83351, projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/StructureBuilder.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/StructureProcessor.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/StructureProcessor.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -0,0 +1,66 @@
+/*
+ * 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.structure.spi;
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+
+/**
+ * Pre and post structure metadata processor.
+ *
+ * @author ales.justin at jboss.org
+ */
+public interface StructureProcessor
+{
+ /**
+ * Prepare structure metadata.
+ *
+ * @param deployment the deployment
+ * @param structureMetaData the structure metadata
+ */
+ void prepareStructureMetaData(Deployment deployment, StructureMetaData structureMetaData);
+
+ /**
+ * Prepare context info.
+ *
+ * @param parentDeploymentContext the parent deployment context
+ * @param contextInfo the context info
+ */
+ void prepareContextInfo(DeploymentContext parentDeploymentContext, ContextInfo contextInfo);
+
+ /**
+ * Apply structure metadata.
+ *
+ * @param deploymentContext the deployment context
+ * @param structureMetaData the structure metadata
+ */
+ void applyStructureMetaData(DeploymentContext deploymentContext, StructureMetaData structureMetaData);
+
+ /**
+ * Apply context info.
+ *
+ * @param deploymentContext the deployment context
+ * @param contextInfo the context info
+ */
+ void applyContextInfo(DeploymentContext deploymentContext, ContextInfo contextInfo);
+}
\ No newline at end of file
Property changes on: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/StructureProcessor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/main/java/org/jboss/deployers/structure/spi/helpers/AbstractStructureBuilder.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -34,6 +34,7 @@
import org.jboss.deployers.spi.structure.StructureMetaDataFactory;
import org.jboss.deployers.structure.spi.DeploymentContext;
import org.jboss.deployers.structure.spi.StructureBuilder;
+import org.jboss.deployers.structure.spi.StructureProcessor;
import org.jboss.logging.Logger;
/**
@@ -46,7 +47,10 @@
{
/** The log */
private final Logger log = Logger.getLogger(getClass());
-
+
+ /** The context info processor */
+ private StructureProcessor structureProcessor;
+
public DeploymentContext populateContext(Deployment deployment, StructureMetaData metaData) throws DeploymentException
{
if (deployment == null)
@@ -61,6 +65,8 @@
DeploymentContext result;
try
{
+ prepareStructureMetaData(deployment, metaData);
+
result = createRootDeploymentContext(deployment, metaData);
if (result == null)
throw new IllegalStateException("Root deployment context is null");
@@ -69,6 +75,8 @@
ContextInfo contextInfo = metaData.getContext("");
if (contextInfo == null)
contextInfo = StructureMetaDataFactory.createContextInfo("", null);
+
+ applyStructureMetaData(result, metaData);
contextInfo.setPredeterminedManagedObjects(deployment.getPredeterminedManagedObjects());
applyContextInfo(result, contextInfo);
}
@@ -120,6 +128,8 @@
// Only process the child contexts
if ("".equals(child.getPath()) == false)
{
+ prepareContextInfo(context, child);
+
DeploymentContext childContext = createChildDeploymentContext(context, child);
if (childContext == null)
throw new IllegalStateException("Child deployment context is null");
@@ -146,6 +156,42 @@
}
/**
+ * Prepare the structure metadata.
+ *
+ * @param deploymentContext the deployment
+ * @param structureMetaData the structure metadata
+ */
+ protected void prepareStructureMetaData(Deployment deploymentContext, StructureMetaData structureMetaData)
+ {
+ if (structureProcessor != null)
+ structureProcessor.prepareStructureMetaData(deploymentContext, structureMetaData);
+ }
+
+ /**
+ * Prepare the structure metadata.
+ *
+ * @param parentDeploymentContext the parent deployment context
+ * @param contextInfo the context info
+ */
+ protected void prepareContextInfo(DeploymentContext parentDeploymentContext, ContextInfo contextInfo)
+ {
+ if (structureProcessor != null)
+ structureProcessor.prepareContextInfo(parentDeploymentContext, contextInfo);
+ }
+
+ /**
+ * Apply the structure metadata.
+ *
+ * @param deploymentContext the parent deployment context
+ * @param structureMetaData the structure metadata
+ */
+ protected void applyStructureMetaData(DeploymentContext deploymentContext, StructureMetaData structureMetaData)
+ {
+ if (structureProcessor != null)
+ structureProcessor.applyStructureMetaData(deploymentContext, structureMetaData);
+ }
+
+ /**
* Apply the context info. This transfers the PredeterminedManagedObjects
* and TransientManagedObjects and other information from the ContextInfo to the DeploymentContext.
*
@@ -161,6 +207,9 @@
context.setRelativeOrder(contextInfo.getRelativeOrder());
applyComparator(context, contextInfo);
+
+ if (structureProcessor != null)
+ structureProcessor.applyContextInfo(context, contextInfo);
}
/**
@@ -238,4 +287,24 @@
String name = parent.getName() + "/" + path;
return new AbstractDeploymentContext(name, path);
}
+
+ /**
+ * Set context info processor.
+ *
+ * @param structureProcessor the context info processor
+ */
+ public void setContextInfoProcessor(StructureProcessor structureProcessor)
+ {
+ this.structureProcessor = structureProcessor;
+ }
+
+ /**
+ * Get the context info processor.
+ *
+ * @return the context info processor
+ */
+ protected StructureProcessor getContextInfoProcessor()
+ {
+ return structureProcessor;
+ }
}
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/AbstractModificationTypeMatcher.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -21,11 +21,13 @@
*/
package org.jboss.deployers.vfs.plugins.structure.modify;
+import java.util.List;
+
import org.jboss.deployers.spi.structure.ContextInfo;
import org.jboss.deployers.spi.structure.ModificationType;
import org.jboss.deployers.spi.structure.StructureMetaData;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
/**
* Abstract modification type matcher.
@@ -35,69 +37,84 @@
public abstract class AbstractModificationTypeMatcher implements ModificationTypeMatcher
{
protected Logger log = Logger.getLogger(getClass());
-
- private boolean applyModificationToTop;
+
+ private boolean checkChildren;
private ModificationType modificationType;
- public boolean determineModification(StructureContext structureContext)
+ public boolean determineModification(VirtualFile root, StructureMetaData structureMetaData)
{
- boolean result = isModificationDetermined(structureContext);
+ ContextInfo contextInfo = structureMetaData.getContext("");
+ if (contextInfo.getModificationType() != null)
+ return true;
+
+ boolean result = isModificationDetermined(root, contextInfo);
if (result)
{
- if (applyModificationToTop && structureContext.isTopLevel() == false)
+ contextInfo.setModificationType(modificationType);
+ return true;
+ }
+
+ if (checkChildren)
+ {
+ List<ContextInfo> contexts = structureMetaData.getContexts();
+ if (contexts != null && contexts.isEmpty() == false)
{
- // we need to modify an existing ContextInfo
- StructureContext topSC = getTopStructureContext(structureContext);
- StructureMetaData topSMD = topSC.getMetaData();
- ContextInfo contextInfo = topSMD.getContext("");
- if (contextInfo.getModificationType() != null)
+ for (ContextInfo child : contexts)
{
- log.debug("Ignoring modification type change, already set: " + contextInfo);
+ String path = child.getPath();
+ // Only process the child contexts
+ if ("".equals(path) == false)
+ {
+ try
+ {
+ VirtualFile file = root.getChild(path);
+ if (file != null && isModificationDetermined(file, child))
+ {
+ contextInfo.setModificationType(modificationType);
+ return true;
+ }
+ }
+ catch (Exception e)
+ {
+ log.debug("Exception checking child context (" + child + ") for modification, cause: " + e);
+ }
+ }
}
- else
- {
- contextInfo.setModificationType(modificationType);
- }
}
- else
- {
- // prepare the info for the actual creation
- structureContext.setModificationType(modificationType);
- }
}
+ return false;
+ }
+
+ public boolean determineModification(VirtualFile root, ContextInfo contextInfo)
+ {
+ if (contextInfo.getModificationType() != null)
+ return true;
+
+ boolean result = isModificationDetermined(root, contextInfo);
+ if (result)
+ {
+ contextInfo.setModificationType(modificationType);
+ }
return result;
}
/**
- * Do we have a modification match.
+ * Is modification determined.
*
- * @param structureContext the structure context
- * @return true if we should apply the modification
+ * @param file the file
+ * @param contextInfo the context info
+ * @return true if we should apply modification type, false otherwise
*/
- protected abstract boolean isModificationDetermined(StructureContext structureContext);
+ protected abstract boolean isModificationDetermined(VirtualFile file, ContextInfo contextInfo);
/**
- * Get top structure context.
- *
- * @param context the current structure context
- * @return the top structure context
- */
- protected StructureContext getTopStructureContext(StructureContext context)
- {
- while (context.getParentContext() != null)
- context = context.getParentContext();
-
- return context;
- }
-
- /**
* Do we apply modification to the top structure context.
*
- * @param applyModificationToTop the apply to top flag
+ * @param checkChildren the apply to top flag
*/
- public void setApplyModificationToTop(boolean applyModificationToTop)
+ public void setCheckChildren(boolean checkChildren)
{
- this.applyModificationToTop = applyModificationToTop;
+ this.checkChildren = checkChildren;
}
/**
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/FileModificationTypeMatcher.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/FileModificationTypeMatcher.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/FileModificationTypeMatcher.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -21,7 +21,11 @@
*/
package org.jboss.deployers.vfs.plugins.structure.modify;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.deployers.spi.structure.ContextInfo;
import org.jboss.virtual.VirtualFile;
/**
@@ -32,6 +36,7 @@
public class FileModificationTypeMatcher extends AbstractModificationTypeMatcher
{
private String[] paths;
+ private boolean metadataOnly;
public FileModificationTypeMatcher(String... paths)
{
@@ -41,32 +46,73 @@
this.paths = paths;
}
+ protected boolean isModificationDetermined(VirtualFile root, ContextInfo contextInfo)
+ {
+ for (String path : paths)
+ {
+ for (VirtualFile file : getStartingFiles(root, contextInfo))
+ {
+ try
+ {
+ if (file.getChild(path) != null)
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.debug("Cannot determine modification type, cause: " + e);
+ }
+ }
+ }
+ return false;
+ }
+
/**
- * Get the starting file.
+ * Get starting files for path check.
*
- * @param structureContext the structure context
- * @return the startting file; where do we start checking for paths
+ * @param file the current file
+ * @param contextInfo the context info
+ * @return list of starting files
*/
- protected VirtualFile getStartingFile(StructureContext structureContext)
+ protected List<VirtualFile> getStartingFiles(VirtualFile file, ContextInfo contextInfo)
{
- return structureContext.getFile();
- }
-
- protected boolean isModificationDetermined(StructureContext structureContext)
- {
- VirtualFile startingFile = getStartingFile(structureContext);
- for (String path : paths)
+ if (metadataOnly)
{
- try
+ List<String> metadataPaths = contextInfo.getMetaDataPath();
+ if (metadataPaths == null || metadataPaths.isEmpty())
{
- if (startingFile.getChild(path) != null)
- return true;
+ return Collections.emptyList();
}
- catch (Exception e)
+ else
{
- log.debug("Cannot determine modification type, cause: " + e);
+ List<VirtualFile> result = new ArrayList<VirtualFile>(metadataPaths.size());
+ for (String metadataPath : metadataPaths)
+ {
+ try
+ {
+ VirtualFile child = file.getChild(metadataPath);
+ if (child != null)
+ result.add(child);
+ }
+ catch (Exception ignored)
+ {
+ }
+ }
+ return result;
}
}
- return false;
+ else
+ {
+ return Collections.singletonList(file);
+ }
}
+
+ /**
+ * Should we check metadata only.
+ *
+ * @param metadataOnly the metadata only flag
+ */
+ public void setMetadataOnly(boolean metadataOnly)
+ {
+ this.metadataOnly = metadataOnly;
+ }
}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeMatcher.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeMatcher.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeMatcher.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -21,7 +21,9 @@
*/
package org.jboss.deployers.vfs.plugins.structure.modify;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.virtual.VirtualFile;
/**
* Determine if we need some modification.
@@ -33,8 +35,18 @@
/**
* Should we modify the file.
*
- * @param structureContext the structure context
+ * @param root the deployment root
+ * @param structureMetaData the current structure metadata
* @return true if we determined modification
*/
- boolean determineModification(StructureContext structureContext);
+ boolean determineModification(VirtualFile root, StructureMetaData structureMetaData);
+
+ /**
+ * Should we modify the file.
+ *
+ * @param root the deployment root
+ * @param contextInfo the current context info
+ * @return true if we determined modification
+ */
+ boolean determineModification(VirtualFile root, ContextInfo contextInfo);
}
\ No newline at end of file
Deleted: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureDeployer.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureDeployer.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.structure.modify;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
-import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
-
-/**
- * Determine if we need some modification.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class ModificationTypeStructureDeployer implements StructureDeployer
-{
- private List<ModificationTypeMatcher> matchers;
-
- public boolean determineStructure(StructureContext context) throws DeploymentException
- {
- if (matchers != null && matchers.isEmpty() == false)
- {
- for (ModificationTypeMatcher matcher : matchers)
- {
- if (matcher.determineModification(context))
- {
- break;
- }
- }
- }
- return false;
- }
-
- /**
- * Set modification type matchers.
- *
- * @param matchers the modification type matchers.
- */
- public void setMatchers(List<ModificationTypeMatcher> matchers)
- {
- this.matchers = matchers;
- }
-
- /**
- * Add modification type matcher.
- *
- * @param matcher the modification type matcher
- */
- public void addMatcher(ModificationTypeMatcher matcher)
- {
- if (matchers == null)
- matchers = new ArrayList<ModificationTypeMatcher>();
-
- matchers.add(matcher);
- }
-
- /**
- * Remove modification type matcher.
- *
- * @param matcher the modification type matcher
- */
- public void removeMatcher(ModificationTypeMatcher matcher)
- {
- if (matchers != null)
- {
- matchers.remove(matcher);
- }
- }
-
- public boolean isSupportsCandidateAnnotations()
- {
- return false;
- }
-
- public int getRelativeOrder()
- {
- return 1;
- }
-
- public void setRelativeOrder(int order)
- {
- }
-}
Copied: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureProcessor.java (from rev 83354, projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureDeployer.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureProcessor.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/ModificationTypeStructureProcessor.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.plugins.structure.modify;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.structure.spi.StructureProcessor;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Determine if we need some modification.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ModificationTypeStructureProcessor implements StructureProcessor
+{
+ private List<ModificationTypeMatcher> matchers;
+
+ public void prepareStructureMetaData(Deployment deployment, StructureMetaData structureMetaData)
+ {
+ if (deployment instanceof VFSDeployment == false)
+ return;
+
+ VFSDeployment vfsDeployment = VFSDeployment.class.cast(deployment);
+ VirtualFile root = vfsDeployment.getRoot();
+ checkForModification(root, structureMetaData);
+ }
+
+ public void prepareContextInfo(DeploymentContext parentDeploymentContext, ContextInfo contextInfo)
+ {
+ if (parentDeploymentContext instanceof VFSDeploymentContext == false || contextInfo == null)
+ return;
+
+ VFSDeploymentContext vfsParentDeploymentContext = VFSDeploymentContext.class.cast(parentDeploymentContext);
+ VirtualFile root = vfsParentDeploymentContext.getFile(contextInfo.getPath());
+ checkForModification(root, contextInfo);
+ }
+
+ public void applyStructureMetaData(DeploymentContext deploymentContext, StructureMetaData structureMetaData)
+ {
+ }
+
+ public void applyContextInfo(DeploymentContext deploymentContext, ContextInfo contextInfo)
+ {
+ }
+
+ /**
+ * Check for modification.
+ *
+ * @param root the deployment root
+ * @param structureMetaData the structure metadata
+ */
+ protected void checkForModification(VirtualFile root, StructureMetaData structureMetaData)
+ {
+ if (structureMetaData.getContext("") == null)
+ return;
+
+ if (matchers != null && matchers.isEmpty() == false)
+ {
+ for (ModificationTypeMatcher matcher : matchers)
+ {
+ if (matcher.determineModification(root, structureMetaData))
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Check for modification.
+ *
+ * @param root the deployment root
+ * @param contextInfo the context info
+ */
+ protected void checkForModification(VirtualFile root, ContextInfo contextInfo)
+ {
+ if (root == null)
+ return;
+
+ if (matchers != null && matchers.isEmpty() == false)
+ {
+ for (ModificationTypeMatcher matcher : matchers)
+ {
+ if (matcher.determineModification(root, contextInfo))
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Set modification type matchers.
+ *
+ * @param matchers the modification type matchers.
+ */
+ public void setMatchers(List<ModificationTypeMatcher> matchers)
+ {
+ this.matchers = matchers;
+ }
+
+ /**
+ * Add modification type matcher.
+ *
+ * @param matcher the modification type matcher
+ */
+ public void addMatcher(ModificationTypeMatcher matcher)
+ {
+ if (matchers == null)
+ matchers = new ArrayList<ModificationTypeMatcher>();
+
+ matchers.add(matcher);
+ }
+
+ /**
+ * Remove modification type matcher.
+ *
+ * @param matcher the modification type matcher
+ */
+ public void removeMatcher(ModificationTypeMatcher matcher)
+ {
+ if (matchers != null)
+ {
+ matchers.remove(matcher);
+ }
+ }
+}
Deleted: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/RootModificationTypeMatcher.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/RootModificationTypeMatcher.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/RootModificationTypeMatcher.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.plugins.structure.modify;
-
-import org.jboss.virtual.VirtualFile;
-import org.jboss.deployers.vfs.spi.structure.StructureContext;
-
-/**
- * Root modification type matcher.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class RootModificationTypeMatcher extends FileModificationTypeMatcher
-{
- public RootModificationTypeMatcher(String... paths)
- {
- super(paths);
- setApplyModificationToTop(true);
- }
-
- @Override
- protected VirtualFile getStartingFile(StructureContext structureContext)
- {
- return structureContext.getRoot();
- }
-
- @Override
- protected boolean isModificationDetermined(StructureContext structureContext)
- {
- if (structureContext.isTopLevel() == false)
- return false;
-
- return super.isModificationDetermined(structureContext);
- }
-}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/TempTopModificationTypeMatcher.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/TempTopModificationTypeMatcher.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/modify/TempTopModificationTypeMatcher.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -33,7 +33,7 @@
public TempTopModificationTypeMatcher(String... paths)
{
super(paths);
- setApplyModificationToTop(true);
+ setCheckChildren(true);
setModificationType(ModificationType.TEMP);
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/StructureContext.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/StructureContext.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/StructureContext.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -27,7 +27,6 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.spi.structure.ModificationType;
import org.jboss.deployers.spi.structure.StructureMetaData;
import org.jboss.virtual.VirtualFile;
@@ -64,9 +63,6 @@
/** The callbacks */
private Set<Object> callbacks;
- /** The modification type */
- private ModificationType modificationType;
-
/**
* Helper method to check parent is not null before retrieving parameters
*
@@ -323,24 +319,4 @@
getMetaData().removeContext(child);
}
-
- /**
- * Get modification type.
- *
- * @return the modification type
- */
- public ModificationType getModificationType()
- {
- return modificationType;
- }
-
- /**
- * Set modification type.
- *
- * @param modificationType the modification type
- */
- public void setModificationType(ModificationType modificationType)
- {
- this.modificationType = modificationType;
- }
}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java 2009-01-26 10:29:56 UTC (rev 83404)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java 2009-01-26 12:17:39 UTC (rev 83405)
@@ -33,7 +33,6 @@
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.spi.structure.ModificationType;
import org.jboss.deployers.vfs.spi.structure.CandidateAnnotationsCallback;
import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
@@ -526,23 +525,9 @@
*/
protected void applyContextInfo(StructureContext context, ContextInfo result)
{
- if (result != null)
+ if (result != null && contextInfoOrder != null)
{
- if (contextInfoOrder != null)
- result.setRelativeOrder(contextInfoOrder);
-
- ModificationType modificationType = context.getModificationType();
- if (modificationType != null)
- {
- if (result.getModificationType() != null)
- {
- log.debug("Ignoring modification type change, already set: " + result);
- }
- else
- {
- result.setModificationType(modificationType);
- }
- }
+ result.setRelativeOrder(contextInfoOrder);
}
}
}
More information about the jboss-cvs-commits
mailing list