You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/05/10 01:51:08 UTC
cvs commit: avalon/composition/impl/src/java/org/apache/avalon/composition/util StringHelper.java
mcconnell 2004/05/09 16:51:08
Modified: composition/impl/src/java/org/apache/avalon/composition/model/impl
DefaultClassLoaderContext.java
DefaultClassLoaderModel.java
DefaultContainmentModel.java
DefaultModelFactory.java DefaultSystemContext.java
DirectoryScanner.java Scanner.java
composition/spi/src/java/org/apache/avalon/composition/provider
ClassLoaderContext.java SystemContext.java
merlin/impl/src/java/org/apache/avalon/merlin/impl
DefaultFactory.java
merlin/install merlin.nsi
versioning avalon-merlin.ent
Removed: composition/impl/src/java/org/apache/avalon/composition/util
StringHelper.java
Log:
Remove the nasty static utility class StringHelper and place equivalent functionality under the SystemContext.
Revision Changes Path
1.8 +29 -14 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderContext.java
Index: DefaultClassLoaderContext.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderContext.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultClassLoaderContext.java 17 Mar 2004 10:39:10 -0000 1.7
+++ DefaultClassLoaderContext.java 9 May 2004 23:51:08 -0000 1.8
@@ -24,6 +24,7 @@
import org.apache.avalon.composition.model.TypeRepository;
import org.apache.avalon.composition.model.ServiceRepository;
import org.apache.avalon.composition.provider.ClassLoaderContext;
+import org.apache.avalon.composition.provider.SystemContext;
import org.apache.avalon.repository.Repository;
@@ -109,6 +110,11 @@
*/
private final URL[] m_implied;
+ /**
+ * The system context.
+ */
+ private final SystemContext m_system;
+
//==============================================================
// constructor
//==============================================================
@@ -117,16 +123,17 @@
* Creation of a root classloader context.
*
* @param logger the logging channel to assign to the classloader model
+ * @param system the system context
* @param repository a local repository
* @param base the system base directory
* @param parent the parent classloader
* @param directive the classloader directive
*/
public DefaultClassLoaderContext(
- Logger logger, Repository repository, File base,
+ Logger logger, SystemContext system,
ClassLoader parent, ClassLoaderDirective directive )
{
- this( logger, repository, base, parent,
+ this( logger, system, parent,
new OptionalPackage[0], null, null, null, directive, null );
}
@@ -134,6 +141,7 @@
* Creation of a new classloader context.
*
* @param logger the logging channel to assign to the classloader model
+ * @param system the system context
* @param repository a local repository
* @param base the system base directory
* @param parent the parent classloader
@@ -146,7 +154,7 @@
* @param directive the classloader directive
*/
public DefaultClassLoaderContext(
- Logger logger, Repository repository, File base,
+ Logger logger, SystemContext system,
ClassLoader parent, OptionalPackage[] packages,
ExtensionManager manager, TypeRepository types,
ServiceRepository services,
@@ -157,14 +165,6 @@
{
throw new NullPointerException( "logger" );
}
- if( repository == null )
- {
- throw new NullPointerException( "repository" );
- }
- if( base == null )
- {
- throw new NullPointerException( "base" );
- }
if( parent == null )
{
throw new NullPointerException( "parent" );
@@ -177,16 +177,21 @@
{
throw new NullPointerException( "directive" );
}
+ if( system == null )
+ {
+ throw new NullPointerException( "system" );
+ }
m_logger = logger;
- m_repository = repository;
- m_base = base;
+ m_repository = system.getRepository();
+ m_base = system.getAnchorDirectory();
m_parent = parent;
m_packages = packages;
m_manager = manager;
m_types = types;
m_services = services;
m_directive = directive;
+ m_system = system;
if( implied == null )
{
@@ -293,6 +298,16 @@
public ClassLoaderDirective getClassLoaderDirective()
{
return m_directive;
+ }
+
+ /**
+ * Return the system context.
+ *
+ * @return the system context
+ */
+ public SystemContext getSystemContext()
+ {
+ return m_system;
}
/**
1.20 +14 -10 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java
Index: DefaultClassLoaderModel.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DefaultClassLoaderModel.java 1 May 2004 17:03:43 -0000 1.19
+++ DefaultClassLoaderModel.java 9 May 2004 23:51:08 -0000 1.20
@@ -45,7 +45,7 @@
import org.apache.avalon.composition.model.ServiceRepository;
import org.apache.avalon.composition.model.ModelException;
import org.apache.avalon.composition.provider.ClassLoaderContext;
-import org.apache.avalon.composition.util.StringHelper;
+import org.apache.avalon.composition.provider.SystemContext;
import org.apache.avalon.extension.Extension;
import org.apache.avalon.extension.manager.ExtensionManager;
@@ -152,7 +152,7 @@
{
getLocalLogger().debug(
"base: " +
- StringHelper.toString( context.getBaseDirectory() ) );
+ context.getSystemContext().toString( context.getBaseDirectory() ) );
}
File base =
context.getBaseDirectory();
@@ -186,7 +186,7 @@
if( getLocalLogger().isDebugEnabled() )
{
String str = "classpath: "
- + StringHelper.toString( m_classpath );
+ + context.getSystemContext().toString( m_classpath );
getLocalLogger().debug( str );
}
@@ -204,7 +204,8 @@
ArrayList types = new ArrayList();
ArrayList services = new ArrayList();
Logger scannerLogger = getLocalLogger().getChildLogger( "scanner" );
- Scanner scanner = new Scanner( scannerLogger, m_classLoader );
+ SystemContext system = context.getSystemContext();
+ Scanner scanner = new Scanner( scannerLogger, system, m_classLoader );
scanner.scan( m_urls, types, services );
//
@@ -368,13 +369,14 @@
Logger logger, ContainmentProfile profile, URL[] implied )
{
Repository repository = m_context.getRepository();
+ SystemContext system = m_context.getSystemContext();
File base = m_context.getBaseDirectory();
OptionalPackage[] packages = getOptionalPackages();
ClassLoaderDirective directive =
profile.getClassLoaderDirective();
return new DefaultClassLoaderContext(
- logger, repository, base, m_classLoader, packages,
+ logger, system, m_classLoader, packages,
m_extension, m_types, m_services, directive, implied );
}
@@ -416,7 +418,7 @@
{
if( getLogger().isDebugEnabled() )
{
- getLogger().debug( "implicit entries: " + implicit.length );
+ getLocalLogger().debug( "implicit entries: " + implicit.length );
}
for( int i=0; i<implicit.length; i++ )
@@ -432,7 +434,7 @@
if( files.length > 0 )
{
- if( getLogger().isDebugEnabled() )
+ if( getLocalLogger().isDebugEnabled() )
{
getLogger().debug( "included entries: " + files.length );
}
@@ -488,7 +490,8 @@
final Extension[] available = Extension.getAvailable( manifests );
final Extension[] required = Extension.getRequired( manifests );
- m_manager.scanDependencies( required, available, dependencies, unsatisfied );
+ m_manager.scanDependencies(
+ required, available, dependencies, unsatisfied );
if( 0 != unsatisfied.size() )
{
final int size = unsatisfied.size();
@@ -616,7 +619,8 @@
public File[] expandFileSetDirectives (
File base, FilesetDirective[] filesets ) throws IOException, IllegalStateException
{
- getLocalLogger().debug("base=[" + base + "]");
+ //getLocalLogger().debug("base=[" + base + "]");
+
ArrayList list = new ArrayList();
for( int i=0; i<filesets.length; i++ )
1.45 +4 -3 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- DefaultContainmentModel.java 1 May 2004 17:03:43 -0000 1.44
+++ DefaultContainmentModel.java 9 May 2004 23:51:08 -0000 1.45
@@ -56,7 +56,7 @@
import org.apache.avalon.composition.provider.SecurityModel;
import org.apache.avalon.composition.provider.ComponentContext;
import org.apache.avalon.composition.provider.ContainmentContext;
-import org.apache.avalon.composition.util.StringHelper;
+import org.apache.avalon.composition.provider.SystemContext;
import org.apache.avalon.composition.util.DefaultState;
import org.apache.avalon.logging.provider.LoggingManager;
@@ -949,8 +949,9 @@
if( getLogger().isDebugEnabled() )
{
+ SystemContext system = m_context.getSystemContext();
final String message =
- StringHelper.toString( REZ.getString( "containment.add", name ) );
+ REZ.getString( "containment.add", system.toString( name ) );
getLogger().debug( message );
}
1.16 +2 -5 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java
Index: DefaultModelFactory.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DefaultModelFactory.java 1 Apr 2004 04:06:52 -0000 1.15
+++ DefaultModelFactory.java 9 May 2004 23:51:08 -0000 1.16
@@ -356,16 +356,13 @@
try
{
- Repository repository = m_system.getRepository();
- File base = m_system.getAnchorDirectory();
-
ClassLoader root = m_system.getAPIClassLoader();
ClassLoaderDirective classLoaderDirective =
profile.getClassLoaderDirective();
ClassLoaderContext classLoaderContext =
new DefaultClassLoaderContext(
- logger, repository, base, root,
+ logger, m_system, root,
classLoaderDirective );
ClassLoaderModel classLoaderModel =
1.32 +79 -1 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java
Index: DefaultSystemContext.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultSystemContext.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- DefaultSystemContext.java 4 Apr 2004 23:33:56 -0000 1.31
+++ DefaultSystemContext.java 9 May 2004 23:51:08 -0000 1.32
@@ -406,9 +406,87 @@
getRuntime().release( model, instance );
}
+ /**
+ * Prepare a string representation of an object for presentation.
+ * @param object the object to parse
+ * @return the presentation string
+ */
+ public String toString( Object object )
+ {
+ if( object == null ) return "";
+
+ if( object instanceof String )
+ {
+ return processString( (String) object );
+ }
+ else
+ {
+ return processString( object.toString() );
+ }
+ }
+
+ /**
+ * Prepare a string representation of an object for presentation.
+ * @param name the value to parse
+ * @return the presentation string
+ */
+ public String processString( String name )
+ {
+ if( name == null ) return "";
+
+ String str = name.replace( '\\', '/' );
+
+ String base = getBaseDirectory().toString().replace( '\\', '/' );
+ if( str.indexOf( base ) > -1 )
+ {
+ return getString( str, base, "${merlin.dir}" );
+ }
+
+ final String dir =
+ System.getProperty( "user.dir" ).replace( '\\', '/' );
+ if( str.indexOf( dir ) > -1 )
+ {
+ return getString( str, dir, "${user.dir}" );
+ }
+
+ return name;
+ }
+
+ /**
+ * Prepare a string representation of an object array for presentation.
+ * @param objects the array of objects
+ * @return the presentation string
+ */
+ public String toString( Object[] objects )
+ {
+ StringBuffer buffer = new StringBuffer();
+ for( int i=0; i<objects.length; i++ )
+ {
+ if( i > 0 ) buffer.append( ";" );
+ buffer.append( toString( objects[i] ) );
+ }
+ return buffer.toString();
+ }
+
//------------------------------------------------------------------
// runtime operations
//------------------------------------------------------------------
+
+ private String getString( String name, String pattern, String replacement )
+ {
+ final int n = name.indexOf( pattern );
+ if( n == -1 ) return name;
+ if( name.startsWith( pattern ) )
+ {
+ return replacement + name.substring( pattern.length() );
+ }
+ else
+ {
+ String header = name.substring( 0, n );
+ String tail = name.substring( n + pattern.length() );
+ return header + replacement + tail;
+ }
+ }
/**
* Return the runtime factory.
1.7 +353 -171 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DirectoryScanner.java
Index: DirectoryScanner.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/DirectoryScanner.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DirectoryScanner.java 30 Apr 2004 14:05:59 -0000 1.6
+++ DirectoryScanner.java 9 May 2004 23:51:08 -0000 1.7
@@ -231,7 +231,8 @@
* @return <code>true</code> if the pattern matches against the string,
* or <code>false</code> otherwise.
*/
- protected static boolean matchPath(String pattern, String str) {
+ protected static boolean matchPath(String pattern, String str)
+ {
return ScannerUtils.matchPath(pattern, str);
}
@@ -249,7 +250,8 @@
* or <code>false</code> otherwise.
*/
protected static boolean matchPath(String pattern, String str,
- boolean isCaseSensitive) {
+ boolean isCaseSensitive)
+ {
return ScannerUtils.matchPath(pattern, str, isCaseSensitive);
}
@@ -267,7 +269,8 @@
* @return <code>true</code> if the string matches against the pattern,
* or <code>false</code> otherwise.
*/
- public static boolean match(String pattern, String str) {
+ public static boolean match(String pattern, String str)
+ {
return ScannerUtils.match(pattern, str);
}
@@ -289,7 +292,8 @@
* or <code>false</code> otherwise.
*/
protected static boolean match(String pattern, String str,
- boolean isCaseSensitive) {
+ boolean isCaseSensitive)
+ {
return ScannerUtils.match(pattern, str, isCaseSensitive);
}
@@ -300,7 +304,8 @@
* contents of the <code>defaultExcludes</code>
* <code>Vector</code>.
*/
- public static String[] getDefaultExcludes() {
+ public static String[] getDefaultExcludes()
+ {
return (String[]) defaultExcludes.toArray(new String[defaultExcludes
.size()]);
}
@@ -314,8 +319,10 @@
* <code>false</code> if it already
* existed.
*/
- public static boolean addDefaultExclude(String s) {
- if (defaultExcludes.indexOf(s) == -1) {
+ public static boolean addDefaultExclude(String s)
+ {
+ if (defaultExcludes.indexOf(s) == -1)
+ {
defaultExcludes.add(s);
return true;
}
@@ -331,17 +338,20 @@
* <code>false</code> if <code>s</code> was not
* in the default excludes list to begin with
*/
- public static boolean removeDefaultExclude(String s) {
+ public static boolean removeDefaultExclude(String s)
+ {
return defaultExcludes.remove(s);
}
/**
* Go back to the hard wired default exclude patterns
*/
- public static void resetDefaultExcludes() {
+ public static void resetDefaultExcludes()
+ {
defaultExcludes = new Vector();
- for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
+ for (int i = 0; i < DEFAULTEXCLUDES.length; i++)
+ {
defaultExcludes.add(DEFAULTEXCLUDES[i]);
}
}
@@ -355,7 +365,8 @@
* @param basedir The base directory to scan.
* Must not be <code>null</code>.
*/
- public void setBasedir(String basedir) {
+ public void setBasedir(String basedir)
+ {
setBasedir(new File(basedir.replace('/', File.separatorChar).replace(
'\\', File.separatorChar)));
}
@@ -367,7 +378,8 @@
* @param basedir The base directory for scanning.
* Should not be <code>null</code>.
*/
- public void setBasedir(File basedir) {
+ public void setBasedir(File basedir)
+ {
this.basedir = basedir;
}
@@ -377,7 +389,8 @@
*
* @return the base directory to be scanned
*/
- public File getBasedir() {
+ public File getBasedir()
+ {
return basedir;
}
@@ -387,7 +400,8 @@
* @return whether or not the scanning is case sensitive
* @since ant 1.6
*/
- public boolean isCaseSensitive() {
+ public boolean isCaseSensitive()
+ {
return isCaseSensitive;
}
/**
@@ -397,7 +411,8 @@
* @param isCaseSensitive whether or not the file system should be
* regarded as a case sensitive one
*/
- public void setCaseSensitive(boolean isCaseSensitive) {
+ public void setCaseSensitive(boolean isCaseSensitive)
+ {
this.isCaseSensitive = isCaseSensitive;
}
@@ -408,7 +423,8 @@
*
* @since ant 1.6
*/
- public boolean isFollowSymlinks() {
+ public boolean isFollowSymlinks()
+ {
return followSymlinks;
}
@@ -417,7 +433,8 @@
*
* @param followSymlinks whether or not symbolic links should be followed
*/
- public void setFollowSymlinks(boolean followSymlinks) {
+ public void setFollowSymlinks(boolean followSymlinks)
+ {
this.followSymlinks = followSymlinks;
}
@@ -434,16 +451,22 @@
* list is given, all elements must be
* non-<code>null</code>.
*/
- public void setIncludes(String[] includes) {
- if (includes == null) {
+ public void setIncludes(String[] includes)
+ {
+ if (includes == null)
+ {
this.includes = null;
- } else {
+ }
+ else
+ {
this.includes = new String[includes.length];
- for (int i = 0; i < includes.length; i++) {
+ for (int i = 0; i < includes.length; i++)
+ {
String pattern;
pattern = includes[i].replace('/', File.separatorChar).replace(
'\\', File.separatorChar);
- if (pattern.endsWith(File.separator)) {
+ if (pattern.endsWith(File.separator))
+ {
pattern += "**";
}
this.includes[i] = pattern;
@@ -464,16 +487,22 @@
* 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) {
- if (excludes == null) {
+ public void setExcludes(String[] excludes)
+ {
+ if( excludes == null)
+ {
this.excludes = null;
- } else {
+ }
+ else
+ {
this.excludes = new String[excludes.length];
- for (int i = 0; i < excludes.length; i++) {
+ for (int i = 0; i < excludes.length; i++)
+ {
String pattern;
pattern = excludes[i].replace('/', File.separatorChar).replace(
'\\', File.separatorChar);
- if (pattern.endsWith(File.separator)) {
+ if (pattern.endsWith(File.separator))
+ {
pattern += "**";
}
this.excludes[i] = pattern;
@@ -486,7 +515,8 @@
*
* @param selectors specifies the selectors to be invoked on a scan
*/
- public void setSelectors(FileSelector[] selectors) {
+ public void setSelectors(FileSelector[] selectors)
+ {
this.selectors = selectors;
}
@@ -498,7 +528,8 @@
* @return <code>true</code> if all files and directories which have
* been found so far have been included.
*/
- public boolean isEverythingIncluded() {
+ public boolean isEverythingIncluded()
+ {
return everythingIncluded;
}
@@ -511,30 +542,37 @@
* incorrectly (i.e. if it is <code>null</code>, doesn't exist,
* or isn't a directory).
*/
- public void scan() throws IllegalStateException, IOException {
- if (basedir == null) {
+ public void scan() throws IllegalStateException, IOException
+ {
+ if (basedir == null)
+ {
throw new IllegalStateException("No basedir set");
}
- if (!basedir.exists()) {
+ if (!basedir.exists())
+ {
System.out.println("basedir=[" + basedir + "]");
throw new IllegalStateException("basedir " + basedir
+ " does not exist");
}
- if (!basedir.isDirectory()) {
+ if (!basedir.isDirectory())
+ {
throw new IllegalStateException("basedir " + basedir
+ " is not a directory");
}
- if (includes == null) {
+ if (includes == null)
+ {
// No includes supplied, so set it to 'matches all'
includes = new String[1];
includes[0] = "*.jar";
}
- if (excludes == null) {
+ if (excludes == null)
+ {
excludes = new String[0];
}
- if (selectors == null) {
+ if (selectors == null)
+ {
selectors = new FileSelector[1];
selectors[0] = new DefaultFileSelector();
}
@@ -548,17 +586,26 @@
dirsExcluded = new Vector();
dirsDeselected = new Vector();
- if (isIncluded("")) {
- if (!isExcluded("")) {
- if (isSelected("", basedir)) {
+ if (isIncluded(""))
+ {
+ if (!isExcluded(""))
+ {
+ if (isSelected("", basedir))
+ {
dirsIncluded.addElement("");
- } else {
+ }
+ else
+ {
dirsDeselected.addElement("");
}
- } else {
+ }
+ else
+ {
dirsExcluded.addElement("");
}
- } else {
+ }
+ else
+ {
dirsNotIncluded.addElement("");
}
checkIncludePatterns();
@@ -570,23 +617,31 @@
* this routine is actually checking all the include patterns in
* order to avoid scanning everything under base dir
*/
- private void checkIncludePatterns() throws IOException {
+ private void checkIncludePatterns() throws IOException
+ {
Hashtable newroots = new Hashtable();
// put in the newroots vector the include patterns without
// wildcard tokens
- for (int icounter = 0; icounter < includes.length; icounter++) {
+
+ for( int icounter = 0; icounter < includes.length; icounter++ )
+ {
String newpattern =
ScannerUtils.rtrimWildcardTokens(includes[icounter]);
newroots.put(newpattern, includes[icounter]);
- getLogger().debug("newpattern=[" + newpattern + "]; " +
- "includes[" + icounter + "]=[" + includes[icounter] + "]");
+ getLogger().debug(
+ "newpattern=[" + newpattern + "]; "
+ + "includes[" + icounter + "]=["
+ + includes[icounter] + "]" );
}
- if (newroots.containsKey("")) {
+ if (newroots.containsKey(""))
+ {
// we are going to scan everything anyway
scandir(basedir, "", true);
- } else {
+ }
+ else
+ {
// only scan directories that can include matched files or
// directories
Enumeration enum2 = newroots.keys();
@@ -595,7 +650,8 @@
canonBase = basedir.getCanonicalFile();
getLogger().debug("canonBase=[" + canonBase + "]");
- while (enum2.hasMoreElements()) {
+ while (enum2.hasMoreElements())
+ {
String currentelement = (String) enum2.nextElement();
getLogger().debug("currentelement=[" + currentelement + "]");
String originalpattern = (String) newroots.get(currentelement);
@@ -603,68 +659,93 @@
File myfile = new File(basedir, currentelement);
getLogger().debug("myfile=[" + myfile.getAbsolutePath() + "]");
- if (myfile.exists()) {
+ if (myfile.exists())
+ {
// may be on a case insensitive file system. We want
// the results to show what's really on the disk, so
// we need to double check.
File canonFile = myfile.getCanonicalFile();
String path = fileUtils.removeLeadingPath(canonBase,
canonFile);
- if (!path.equals(currentelement) || ON_VMS) {
+ if (!path.equals(currentelement) || ON_VMS)
+ {
myfile = findFile(basedir, currentelement);
- if (myfile != null) {
+ if( null != myfile )
+ {
currentelement =
- fileUtils.removeLeadingPath(basedir,
- myfile);
+ fileUtils.removeLeadingPath(
+ basedir, myfile );
}
}
}
- if ((myfile == null || !myfile.exists()) && !isCaseSensitive) {
+ if( ( myfile == null || !myfile.exists() ) && !isCaseSensitive )
+ {
File f = findFileCaseInsensitive(basedir, currentelement);
- if (f.exists()) {
+ if (f.exists())
+ {
// adapt currentelement to the case we've
// actually found
- currentelement = fileUtils.removeLeadingPath(basedir,
- f);
+ currentelement =
+ fileUtils.removeLeadingPath(
+ basedir, f );
myfile = f;
}
}
- if (myfile != null && myfile.exists()) {
+ if( myfile != null && myfile.exists() )
+ {
if (!followSymlinks
- && isSymlink(basedir, currentelement)) {
+ && isSymlink(basedir, currentelement))
+ {
continue;
}
- if (myfile.isDirectory()) {
+ if (myfile.isDirectory())
+ {
getLogger().debug("file is a directory!");
- if (isIncluded(currentelement)
- && currentelement.length() > 0) {
- getLogger().debug("calling accounForIncludedDir(" +
- currentelement + "," + myfile.getAbsolutePath() + ")");
- accountForIncludedDir(currentelement, myfile, true);
- } else {
- if (currentelement.length() > 0) {
- if (currentelement.charAt(currentelement
- .length() - 1)
- != File.separatorChar) {
+ if( isIncluded(currentelement)
+ && currentelement.length() > 0)
+ {
+ getLogger().debug(
+ "calling accounForIncludedDir("
+ + currentelement + ","
+ + myfile.getAbsolutePath()
+ + ")" );
+ accountForIncludedDir( currentelement, myfile, true );
+ }
+ else
+ {
+ if (currentelement.length() > 0)
+ {
+ if(
+ currentelement.charAt(
+ currentelement.length() - 1)
+ != File.separatorChar )
+ {
currentelement =
- currentelement + File.separatorChar;
+ currentelement + File.separatorChar;
}
}
- getLogger().debug("calling scandir(" +
- myfile.getAbsolutePath() + "," +
- currentelement + ")");
- scandir(myfile, currentelement, true);
+ getLogger().debug(
+ "calling scandir("
+ + myfile.getAbsolutePath()
+ + ","
+ + currentelement
+ + ")" );
+ scandir( myfile, currentelement, true );
}
- } else {
- if (isCaseSensitive
- && originalpattern.equals(currentelement)) {
+ }
+ else
+ {
+ if( isCaseSensitive
+ && originalpattern.equals(currentelement) )
+ {
accountForIncludedFile(currentelement, myfile);
- } else if (!isCaseSensitive
- && originalpattern
- .equalsIgnoreCase(currentelement)) {
+ }
+ else if( !isCaseSensitive
+ && originalpattern.equalsIgnoreCase(currentelement) )
+ {
accountForIncludedFile(currentelement, myfile);
}
}
@@ -697,21 +778,28 @@
{
getLogger().debug("Inside scandir");
- if (dir == null) {
+ if (dir == null)
+ {
throw new IOException("dir must not be null.");
- } else if (!dir.exists()) {
+ }
+ else if (!dir.exists())
+ {
throw new IOException(dir + " doesn't exists.");
- } else if (!dir.isDirectory()) {
+ }
+ else if (!dir.isDirectory())
+ {
throw new IOException(dir + " is not a directory.");
}
// avoid double scanning of directories, can only happen in fast mode
- if (fast && hasBeenScanned(vpath)) {
+ if (fast && hasBeenScanned(vpath))
+ {
return;
}
String[] newfiles = dir.list();
- if (newfiles == null) {
+ if (newfiles == null)
+ {
/*
* two reasons are mentioned in the API docs for File.list
* (1) dir is not a directory. This is impossible as
@@ -719,26 +807,38 @@
* (2) an IO error occurred (why doesn't it throw an exception
* then???)
*/
- throw new IOException("IO error scanning directory "
- + dir.getAbsolutePath());
+ throw new IOException(
+ "IO error scanning directory "
+ + dir.getAbsolutePath());
}
- if (!followSymlinks) {
+ if (!followSymlinks)
+ {
Vector noLinks = new Vector();
- for (int i = 0; i < newfiles.length; i++) {
- try {
- if (fileUtils.isSymbolicLink(dir, newfiles[i])) {
+ for (int i = 0; i < newfiles.length; i++)
+ {
+ try
+ {
+ if (fileUtils.isSymbolicLink(dir, newfiles[i]))
+ {
String name = vpath + newfiles[i];
File file = new File(dir, newfiles[i]);
- if (file.isDirectory()) {
+ if (file.isDirectory())
+ {
dirsExcluded.addElement(name);
- } else {
+ }
+ else
+ {
filesExcluded.addElement(name);
}
- } else {
+ }
+ else
+ {
noLinks.addElement(newfiles[i]);
}
- } catch (IOException ioe) {
+ }
+ catch (IOException ioe)
+ {
String msg = "IOException caught while checking "
+ "for links, couldn't get canonical path!";
// will be caught and redirected to Ant's logging system
@@ -750,32 +850,44 @@
noLinks.copyInto(newfiles);
}
- for (int i = 0; i < newfiles.length; i++) {
+ for (int i = 0; i < newfiles.length; i++)
+ {
String name = vpath + newfiles[i];
File file = new File(dir, newfiles[i]);
getLogger().debug("file=[" + file.getAbsolutePath() + "]");
- if (file.isDirectory()) {
+ if (file.isDirectory())
+ {
getLogger().debug("this is a directory.");
- if (isIncluded(name)) {
+ if (isIncluded(name))
+ {
getLogger().debug("and it will be included");
accountForIncludedDir(name, file, fast);
- } else {
+ }
+ else
+ {
getLogger().debug("and it will not be included");
everythingIncluded = false;
dirsNotIncluded.addElement(name);
- if (fast && couldHoldIncluded(name)) {
+ if (fast && couldHoldIncluded(name))
+ {
scandir(file, name + File.separator, fast);
}
}
- if (!fast) {
+ if (!fast)
+ {
scandir(file, name + File.separator, fast);
}
- } else if (file.isFile()) {
+ }
+ else if (file.isFile())
+ {
getLogger().debug("this is a file");
- if (isIncluded(name)) {
+ if (isIncluded(name))
+ {
getLogger().debug("and it will be included");
accountForIncludedFile(name, file);
- } else {
+ }
+ else
+ {
getLogger().debug("and it will not be included");
everythingIncluded = false;
filesNotIncluded.addElement(name);
@@ -789,19 +901,27 @@
* @param name path of the file relative to the directory of the fileset
* @param file included file
*/
- private void accountForIncludedFile(String name, File file) {
+ private void accountForIncludedFile(String name, File file)
+ {
if (!filesIncluded.contains(name)
&& !filesExcluded.contains(name)
- && !filesDeselected.contains(name)) {
+ && !filesDeselected.contains(name))
+ {
- if (!isExcluded(name)) {
- if (isSelected(name, file)) {
+ if (!isExcluded(name))
+ {
+ if (isSelected(name, file))
+ {
filesIncluded.addElement(name);
- } else {
+ }
+ else
+ {
everythingIncluded = false;
filesDeselected.addElement(name);
}
- } else {
+ }
+ else
+ {
everythingIncluded = false;
filesExcluded.addElement(name);
}
@@ -822,35 +942,45 @@
if (!dirsIncluded.contains(name)
&& !dirsExcluded.contains(name)
- && !dirsDeselected.contains(name)) {
+ && !dirsDeselected.contains(name))
+ {
getLogger().debug("waypoint-1");
- if (!isExcluded(name)) {
+ if (!isExcluded(name))
+ {
getLogger().debug("waypoint-2a");
- if (isSelected(name, file)) {
+ if (isSelected(name, file))
+ {
getLogger().debug("waypoint-3a");
dirsIncluded.addElement(name);
- if (fast) {
+ if (fast)
+ {
getLogger().debug("calling scandir(" +
file.getAbsolutePath() + "," +
name + File.separator);
scandir(file, name + File.separator, fast);
}
- } else {
+ }
+ else
+ {
getLogger().debug("waypoint-3b");
everythingIncluded = false;
dirsDeselected.addElement(name);
- if (fast && couldHoldIncluded(name)) {
+ if (fast && couldHoldIncluded(name))
+ {
getLogger().debug("waypoint-4b");
scandir(file, name + File.separator, fast);
}
}
- } else {
+ }
+ else
+ {
getLogger().debug("waypoint-2b");
everythingIncluded = false;
dirsExcluded.addElement(name);
- if (fast && couldHoldIncluded(name)) {
+ if (fast && couldHoldIncluded(name))
+ {
getLogger().debug("waypoint-3c");
scandir(file, name + File.separator, fast);
}
@@ -866,9 +996,12 @@
* @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 < includes.length; i++) {
- if (matchPath(includes[i], name, isCaseSensitive)) {
+ protected boolean isIncluded(String name)
+ {
+ for (int i = 0; i < includes.length; i++)
+ {
+ if (matchPath(includes[i], name, isCaseSensitive))
+ {
return true;
}
}
@@ -883,10 +1016,14 @@
* @return <code>true</code> when the name matches against the start of at
* least one include pattern, or <code>false</code> otherwise.
*/
- protected boolean couldHoldIncluded(String name) {
- for (int i = 0; i < includes.length; i++) {
- if (matchPatternStart(includes[i], name, isCaseSensitive)) {
- if (isMorePowerfulThanExcludes(name, includes[i])) {
+ protected boolean couldHoldIncluded(String name)
+ {
+ for (int i = 0; i < includes.length; i++)
+ {
+ if (matchPatternStart(includes[i], name, isCaseSensitive))
+ {
+ if (isMorePowerfulThanExcludes(name, includes[i]))
+ {
return true;
}
}
@@ -909,10 +1046,13 @@
* @param includepattern one include pattern
* @return true if there is no exclude pattern more powerful than this include pattern
*/
- private boolean isMorePowerfulThanExcludes(String name, String includepattern) {
+ private boolean isMorePowerfulThanExcludes(String name, String includepattern)
+ {
String soughtexclude = name + File.separator + "**";
- for (int counter = 0; counter < excludes.length; counter++) {
- if (excludes[counter].equals(soughtexclude)) {
+ for (int counter = 0; counter < excludes.length; counter++)
+ {
+ if (excludes[counter].equals(soughtexclude))
+ {
return false;
}
}
@@ -927,8 +1067,10 @@
* @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 < excludes.length; i++) {
+ protected boolean isExcluded(String name)
+ {
+ for (int i = 0; i < excludes.length; i++)
+ {
if (matchPath(excludes[i], name, isCaseSensitive)) {
return true;
}
@@ -944,10 +1086,14 @@
* @return <code>false</code> when the selectors says that the file
* should not be selected, <code>true</code> otherwise.
*/
- protected boolean isSelected(String name, File file) {
- if (selectors != null) {
- for (int i = 0; i < selectors.length; i++) {
- if (!selectors[i].isSelected(basedir, name, file)) {
+ protected boolean isSelected(String name, File file)
+ {
+ if (selectors != null)
+ {
+ for (int i = 0; i < selectors.length; i++)
+ {
+ if (!selectors[i].isSelected(basedir, name, file))
+ {
return false;
}
}
@@ -963,7 +1109,8 @@
* @return the names of the files which matched at least one of the
* include patterns and none of the exclude patterns.
*/
- public String[] getIncludedFiles() {
+ public String[] getIncludedFiles()
+ {
String[] files = new String[filesIncluded.size()];
filesIncluded.copyInto(files);
Arrays.sort(files);
@@ -981,7 +1128,8 @@
*
* @since Ant 1.6
*/
- private String[] list(File file) {
+ private String[] list(File file)
+ {
String[] files = (String[]) fileListMap.get(file);
if (files == null) {
files = file.list();
@@ -1006,8 +1154,8 @@
private File findFileCaseInsensitive(File base, String path)
throws IOException
{
- File f = findFileCaseInsensitive(base,
- ScannerUtils.tokenizePath(path));
+ File f = findFileCaseInsensitive(
+ base, ScannerUtils.tokenizePath(path));
return f == null ? new File(base, path) : f;
}
@@ -1023,26 +1171,35 @@
private File findFileCaseInsensitive(File base, Vector pathElements)
throws IOException
{
- if (pathElements.size() == 0) {
+ if (pathElements.size() == 0)
+ {
return base;
- } else {
- if (!base.isDirectory()) {
+ }
+ else
+ {
+ if (!base.isDirectory())
+ {
return null;
}
String[] files = list(base);
- if (files == null) {
+ if (files == null)
+ {
throw new IOException("IO error scanning directory "
+ base.getAbsolutePath());
}
String current = (String) pathElements.remove(0);
- for (int i = 0; i < files.length; i++) {
- if (files[i].equals(current)) {
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].equals(current))
+ {
base = new File(base, files[i]);
return findFileCaseInsensitive(base, pathElements);
}
}
- for (int i = 0; i < files.length; i++) {
- if (files[i].equalsIgnoreCase(current)) {
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].equalsIgnoreCase(current))
+ {
base = new File(base, files[i]);
return findFileCaseInsensitive(base, pathElements);
}
@@ -1059,7 +1216,8 @@
*
* @since Ant 1.6
*/
- private File findFile(File base, String path) throws IOException {
+ private File findFile(File base, String path) throws IOException
+ {
return findFile(base, ScannerUtils.tokenizePath(path));
}
@@ -1071,21 +1229,29 @@
*
* @since Ant 1.6
*/
- private File findFile(File base, Vector pathElements) throws IOException {
- if (pathElements.size() == 0) {
+ private File findFile(File base, Vector pathElements) throws IOException
+ {
+ if (pathElements.size() == 0)
+ {
return base;
- } else {
- if (!base.isDirectory()) {
+ }
+ else
+ {
+ if (!base.isDirectory())
+ {
return null;
}
String[] files = list(base);
- if (files == null) {
+ if (files == null)
+ {
throw new IOException("IO error scanning directory "
+ base.getAbsolutePath());
}
String current = (String) pathElements.remove(0);
- for (int i = 0; i < files.length; i++) {
- if (files[i].equals(current)) {
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].equals(current))
+ {
base = new File(base, files[i]);
return findFile(base, pathElements);
}
@@ -1099,7 +1265,8 @@
* basedir?
* @since Ant 1.6
*/
- private boolean isSymlink(File base, String path) {
+ private boolean isSymlink(File base, String path)
+ {
return isSymlink(base, ScannerUtils.tokenizePath(path));
}
@@ -1108,17 +1275,25 @@
* basedir?
* @since Ant 1.6
*/
- private boolean isSymlink(File base, Vector pathElements) {
- if (pathElements.size() > 0) {
+ private boolean isSymlink(File base, Vector pathElements)
+ {
+ if (pathElements.size() > 0)
+ {
String current = (String) pathElements.remove(0);
- try {
- if (fileUtils.isSymbolicLink(base, current)) {
+ try
+ {
+ if (fileUtils.isSymbolicLink(base, current))
+ {
return true;
- } else {
+ }
+ else
+ {
base = new File(base, current);
return isSymlink(base, pathElements);
}
- } catch (IOException ioe) {
+ }
+ catch (IOException ioe)
+ {
String msg = "IOException caught while checking "
+ "for links, couldn't get canonical path!";
// will be caught and redirected to Ant's logging system
@@ -1140,30 +1315,35 @@
*
* <p>Registers the given directory as scanned as a side effect.</p>
*/
- private boolean hasBeenScanned(String vpath) {
+ private boolean hasBeenScanned(String vpath)
+ {
return !scannedDirs.add(vpath);
}
/**
* Clear internal caches.
*/
- private void clearCaches() {
+ private void clearCaches()
+ {
fileListMap.clear();
scannedDirs.clear();
}
- public String toString() {
+ public String toString()
+ {
StringBuffer buffer = new StringBuffer();
buffer.append("{basedir=[" + basedir.getAbsolutePath() + "];");
buffer.append("isCaseSensitive=[" + isCaseSensitive + "];");
buffer.append("includes=(");
- for (int i = 0; i < includes.length; i++) {
+ for (int i = 0; i < includes.length; i++)
+ {
if (i != 0) buffer.append(",");
buffer.append(includes[i]);
}
buffer.append(");");
buffer.append("excludes=(");
- for (int i = 0; i < excludes.length; i++) {
+ for (int i = 0; i < excludes.length; i++)
+ {
if (i != 0) buffer.append(",");
buffer.append(excludes[i]);
}
@@ -1171,11 +1351,13 @@
return buffer.toString();
}
- public Logger getLogger() {
+ public Logger getLogger()
+ {
return m_logger;
}
- public void setLogger(Logger logger) {
+ public void setLogger(Logger logger)
+ {
m_logger = logger;
}
1.10 +17 -5 avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/Scanner.java
Index: Scanner.java
===================================================================
RCS file: /home/cvs/avalon/composition/impl/src/java/org/apache/avalon/composition/model/impl/Scanner.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Scanner.java 17 Mar 2004 10:39:10 -0000 1.9
+++ Scanner.java 9 May 2004 23:51:08 -0000 1.10
@@ -31,7 +31,7 @@
import org.apache.avalon.composition.model.ModelException;
import org.apache.avalon.composition.data.builder.ProfilePackageBuilder;
-import org.apache.avalon.composition.util.StringHelper;
+import org.apache.avalon.composition.provider.SystemContext;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
@@ -94,6 +94,11 @@
*/
private ClassLoader m_classloader;
+ /**
+ * System context.
+ */
+ private SystemContext m_system;
+
//===================================================================
// constructor
//===================================================================
@@ -106,13 +111,18 @@
* @param logger the logging channel
* @param classloader the classloader
*/
- public Scanner( Logger logger, ClassLoader classloader )
+ public Scanner( Logger logger, SystemContext system, ClassLoader classloader )
{
if( classloader == null )
{
throw new NullPointerException( "classloader" );
}
+ if( system == null )
+ {
+ throw new NullPointerException( "system" );
+ }
m_classloader = classloader;
+ m_system = system;
enableLogging( logger );
}
@@ -147,7 +157,7 @@
final String message =
REZ.getString(
"scanner.scanning",
- StringHelper.toString( url.toString() ) );
+ m_system.toString( url.toString() ) );
getLogger().debug( message );
}
@@ -195,7 +205,9 @@
if( !uri.toString().endsWith( "!/" ) )
{
final String error =
- REZ.getString( "scanner.nested-jar-unsupported.error", url.toString() );
+ REZ.getString(
+ "scanner.nested-jar-unsupported.error",
+ url.toString() );
throw new ModelException( error );
}
1.2 +7 -1 avalon/composition/spi/src/java/org/apache/avalon/composition/provider/ClassLoaderContext.java
Index: ClassLoaderContext.java
===================================================================
RCS file: /home/cvs/avalon/composition/spi/src/java/org/apache/avalon/composition/provider/ClassLoaderContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassLoaderContext.java 10 Feb 2004 16:23:35 -0000 1.1
+++ ClassLoaderContext.java 9 May 2004 23:51:08 -0000 1.2
@@ -116,4 +116,10 @@
*/
URL[] getImplicitURLs();
+ /**
+ * Return the system context.
+ *
+ * @return the system context
+ */
+ SystemContext getSystemContext();
}
1.8 +16 -1 avalon/composition/spi/src/java/org/apache/avalon/composition/provider/SystemContext.java
Index: SystemContext.java
===================================================================
RCS file: /home/cvs/avalon/composition/spi/src/java/org/apache/avalon/composition/provider/SystemContext.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SystemContext.java 4 Apr 2004 23:33:56 -0000 1.7
+++ SystemContext.java 9 May 2004 23:51:08 -0000 1.8
@@ -173,4 +173,19 @@
* @exception Exception if a deployment error occurs
*/
void release( DeploymentModel model, Object instance );
+
+ /**
+ * Prepare a string representation of an object for presentation.
+ * @param object the object to parse
+ * @return the presentation string
+ */
+ String toString( Object object );
+
+ /**
+ * Prepare a string representation of an object array for presentation.
+ * @param objects the array of objects
+ * @return the presentation string
+ */
+ String toString( Object[] objects );
+
}
1.43 +5 -6 avalon/merlin/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java
Index: DefaultFactory.java
===================================================================
RCS file: /home/cvs/avalon/merlin/impl/src/java/org/apache/avalon/merlin/impl/DefaultFactory.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- DefaultFactory.java 19 Apr 2004 10:50:42 -0000 1.42
+++ DefaultFactory.java 9 May 2004 23:51:08 -0000 1.43
@@ -39,7 +39,6 @@
import org.apache.avalon.composition.model.impl.DefaultSystemContextFactory;
import org.apache.avalon.composition.provider.SystemContext;
import org.apache.avalon.composition.provider.SystemContextFactory;
-import org.apache.avalon.composition.util.StringHelper;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.configuration.Configuration;
@@ -227,7 +226,7 @@
buffer.append( "\n" );
buffer.append( REZ.getString( "info.listing" ) );
buffer.append( LINE );
- createInfoListing( buffer, hosts, m_context, criteria );
+ createInfoListing( buffer, hosts, m_context, criteria, systemContext );
buffer.append( "\n" );
buffer.append( LINE );
getLogger().info( buffer.toString() );
@@ -268,7 +267,7 @@
{
getLogger().debug(
"installing: "
- + StringHelper.toString( url ) );
+ + systemContext.toString( url ) );
}
try
@@ -701,7 +700,7 @@
private void createInfoListing(
StringBuffer buffer, String[] hosts, InitialContext context,
- KernelCriteria criteria )
+ KernelCriteria criteria, SystemContext system )
{
buffer.append( "\n" );
buffer.append(
@@ -814,7 +813,7 @@
for( int i=0; i<hosts.length; i++ )
{
if( i>0 ) buffer.append( "," );
- buffer.append( StringHelper.toString( hosts[i] ) );
+ buffer.append( system.toString( hosts[i] ) );
}
buffer.append( "\n ${merlin.deployment} == " );
@@ -822,7 +821,7 @@
for( int i=0; i<urls.length; i++ )
{
if( i>0 ) buffer.append( "," );
- buffer.append( StringHelper.toString( urls[i] ) );
+ buffer.append( system.toString( urls[i] ) );
}
}
1.4 +1 -1 avalon/merlin/install/merlin.nsi
Index: merlin.nsi
===================================================================
RCS file: /home/cvs/avalon/merlin/install/merlin.nsi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- merlin.nsi 8 May 2004 23:04:46 -0000 1.3
+++ merlin.nsi 9 May 2004 23:51:08 -0000 1.4
@@ -26,7 +26,7 @@
;General
Name "Merlin Platform 3.3"
- OutFile "merlin-install-3.3.0-RC5.exe"
+ OutFile "merlin-install-3.3.0-RC6.exe"
;Folder selection page
InstallDir "C:\merlin"
1.12 +1 -1 avalon/versioning/avalon-merlin.ent
Index: avalon-merlin.ent
===================================================================
RCS file: /home/cvs/avalon/versioning/avalon-merlin.ent,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- avalon-merlin.ent 8 May 2004 18:24:18 -0000 1.11
+++ avalon-merlin.ent 9 May 2004 23:51:08 -0000 1.12
@@ -47,7 +47,7 @@
<!ENTITY merlin-id "merlin">
<!ENTITY merlin-spec "3.3">
-<!ENTITY merlin-product-version "3.3-RC5">
+<!ENTITY merlin-product-version "3.3-RC6">
<!ENTITY merlin-api-id "merlin-api">
<!ENTITY merlin-api-version "3.3.0">
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org