Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/resource In directory sc8-pr-cvs1:/tmp/cvs-serv6089/core/src/com/babeldoc/core/resource Modified Files: IResource.java Resource.java ResourceFactory.java Added Files: ResourceConfigInfo.java Log Message: Resources now are Configurable. Added dbDriver configuration option to sql resources. Lots of work on the resources - made things more logical from a SW POV. Added Null scanner. --- NEW FILE: ResourceConfigInfo.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/resource/ResourceConfigInfo.java,v 1.1 2003/08/15 00:25:29 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.core.resource; import com.babeldoc.core.option.ConfigInfo; import java.util.Collection; /** * Configuration information object for resources. This will allow objects * to describe those configuration options that are required and optional. * * @author bmcdonald * @version 1.1 */ public abstract class ResourceConfigInfo extends ConfigInfo { /** * Return an xmlized version of the of the config info * * @return String of configuration information. */ public String toXml() { return null; } /** * This method returns options that are general to all components * * @return comments */ public Collection getGeneralOptions() { return null; } } Index: IResource.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/resource/IResource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IResource.java 27 Jun 2003 02:19:59 -0000 1.3 --- IResource.java 15 Aug 2003 00:25:29 -0000 1.4 *************** *** 66,69 **** --- 66,72 ---- package com.babeldoc.core.resource; + import com.babeldoc.core.INamed; + import com.babeldoc.core.option.IConfigurable; + /** * Interface for connection managers. Primarily to be used by connection pools *************** *** 75,79 **** * @version 1.0 */ ! public interface IResource extends com.babeldoc.core.INamed { /** * Check back in a checked out connection --- 78,83 ---- * @version 1.0 */ ! public interface IResource ! extends INamed, IConfigurable { /** * Check back in a checked out connection Index: Resource.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/resource/Resource.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Resource.java 27 Jun 2003 02:19:59 -0000 1.5 --- Resource.java 15 Aug 2003 00:25:29 -0000 1.6 *************** *** 66,71 **** package com.babeldoc.core.resource; ! import com.babeldoc.core.config.ConfigService; ! import com.babeldoc.core.config.IConfig; --- 66,70 ---- package com.babeldoc.core.resource; ! import com.babeldoc.core.Named; *************** *** 77,100 **** * @version 1.0 */ ! public abstract class Resource extends com.babeldoc.core.Named implements IResource { - /** Constants - will move to confserver when needs to be done. */ - public static String CONFIG_FILENAME = "resource/"; ! /** Configuration stuff */ ! private IConfig config; /** ! * Get the config object * ! * @return DOCUMENT ME! */ ! protected IConfig getConfig() { ! if (config == null) { ! config = ConfigService.getInstance().getConfig(CONFIG_FILENAME + ! getName()); } ! return config; } } --- 76,126 ---- * @version 1.0 */ ! abstract public class Resource ! extends Named implements IResource { ! /** State variables */ ! private boolean initialized = false; /** ! * Setup the resource - this MUST be overridden by child resources * ! * @throws ResourceException */ ! abstract protected void setup() throws ResourceException; ! ! /** ! * Get a new connection. ! * ! * @return NOTHING - the extending class needs to do the actual work ! * ! * @throws ResourceException ! */ ! synchronized public Object checkOut() throws ResourceException { ! // If not initialized, setup now ! if (!isInitialized()) { ! setup(); ! setInitialized(true); } ! return null; ! } ! ! /** ! * Has this resource been initialized ! * ! * @return ! */ ! protected boolean isInitialized() { ! return initialized; ! } ! ! /** ! * Set this resouces initialized state ! * ! * @param initialized ! */ ! protected void setInitialized(boolean initialized) { ! this.initialized = initialized; } } Index: ResourceFactory.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/resource/ResourceFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ResourceFactory.java 27 Jun 2003 02:19:59 -0000 1.5 --- ResourceFactory.java 15 Aug 2003 00:25:29 -0000 1.6 *************** *** 68,71 **** --- 68,73 ---- import com.babeldoc.core.I18n; import com.babeldoc.core.LogService; + import com.babeldoc.core.option.IConfigData; + import com.babeldoc.core.option.ConfigData; import com.babeldoc.core.config.ConfigService; *************** *** 133,137 **** // LogService.getInstance().logDebug("[ResourceFactory.getResource] resource not cached, creating"); try { ! String typeName = ConfigService.getString(RESOURCE + "/" + name, TYPE); // LogService.getInstance().logDebug("[ResourceFactory.getResource]: Type: \""+typeName+"\""); --- 135,140 ---- // LogService.getInstance().logDebug("[ResourceFactory.getResource] resource not cached, creating"); try { ! String resourceConfigName = RESOURCE + "/" + name; ! String typeName = ConfigService.getString(resourceConfigName, TYPE); // LogService.getInstance().logDebug("[ResourceFactory.getResource]: Type: \""+typeName+"\""); *************** *** 142,145 **** --- 145,150 ---- resource = (Resource) classObj.newInstance(); resource.setName(name); + IConfigData configData = ConfigData.getConfigData("root", resourceConfigName); + resource.getInfo().applyConfigData(configData); getInstance().resources.put(name, resource); } else { |