Return-Path: Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: (qmail 98317 invoked from network); 2 Jul 2010 10:19:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jul 2010 10:19:29 -0000 Received: (qmail 78052 invoked by uid 500); 2 Jul 2010 10:19:29 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 78002 invoked by uid 500); 2 Jul 2010 10:19:27 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 77995 invoked by uid 99); 2 Jul 2010 10:19:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jul 2010 10:19:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jul 2010 10:19:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3807723888E8; Fri, 2 Jul 2010 10:17:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r959936 - in /incubator/lcf/trunk/modules: connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/ connectors/sharepoint/connector/org/apache/lcf/crawler/connectors/sharepoint/ framework/core/org/apache/lcf/core/common/ fram... Date: Fri, 02 Jul 2010 10:17:58 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100702101759.3807723888E8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Fri Jul 2 10:17:58 2010 New Revision: 959936 URL: http://svn.apache.org/viewvc?rev=959936&view=rev Log: Pull 'working path' idea out of classloader and make it a global LCF concept, then base all path properties off of it. This makes it possible to have a completely relative properties.xml file, which will be handy later for canned installers. Modified: incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioAuthority.java incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioConnector.java incubator/lcf/trunk/modules/connectors/sharepoint/connector/org/apache/lcf/crawler/connectors/sharepoint/SharePointRepository.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockManager.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockObject.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockPool.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCF.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/Logging.java Modified: incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioAuthority.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioAuthority.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioAuthority.java (original) +++ incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioAuthority.java Fri Jul 2 10:17:58 2010 @@ -214,7 +214,7 @@ public class MeridioAuthority extends or * Now try and login to Meridio; the wrapper's constructor can be * used as it calls the Meridio login method *================================================================*/ - String meridioWSDDLocation = LCF.getProperty(wsddPathProperty); + File meridioWSDDLocation = LCF.getFileProperty(wsddPathProperty); if (meridioWSDDLocation == null) throw new LCFException("Meridio wsdd location path (property "+wsddPathProperty+") must be specified!"); @@ -223,7 +223,7 @@ public class MeridioAuthority extends or UserName, Password, InetAddress.getLocalHost().getHostName(), myFactory, - meridioWSDDLocation); + meridioWSDDLocation.toString()); } catch (UnknownHostException unknownHostException) { Modified: incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioConnector.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioConnector.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioConnector.java (original) +++ incubator/lcf/trunk/modules/connectors/meridio/connector/org/apache/lcf/crawler/connectors/meridio/MeridioConnector.java Fri Jul 2 10:17:58 2010 @@ -194,7 +194,7 @@ public class MeridioConnector extends or * Now try and login to Meridio; the wrapper's constructor can be * used as it calls the Meridio login method *================================================================*/ - String meridioWSDDLocation = LCF.getProperty(wsddPathProperty); + File meridioWSDDLocation = LCF.getFileProperty(wsddPathProperty); if (meridioWSDDLocation == null) throw new LCFException("Meridio wsdd location path (property "+wsddPathProperty+") must be specified!"); @@ -209,7 +209,7 @@ public class MeridioConnector extends or params.getObfuscatedParameter("Password"), InetAddress.getLocalHost().getHostName(), myFactory, - meridioWSDDLocation); + meridioWSDDLocation.toString()); } catch (UnknownHostException unknownHostException) { Modified: incubator/lcf/trunk/modules/connectors/sharepoint/connector/org/apache/lcf/crawler/connectors/sharepoint/SharePointRepository.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/sharepoint/connector/org/apache/lcf/crawler/connectors/sharepoint/SharePointRepository.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/connectors/sharepoint/connector/org/apache/lcf/crawler/connectors/sharepoint/SharePointRepository.java (original) +++ incubator/lcf/trunk/modules/connectors/sharepoint/connector/org/apache/lcf/crawler/connectors/sharepoint/SharePointRepository.java Fri Jul 2 10:17:58 2010 @@ -187,11 +187,11 @@ public class SharePointRepository extend fileBaseUrl = serverUrl + encodedServerLocation; - String sharepointWSDDLocation = LCF.getProperty(wsddPathProperty); + File sharepointWSDDLocation = LCF.getFileProperty(wsddPathProperty); if (sharepointWSDDLocation == null) throw new LCFException("SharePoint wsdd location path (property "+wsddPathProperty+") must be specified!"); - proxy = new SPSProxyHelper( serverUrl, encodedServerLocation, serverLocation, userName, password, myFactory, sharepointWSDDLocation, + proxy = new SPSProxyHelper( serverUrl, encodedServerLocation, serverLocation, userName, password, myFactory, sharepointWSDDLocation.toString(), connectionManager ); } } Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java Fri Jul 2 10:17:58 2010 @@ -31,8 +31,6 @@ public class LCFResourceLoader { public static final String _rcsid = "@(#)$Id$"; - /** The current 'working directory' */ - protected String instanceDir; /** The parent class loader */ protected ClassLoader parent; /** The class loader we're caching */ @@ -41,17 +39,16 @@ public class LCFResourceLoader protected ArrayList currentClasspath = new ArrayList(); /** Construct a resource manager. - *@param instanceDir is the current "working path" of the instance. *@param parent is the parent class loader. */ - public LCFResourceLoader(String instanceDir, ClassLoader parent) + public LCFResourceLoader(ClassLoader parent) throws LCFException { - this.instanceDir = makeLegalDir(instanceDir); this.parent = parent; } /** Set the classpath to a given list of libdirs. + *@param libdirList is an arraylist of File objects, each representing a directory. */ public synchronized void setClassPath(ArrayList libdirList) throws LCFException @@ -64,8 +61,8 @@ public class LCFResourceLoader int i = 0; while (i < libdirList.size()) { - String path = (String)libdirList.get(i++); - addToClassPath(path,null); + File dir = (File)libdirList.get(i++); + addToClassPath(dir,null); } } @@ -80,12 +77,11 @@ public class LCFResourceLoader } /** Add to the class-search path. - *@param path is the path to a jar or class root, relative to the "working path" of this loader. + *@param file is the jar or class root. */ - public synchronized void addToClassPath(String path) + public synchronized void addToClassPath(final File file) throws LCFException { - final File file = resolvePath(new File(instanceDir), path); if (file.canRead()) { addDirsToClassPath(new File[]{file.getParentFile()}, @@ -97,18 +93,17 @@ public class LCFResourceLoader } } ); } else - throw new LCFException("Path '"+path+"' does not exist or is not readable"); + throw new LCFException("Path '"+file.toString()+"' does not exist or is not readable"); } /** Add to the class-search path. *@param dir is the directory to add. *@param filter is the file filter to use on that directory. */ - public synchronized void addToClassPath(String dir, FileFilter filter) + public synchronized void addToClassPath(File dir, FileFilter filter) throws LCFException { - File base = resolvePath(new File(instanceDir), dir); - addDirsToClassPath(new File[]{base}, new FileFilter[]{filter}); + addDirsToClassPath(new File[]{dir}, new FileFilter[]{filter}); } /** Get the specified class using the proper classloader. @@ -186,21 +181,5 @@ public class LCFResourceLoader } } - - /** Ensures a path is always interpreted as a directory */ - protected static String makeLegalDir(String path) - { - return (path != null && (!(path.endsWith("/") || path.endsWith("\\"))))?path+File.separator: path; - } - - /** Resolve a path. - *@param base is the "working directory". - *@param path is the path, to be calculated relative to the base. - */ - protected static File resolvePath(File base,String path) - { - File r = new File(path); - return r.isAbsolute() ? r : new File(base, path); - } } \ No newline at end of file Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockManager.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockManager.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockManager.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockManager.java Fri Jul 2 10:17:58 2010 @@ -48,15 +48,15 @@ public class LockManager implements ILoc protected static LockPool mySections = new LockPool(); // This is the directory used for cross-JVM synchronization, or null if off - protected String synchDirectory = null; + protected File synchDirectory = null; public LockManager() throws LCFException { - synchDirectory = LCF.getProperty(synchDirectoryProperty); + synchDirectory = LCF.getFileProperty(synchDirectoryProperty); if (synchDirectory != null) { - if (!new File(synchDirectory).isDirectory()) + if (!synchDirectory.isDirectory()) throw new LCFException("Property "+synchDirectoryProperty+" must point to an existing, writeable directory!",LCFException.SETUP_ERROR); } } @@ -1842,7 +1842,7 @@ public class LockManager implements ILoc int hashcode = key.hashCode(); int outerDirNumber = (hashcode & (1023)); int innerDirNumber = ((hashcode >> 10) & (1023)); - String fullDir = synchDirectory; + String fullDir = synchDirectory.toString(); if (fullDir.length() == 0 || !fullDir.endsWith("/")) fullDir = fullDir + "/"; fullDir = fullDir + Integer.toString(outerDirNumber)+"/"+Integer.toString(innerDirNumber); Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockObject.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockObject.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockObject.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockObject.java Fri Jul 2 10:17:58 2010 @@ -47,7 +47,7 @@ public class LockObject private static final String LOCKEDANOTHERJVM = "Locked by another JVM"; - public LockObject(LockPool lockPool, Object lockKey, String synchDir) + public LockObject(LockPool lockPool, Object lockKey, File synchDir) { this.lockPool = lockPool; this.lockKey = lockKey; @@ -58,7 +58,7 @@ public class LockObject int hashcode = lockKey.hashCode(); int outerDirNumber = (hashcode & (1023)); int innerDirNumber = ((hashcode >> 10) & (1023)); - String fullDir = synchDir; + String fullDir = synchDir.toString(); if (fullDir.length() == 0 || !fullDir.endsWith(SLASH)) fullDir = fullDir + SLASH; fullDir = fullDir + Integer.toString(outerDirNumber)+SLASH+Integer.toString(innerDirNumber); Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockPool.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockPool.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockPool.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/lockmanager/LockPool.java Fri Jul 2 10:17:58 2010 @@ -19,6 +19,7 @@ package org.apache.lcf.core.lockmanager; import java.util.*; +import java.io.*; public class LockPool { @@ -26,7 +27,7 @@ public class LockPool private HashMap myLocks = new HashMap(); - public synchronized LockObject getObject(Object lockKey, String synchDir) + public synchronized LockObject getObject(Object lockKey, File synchDir) { LockObject lo = (LockObject)myLocks.get(lockKey); if (lo == null) Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCF.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCF.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCF.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCF.java Fri Jul 2 10:17:58 2010 @@ -35,7 +35,13 @@ public class LCF public static final String NODE_LIBDIR = "libdir"; public static final String ATTRIBUTE_PATH = "path"; + // "Working directory" + + /** This is the working directory file object. */ + protected static File workingDirectory = null; + // Class loader + /** The object that manages LCF plugin class loading. This is initialized when the initialize method is called. */ protected static LCFResourceLoader resourceLoader = null; @@ -146,24 +152,25 @@ public class LCF propertyFilePath = new File(configPath,"properties.xml").toString(); } - // Initialize resource loader. - // To do this, we need the "working directory". But we cannot use the actual system cwd, because different LCF processes will have different ones. + // Initialize working directory. We cannot use the actual system cwd, because different LCF processes will have different ones. // So, instead, we use the location of the property file itself, and call that the "working directory". - File wd = new File(propertyFilePath).getAbsoluteFile().getParentFile(); - resourceLoader = new LCFResourceLoader(wd.toString(),Thread.currentThread().getContextClassLoader()); + workingDirectory = new File(propertyFilePath).getAbsoluteFile().getParentFile(); + + // Initialize resource loader. + resourceLoader = new LCFResourceLoader(Thread.currentThread().getContextClassLoader()); - // Read configuration + // Read configuration! localConfiguration = new ConfigParams(); localProperties = new HashMap(); checkProperties(); - String logConfigFile = getProperty(logConfigFileProperty); + File logConfigFile = getFileProperty(logConfigFileProperty); if (logConfigFile == null) { System.err.println("Couldn't find "+logConfigFileProperty+" property; using default"); String configPath = (String)props.get("user.home") + "/"+applicationName; configPath = configPath.replace('\\', '/'); - logConfigFile = new File(configPath,"logging.ini").toString(); + logConfigFile = new File(configPath,"logging.ini"); } Logging.initializeLoggingSystem(logConfigFile); @@ -257,18 +264,28 @@ public class LCF throw new LCFException("Node type '"+NODE_LIBDIR+"' requires a '"+ATTRIBUTE_PATH+" attribute"); // What exactly should I do with this classpath information? The classloader can be dynamically updated, but if I do that will everything work? // I'm going to presume the answer is "yes" for now... - libDirs.add(path); + libDirs.add(resolvePath(path)); } } // Apply libdirs to the resource loader. resourceLoader.setClassPath(libDirs); } - /** Read a property, either from the system properties, or from the local property file image. + /** Resolve a file path, possibly relative to LCF's concept of its "working directory". + *@param path is the path, to be calculated relative to the LCF "working directory". + *@return the resolved file. + */ + public static File resolvePath(String path) + { + File r = new File(path); + return r.isAbsolute() ? r : new File(workingDirectory, path); + } + + /** Read a (string) property, either from the system properties, or from the local configuration file. *@param s is the property name. *@return the property value, as a string. */ - public static final String getProperty(String s) + public static String getProperty(String s) { String rval = System.getProperty(s); if (rval == null) @@ -276,6 +293,17 @@ public class LCF return rval; } + /** Read a File property, either from the system properties, or from the local configuration file. + * Relative file references are resolved according to the "working directory" for LCF. + */ + public static File getFileProperty(String s) + { + String value = getProperty(s); + if (value == null) + return null; + return resolvePath(value); + } + /** Attempt to make sure a path is a folder * @param path */ Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/Logging.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/Logging.java?rev=959936&r1=959935&r2=959936&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/Logging.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/Logging.java Fri Jul 2 10:17:58 2010 @@ -51,7 +51,7 @@ public class Logging /** Initialize logger setup. */ - public static synchronized void initializeLoggingSystem(String logConfigFile) + public static synchronized void initializeLoggingSystem(File logConfigFile) { if (logLevelMap != null) return; @@ -70,7 +70,7 @@ public class Logging loggerTable = new HashMap(); // Initialize the logger - PropertyConfigurator.configure(logConfigFile); + PropertyConfigurator.configure(logConfigFile.toString()); //System.err.println("LCF logger setup complete"); }