commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34353] New: - [configuration]Provide support for declaring and creating objects
Date Thu, 07 Apr 2005 17:45:32 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34353>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34353

           Summary: [configuration]Provide support for declaring and
                    creating objects
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Configuration
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: oliver.heger@t-online.de


A useful enhancement for the configuration API could be a way to create and
initialize objects whose class and initialization parameters are defined in a
configuration file.

The idea is that both the class name and initialization parameters for an object
are defined in a standard format. A createObject(String key) method (which might
fit best in DataConfiguration?) would extract the class name from the specified
property, create the object using reflection and then populate properties via
[beanutils].

For the concrete format for declaring objects in a configuration file there are
many possibilities. We have to define a format which is easy to use, but
although suports complex initialization parameters. A possible object
declaration could look as follows (here in XML flavour, but other configuration
sources are of course possible, too):

<myobject>
  <class>package.ClassName</class>
  <args>
    <arg1>value1</arg1>
    <arg2>value2></arg2>
    ...
  </args>
</myobject>

We could even go a step further and define an interface
public interface Configurable
{
  void initialize(Configuration config);
}

If the newly created object implements this interface, its initialize() method
will be called and a sub configuration will be passed that contains the content
of the <args> section. This would allow for arbitrary complex and also
hierarchical initialization parameters. It's a bit similar to what IoC
frameworks do.

Side note: If we add more features to the configuration definition files
processed by ConfigurationFactory (e.g locators or declarations for reloading
strategies) and use a XMLConfiguration to load these files, the proposed object
creation facility may come in handy.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message