The common base for all Boot classes.
This initializes the subsystem and all dependent subsystems.
Implementors of this class have to provide a public static
getInstance() method which returns a singleton instance of the
booter implementation.
Further creation of Boot object should be prevented using
protected or private constructors in that class, or proper
initialzation cannot be guaranteed.
| Method from org.jfree.base.AbstractBoot Detail: |
protected Configuration createDefaultHierarchicalConfiguration(String staticConfig,
String userConfig,
boolean addSysProps) {
return createDefaultHierarchicalConfiguration
(staticConfig, userConfig, addSysProps, PropertyFileConfiguration.class);
}
Creates a default configuration setup, which loads its settings from
the static configuration (defaults provided by the developers of the
library) and the user configuration (settings provided by the deployer).
The deployer's settings override the developer's settings.
If the parameter addSysProps is set to true, the system
properties will be added as third configuration layer. The system
properties configuration allows to override all other settings. |
protected Configuration createDefaultHierarchicalConfiguration(String staticConfig,
String userConfig,
boolean addSysProps,
Class source) {
final HierarchicalConfiguration globalConfig
= new HierarchicalConfiguration();
if (staticConfig != null) {
final PropertyFileConfiguration rootProperty
= new PropertyFileConfiguration();
rootProperty.load(staticConfig, getClass());
globalConfig.insertConfiguration(rootProperty);
globalConfig.insertConfiguration(
getPackageManager().getPackageConfiguration());
}
if (userConfig != null) {
String userConfigStripped;
if (userConfig.startsWith("/")) {
userConfigStripped = userConfig.substring(1);
}
else {
userConfigStripped = userConfig;
}
try {
final Enumeration userConfigs = ObjectUtilities.getClassLoader
(getClass()).getResources(userConfigStripped);
final ArrayList configs = new ArrayList();
while (userConfigs.hasMoreElements()) {
final URL url = (URL) userConfigs.nextElement();
try {
final PropertyFileConfiguration baseProperty =
new PropertyFileConfiguration();
final InputStream in = url.openStream();
baseProperty.load(in);
in.close();
configs.add(baseProperty);
}
catch(IOException ioe) {
Log.warn ("Failed to load the user configuration at " + url, ioe);
}
}
for (int i = configs.size() - 1; i >= 0; i--) {
final PropertyFileConfiguration baseProperty =
(PropertyFileConfiguration) configs.get(i);
globalConfig.insertConfiguration(baseProperty);
}
}
catch (IOException e) {
Log.warn ("Failed to lookup the user configurations.", e);
}
}
if (addSysProps) {
final SystemPropertyConfiguration systemConfig
= new SystemPropertyConfiguration();
globalConfig.insertConfiguration(systemConfig);
}
return globalConfig;
}
|
public synchronized ExtendedConfiguration getExtendedConfig() {
if (extWrapper == null) {
extWrapper = new ExtendedConfigurationWrapper(getGlobalConfig());
}
return extWrapper;
}
Returns the global configuration as extended configuration. |
public synchronized Configuration getGlobalConfig() {
if (this.globalConfig == null) {
this.globalConfig = loadConfiguration();
}
return this.globalConfig;
}
Returns the global configuration. |
public synchronized PackageManager getPackageManager() {
if (this.packageManager == null) {
this.packageManager = PackageManager.createInstance(this);
}
return this.packageManager;
}
Returns the packageManager instance of the package manager. |
abstract protected BootableProjectInfo getProjectInfo()
Returns the project info. |
public final synchronized boolean isBootDone() {
return this.bootDone;
}
Checks, whether the booting is complete. |
public final synchronized boolean isBootInProgress() {
return this.bootInProgress;
}
Checks, whether the booting is in progress. |
protected AbstractBoot loadBooter(String classname) {
if (classname == null) {
return null;
}
try {
final Class c = ObjectUtilities.getClassLoader(
getClass()).loadClass(classname);
final Method m = c.getMethod("getInstance", (Class[]) null);
return (AbstractBoot) m.invoke(null, (Object[]) null);
}
catch (Exception e) {
Log.info ("Unable to boot dependent class: " + classname);
return null;
}
}
Loads the specified booter implementation. |
abstract protected Configuration loadConfiguration()
Loads the configuration. This will be called exactly once. |
abstract protected void performBoot()
|
public final void start() {
synchronized (this) {
if (isBootDone()) {
return;
}
while (isBootInProgress()) {
try {
wait();
}
catch (InterruptedException e) {
// ignore ..
}
}
if (isBootDone()) {
return;
}
this.bootInProgress = true;
}
// boot dependent libraries ...
final BootableProjectInfo info = getProjectInfo();
if (info != null) {
final BootableProjectInfo[] childs = info.getDependencies();
for (int i = 0; i < childs.length; i++) {
final AbstractBoot boot = loadBooter(childs[i].getBootClass());
if (boot != null) {
// but we're waiting until the booting is complete ...
synchronized(boot) {
boot.start();
while (boot.isBootDone() == false) {
try {
boot.wait();
}
catch (InterruptedException e) {
// ignore it ..
}
}
}
}
}
}
performBoot();
if (info != null)
{
Log.info (info.getName() + " " + info.getVersion() + " started.");
}
else
{
Log.info (getClass() + " started.");
}
synchronized (this) {
this.bootInProgress = false;
this.bootDone = true;
notifyAll();
}
}
|