You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/10/05 20:54:56 UTC
svn commit: r821961 [13/30] - in /geronimo/sandbox/djencks/osgi/framework:
./ buildsupport/ buildsupport/car-maven-plugin/
buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/
buildsupport/geronimo-maven-plugin/src/main/jav...
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,44 @@
+package org.apache.geronimo.system.plugin.plexus.io.filemappers;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Interface of a component, which may be used to map file names.
+ */
+public interface FileMapper
+{
+ /**
+ * Role used to register component implementations with the container.
+ */
+ public static final String ROLE = FileMapper.class.getName();
+
+ /**
+ * The default role-hint: "default".
+ */
+ public static final String DEFAULT_ROLE_HINT = "default";
+
+ /**
+ * Maps the given source name to a target name.
+ *
+ * @param pName
+ * The source name.
+ * @return The target name.
+ * @throws IllegalArgumentException
+ * The source name is null or empty.
+ */
+ public String getMappedFileName( String pName );
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FileMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,44 @@
+package org.apache.geronimo.system.plugin.plexus.io.filemappers;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Implementation of a flattening file mapper: Removes all directory parts.
+ */
+public class FlattenFileMapper extends AbstractFileMapper
+{
+ /**
+ * The flatten file mappers role-hint: "flatten".
+ */
+ public static final String ROLE_HINT = "flatten";
+
+ public String getMappedFileName( String pName )
+ {
+ String name = super.getMappedFileName( pName ); // Check for null, etc.
+ int offset = pName.lastIndexOf( '/' );
+ if ( offset >= 0 )
+ {
+ name = name.substring( offset + 1 );
+ }
+ offset = pName.lastIndexOf( '\\' );
+ if ( offset >= 0 )
+ {
+ name = name.substring( offset + 1 );
+ }
+ return name;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/FlattenFileMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,37 @@
+package org.apache.geronimo.system.plugin.plexus.io.filemappers;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Default implementation of {@link FileMapper}, which performs the identity mapping: All names are left unchanged.
+ */
+public class IdentityMapper extends AbstractFileMapper
+{
+ /**
+ * The identity mappers role-hint: "identity".
+ */
+ public static final String ROLE_HINT = "identity";
+
+ public String getMappedFileName( String pName )
+ {
+ if ( pName == null || pName.length() == 0 )
+ {
+ throw new IllegalArgumentException( "The source name must not be null." );
+ }
+ return pName;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/IdentityMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,71 @@
+package org.apache.geronimo.system.plugin.plexus.io.filemappers;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A file mapper, which maps to a constant target name.
+ */
+public class MergeFileMapper extends AbstractFileMapper
+{
+ /**
+ * The merge mappers role-hint: "merge".
+ */
+ public static final String ROLE_HINT = "merge";
+
+ private String targetName;
+
+ /**
+ * Sets the merge mappers target name.
+ *
+ * @throws IllegalArgumentException
+ * The target name is null or empty.
+ */
+ public void setTargetName( String pName )
+ {
+ if ( pName == null )
+ {
+ throw new IllegalArgumentException( "The target name is null." );
+ }
+ if ( pName.length() == 0 )
+ {
+ throw new IllegalArgumentException( "The target name is empty." );
+ }
+ targetName = pName;
+ }
+
+ /**
+ * Returns the merge mappers target name.
+ *
+ * @throws IllegalArgumentException
+ * The target name is null or empty.
+ */
+ public String getTargetName()
+ {
+ return targetName;
+ }
+
+ public String getMappedFileName( String pName )
+ {
+ final String name = getTargetName();
+ if ( name == null )
+ {
+ throw new IllegalStateException( "The target file name has not been set." );
+ }
+ super.getMappedFileName( pName ); // Check for null, etc.
+ return name;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/MergeFileMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,65 @@
+package org.apache.geronimo.system.plugin.plexus.io.filemappers;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * A file mapper, which maps by adding a prefix.
+ */
+public class PrefixFileMapper extends AbstractFileMapper
+{
+ /**
+ * The merge mappers role-hint: "prefix".
+ */
+ public static final String ROLE_HINT = "prefix";
+
+ private String prefix;
+
+ public String getMappedFileName( String name )
+ {
+ final String s = super.getMappedFileName( name ); // Check for null, etc.
+ return getMappedFileName( prefix, s );
+ }
+
+ /**
+ * Returns the prefix to add.
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ /**
+ * Sets the prefix to add.
+ */
+ public void setPrefix( String prefix )
+ {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Performs the mapping of a file name by adding a prefix.
+ */
+ public static String getMappedFileName( String prefix, String name )
+ {
+ if ( prefix == null || prefix.length() == 0 )
+ {
+ return name;
+ }
+ return prefix + name;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/PrefixFileMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,109 @@
+package org.apache.geronimo.system.plugin.plexus.io.filemappers;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+
+/**
+ * Implementation of a file mapper, which uses regular expressions.
+ */
+public class RegExpFileMapper extends AbstractFileMapper {
+ /**
+ * The regexp mappers role-hint: "regexp".
+ */
+ public static final String ROLE_HINT = "regexp";
+
+ private Pattern pattern;
+ private String replacement;
+ private boolean replaceAll;
+
+ /**
+ * Sets the regular expression pattern.
+ */
+ public void setPattern(String pPattern)
+ {
+ pattern = Pattern.compile(pPattern);
+ }
+
+ /**
+ * Returns the regular expression pattern.
+ */
+ public String getPattern()
+ {
+ return pattern == null ? null : pattern.pattern();
+ }
+
+ /**
+ * Sets the replacement string.
+ */
+ public void setReplacement(String pReplacement)
+ {
+ replacement = pReplacement;
+ }
+
+ /**
+ * Returns the replacement string.
+ */
+ public String getReplacement()
+ {
+ return replacement;
+ }
+
+ /**
+ * Returns, whether to replace the first occurrency of the pattern
+ * (default), or all.
+ */
+ public boolean getReplaceAll()
+ {
+ return replaceAll;
+ }
+
+ /**
+ * Sets, whether to replace the first occurrency of the pattern
+ * (default), or all.
+ */
+ public void setReplaceAll(boolean pReplaceAll)
+ {
+ replaceAll = pReplaceAll;
+ }
+
+ public String getMappedFileName(String pName)
+ {
+ final String name = super.getMappedFileName(pName);
+ if (pattern == null)
+ {
+ throw new IllegalStateException("The regular expression pattern has not been set.");
+ }
+ if (replacement == null)
+ {
+ throw new IllegalStateException("The pattern replacement string has not been set.");
+ }
+ final Matcher matcher = pattern.matcher(name);
+ if (!matcher.find())
+ {
+ return name;
+ }
+ if (!getReplaceAll())
+ {
+ return matcher.replaceFirst(replacement);
+ }
+ return matcher.replaceAll(replacement);
+ }
+}
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/RegExpFileMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html Mon Oct 5 18:54:50 2009
@@ -0,0 +1,16 @@
+<html><head><title>File Mappers</title></head>
+<body><h1>File Mappers</h1>
+<p>File mappers can be used, for example, when files are being copied, moved, archived, or unarchived.
+ The purpose of a file mapper is to select the target files name and destination.</p>
+<p>Examples:</p>
+<ul>
+ <li>The <a href="IdentityMapper.html">IdentityMapper</a> is a trivial file mapper,
+ which leaves all file names are unchanged. This is mainly useful as a default
+ file mapper.</li>
+ <li>The <a href="FileExtensionMapper.html">FileNameExtensionMapper</a> changes the
+ file names extension. This can be used, for example, when you run the
+ <a href="http://xml.apache.org/fop">FOP</a> transformer to produce PDF.
+ Of course, you would want the created files to have the extension <code>.pdf</code>,
+ rather than <code>.xml</code>.</li>
+</ul>
+</body></html>
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/filemappers/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,36 @@
+package org.apache.geronimo.system.plugin.plexus.io.fileselectors;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+
+/**
+ * The default file selector: Selects all files.
+ */
+public class AllFilesFileSelector implements FileSelector
+{
+ /**
+ * The all files selectors role-hint: "all".
+ */
+ public static final String ROLE_HINT = "all";
+
+ public boolean isSelected( FileInfo fileInfo ) throws IOException
+ {
+ return true;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/AllFilesFileSelector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,55 @@
+package org.apache.geronimo.system.plugin.plexus.io.fileselectors;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * An object implementing this interface is passed to the
+ * file selector when the method
+ * {@link FileSelector#isSelected(FileInfo)}
+ * is invoked. This object provides information about
+ * the file to select or deselect.
+ */
+public interface FileInfo
+{
+ /**
+ * Returns the resources name, which may include path components,
+ * like directory names, or something like that. The resources name
+ * is expected to be a relative name and the path components must
+ * be separated by {@link java.io.File#pathSeparator}
+ */
+ String getName();
+
+ /**
+ * Creates an {@link InputStream}, which may be used to read
+ * the files contents. This is useful, if the file selector
+ * comes to a decision based on the files contents.
+ */
+ InputStream getContents() throws IOException;
+
+ /**
+ * Returns, whether the {@link FileInfo} refers to a file.
+ */
+ boolean isFile();
+
+ /**
+ * Returns, whether the {@link FileInfo} refers to a directory.
+ */
+ boolean isDirectory();
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileInfo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,44 @@
+package org.apache.geronimo.system.plugin.plexus.io.fileselectors;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+
+/**
+ * Interface of a component, which selects/deselects files.
+ */
+public interface FileSelector
+{
+ /**
+ * Role used to register component implementations with the container.
+ */
+ public static final String ROLE = FileSelector.class.getName();
+
+ /**
+ * The default role-hint: "default".
+ */
+ public static final String DEFAULT_ROLE_HINT = "default";
+
+ /**
+ * Returns, whether the given file is selected.
+ * @param An instance of FileInfo with the files meta data.
+ * It is recommended, that the caller creates an instance
+ * of {@link PlexusIoResource}.
+ */
+ boolean isSelected( FileInfo fileInfo ) throws IOException;
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/FileSelector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,254 @@
+package org.apache.geronimo.system.plugin.plexus.io.fileselectors;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.geronimo.system.plugin.plexus.util.FileUtils;
+import org.apache.geronimo.system.plugin.plexus.util.SelectorUtils;
+
+
+/**
+ * This file selector uses a set of patterns for including/excluding
+ * files.
+ */
+public class IncludeExcludeFileSelector implements FileSelector
+{
+ /**
+ * The include/exclude file selectors role-hint: "standard".
+ */
+ public static final String ROLE_HINT = "standard";
+
+ private static final String[] ALL_INCLUDES = new String[]{ getCanonicalName( "**/*" ) };
+ private static final String[] ZERO_EXCLUDES = new String[0];
+
+ private boolean isCaseSensitive = true;
+
+ private boolean useDefaultExcludes = true;
+
+ private String[] includes;
+
+ private String[] excludes;
+
+ private String[] computedIncludes = ALL_INCLUDES;
+
+ private String[] computedExcludes = ZERO_EXCLUDES;
+
+ /**
+ * Tests whether or not a name matches against at least one exclude
+ * pattern.
+ *
+ * @param name The name to match. Must not be <code>null</code>.
+ * @return <code>true</code> when the name matches against at least one
+ * exclude pattern, or <code>false</code> otherwise.
+ */
+ protected boolean isExcluded( String name )
+ {
+ for ( int i = 0; i < computedExcludes.length; i++ )
+ {
+ if ( matchPath( computedExcludes[i], name, isCaseSensitive ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sets the list of include patterns to use. All '/' and '\' characters
+ * are replaced by <code>File.separatorChar</code>, so the separator used
+ * need not match <code>File.separatorChar</code>.
+ * <p>
+ * When a pattern ends with a '/' or '\', "**" is appended.
+ *
+ * @param includes A list of include patterns.
+ * May be <code>null</code>, indicating that all files
+ * should be included. If a non-<code>null</code>
+ * list is given, all elements must be
+ * non-<code>null</code>.
+ */
+ public void setIncludes( String[] includes )
+ {
+ this.includes = includes;
+ if ( includes == null )
+ {
+ computedIncludes = ALL_INCLUDES;
+ }
+ else
+ {
+ computedIncludes = new String[includes.length];
+ for ( int i = 0; i < includes.length; i++ )
+ {
+ String pattern = asPattern( includes[i] );
+ computedIncludes[i] = pattern;
+ }
+ }
+ }
+
+ private static String getCanonicalName( String pName )
+ {
+ return pName.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
+ }
+
+ private String asPattern( String pPattern )
+ {
+ String pattern = getCanonicalName( pPattern.trim() );
+ if ( pattern.endsWith( File.separator ) )
+ {
+ pattern += "**";
+ }
+ return pattern;
+ }
+
+ /**
+ * Returns the list of include patterns to use.
+ *
+ * @return A list of include patterns.
+ * May be <code>null</code>, indicating that all files
+ * should be included. If a non-<code>null</code>
+ * list is given, all elements must be
+ * non-<code>null</code>.
+ */
+ public String[] getIncludes()
+ {
+ return includes;
+ }
+
+ /**
+ * Sets the list of exclude patterns to use. All '/' and '\' characters
+ * are replaced by <code>File.separatorChar</code>, so the separator used
+ * need not match <code>File.separatorChar</code>.
+ * <p>
+ * When a pattern ends with a '/' or '\', "**" is appended.
+ *
+ * @param excludes A list of exclude patterns.
+ * May be <code>null</code>, indicating that no files
+ * should be excluded. If a non-<code>null</code> list is
+ * given, all elements must be non-<code>null</code>.
+ */
+ public void setExcludes( String[] excludes )
+ {
+ this.excludes = excludes;
+ final String[] defaultExcludes = useDefaultExcludes ? FileUtils.getDefaultExcludes() : ZERO_EXCLUDES;
+ if ( excludes == null )
+ {
+ computedExcludes = defaultExcludes;
+ }
+ else
+ {
+ computedExcludes = new String[excludes.length + defaultExcludes.length];
+ for ( int i = 0; i < excludes.length; i++ )
+ {
+ computedExcludes[i] = asPattern( excludes[i] );
+ }
+ if ( defaultExcludes.length > 0 )
+ {
+ System.arraycopy( defaultExcludes, 0, computedExcludes, excludes.length, defaultExcludes.length );
+ }
+ }
+ }
+
+ /**
+ * Returns the list of exclude patterns to use.
+ *
+ * @return A list of exclude patterns.
+ * May be <code>null</code>, indicating that no files
+ * should be excluded. If a non-<code>null</code> list is
+ * given, all elements must be non-<code>null</code>.
+ */
+ public String[] getExcludes()
+ {
+ return excludes;
+ }
+
+ /**
+ * Tests, whether the given pattern is matching the given name.
+ * @param pattern The pattern to match
+ * @param name The name to test
+ * @param isCaseSensitive Whether the pattern is case sensitive.
+ * @return True, if the pattern matches, otherwise false
+ */
+ protected boolean matchPath( String pattern, String name,
+ boolean isCaseSensitive )
+ {
+ return SelectorUtils.matchPath( pattern, name, isCaseSensitive );
+ }
+
+ /**
+ * Tests whether or not a name matches against at least one include
+ * pattern.
+ *
+ * @param name The name to match. Must not be <code>null</code>.
+ * @return <code>true</code> when the name matches against at least one
+ * include pattern, or <code>false</code> otherwise.
+ */
+ protected boolean isIncluded( String name )
+ {
+ for ( int i = 0; i < computedIncludes.length; i++ )
+ {
+ if ( matchPath( computedIncludes[i], name, isCaseSensitive ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isSelected( FileInfo fileInfo ) throws IOException
+ {
+ final String name = getCanonicalName( fileInfo.getName() );
+ return isIncluded( name ) && !isExcluded( name );
+ }
+
+ /**
+ * Returns, whether the include/exclude patterns are case sensitive.
+ * @return True, if the patterns are case sensitive (default), or false.
+ */
+ public boolean isCaseSensitive()
+ {
+ return isCaseSensitive;
+ }
+
+ /**
+ * Sets, whether the include/exclude patterns are case sensitive.
+ * @param caseSensitive True, if the patterns are case sensitive (default), or false.
+ */
+ public void setCaseSensitive( boolean caseSensitive )
+ {
+ isCaseSensitive = caseSensitive;
+ }
+
+ /**
+ * Returns, whether to use the default excludes, as specified by
+ * {@link FileUtils#getDefaultExcludes()}.
+ */
+ public boolean isUseDefaultExcludes()
+ {
+ return useDefaultExcludes;
+ }
+
+ /**
+ * Sets, whether to use the default excludes, as specified by
+ * {@link FileUtils#getDefaultExcludes()}.
+ */
+ public void setUseDefaultExcludes( boolean pUseDefaultExcludes )
+ {
+ useDefaultExcludes = pUseDefaultExcludes;
+ setExcludes( excludes );
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/IncludeExcludeFileSelector.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html Mon Oct 5 18:54:50 2009
@@ -0,0 +1,13 @@
+<html><head><title>File Selectors</title></head>
+<body><h1>File Selectors</h1>
+<p>File selectors can be used to select or deselect a subset of files.
+ For example, the plexus archivers or unarchivers use file selectors
+ for selecting a subset of files in a directory.</p>
+<p>Examples:</p>
+<ul>
+ <li>The <a href="AllFilesSelector.html">AllFilesSelector</a> is a default
+ file selector, which simply selects all files.</li>
+ <li>The <a href="IncludeExcludeFileSelector.html">IncludeExcludeFileSelector</a>
+ selects or deselects files based on include/exclude patterns.</li>
+</ul>
+</body></html>
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/fileselectors/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,90 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.slf4j.Logger;
+
+
+
+/**
+ * Default implementation of {@link PlexusIoFileResourceCollection} for
+ * zip files, tar files, etc.
+ * @author jwi
+ *
+ */
+public abstract class AbstractPlexusIoArchiveResourceCollection extends AbstractPlexusIoResourceCollection
+ implements PlexusIoArchivedResourceCollection
+{
+
+ private File file;
+
+ protected AbstractPlexusIoArchiveResourceCollection()
+ {
+ }
+
+ protected AbstractPlexusIoArchiveResourceCollection( Logger logger )
+ {
+ super( logger );
+ }
+
+ /**
+ * Sets the zip file
+ */
+ public void setFile( File file )
+ {
+ this.file = file;
+ }
+
+ /**
+ * Returns the zip file
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Returns an iterator over the archives entries.
+ */
+ protected abstract Iterator getEntries() throws IOException;
+
+ public Iterator getResources() throws IOException
+ {
+ final List result = new ArrayList();
+ for (Iterator it = getEntries(); it.hasNext(); )
+ {
+ final PlexusIoResource res = (PlexusIoResource) it.next();
+ if ( isSelected( res ) )
+ {
+ result.add( res );
+ }
+ }
+ return result.iterator();
+ }
+
+ public long getLastModified() throws IOException
+ {
+ File f = getFile();
+ return f == null ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : f.lastModified();
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoArchiveResourceCollection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,124 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Default implementation of {@link PlexusIoResource}.
+ */
+public abstract class AbstractPlexusIoResource implements PlexusIoResource
+{
+ private String name;
+
+ private long lastModified, size;
+
+ private boolean isFile, isDirectory, isExisting;
+
+ /**
+ * Creates a new instance with default settings.
+ */
+ public AbstractPlexusIoResource()
+ {
+ }
+
+ /**
+ * Sets the date, when the resource was last modified.
+ * @param Date of last modification, if known.
+ * Otherwise, {@link #UNKNOWN_MODIFICATION_DATE}.
+ * @see java.io.File#lastModified()
+ */
+ public void setLastModified( long lastModified )
+ {
+ this.lastModified = lastModified;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
+
+ /**
+ * Sets the resources name, which may include path components,
+ * like directory names, or something like that. The resources name
+ * is expected to be a relative name and the path components must
+ * be separated by {@link java.io.File#pathSeparator}
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Sets the resources size.
+ * @param size The resources size, if known. Otherwise returns
+ * {@link #UNKNOWN_RESOURCE_SIZE}.
+ * @see java.io.File#length()
+ */
+ public void setSize( long size )
+ {
+ this.size = size;
+ }
+
+ public long getSize()
+ {
+ return size;
+ }
+
+ /**
+ * Sets, whether the resource is a directory.
+ */
+ public void setDirectory( boolean isDirectory )
+ {
+ this.isDirectory = isDirectory;
+ }
+
+ public boolean isDirectory()
+ {
+ return isDirectory;
+ }
+
+ /**
+ * Sets, whether the resource exists.
+ */
+ public void setExisting( boolean isExisting )
+ {
+ this.isExisting = isExisting;
+ }
+
+ public boolean isExisting()
+ {
+ return isExisting;
+ }
+
+ /**
+ * Sets, whether the resource is a file.
+ */
+ public void setFile( boolean isFile )
+ {
+ this.isFile = isFile;
+ }
+
+ public boolean isFile()
+ {
+ return isFile;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,266 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.geronimo.system.plugin.plexus.io.filemappers.FileMapper;
+import org.apache.geronimo.system.plugin.plexus.io.filemappers.PrefixFileMapper;
+import org.apache.geronimo.system.plugin.plexus.io.fileselectors.FileSelector;
+import org.slf4j.Logger;
+
+
+/**
+ * Default implementation of a resource collection.
+ */
+public abstract class AbstractPlexusIoResourceCollection
+ implements PlexusIoResourceCollection
+{
+ private String prefix;
+
+ private String[] includes;
+
+ private String[] excludes;
+
+ private FileSelector[] fileSelectors;
+
+ private boolean caseSensitive = true;
+
+ private boolean usingDefaultExcludes = true;
+
+ private boolean includingEmptyDirectories = true;
+
+ private FileMapper[] fileMappers;
+
+ private Logger logger;
+
+ protected AbstractPlexusIoResourceCollection()
+ {
+ }
+
+ protected AbstractPlexusIoResourceCollection( Logger logger )
+ {
+ this.logger = logger;
+ }
+
+ protected Logger getLogger()
+ {
+ return logger;
+ }
+
+ /**
+ * Sets a string of patterns, which excluded files
+ * should match.
+ */
+ public void setExcludes( String[] excludes )
+ {
+ this.excludes = excludes;
+ }
+
+ /**
+ * Returns a string of patterns, which excluded files
+ * should match.
+ */
+ public String[] getExcludes()
+ {
+ return excludes;
+ }
+
+ /**
+ * Sets a set of file selectors, which should be used
+ * to select the included files.
+ */
+ public void setFileSelectors( FileSelector[] fileSelectors )
+ {
+ this.fileSelectors = fileSelectors;
+ }
+
+ /**
+ * Returns a set of file selectors, which should be used
+ * to select the included files.
+ */
+ public FileSelector[] getFileSelectors()
+ {
+ return fileSelectors;
+ }
+
+ /**
+ * Sets a string of patterns, which included files
+ * should match.
+ */
+ public void setIncludes( String[] includes )
+ {
+ this.includes = includes;
+ }
+
+ /**
+ * Returns a string of patterns, which included files
+ * should match.
+ */
+ public String[] getIncludes()
+ {
+ return includes;
+ }
+
+ /**
+ * Sets the prefix, which the file sets contents shall
+ * have.
+ */
+ public void setPrefix( String prefix )
+ {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Returns the prefix, which the file sets contents shall
+ * have.
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ /**
+ * Sets, whether the include/exclude patterns are
+ * case sensitive. Defaults to true.
+ */
+ public void setCaseSensitive( boolean caseSensitive )
+ {
+ this.caseSensitive = caseSensitive;
+ }
+
+ /**
+ * Returns, whether the include/exclude patterns are
+ * case sensitive. Defaults to true.
+ */
+ public boolean isCaseSensitive()
+ {
+ return caseSensitive;
+ }
+
+ /**
+ * Sets, whether the default excludes are being
+ * applied. Defaults to true.
+ */
+ public void setUsingDefaultExcludes( boolean usingDefaultExcludes )
+ {
+ this.usingDefaultExcludes = usingDefaultExcludes;
+ }
+
+ /**
+ * Returns, whether the default excludes are being
+ * applied. Defaults to true.
+ */
+ public boolean isUsingDefaultExcludes()
+ {
+ return usingDefaultExcludes;
+ }
+
+ /**
+ * Sets, whether empty directories are being included. Defaults
+ * to true.
+ */
+ public void setIncludingEmptyDirectories( boolean includingEmptyDirectories )
+ {
+ this.includingEmptyDirectories = includingEmptyDirectories;
+ }
+
+ /**
+ * Returns, whether empty directories are being included. Defaults
+ * to true.
+ */
+ public boolean isIncludingEmptyDirectories()
+ {
+ return includingEmptyDirectories;
+ }
+
+ protected boolean isSelected( PlexusIoResource plexusIoResource ) throws IOException
+ {
+ FileSelector[] fileSelectors = getFileSelectors();
+ if ( fileSelectors != null )
+ {
+ for ( int i = 0; i < fileSelectors.length; i++ )
+ {
+ if ( !fileSelectors[i].isSelected( plexusIoResource ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns the file name mappers, which are used to transform
+ * the resource names.
+ */
+ public FileMapper[] getFileMappers()
+ {
+ return fileMappers;
+ }
+
+ /**
+ * Sets the file name mappers, which are used to transform
+ * the resource names.
+ */
+ public void setFileMappers( FileMapper[] fileMappers )
+ {
+ this.fileMappers = fileMappers;
+ }
+
+ public String getName( PlexusIoResource resource )
+ throws IOException
+ {
+ String name = resource.getName();
+ final FileMapper[] mappers = getFileMappers();
+ if ( mappers != null )
+ {
+ for ( int i = 0; i < mappers.length; i++ )
+ {
+ name = mappers[i].getMappedFileName( name );
+ }
+ }
+ return PrefixFileMapper.getMappedFileName( getPrefix(), name );
+ }
+
+ public long getLastModified()
+ throws IOException
+ {
+ long lastModified = PlexusIoResource.UNKNOWN_MODIFICATION_DATE;
+ for ( final Iterator iter = getResources(); iter.hasNext(); )
+ {
+ final PlexusIoResource res = (PlexusIoResource) iter.next();
+ long l = res.getLastModified();
+ if ( l == PlexusIoResource.UNKNOWN_MODIFICATION_DATE )
+ {
+ return PlexusIoResource.UNKNOWN_MODIFICATION_DATE;
+ }
+ if ( lastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE
+ || l > lastModified )
+ {
+ lastModified = l;
+ }
+ }
+ return lastModified;
+ }
+
+ public void enableLogging( Logger logger )
+ {
+ this.logger = logger;
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceCollection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,43 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributes;
+
+public abstract class AbstractPlexusIoResourceWithAttributes
+ extends AbstractPlexusIoResource
+ implements PlexusIoResourceWithAttributes
+{
+
+ private PlexusIoResourceAttributes attributes;
+
+ public AbstractPlexusIoResourceWithAttributes()
+ {
+ super();
+ }
+
+ public PlexusIoResourceAttributes getAttributes()
+ {
+ return attributes;
+ }
+
+ public void setAttributes( PlexusIoResourceAttributes attributes )
+ {
+ this.attributes = attributes;
+ }
+
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/AbstractPlexusIoResourceWithAttributes.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,46 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public interface PlexusIOResourceCollectionWithAttributes
+{
+
+ /**
+ * Sets the file and directory attributes to use as defaults.
+ *
+ * @param uid
+ * @param userName
+ * @param gid
+ * @param groupName
+ * @param fileMode The octal mode to use for files
+ * @param dirMode The octal mode to use for directories
+ */
+ void setDefaultAttributes( int uid, String userName, int gid, String groupName, int fileMode, int dirMode );
+
+ /**
+ * Sets the file and directory attributes to use as overrides.
+ *
+ * @param uid
+ * @param userName
+ * @param gid
+ * @param groupName
+ * @param fileMode The octal mode to use for files
+ * @param dirMode The octal mode to use for directories
+ */
+ void setOverrideAttributes( int uid, String userName, int gid, String groupName, int fileMode, int dirMode );
+
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIOResourceCollectionWithAttributes.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,38 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+
+/**
+ * Extension of {@link PlexusIoResourceCollection} for archive
+ * files: Zip, tar, gzip, bzip2, etc. files.
+ */
+public interface PlexusIoArchivedResourceCollection
+ extends PlexusIoResourceCollection
+{
+ /**
+ * Sets the arcihve file
+ */
+ void setFile( File file );
+
+ /**
+ * Returns the archive file
+ */
+ File getFile();
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoArchivedResourceCollection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,110 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+
+
+/**
+ * Abstract base class for compressed files, aka singleton
+ * resource collections.
+ */
+public abstract class PlexusIoCompressedFileResourceCollection
+ implements PlexusIoArchivedResourceCollection
+{
+ private File file;
+ private String path;
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void setFile( File file )
+ {
+ this.file = file;
+
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath( String path )
+ {
+ this.path = path;
+
+ }
+
+ public Iterator getResources()
+ throws IOException
+ {
+ final File f = getFile();
+ final String p = (getPath() == null ? getName( f ) : getPath()).replace( '\\', '/' );
+ if ( f == null )
+ {
+ throw new IOException( "No archive file is set." );
+ }
+ if ( ! f.isFile() )
+ {
+ throw new IOException( "The archive file " + f.getPath()
+ + " does not exist or is no file." );
+ }
+
+ final PlexusIoResource resource = new PlexusIoFileResource(f, p)
+ {
+ public InputStream getContents()
+ throws IOException
+ {
+ return getInputStream( f );
+ }
+ };
+
+ return Collections.singleton( resource ).iterator();
+ }
+
+ protected String getName( File file ) throws IOException {
+ final String name = file.getPath();
+ final String ext = getDefaultExtension();
+ if ( ext != null && ext.length() > 0 && name.endsWith( ext ) )
+ {
+ return name.substring( 0, name.length() - ext.length() );
+ }
+ return name;
+ }
+
+ protected abstract String getDefaultExtension();
+
+ protected abstract InputStream getInputStream( File file ) throws IOException;
+
+ public String getName( PlexusIoResource resource )
+ throws IOException
+ {
+ return resource.getName();
+ }
+
+ public long getLastModified() throws IOException
+ {
+ File f = getFile();
+ return f == null ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : f.lastModified();
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoCompressedFileResourceCollection.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,155 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributes;
+
+/**
+ * Implementation of {@link PlexusIoResource} for files.
+ */
+public class PlexusIoFileResource
+ extends AbstractPlexusIoResourceWithAttributes
+ implements PlexusIoResourceWithAttributes
+{
+ private File file;
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource()
+ {
+ // Does nothing
+ }
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource( File file )
+ {
+ this( file, file.getPath().replace( '\\', '/' ) );
+ }
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource( File file, PlexusIoResourceAttributes attrs )
+ {
+ this( file, file.getPath().replace( '\\', '/' ), attrs );
+ }
+
+ /**
+ * Creates a new instance.
+ */
+ public PlexusIoFileResource( File file, String name )
+ {
+ setFile( file );
+ setName( name );
+ }
+
+ public PlexusIoFileResource( File file, String name, PlexusIoResourceAttributes attrs )
+ {
+ setName( name );
+ setAttributes( attrs );
+ setFile( file );
+ }
+
+ /**
+ * Sets the resources file.
+ */
+ public void setFile( File file )
+ {
+ this.file = file;
+ setLastModified( file.lastModified() );
+ setSize( file.length() );
+ setFile( file.isFile() );
+ setDirectory( file.isDirectory() );
+ setExisting( file.exists() );
+ }
+
+ /**
+ * Returns the resources file.
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ public InputStream getContents()
+ throws IOException
+ {
+ return new FileInputStream( getFile() );
+ }
+
+ public URL getURL()
+ throws IOException
+ {
+ return getFile().toURI().toURL();
+ }
+
+ public long getLastModified()
+ {
+ return getFile().lastModified();
+ }
+
+ public long getSize()
+ {
+ return getFile().length();
+ }
+
+ public boolean isDirectory()
+ {
+ return getFile().isDirectory();
+ }
+
+ public boolean isExisting()
+ {
+ return getFile().exists();
+ }
+
+ public boolean isFile()
+ {
+ return getFile().isFile();
+ }
+
+ public void setDirectory( boolean isDirectory )
+ {
+ }
+
+ public void setExisting( boolean isExisting )
+ {
+ }
+
+ public void setFile( boolean isFile )
+ {
+ }
+
+ public void setLastModified( long lastModified )
+ {
+ file.setLastModified( lastModified );
+ }
+
+ public void setSize( long size )
+ {
+ }
+
+}
\ No newline at end of file
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResourceCollection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResourceCollection.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResourceCollection.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/io/resources/PlexusIoFileResourceCollection.java Mon Oct 5 18:54:50 2009
@@ -0,0 +1,188 @@
+package org.apache.geronimo.system.plugin.plexus.io.resources;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geronimo.system.plugin.plexus.io.attributes.FileAttributes;
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributeUtils;
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributes;
+import org.apache.geronimo.system.plugin.plexus.util.DirectoryScanner;
+import org.slf4j.Logger;
+
+
+/**
+ * Implementation of {@link PlexusIoResourceCollection} for the set
+ * of files in a common directory.
+ */
+public class PlexusIoFileResourceCollection
+ extends AbstractPlexusIoResourceCollection
+ implements PlexusIOResourceCollectionWithAttributes
+{
+ /**
+ * Role hint of this component
+ */
+ public static final String ROLE_HINT = "files";
+
+ private File baseDir;
+
+ private boolean isFollowingSymLinks = true;
+
+ private FileAttributes defaultFileAttributes;
+
+ private FileAttributes defaultDirAttributes;
+
+ private FileAttributes overrideFileAttributes;
+
+ private FileAttributes overrideDirAttributes;
+
+ public PlexusIoFileResourceCollection()
+ {
+ }
+
+ public PlexusIoFileResourceCollection( Logger logger )
+ {
+ super( logger );
+ }
+
+ public void setDefaultAttributes( int uid, String userName, int gid, String groupName, int fileMode, int dirMode )
+ {
+ defaultFileAttributes = new FileAttributes( uid, userName, gid, groupName, new char[]{} );
+ defaultFileAttributes.setOctalMode( fileMode );
+
+ defaultDirAttributes = new FileAttributes( uid, userName, gid, groupName, new char[]{} );
+ defaultDirAttributes.setOctalMode( dirMode );
+ }
+
+ public void setOverrideAttributes( int uid, String userName, int gid, String groupName, int fileMode, int dirMode )
+ {
+ overrideFileAttributes = new FileAttributes( uid, userName, gid, groupName, new char[]{} );
+ overrideFileAttributes.setOctalMode( fileMode );
+
+ overrideDirAttributes = new FileAttributes( uid, userName, gid, groupName, new char[]{} );
+ overrideDirAttributes.setOctalMode( dirMode );
+ }
+
+ /**
+ * Sets the file collections base directory.
+ */
+ public void setBaseDir( File baseDir )
+ {
+ this.baseDir = baseDir;
+ }
+
+ /**
+ * Returns the file collections base directory.
+ */
+ public File getBaseDir()
+ {
+ return baseDir;
+ }
+
+ /**
+ * Returns, whether symbolic links should be followed.
+ * Defaults to true.
+ */
+ public boolean isFollowingSymLinks()
+ {
+ return isFollowingSymLinks;
+ }
+
+ /**
+ * Returns, whether symbolic links should be followed.
+ * Defaults to true.
+ */
+ public void setFollowingSymLinks( boolean pIsFollowingSymLinks )
+ {
+ isFollowingSymLinks = pIsFollowingSymLinks;
+ }
+
+ private void addResources( List list, String[] resources, Map attributesByPath ) throws IOException
+ {
+ final File dir = getBaseDir();
+ for ( int i = 0; i < resources.length; i++ )
+ {
+ String name = resources[i];
+ String sourceDir = name.replace( '\\', '/' );
+
+ File f = new File( dir, sourceDir );
+
+ PlexusIoResourceAttributes attrs = (PlexusIoResourceAttributes) attributesByPath.get( name.length() > 0 ? name : "." );
+ if ( attrs == null )
+ {
+ attrs = (PlexusIoResourceAttributes) attributesByPath.get( f.getAbsolutePath() );
+ }
+
+ if ( f.isDirectory() )
+ {
+ attrs = PlexusIoResourceAttributeUtils.mergeAttributes( overrideDirAttributes, attrs, defaultDirAttributes );
+ }
+ else
+ {
+ attrs = PlexusIoResourceAttributeUtils.mergeAttributes( overrideFileAttributes, attrs, defaultFileAttributes );
+ }
+
+ PlexusIoFileResource resource = new PlexusIoFileResource( f, name, attrs );
+ if ( isSelected( resource ) )
+ {
+ list.add( resource );
+ }
+ }
+ }
+
+ public Iterator getResources() throws IOException
+ {
+ final DirectoryScanner ds = new DirectoryScanner();
+ final File dir = getBaseDir();
+ ds.setBasedir( dir );
+ final String[] inc = getIncludes();
+ if ( inc != null && inc.length > 0 )
+ {
+ ds.setIncludes( inc );
+ }
+ final String[] exc = getExcludes();
+ if ( exc != null && exc.length > 0 )
+ {
+ ds.setExcludes( exc );
+ }
+ if ( isUsingDefaultExcludes() )
+ {
+ ds.addDefaultExcludes();
+ }
+ ds.setCaseSensitive( isCaseSensitive() );
+ ds.setFollowSymlinks( isFollowingSymLinks() );
+ ds.scan();
+
+ Map attributesByPath = PlexusIoResourceAttributeUtils.getFileAttributesByPath( getBaseDir() );
+
+ final List result = new ArrayList();
+ if ( isIncludingEmptyDirectories() )
+ {
+ String[] dirs = ds.getIncludedDirectories();
+ addResources( result, dirs, attributesByPath );
+ }
+
+ String[] files = ds.getIncludedFiles();
+ addResources( result, files, attributesByPath );
+ return result.iterator();
+ }
+}
\ No newline at end of file