FileDocCategorySizeDatePackage
LocalStringsManagerFactory.javaAPI DocGlassfish v2 API7113Fri May 04 22:25:20 BST 2007com.sun.enterprise.cli.framework

LocalStringsManagerFactory

public class LocalStringsManagerFactory extends Object
This is a factory class that creates the LocalStringsManager
author
pa100654

Fields Summary
private static HashMap
stringManagers
private static String
PROPERTY_FILE
private static final String
FRAMEWORK_BASE_PACKAGE
private static LocalStringsManager
commandLocalStringsManager
Constructors Summary
protected LocalStringsManagerFactory()
Creates a new instance of LocalStringsManagerFactory

    
           
      
    
    
Methods Summary
public static LocalStringsManagergetCommandLocalStringsManager()
Returns the instance of the LocalStringsManager object for the CLI Commands module. the caller can access all the methods in this class.

        if (commandLocalStringsManager == null)
        {
            LocalStringsManager lsm = 
                LocalStringsManagerFactory.getFrameworkLocalStringsManager();
            throw new CommandValidationException(
                        lsm.getString("CouldNotFindLocalStringsProperties"));
        }
        return commandLocalStringsManager;
    
public static LocalStringsManagergetFrameworkLocalStringsManager()
Returns the instance of the LocalStringsManager object for the CLI framework module. the caller can access all the methods in this class.

param
packageName name of the package

        return getLocalStringsManager(FRAMEWORK_BASE_PACKAGE, PROPERTY_FILE);
    
public static LocalStringsManagergetLocalStringsManager(java.lang.String packageName, java.lang.String propertiesFileName)
Returns the instance of the LocalStringsManager object, the caller can access all the methods in this class.

param
packageName name of the package

        LocalStringsManager stringsManager = 
                    (LocalStringsManager) stringManagers.get(packageName);
        if ((stringsManager == null) || 
            (!stringsManager.getPropertiesFile().equals(propertiesFileName)))
        {
            try
            {
                stringsManager = new LocalStringsManager(packageName, 
                                                            propertiesFileName);
                stringManagers.put(packageName, stringsManager);
            }
            catch(java.util.MissingResourceException mre)
            {
                //throw new CommandException(mre.getLocalizedMessage());
                throw new CommandValidationException(mre.getLocalizedMessage(), mre);
            }
        }
        return stringsManager;
    
public static voidsetCommandLocalStringsManagerProperties(java.util.Iterator propertiesIter)
sets the list of base_package and property_file_name properties for the CLI Commands module.

param
properties vector of java.util.Properties (name/value pairs of base-package and property-file-name) objects

        Vector localizePropertiesList = new Vector();
        while (propertiesIter.hasNext())
        {
		    Properties localizeProperties = new Properties();
            Properties properties = (Properties) propertiesIter.next();
            String basePackage = properties.getProperty("base-package");
            String propertyFile = properties.getProperty("property-file-name",
                                    LocalStringsManagerFactory.PROPERTY_FILE);
            if ((basePackage != null) && (!basePackage.equals("")))
            {
		CLILogger.getInstance().printDebugMessage("basePackage: " + basePackage);
		CLILogger.getInstance().printDebugMessage("propertyFile: " + propertyFile);
                localizeProperties.setProperty("base-package", basePackage);
                localizeProperties.setProperty("property-file-name", propertyFile);
                localizePropertiesList.add(localizeProperties);
            }
        }
        if (localizePropertiesList.size() > 0)
        {
            commandLocalStringsManager = 
                               new LocalStringsManager(localizePropertiesList);
        }
    
public static voidsetInstance(java.lang.String packageName, LocalStringsManager stringsManager)
Sets the LocalStringsManager object.

param
packageName name of the package used by the LocalStringsManager.
param
stringsManager LocalStringsManager object

        stringManagers.put(packageName, stringsManager);