You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "T X (JIRA)" <ji...@apache.org> on 2018/10/10 20:00:05 UTC

[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, 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 properties can be mapped to a java.util.Map key/value pairs automatically.

If we wanted to configure more SMTP settings, we'd have to remember to update both the SMTP configuration 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, a new configuration item 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 properties can be mapped to a java.util.Map key/value pairs automatically.

If we wanted to configure more SMTP settings, we'd have to remember to update both the SMTP configuration 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, a new configuration item 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, 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 properties can be mapped to a java.util.Map key/value pairs automatically.
> If we wanted to configure more SMTP settings, we'd have to remember to update both the SMTP configuration 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, a new configuration item need only be added to {{notification.cfg}}.



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