BaseBoot.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.11 2007/11/02 17:50:34 taqua Exp $
  36. *
  37. * Changes
  38. * -------
  39. * 07-Jun-2004 : Added source headers (DG);
  40. *
  41. */
  42. package org.jfree.base;
  43. import org.jfree.JCommon;
  44. import org.jfree.base.config.ModifiableConfiguration;
  45. import org.jfree.base.log.DefaultLogModule;
  46. import org.jfree.util.Configuration;
  47. import org.jfree.util.ObjectUtilities;
  48. /**
  49. * The base boot class. This initializes the services provided by
  50. * JCommon.
  51. *
  52. * @author Thomas Morgner
  53. */
  54. public class BaseBoot extends AbstractBoot {
  55. /**
  56. * Singleton instance.
  57. */
  58. private static BaseBoot singleton;
  59. /**
  60. * The project info.
  61. */
  62. private BootableProjectInfo bootableProjectInfo;
  63. /**
  64. * Default constructor (private).
  65. */
  66. private BaseBoot() {
  67. this.bootableProjectInfo = JCommon.INFO;
  68. }
  69. /**
  70. * Returns the global configuration as modifiable configuration reference.
  71. *
  72. * @return the global configuration
  73. */
  74. public static ModifiableConfiguration getConfiguration() {
  75. return (ModifiableConfiguration) getInstance().getGlobalConfig();
  76. }
  77. /**
  78. * Returns the global configuration for JFreeReport.
  79. * <p>
  80. * In the current implementation, the configuration has no properties defined, but
  81. * references a parent configuration that:</p>
  82. * <ul> <li>copies across all the
  83. * <code>System</code> properties to use as report configuration properties (obviously
  84. * the majority of them will not apply to reports);</li> <li>itself references a parent
  85. * configuration that reads its properties from a file <code>jfreereport.properties</code>.
  86. * </ul>
  87. *
  88. * @return the global configuration.
  89. */
  90. protected synchronized Configuration loadConfiguration() {
  91. return createDefaultHierarchicalConfiguration
  92. ("/org/jfree/base/jcommon.properties",
  93. "/jcommon.properties", true, BaseBoot.class);
  94. }
  95. /**
  96. * Returns the boot instance.
  97. *
  98. * @return The boot instance.
  99. */
  100. public static synchronized AbstractBoot getInstance() {
  101. if (singleton == null) {
  102. singleton = new BaseBoot();
  103. }
  104. return singleton;
  105. }
  106. /**
  107. * Performs the boot process.
  108. */
  109. protected void performBoot() {
  110. // configure the classloader from the properties-file.
  111. ObjectUtilities.setClassLoaderSource
  112. (getConfiguration().getConfigProperty("org.jfree.ClassLoader"));
  113. getPackageManager().addModule(DefaultLogModule.class.getName());
  114. getPackageManager().load("org.jfree.jcommon.modules.");
  115. getPackageManager().initializeModules();
  116. }
  117. /**
  118. * Returns the project info.
  119. *
  120. * @return The project info.
  121. */
  122. protected BootableProjectInfo getProjectInfo() {
  123. return this.bootableProjectInfo;
  124. }
  125. }