unbbayes.util
Class ResourceController

java.lang.Object
  extended by unbbayes.util.ResourceController

public class ResourceController
extends Object

This class is used to facilite the use of the diverses files of resources of the project. It contains methods to get this resources. Altered this class in order to use singleton pattern and make it possible to change the classloader/locales dinamically (e.g. plugins). If any classloader modification is needed, you may extend/implement a new ClassLoader and set it as this class' default classloader (as a example, you may implement a network classloader and set it as this singleton instance's default classloader). The plugin support is implemented by setting the default classloader as the plugin classloader.

Version:
19/12/2009
Author:
Laecio, Shou Matsumoto

Field Summary
static ResourceBundle RS_GUI
          Call to ResourceController.newInstance().getBundle(GuiResources.class.getName())
 
Constructor Summary
protected ResourceController()
          Default constructor is made protected just to make it easy to extend.
 
Method Summary
 ResourceBundle getBundle(String baseName)
          Obtains a ResourceBundle using current configuration of locale and classloader.
 ResourceBundle getBundle(String baseName, Locale locale, ClassLoader classLoader)
          Delegator to ResourceBundle.getBundle(baseName, locale, classLoader)
 ClassLoader getDefaultClassLoader()
          The default class loader to be used in order to load the resources.
 Locale getDefaultLocale()
          This is the locale to be used in order to load the resource file.
 String getExtensionPointID()
          ID of the extension point, used by plugin loader to load Resources plugins.
 UnBBayesPluginContextHolder getUnBBayesPluginContextHolder()
           
protected  ClassLoader loadPluginClassLoader()
          Obtains a ClassLoader which loads classes bound by plugins.
static ResourceController newInstance()
           
 void setDefaultClassLoader(ClassLoader defaultClassLoader)
          The default class loader to be used in order to load the resources.
 void setDefaultLocale(Locale defaultLocale)
          This is the locale to be used in order to load the resource file.
 void setExtensionPointID(String extensionPointID)
          ID of the extension point, used by plugin loader to load Resources plugins.
 void setUnBBayesPluginContextHolder(UnBBayesPluginContextHolder unbbayesPluginContextHolder)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RS_GUI

public static ResourceBundle RS_GUI
Call to ResourceController.newInstance().getBundle(GuiResources.class.getName())

Constructor Detail

ResourceController

protected ResourceController()
Default constructor is made protected just to make it easy to extend. Usually, you must use #newInstance(). This method just uses UnBBayesPluginContextHolder in order to obtain the plugin classloader and sets it as the default classloader using #loadPluginClassLoader()

Method Detail

loadPluginClassLoader

protected ClassLoader loadPluginClassLoader()
Obtains a ClassLoader which loads classes bound by plugins.

Returns:

newInstance

public static ResourceController newInstance()
Returns:
a singleton instance of this class.

getDefaultClassLoader

public ClassLoader getDefaultClassLoader()
The default class loader to be used in order to load the resources.

Returns:
the defaultClassLoader

setDefaultClassLoader

public void setDefaultClassLoader(ClassLoader defaultClassLoader)
The default class loader to be used in order to load the resources.

Parameters:
defaultClassLoader - the defaultClassLoader to set

getDefaultLocale

public Locale getDefaultLocale()
This is the locale to be used in order to load the resource file. The initial value is Locale.getDefault()

Returns:
the defaultLocale

setDefaultLocale

public void setDefaultLocale(Locale defaultLocale)
This is the locale to be used in order to load the resource file. The initial value is Locale.getDefault()

Parameters:
defaultLocale - the defaultLocale to set

getBundle

public ResourceBundle getBundle(String baseName)
Obtains a ResourceBundle using current configuration of locale and classloader. It calls ResourceBundle.getBundle(baseName, this.getDefaultLocale(), this.getDefaultClassLoader()).

Parameters:
baseName - : base name of the class to be loaded.
Returns:
a instance of ResourceBundle

getBundle

public ResourceBundle getBundle(String baseName,
                                Locale locale,
                                ClassLoader classLoader)
Delegator to ResourceBundle.getBundle(baseName, locale, classLoader)

Parameters:
baseName -
locale -
classLoader -
Returns:

getExtensionPointID

public String getExtensionPointID()
ID of the extension point, used by plugin loader to load Resources plugins. The default value is usually "ResourceBundle"

Returns:
the extensionPointID

setExtensionPointID

public void setExtensionPointID(String extensionPointID)
ID of the extension point, used by plugin loader to load Resources plugins. The default value is usually "ResourceBundle"

Parameters:
extensionPointID - the extensionPointID to set

getUnBBayesPluginContextHolder

public UnBBayesPluginContextHolder getUnBBayesPluginContextHolder()
Returns:
the unbbayesPluginContextHolder

setUnBBayesPluginContextHolder

public void setUnBBayesPluginContextHolder(UnBBayesPluginContextHolder unbbayesPluginContextHolder)
Parameters:
unbbayesPluginContextHolder - the unbbayesPluginContextHolder to set


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.