FileDocCategorySizeDatePackage
ConfigBeansFactory.javaAPI DocGlassfish v2 API11652Fri May 04 22:31:18 BST 2007com.sun.enterprise.config

ConfigBeansFactory

public class ConfigBeansFactory extends Object
A factory to create ConfigContext objects.

Fields Summary
Constructors Summary
Methods Summary
private static java.lang.StringconvertName(java.lang.String name)
Convert a DTD name into a bean name: Any - or _ character is removed. The letter following - and _ is changed to be upper-case. If the user mixes upper-case and lower-case, the case is not changed. If the Word is entirely in upper-case, the word is changed to lower-case (except the characters following - and _) The first letter is always upper-case.

        CharacterIterator  ci;
        StringBuffer    n = new StringBuffer();
        boolean    up = true;
        boolean    keepCase = false;
        char    c;
        
        // hack need for schema2beans limitation.
        if(name.equals("property")) {
            name = "element-property";
        }
        
        ci = new StringCharacterIterator(name);
        c = ci.first();
        
        // If everything is uppercase, we'll lowercase the name.
        while (c != CharacterIterator.DONE) {
            if (Character.isLowerCase(c)) {
                keepCase = true;
                break;
            }
            c = ci.next();
        }
        
        c = ci.first();
        while (c != CharacterIterator.DONE) {
            if (c == '-" || c == '_")
                up = true;
            else {
                if (up)
                    c = Character.toUpperCase(c);
                else
                    if (!keepCase)
                        c = Character.toLowerCase(c);
                n.append(c);
                up = false;
            }
            c = ci.next();
        }
        return n.toString();
    
public static ConfigBeangetConfigBeanByXPath(ConfigContext ctx, java.lang.String xpath)

         ConfigBean cb = ctx.getRootConfigBean();
         
         if(cb == null) throw new ConfigException("getConfigBeanByXPath: null context");
         cb.setConfigContext(ctx);
         return getConfigBeanByXPath(cb, xpath);
    
public static ConfigBeangetConfigBeanByXPath(ConfigBean server, java.lang.String xpath)

        Object ret = server;
        try {             
            XpathSupport xp = new XpathSupport(xpath);
            ArrayList arr = xp.getMethodArray();
            
            if(arr.size() == 0 || arr.size() == 1) {
                ((ConfigBean) ret).setXPath(xpath); //fixed on 040102
                return (ConfigBean) ret;
            }
            
            for(int i=1;i<arr.size();i++) {
                MethodCaller methodCaller = (MethodCaller) arr.get(i);
				//_logger.log(Level.FINE,"Method = "+methodCaller);
                Method m = ret.getClass().getMethod(methodCaller.getMethodName(), methodCaller.getParamClasses());
				//_logger.log(Level.FINE,"m=" + m);
                ret = m.invoke(ret, methodCaller.getParams());
            }
            
            ((ConfigBean) ret).setConfigContext(server.getConfigContext());
            ((ConfigBean) ret).setXPath(xpath);
            return (ConfigBean) ret;
        } catch(Throwable t) {
			//_logger.log(Level.INFO,"config.get_config_bean_xpath_exception",t);
        }
        return null;
        
    
public static java.lang.StringgetConfigBeanNameByXPath(java.lang.String xpath)
Utility method to get the bean name based on an xpath

        XpathSupport xp = new XpathSupport(xpath);
        ArrayList arr = xp.getClassNameArray();
        
        if(arr.size() == 0) return null;
        return (String)arr.get(arr.size()-1);