Details
-
Improvement
-
Status: Open
-
Trivial
-
Resolution: Unresolved
-
None
-
None
-
None
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:
<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>
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:
<bean class="EmailNotificationServerImpl" id="emailNotificationServerImpl"> <property name="mailServerSettings" source="notification.cfg" /> </bean>
In this way, new configuration items need only be added to notification.cfg.