001/* ======================================================================== 002 * JCommon : a free general purpose class library for the Java(tm) platform 003 * ======================================================================== 004 * 005 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. 006 * 007 * Project Info: http://www.jfree.org/jcommon/index.html 008 * 009 * This library is free software; you can redistribute it and/or modify it 010 * under the terms of the GNU Lesser General Public License as published by 011 * the Free Software Foundation; either version 2.1 of the License, or 012 * (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but 015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 017 * License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this library; if not, write to the Free Software 021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 022 * USA. 023 * 024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 025 * in the United States and other countries.] 026 * 027 * ------------- 028 * BaseBoot.java 029 * ------------- 030 * (C)opyright 2004, by Thomas Morgner and Contributors. 031 * 032 * Original Author: Thomas Morgner; 033 * Contributor(s): David Gilbert (for Object Refinery Limited); 034 * 035 * $Id: BaseBoot.java,v 1.11 2007/11/02 17:50:34 taqua Exp $ 036 * 037 * Changes 038 * ------- 039 * 07-Jun-2004 : Added source headers (DG); 040 * 041 */ 042 043package org.jfree.base; 044 045import org.jfree.JCommon; 046import org.jfree.base.config.ModifiableConfiguration; 047import org.jfree.base.log.DefaultLogModule; 048import org.jfree.util.Configuration; 049import org.jfree.util.ObjectUtilities; 050 051/** 052 * The base boot class. This initializes the services provided by 053 * JCommon. 054 * 055 * @author Thomas Morgner 056 */ 057public class BaseBoot extends AbstractBoot { 058 059 /** 060 * Singleton instance. 061 */ 062 private static BaseBoot singleton; 063 064 /** 065 * The project info. 066 */ 067 private BootableProjectInfo bootableProjectInfo; 068 069 /** 070 * Default constructor (private). 071 */ 072 private BaseBoot() { 073 this.bootableProjectInfo = JCommon.INFO; 074 } 075 076 /** 077 * Returns the global configuration as modifiable configuration reference. 078 * 079 * @return the global configuration 080 */ 081 public static ModifiableConfiguration getConfiguration() { 082 return (ModifiableConfiguration) getInstance().getGlobalConfig(); 083 } 084 085 /** 086 * Returns the global configuration for JFreeReport. 087 * <p/> 088 * In the current implementation, the configuration has no properties defined, but 089 * references a parent configuration that: <ul> <li>copies across all the 090 * <code>System</code> properties to use as report configuration properties (obviously 091 * the majority of them will not apply to reports);</li> <li>itself references a parent 092 * configuration that reads its properties from a file <code>jfreereport.properties</code>. 093 * </ul> 094 * 095 * @return the global configuration. 096 */ 097 protected synchronized Configuration loadConfiguration() { 098 return createDefaultHierarchicalConfiguration 099 ("/org/jfree/base/jcommon.properties", 100 "/jcommon.properties", true, BaseBoot.class); 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}