Return-Path: Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: (qmail 17914 invoked from network); 1 Jul 2010 13:47:41 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Jul 2010 13:47:41 -0000 Received: (qmail 47620 invoked by uid 500); 1 Jul 2010 13:47:41 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 47571 invoked by uid 500); 1 Jul 2010 13:47:40 -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 47564 invoked by uid 99); 1 Jul 2010 13:47:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jul 2010 13:47:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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; Thu, 01 Jul 2010 13:47:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1247623889E2; Thu, 1 Jul 2010 13:46:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r959660 - in /incubator/lcf/trunk/modules/framework: agents/org/apache/lcf/agents/interfaces/ core/org/apache/lcf/core/common/ core/org/apache/lcf/core/interfaces/ core/org/apache/lcf/core/system/ pull-agent/org/apache/lcf/authorities/inter... Date: Thu, 01 Jul 2010 13:46:10 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100701134611.1247623889E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Thu Jul 1 13:46:10 2010 New Revision: 959660 URL: http://svn.apache.org/viewvc?rev=959660&view=rev Log: Add a class loader specific to LCF, which is initialized with information gleaned from the configuration file. The configuration file is now XML, and defaults to properties.xml rather than properties.ini. Added: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java (with props) Modified: incubator/lcf/trunk/modules/framework/agents/org/apache/lcf/agents/interfaces/OutputConnectorFactory.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCF.java incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/authorities/interfaces/AuthorityConnectorFactory.java incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/interfaces/RepositoryConnectorFactory.java incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/agents/tests/TestBase.java incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/core/tests/TestBase.java incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestBase.java incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestConnectorBase.java Modified: incubator/lcf/trunk/modules/framework/agents/org/apache/lcf/agents/interfaces/OutputConnectorFactory.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/agents/org/apache/lcf/agents/interfaces/OutputConnectorFactory.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/agents/org/apache/lcf/agents/interfaces/OutputConnectorFactory.java (original) +++ incubator/lcf/trunk/modules/framework/agents/org/apache/lcf/agents/interfaces/OutputConnectorFactory.java Thu Jul 1 13:46:10 2010 @@ -19,6 +19,7 @@ package org.apache.lcf.agents.interfaces; import org.apache.lcf.core.interfaces.*; +import org.apache.lcf.agents.system.LCF; import java.util.*; import java.io.*; @@ -129,7 +130,7 @@ public class OutputConnectorFactory { try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -149,8 +150,7 @@ public class OutputConnectorFactory } catch (ClassNotFoundException e) { - throw new LCFException("No class implementing IOutputConnector called '"+ - className+"'.", + throw new LCFException("No output connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) @@ -199,7 +199,7 @@ public class OutputConnectorFactory try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -224,8 +224,7 @@ public class OutputConnectorFactory if (connMgr.isInstalled(className) == false) return null; - throw new LCFException("No class implementing IOutputConnector called '"+ - className+"'.", + throw new LCFException("No output connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) @@ -552,7 +551,7 @@ public class OutputConnectorFactory try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -579,8 +578,7 @@ public class OutputConnectorFactory if (connMgr.isInstalled(className) == false) return null; - throw new LCFException("No class implementing IOutputConnector called '"+ - className+"'.", + throw new LCFException("No output connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) Added: 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=959660&view=auto ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java (added) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java Thu Jul 1 13:46:10 2010 @@ -0,0 +1,206 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.lcf.core.common; + +import org.apache.lcf.core.interfaces.*; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.MalformedURLException; +import java.util.*; +import java.io.*; + +/** An instance of this class is capable of minting URLClassLoader objects on +* demand, for the purpose of loading plugins. +*/ +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 */ + protected ClassLoader classLoader = null; + /** The current 'classpath' - a list of File objects */ + 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) + throws LCFException + { + this.instanceDir = makeLegalDir(instanceDir); + this.parent = parent; + } + + /** Set the classpath to a given list of libdirs. + */ + public synchronized void setClassPath(ArrayList libdirList) + throws LCFException + { + if (currentClasspath.size() > 0) + { + currentClasspath.clear(); + classLoader = null; + } + int i = 0; + while (i < libdirList.size()) + { + String path = (String)libdirList.get(i++); + addToClassPath(path,null); + } + } + + /** Clear the class-search path. + */ + public synchronized void clearClassPath() + { + if (currentClasspath.size() == 0) + return; + currentClasspath.clear(); + classLoader = null; + } + + /** 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. + */ + public synchronized void addToClassPath(String path) + throws LCFException + { + final File file = resolvePath(new File(instanceDir), path); + if (file.canRead()) + { + addDirsToClassPath(new File[]{file.getParentFile()}, + new FileFilter[]{new FileFilter() { + public boolean accept(final File pathname) + { + return pathname.equals(file); + } + } } ); + } + else + throw new LCFException("Path '"+path+"' 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) + throws LCFException + { + File base = resolvePath(new File(instanceDir), dir); + addDirsToClassPath(new File[]{base}, new FileFilter[]{filter}); + } + + /** Get the specified class using the proper classloader. + *@param cname is the fully-qualified class name. + */ + public synchronized Class findClass(String cname) + throws ClassNotFoundException,LCFException + { + if (classLoader == null) + { + // Mint a class loader on demand + if (currentClasspath.size() == 0) + classLoader = parent; + else + { + URL[] elements = new URL[currentClasspath.size()]; + + for (int j = 0; j < currentClasspath.size(); j++) + { + try + { + URL element = ((File)currentClasspath.get(j)).toURI().normalize().toURL(); + elements[j] = element; + } + catch (MalformedURLException e) + { + // Should never happen, but... + throw new LCFException(e.getMessage(),e); + } + } + classLoader = URLClassLoader.newInstance(elements, parent); + } + } + + // If we ever get this far, we have a classloader at least... + return Class.forName(cname,true,classLoader); + } + + /** Add fully-resolved directories (with filters) to the current class path. + *@param baseList is the list of library directories. + *@param filterList is the corresponding list of filters. + */ + protected void addDirsToClassPath(File[] baseList, FileFilter[] filterList) + throws LCFException + { + int i = 0; + while (i < baseList.length) + { + File base = baseList[i]; + FileFilter filter; + if (filterList != null) + filter = filterList[i]; + else + filter = null; + + if (base.canRead() && base.isDirectory()) + { + File[] files = base.listFiles(filter); + + if (files != null && files.length > 0) + { + int j = 0; + while (j < files.length) + { + File file = files[j++]; + currentClasspath.add(file); + // Invalidate the current classloader + classLoader = null; + } + } + } + else + throw new LCFException("Supposed directory '"+base.toString()+"' is either not readable, or is not a directory"); + i++; + } + } + + + /** 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 Propchange: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/common/LCFResourceLoader.java ------------------------------------------------------------------------------ svn:keywords = Id Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java Thu Jul 1 13:46:10 2010 @@ -75,6 +75,15 @@ public class ConfigParams fromXML(xml); } + /** Construct from XML. + *@param xmlstream is the input XML stream. Does NOT close the stream. + */ + public ConfigParams(InputStream xmlstream) + throws LCFException + { + fromXML(xmlstream); + } + /** Get as XML *@return the xml corresponding to these ConfigParams. */ @@ -133,9 +142,25 @@ public class ConfigParams public void fromXML(String xml) throws LCFException { + XMLDoc doc = new XMLDoc(xml); + initializeFromDoc(doc); + } + + /** Read from an XML binary stream. + *@param xmlstream is the input XML stream. Does NOT close the stream. + */ + public void fromXML(InputStream xmlstream) + throws LCFException + { + XMLDoc doc = new XMLDoc(xmlstream); + initializeFromDoc(doc); + } + + protected void initializeFromDoc(XMLDoc doc) + throws LCFException + { children.clear(); params.clear(); - XMLDoc doc = new XMLDoc(xml); ArrayList list = new ArrayList(); doc.processPath(list, "*", 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=959660&r1=959659&r2=959660&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 Thu Jul 1 13:46:10 2010 @@ -19,6 +19,7 @@ package org.apache.lcf.core.system; import org.apache.lcf.core.interfaces.*; +import org.apache.lcf.core.common.LCFResourceLoader; import java.io.*; import java.util.*; import java.security.MessageDigest; @@ -27,7 +28,17 @@ public class LCF { public static final String _rcsid = "@(#)$Id$"; + // Configuration XML node names and attribute names + public static final String NODE_PROPERTY = "property"; + public static final String ATTRIBUTE_NAME = "name"; + public static final String ATTRIBUTE_VALUE = "value"; + public static final String NODE_LIBDIR = "libdir"; + public static final String ATTRIBUTE_PATH = "path"; + // Class loader + /** The object that manages LCF plugin class loading. This is initialized when the initialize method is called. */ + protected static LCFResourceLoader resourceLoader = null; + // Shutdown hooks /** Temporary file collector */ protected static FileTrack tracker = null; @@ -67,8 +78,8 @@ public class LCF protected static String masterDatabaseName = null; protected static String masterDatabaseUsername = null; protected static String masterDatabasePassword = null; - protected static java.util.Properties localProperties = null; - //protected static String configPath = null; + protected static ConfigParams localConfiguration = null; + protected static Map localProperties = null; protected static long propertyFilelastMod = -1L; protected static String propertyFilePath = null; @@ -77,7 +88,7 @@ public class LCF // System property names public static final String lcfConfigFileProperty = "org.apache.lcf.configfile"; - // System property/property file property names + // System property/config file property names // Database access properties /** Database name property */ @@ -121,6 +132,9 @@ public class LCF try { + // Initialize resource loader + resourceLoader = new LCFResourceLoader(System.getProperty("user.dir"),Thread.currentThread().getContextClassLoader()); + // Get system properties java.util.Properties props = System.getProperties(); // First, look for a define that might indicate where to look @@ -131,11 +145,12 @@ public class LCF System.err.println("Couldn't find "+lcfConfigFileProperty+" property; using default"); String configPath = (String)props.get("user.home") + "/"+applicationName; configPath = configPath.replace('\\', '/'); - propertyFilePath = new File(configPath,"properties.ini").toString(); + propertyFilePath = new File(configPath,"properties.xml").toString(); } - // Read .ini parameters - localProperties = new java.util.Properties(); + // Read configuration + localConfiguration = new ConfigParams(); + localProperties = new HashMap(); checkProperties(); String logConfigFile = getProperty(logConfigFileProperty); @@ -195,8 +210,8 @@ public class LCF InputStream is = new FileInputStream(f); try { - localProperties.load(is); - System.err.println("Property file successfully read"); + localConfiguration.fromXML(is); + System.err.println("Configuration file successfully read"); propertyFilelastMod = f.lastModified(); } finally @@ -205,12 +220,44 @@ public class LCF } } else - System.err.println("Property file not read because it didn't change"); + { + System.err.println("Configuration file not read because it didn't change"); + return; + } } catch (Exception e) { - throw new LCFException("Could not read property file '"+f.toString()+"'",e); + throw new LCFException("Could not read configuration file '"+f.toString()+"'",e); + } + + // For convenience, post-process all "property" nodes so that we have a semblance of the earlier name/value pairs available, by default. + // e.g. + localProperties.clear(); + ArrayList libDirs = new ArrayList(); + int i = 0; + while (i < localConfiguration.getChildCount()) + { + ConfigNode cn = localConfiguration.getChild(i++); + if (cn.getType().equals(NODE_PROPERTY)) + { + String name = cn.getAttributeValue(ATTRIBUTE_NAME); + String value = cn.getAttributeValue(ATTRIBUTE_VALUE); + if (name == null) + throw new LCFException("Node type '"+NODE_PROPERTY+"' requires a '"+ATTRIBUTE_NAME+"' attribute"); + localProperties.put(name,value); + } + else if (cn.getType().equals(NODE_LIBDIR)) + { + String path = cn.getAttributeValue(ATTRIBUTE_PATH); + if (path == null) + 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); + } } + // Apply libdirs to the resource loader. + resourceLoader.setClassPath(libDirs); } /** Read a property, either from the system properties, or from the local property file image. @@ -221,7 +268,7 @@ public class LCF { String rval = System.getProperty(s); if (rval == null) - rval = localProperties.getProperty(s); + rval = (String)localProperties.get(s); return rval; } @@ -998,6 +1045,16 @@ public class LCF } } + + /** Locate a class in the configuration-determined class path. This method + * is designed for loading plugin classes, and their downstream dependents. + */ + public static Class findClass(String cname) + throws ClassNotFoundException,LCFException + { + return resourceLoader.findClass(cname); + } + /** Perform system shutdown, using the registered shutdown hooks. */ protected static void cleanUpSystem() { Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/authorities/interfaces/AuthorityConnectorFactory.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/authorities/interfaces/AuthorityConnectorFactory.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/authorities/interfaces/AuthorityConnectorFactory.java (original) +++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/authorities/interfaces/AuthorityConnectorFactory.java Thu Jul 1 13:46:10 2010 @@ -19,6 +19,7 @@ package org.apache.lcf.authorities.interfaces; import org.apache.lcf.core.interfaces.*; +import org.apache.lcf.core.system.LCF; import java.util.*; import java.io.*; import java.lang.reflect.*; @@ -120,7 +121,7 @@ public class AuthorityConnectorFactory { try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -140,8 +141,7 @@ public class AuthorityConnectorFactory } catch (ClassNotFoundException e) { - throw new LCFException("No class implementing IAuthorityConnector called '"+ - className+"'.", + throw new LCFException("No authority connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) @@ -190,7 +190,7 @@ public class AuthorityConnectorFactory try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -214,8 +214,7 @@ public class AuthorityConnectorFactory if (connMgr.isInstalled(className) == false) return null; - throw new LCFException("No class implementing IAuthorityConnector called '"+ - className+"'.", + throw new LCFException("No authority connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) @@ -452,7 +451,7 @@ public class AuthorityConnectorFactory try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -479,8 +478,7 @@ public class AuthorityConnectorFactory if (connMgr.isInstalled(className) == false) return null; - throw new LCFException("No class implementing IAuthorityConnector called '"+ - className+"'.", + throw new LCFException("No authority connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/interfaces/RepositoryConnectorFactory.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/interfaces/RepositoryConnectorFactory.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/interfaces/RepositoryConnectorFactory.java (original) +++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/interfaces/RepositoryConnectorFactory.java Thu Jul 1 13:46:10 2010 @@ -21,6 +21,7 @@ package org.apache.lcf.crawler.interface import org.apache.lcf.core.interfaces.*; import org.apache.lcf.agents.interfaces.*; import org.apache.lcf.crawler.system.Logging; +import org.apache.lcf.crawler.system.LCF; import java.util.*; import java.io.*; @@ -159,7 +160,7 @@ public class RepositoryConnectorFactory { try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -179,8 +180,7 @@ public class RepositoryConnectorFactory } catch (ClassNotFoundException e) { - throw new LCFException("No class implementing IRepositoryConnector called '"+ - className+"'.", + throw new LCFException("No repository connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) @@ -229,7 +229,7 @@ public class RepositoryConnectorFactory try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -254,8 +254,7 @@ public class RepositoryConnectorFactory if (connMgr.isInstalled(className) == false) return null; - throw new LCFException("No class implementing IRepositoryConnector called '"+ - className+"'.", + throw new LCFException("No repository connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) @@ -605,7 +604,7 @@ public class RepositoryConnectorFactory try { - Class theClass = Class.forName(className); + Class theClass = LCF.findClass(className); Class[] argumentClasses = new Class[0]; // Look for a constructor Constructor c = theClass.getConstructor(argumentClasses); @@ -632,8 +631,7 @@ public class RepositoryConnectorFactory if (connMgr.isInstalled(className) == false) return null; - throw new LCFException("No class implementing IRepositoryConnector called '"+ - className+"'.", + throw new LCFException("No repository connector class '"+className+"' was found.", e); } catch (NoSuchMethodException e) Modified: incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/agents/tests/TestBase.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/agents/tests/TestBase.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/agents/tests/TestBase.java (original) +++ incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/agents/tests/TestBase.java Thu Jul 1 13:46:10 2010 @@ -84,7 +84,7 @@ public class TestBase extends org.apache throws Exception { initialize(); - if (propertiesFile.exists()) + if (isInitialized()) { // Test the uninstall LCF.initializeEnvironment(); Modified: incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/core/tests/TestBase.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/core/tests/TestBase.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/core/tests/TestBase.java (original) +++ incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/core/tests/TestBase.java Thu Jul 1 13:46:10 2010 @@ -29,7 +29,7 @@ import org.junit.*; public class TestBase { protected File currentPath = null; - protected File propertiesFile = null; + protected File configFile = null; protected File loggingFile = null; protected File logOutputFile = null; @@ -41,15 +41,20 @@ public class TestBase currentPath = new File(".").getCanonicalFile(); // First, write a properties file and a logging file, in the current directory. - propertiesFile = new File("properties.ini").getCanonicalFile(); + configFile = new File("properties.xml").getCanonicalFile(); loggingFile = new File("logging.ini").getCanonicalFile(); logOutputFile = new File("lcf.log").getCanonicalFile(); // Set a system property that will point us to the proper place to find the properties file - System.setProperty("org.apache.lcf.configfile",propertiesFile.getCanonicalFile().getAbsolutePath()); + System.setProperty("org.apache.lcf.configfile",configFile.getCanonicalFile().getAbsolutePath()); } } + protected boolean isInitialized() + { + return configFile.exists(); + } + @Before public void setUp() throws Exception @@ -85,10 +90,13 @@ public class TestBase "log4j.appender.MAIN=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.MAIN.layout=org.apache.log4j.PatternLayout\n"); - writeFile(propertiesFile, - "org.apache.lcf.databaseimplementationclass=org.apache.lcf.core.database.DBInterfaceDerby\n" + - "org.apache.lcf.derbydatabasepath="+currentPathString.replaceAll("\\\\","/")+"\n" + - "org.apache.lcf.logconfigfile="+loggingFile.getAbsolutePath().replaceAll("\\\\","/")+"\n"); + writeFile(configFile, + "\n" + + "\n"+ + " \n" + + " \n" + + " \n" + + "\n"); LCF.initializeEnvironment(); IThreadContext tc = ThreadContextFactory.make(); @@ -117,7 +125,7 @@ public class TestBase throws Exception { initialize(); - if (propertiesFile.exists()) + if (isInitialized()) { LCF.initializeEnvironment(); IThreadContext tc = ThreadContextFactory.make(); @@ -127,7 +135,7 @@ public class TestBase // Get rid of the property and logging files. logOutputFile.delete(); - propertiesFile.delete(); + configFile.delete(); loggingFile.delete(); } } @@ -138,7 +146,7 @@ public class TestBase OutputStream os = new FileOutputStream(f); try { - Writer w = new OutputStreamWriter(os); + Writer w = new OutputStreamWriter(os,"utf-8"); try { w.write(fileContents); Modified: incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestBase.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestBase.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestBase.java (original) +++ incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestBase.java Thu Jul 1 13:46:10 2010 @@ -86,7 +86,7 @@ public class TestBase extends org.apache throws Exception { initialize(); - if (propertiesFile.exists()) + if (isInitialized()) { // Test the uninstall LCF.initializeEnvironment(); Modified: incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestConnectorBase.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestConnectorBase.java?rev=959660&r1=959659&r2=959660&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestConnectorBase.java (original) +++ incubator/lcf/trunk/modules/framework/tests/org/apache/lcf/crawler/tests/TestConnectorBase.java Thu Jul 1 13:46:10 2010 @@ -192,7 +192,7 @@ public class TestConnectorBase extends o throws Exception { initialize(); - if (propertiesFile.exists()) + if (isInitialized()) { // Test the uninstall LCF.initializeEnvironment();