FileDocCategorySizeDatePackage
DefaultSettings.javaAPI DocExample4174Mon Jul 23 13:26:54 BST 2007org.apache.struts2.config

DefaultSettings

public class DefaultSettings extends Settings
DefaultSettings implements optional methods of Settings.

This class creates and delegates to other settings by using an internal {@link DelegatingSettings} object.

Fields Summary
protected Log
log
The logging instance for this class.
Settings
delegate
The Settings object that handles API calls.
Constructors Summary
public DefaultSettings()
Constructs an instance by loading the standard property files, any custom property files (struts.custom.properties), and any custom message resources ().

Since this constructor combines Settings from multiple resources, it utilizes a {@link DelegatingSettings} instance, and all API calls are handled by that instance.


                                                        
      

        ArrayList<Settings> list = new ArrayList<Settings>();

        // stuts.properties, default.properties
        try {
            list.add(new PropertiesSettings("struts"));
        } catch (Exception e) {
            log.warn("DefaultSettings: Could not find or error in struts.properties", e);
        }

        Settings[] settings = new Settings[list.size()];
        delegate = new DelegatingSettings(list.toArray(settings));

        // struts.custom.properties
        try {
            StringTokenizer customProperties = new StringTokenizer(delegate.getImpl(StrutsConstants.STRUTS_CUSTOM_PROPERTIES), ",");

            while (customProperties.hasMoreTokens()) {
                String name = customProperties.nextToken();

                try {
                    list.add(new PropertiesSettings(name));
                } catch (Exception e) {
                    log.error("DefaultSettings: Could not find " + name + ".properties. Skipping.");
                }
            }

            settings = new Settings[list.size()];
            delegate = new DelegatingSettings(list.toArray(settings));
        } catch (IllegalArgumentException e) {
            // Assume it's OK, since IllegalArgumentException is thrown  
            // when Settings is unable to find a certain setting,
            // like the struts.custom.properties, which is commented out
        }

    
Methods Summary
public java.lang.StringgetImpl(java.lang.String aName)

        return delegate.getImpl(aName);
    
public booleanisSetImpl(java.lang.String aName)

        return delegate.isSetImpl(aName);
    
public java.util.IteratorlistImpl()

        return delegate.listImpl();
    
public voidsetImpl(java.lang.String name, java.lang.String value)

        delegate.setImpl(name, value);