Frames | No Frames |
1: /* ======================================================================== 2: * JCommon : a free general purpose class library for the Java(tm) platform 3: * ======================================================================== 4: * 5: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. 6: * 7: * Project Info: http://www.jfree.org/jcommon/index.html 8: * 9: * This library is free software; you can redistribute it and/or modify it 10: * under the terms of the GNU Lesser General Public License as published by 11: * the Free Software Foundation; either version 2.1 of the License, or 12: * (at your option) any later version. 13: * 14: * This library is distributed in the hope that it will be useful, but 15: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17: * License for more details. 18: * 19: * You should have received a copy of the GNU Lesser General Public 20: * License along with this library; if not, write to the Free Software 21: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 22: * USA. 23: * 24: * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 25: * in the United States and other countries.] 26: * 27: * ------------- 28: * BaseBoot.java 29: * ------------- 30: * (C)opyright 2004, by Thomas Morgner and Contributors. 31: * 32: * Original Author: Thomas Morgner; 33: * Contributor(s): David Gilbert (for Object Refinery Limited); 34: * 35: * $Id: BaseBoot.java,v 1.9 2006/02/19 21:10:47 taqua Exp $ 36: * 37: * Changes 38: * ------- 39: * 07-Jun-2004 : Added source headers (DG); 40: * 41: */ 42: 43: package org.jfree.base; 44: 45: import org.jfree.JCommon; 46: import org.jfree.base.config.ModifiableConfiguration; 47: import org.jfree.base.log.DefaultLogModule; 48: import org.jfree.util.Configuration; 49: import org.jfree.util.ObjectUtilities; 50: 51: /** 52: * The base boot class. This initializes the services provided by 53: * JCommon. 54: * 55: * @author Thomas Morgner 56: */ 57: public class BaseBoot extends AbstractBoot { 58: 59: /** 60: * Singleton instance. 61: */ 62: private static BaseBoot singleton; 63: 64: /** 65: * The project info. 66: */ 67: private BootableProjectInfo bootableProjectInfo; 68: 69: /** 70: * Default constructor (private). 71: */ 72: private BaseBoot() { 73: this.bootableProjectInfo = JCommon.INFO; 74: } 75: 76: /** 77: * Returns the global configuration as modifiable configuration reference. 78: * 79: * @return the global configuration 80: */ 81: public static ModifiableConfiguration getConfiguration() { 82: return (ModifiableConfiguration) getInstance().getGlobalConfig(); 83: } 84: 85: /** 86: * Returns the global configuration for JFreeReport. 87: * <p/> 88: * In the current implementation, the configuration has no properties defined, but 89: * references a parent configuration that: <ul> <li>copies across all the 90: * <code>System</code> properties to use as report configuration properties (obviously 91: * the majority of them will not apply to reports);</li> <li>itself references a parent 92: * configuration that reads its properties from a file <code>jfreereport.properties</code>. 93: * </ul> 94: * 95: * @return the global configuration. 96: */ 97: protected synchronized Configuration loadConfiguration() { 98: return createDefaultHierarchicalConfiguration 99: ("/org/jfree/base/jcommon.properties", 100: "/jcommon.properties", true); 101: } 102: 103: /** 104: * Returns the boot instance. 105: * 106: * @return The boot instance. 107: */ 108: public static synchronized AbstractBoot getInstance() { 109: if (singleton == null) { 110: singleton = new BaseBoot(); 111: } 112: return singleton; 113: } 114: 115: /** 116: * Performs the boot process. 117: */ 118: protected void performBoot() { 119: // configure the classloader from the properties-file. 120: ObjectUtilities.setClassLoaderSource 121: (getConfiguration().getConfigProperty("org.jfree.ClassLoader")); 122: 123: getPackageManager().addModule(DefaultLogModule.class.getName()); 124: getPackageManager().load("org.jfree.jcommon.modules."); 125: getPackageManager().initializeModules(); 126: } 127: 128: /** 129: * Returns the project info. 130: * 131: * @return The project info. 132: */ 133: protected BootableProjectInfo getProjectInfo() { 134: return this.bootableProjectInfo; 135: } 136: }