FileDocCategorySizeDatePackage
StringManager.javaAPI DocGlassfish v2 API5206Fri May 04 22:36:22 BST 2007com.sun.enterprise.admin.jmx.remote

StringManager

public class StringManager extends Object implements com.sun.enterprise.admin.jmx.remote.IStringManager
This class acts as an adapter to use the appserver internal StringManager. It implements the IStringManager interface that is defined for an jmx-connector string-manager. At the same time it composes a delegatee com.sun.enterprise.util.i18n.StringManager object. The method invocation on this delegatee is through reflection to avoid any compile time dependencies

Fields Summary
private static final Logger
logger
private static Class
asStringManagerClass
private static Method
getStr
private static Method
getStrDef
private static Method
getStrGeneric
private static Method
getManager
private Object
asStringManager
Constructors Summary
public StringManager(String packageName)

    
       
        try {
            if (asStringManagerClass == null) {
                asStringManagerClass = Class.forName("com.sun.enterprise.util.i18n.StringManager");
                getStr = asStringManagerClass.getMethod("getString", new Class[] { String.class});
                getStrDef = asStringManagerClass.getMethod("getString", new Class[] { String.class, Object.class });
                getStrGeneric = asStringManagerClass.getMethod("getString", new Class[] { String.class, Object[].class });
                getManager = asStringManagerClass.getMethod("getManager", new Class[] { String.class });
            }
            
            asStringManager = getManager.invoke(asStringManagerClass, new Object[] { packageName });
        } catch (Throwable e) {
            e.printStackTrace();
            StackTraceElement[] ste = e.getStackTrace();
            for (int i =0; i<ste.length; i++) logger.severe(ste[i].toString());
            logger.severe("StringManager could not be configured");
        }
    
Methods Summary
public java.lang.StringgetString(java.lang.String key)

        try {
            return (String) getStr.invoke(asStringManager, new Object[] { key });
        } catch(Exception ex) {
            logger.severe("Method invocation failed on com.sun.enterprise.util.i18n.StringManager");
            return null;
        }
    
public java.lang.StringgetString(java.lang.String key, java.lang.Object arg)

        try {
            return (String) getStrDef.invoke(asStringManager, new Object[] { key, arg });
        } catch(Exception ex) {
            logger.severe("Method invocation failed on com.sun.enterprise.util.i18n.StringManager");
            return null;
        }
    
public java.lang.StringgetString(java.lang.String key, java.lang.Object[] args)

        try {
            return (String) getStrGeneric.invoke(asStringManager, new Object[] { key, args });
        } catch(Exception ex) {
            logger.severe("Method invocation failed on com.sun.enterprise.util.i18n.StringManager");
            return null;
        }