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:</p> 090 * <ul> <li>copies across all the 091 * <code>System</code> properties to use as report configuration properties (obviously 092 * the majority of them will not apply to reports);</li> <li>itself references a parent 093 * configuration that reads its properties from a file <code>jfreereport.properties</code>. 094 * </ul> 095 * 096 * @return the global configuration. 097 */ 098 protected synchronized Configuration loadConfiguration() { 099 return createDefaultHierarchicalConfiguration 100 ("/org/jfree/base/jcommon.properties", 101 "/jcommon.properties", true, BaseBoot.class); 102 } 103 104 /** 105 * Returns the boot instance. 106 * 107 * @return The boot instance. 108 */ 109 public static synchronized AbstractBoot getInstance() { 110 if (singleton == null) { 111 singleton = new BaseBoot(); 112 } 113 return singleton; 114 } 115 116 /** 117 * Performs the boot process. 118 */ 119 protected void performBoot() { 120 // configure the classloader from the properties-file. 121 ObjectUtilities.setClassLoaderSource 122 (getConfiguration().getConfigProperty("org.jfree.ClassLoader")); 123 124 getPackageManager().addModule(DefaultLogModule.class.getName()); 125 getPackageManager().load("org.jfree.jcommon.modules."); 126 getPackageManager().initializeModules(); 127 } 128 129 /** 130 * Returns the project info. 131 * 132 * @return The project info. 133 */ 134 protected BootableProjectInfo getProjectInfo() { 135 return this.bootableProjectInfo; 136 } 137}