[jboss-cvs] JBossAS SVN: r92015 - in projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi: structure/modified and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 5 11:48:28 EDT 2009
Author: alesj
Date: 2009-08-05 11:48:28 -0400 (Wed, 05 Aug 2009)
New Revision: 92015
Added:
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/PathMatcher.java
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatcherJoinedFilter.java
Modified:
projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
Log:
[JBDEPLOY-209]; add path matcher - needed for SCFilter.
Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2009-08-05 14:51:14 UTC (rev 92014)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java 2009-08-05 15:48:28 UTC (rev 92015)
@@ -44,7 +44,7 @@
* @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public abstract class AbstractVFSParsingDeployer<T> extends AbstractParsingDeployerWithOutput<T> implements FileMatcher
+public abstract class AbstractVFSParsingDeployer<T> extends AbstractParsingDeployerWithOutput<T> implements FileMatcher, PathMatcher
{
/** The alt mappings key */
private static final String ALT_MAPPINGS_MAP_KEY = "AltMappingsMap";
@@ -66,6 +66,31 @@
public boolean isDeployable(VirtualFile file)
{
String fileName = file.getName();
+ return matchFileName(fileName);
+ }
+
+ public boolean isDeployable(String path)
+ {
+ int p = path.lastIndexOf("/");
+
+ String fileName;
+ if (p > 0)
+ fileName = path.substring(p + 1);
+ else
+ fileName = path;
+
+ return matchFileName(fileName);
+ }
+
+ /**
+ * Match file name.
+ *
+ * @param fileName the file name.
+ *
+ * @return true if file name matches, false otherwise
+ */
+ protected boolean matchFileName(String fileName)
+ {
String suffix = getSuffix();
if (suffix == null)
return getNames() != null && getNames().contains(fileName);
Copied: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/PathMatcher.java (from rev 91150, projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/FileMatcher.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/PathMatcher.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/PathMatcher.java 2009-08-05 15:48:28 UTC (rev 92015)
@@ -0,0 +1,38 @@
+/*
+* 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;
+
+/**
+ * Matches path to check if it can be deployed.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface PathMatcher
+{
+ /**
+ * Check if path param is deployable.
+ *
+ * @param path the path
+ * @return true if we have a match, false otherwise
+ */
+ boolean isDeployable(String path);
+}
\ No newline at end of file
Copied: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatcherJoinedFilter.java (from rev 91150, projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/AbstractPathNameFilter.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatcherJoinedFilter.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/structure/modified/PathMatcherJoinedFilter.java 2009-08-05 15:48:28 UTC (rev 92015)
@@ -0,0 +1,93 @@
+/*
+ * 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.spi.structure.modified;
+
+import java.util.Set;
+
+import org.jboss.deployers.vfs.spi.deployer.PathMatcher;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.util.collection.ConcurrentSet;
+
+/**
+ * For virtual file filter we use delegate,
+ * as we already have FileStructure that collects all FileMatchers
+ * which is what we want to use to check if file is accepted.
+ *
+ * For structure cache filer we use PathMatchers.
+ * They should be injected via MC's IoC incallback.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class PathMatcherJoinedFilter implements StructureCacheFilter, VirtualFileFilter
+{
+ /** The path matchers */
+ private Set<PathMatcher> pathMatchers = new ConcurrentSet<PathMatcher>();
+
+ /** The virtual file filter delegate */
+ private VirtualFileFilter delegate;
+
+ public PathMatcherJoinedFilter(VirtualFileFilter delegate)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
+
+ this.delegate = delegate;
+ }
+
+ public boolean accepts(String path)
+ {
+ for (PathMatcher pm : pathMatchers)
+ {
+ if (pm.isDeployable(path))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean accepts(VirtualFile file)
+ {
+ return delegate.accepts(file);
+ }
+
+ /**
+ * Add path matcher.
+ *
+ * @param pm the path matcher
+ * @return Set#add
+ */
+ public boolean addFileMatcher(PathMatcher pm)
+ {
+ return pathMatchers.add(pm);
+ }
+
+ /**
+ * Remove path matcher.
+ *
+ * @param pm the path matcher
+ * @return Set#remove
+ */
+ public boolean removeFileMatcher(PathMatcher pm)
+ {
+ return pathMatchers.remove(pm);
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list