git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Updated] (ARIES-1845) Load configuration file without explicit mapping


     [ https://issues.apache.org/jira/browse/ARIES-1845?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

T X updated ARIES-1845:
-----------------------
    Description: 
In Java, a properties file is, in essence, a map of key/value pairs. In Blueprint there does not appear to be a way to assign the values directly to a bean's map. This results in duplicated code and increases maintenance in some cases. For example, consider the following configuration items for an SMTP server:

{code:xml}
    <bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl">
        <property name="mailServerSettings">
            <map>
                <entry key="mail.smtp.auth" value="$(mail.smtp.auth)"/>
                <entry key="mail.smtp.starttls.enable" value="$(mail.smtp.starttls.enable)"/>
                <entry key="mail.smtp.host" value="$(mail.smtp.host)"/>
                <entry key="mail.smtp.port" value="$(mail.smtp.port)"/>
                <entry key="mail.smtp.timeout" value="$(mail.smtp.timeout)"/>
                <entry key="mail.mime.allowutf8" value="$(mail.mime.allowutf8)"/>
            </map>
        </property>
    </bean>
{code}

The redundant nature of this approach is obvious: key/value pairs from a properties file can be mapped to a {{java.util.Map}}'s key/value pairs automatically.

If we wanted to configure more SMTP settings, we'd have to remember to update both the SMTP properties file and the Blueprint mapping, which is duplication of effort. It would be convenient if there was a way to simply load all properties into a map, directly. For example:

{code:xml}
    <bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl">
        <property name="mailServerSettings" source="notification.cfg" />
    </bean>
{code}

In this way, new configuration items need only be added to {{notification.cfg}}.

  was:
In Java, a properties file is, in essence, a map of key/value pairs. In Blueprint there does not appear to be a way to assign the values directly to a bean's map. This results in duplicated code and increases maintenance in some cases. For example, we have the following configuration items for an SMTP server:

{code:xml}
    <bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl">
        <property name="mailServerSettings">
            <map>
                <entry key="mail.smtp.auth" value="$(mail.smtp.auth)"/>
                <entry key="mail.smtp.starttls.enable" value="$(mail.smtp.starttls.enable)"/>
                <entry key="mail.smtp.host" value="$(mail.smtp.host)"/>
                <entry key="mail.smtp.port" value="$(mail.smtp.port)"/>
                <entry key="mail.smtp.timeout" value="$(mail.smtp.timeout)"/>
                <entry key="mail.mime.allowutf8" value="$(mail.mime.allowutf8)"/>
            </map>
        </property>
    </bean>
{code}

The redundant nature of this approach is obvious: key/value pairs from a properties file can be mapped to a {{java.util.Map}}'s key/value pairs automatically.

If we wanted to configure more SMTP settings, we'd have to remember to update both the SMTP properties file and the Blueprint mapping, which is duplication of effort. It would be convenient if there was a way to simply load all properties into a map, directly. For example:

{code:xml}
    <bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl">
        <property name="mailServerSettings" source="notification.cfg" />
    </bean>
{code}

In this way, new configuration items need only be added to {{notification.cfg}}.


> Load configuration file without explicit mapping
> ------------------------------------------------
>
>                 Key: ARIES-1845
>                 URL: https://issues.apache.org/jira/browse/ARIES-1845
>             Project: Aries
>          Issue Type: Improvement
>          Components: Blueprint
>            Reporter: T X
>            Priority: Trivial
>
> In Java, a properties file is, in essence, a map of key/value pairs. In Blueprint there does not appear to be a way to assign the values directly to a bean's map. This results in duplicated code and increases maintenance in some cases. For example, consider the following configuration items for an SMTP server:
> {code:xml}
>     <bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl">
>         <property name="mailServerSettings">
>             <map>
>                 <entry key="mail.smtp.auth" value="$(mail.smtp.auth)"/>
>                 <entry key="mail.smtp.starttls.enable" value="$(mail.smtp.starttls.enable)"/>
>                 <entry key="mail.smtp.host" value="$(mail.smtp.host)"/>
>                 <entry key="mail.smtp.port" value="$(mail.smtp.port)"/>
>                 <entry key="mail.smtp.timeout" value="$(mail.smtp.timeout)"/>
>                 <entry key="mail.mime.allowutf8" value="$(mail.mime.allowutf8)"/>
>             </map>
>         </property>
>     </bean>
> {code}
> The redundant nature of this approach is obvious: key/value pairs from a properties file can be mapped to a {{java.util.Map}}'s key/value pairs automatically.
> If we wanted to configure more SMTP settings, we'd have to remember to update both the SMTP properties file and the Blueprint mapping, which is duplication of effort. It would be convenient if there was a way to simply load all properties into a map, directly. For example:
> {code:xml}
>     <bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl">
>         <property name="mailServerSettings" source="notification.cfg" />
>     </bean>
> {code}
> In this way, new configuration items need only be added to {{notification.cfg}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)