Ejemplo n.º 1
0
        internal static void applySystemProperties(Map map, Map map2)
        {
            Properties  properties  = java.lang.System.getProperties();
            Enumeration enumeration = properties.keys();

            while (enumeration.hasMoreElements())
            {
                string text     = (string)enumeration.nextElement();
                string property = properties.getProperty(text);
                int    num      = String.instancehelper_indexOf(text, 91);
                int    num2     = String.instancehelper_indexOf(text, 93);
                if (num > 0 && num2 > num)
                {
                    string          text2           = String.instancehelper_substring(text, 0, num);
                    string          propName        = String.instancehelper_substring(text, num + 1, num2);
                    RawPropertyData rawPropertyData = (RawPropertyData)map.get(text2);
                    if (rawPropertyData == null)
                    {
                        string text3 = text2;
                        string text4 = text;
                        string text5 = new StringBuilder().append("System property attempting to set parameter  for unknown component ").append(text2).append(" (").append(text).append(')').toString();

                        throw new InternalConfigurationException(text3, text4, text5);
                    }
                    rawPropertyData.add(propName, property);
                }
                else if (String.instancehelper_indexOf(text, 46) == -1)
                {
                    map2.put(text, property);
                }
            }
        }
        private static PropertySheet getPropSheetInstanceFromClass(Class @class, Map map, string name, ConfigurationManager cm)
        {
            RawPropertyData rawPropertyData = new RawPropertyData(name, @class.getName());
            Iterator        iterator        = map.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                object    obj   = entry.getValue();
                if (obj is Class)
                {
                    obj = ((Class)obj).getName();
                }
                rawPropertyData.getProperties().put(entry.getKey(), obj);
            }
            return(new PropertySheet(@class, name, cm, rawPropertyData));
        }
Ejemplo n.º 3
0
        public virtual RawPropertyData flatten(ConfigurationManager cm)
        {
            RawPropertyData rawPropertyData = new RawPropertyData(this.name, this.className);
            Iterator        iterator        = this.properties.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry entry = (Map.Entry)iterator.next();
                object    obj   = entry.getValue();
                if (obj is string && String.instancehelper_startsWith((string)obj, "_{"))
                {
                    obj = cm.getGloPropReference(ConfigurationManagerUtils.stripGlobalSymbol((string)obj));
                }
                rawPropertyData.properties.put(entry.getKey(), obj);
            }
            return(rawPropertyData);
        }
        public virtual void renameConfigurable(string oldName, string newName)
        {
            PropertySheet propertySheet = this.getPropertySheet(oldName);

            if (propertySheet == null)
            {
                string text = new StringBuilder().append("no configurable (to be renamed) named ").append(oldName).append(" is contained in the CM").toString();

                throw new RuntimeException(text);
            }
            ConfigurationManagerUtils.renameComponent(this, oldName, newName);
            this.symbolTable.remove(oldName);
            this.symbolTable.put(newName, propertySheet);
            RawPropertyData rawPropertyData = (RawPropertyData)this.rawPropertyMap.remove(oldName);

            this.rawPropertyMap.put(newName, new RawPropertyData(newName, rawPropertyData.getClassName(), rawPropertyData.getProperties()));
            this.fireRenamedConfigurable(oldName, newName);
        }
        public virtual void addConfigurable(Configurable configurable, string name)
        {
            if (this.symbolTable.containsKey(name))
            {
                string text = "tried to override existing component name";

                throw new IllegalArgumentException(text);
            }
            RawPropertyData rawPropertyData = new RawPropertyData(name, Object.instancehelper_getClass(configurable).getName());
            PropertySheet   propertySheet   = new PropertySheet(configurable, name, rawPropertyData, this);

            this.symbolTable.put(name, propertySheet);
            this.rawPropertyMap.put(name, rawPropertyData);
            Iterator iterator = this.changeListeners.iterator();

            while (iterator.hasNext())
            {
                ConfigurationChangeListener configurationChangeListener = (ConfigurationChangeListener)iterator.next();
                configurationChangeListener.componentAdded(this, propertySheet);
            }
        }
Ejemplo n.º 6
0
        public PropertySheet(Class confClass, string name, ConfigurationManager cm, RawPropertyData rpd)
        {
            this.registeredProperties = new HashMap();
            this.propValues           = new HashMap();
            this.rawProps             = new HashMap();
            this.ownerClass           = confClass;
            this.cm           = cm;
            this.instanceName = name;
            PropertySheet.parseClass(confClass);
            this.setConfigurableClass(confClass);
            Map properties = rpd.flatten(cm).getProperties();

            this.rawProps = new HashMap(rpd.getProperties());
            Iterator iterator = this.rawProps.keySet().iterator();

            while (iterator.hasNext())
            {
                string text = (string)iterator.next();
                this.propValues.put(text, properties.get(text));
            }
        }
        public virtual PropertySheet getPropertySheet(string instanceName)
        {
            if (!this.symbolTable.containsKey(instanceName))
            {
                RawPropertyData rawPropertyData = (RawPropertyData)this.rawPropertyMap.get(instanceName);
                if (rawPropertyData != null)
                {
                    string className = rawPropertyData.getClassName();
                    try
                    {
                        try
                        {
                            try
                            {
                                Class         @class        = Class.forName(className, ConfigurationManager.__GetCallerID());
                                PropertySheet propertySheet = new PropertySheet(@class.asSubclass(ClassLiteral <Configurable> .Value), instanceName, this, rawPropertyData);
                                this.symbolTable.put(instanceName, propertySheet);
                            }
                            catch (ClassNotFoundException ex)
                            {
                                java.lang.System.err.println(new StringBuilder().append("class not found !").append(ex).toString());
                                goto IL_11B;
                            }
                        }
                        catch (System.Exception ex3)
                        {
                            java.lang.System.err.println(new StringBuilder().append("can not cast class !").append(ex3).toString());
                            goto IL_11B;
                        }
                    }
                    catch (System.Exception ex6)
                    {
                        java.lang.System.err.println(new StringBuilder().append("couldn't load class !").append(ex6).toString());
                    }
                }
            }
IL_11B:
            return((PropertySheet)this.symbolTable.get(instanceName));
        }
Ejemplo n.º 8
0
 public PropertySheet(Configurable configurable, string name, RawPropertyData rpd, ConfigurationManager ConfigurationManager) : this(Object.instancehelper_getClass(configurable), name, ConfigurationManager, rpd)
 {
     this.owner = configurable;
 }