How to define dynamic list of constant values in Blueprint

Solution Verified - Updated -


  • JBoss Fuse 6.1


I would like to define a list of the constant tokens - let's say ["foo", "bar", "baz"]. I would like to access the latter list from all the bundles deployed to the given Fuse instance. I would like to change the contents of the list from time to time.

What is the best way to achieve this in Blueprint and OSGi environment?


In the OSGi environment, the best way to keep the singleton list of the constant elements is to define it as the OSGi service, just as demonstrated on the Blueprint snippet below. With this approach, we can update the list definition by replacing the OSGi bundle in which the list has been defined.

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns=""

    <!-- Constant list service -->

    <bean id="tokens" class="java.util.Arrays" factory-method="asList">

    <service interface="java.util.List" ref="tokens"/>

    <!-- Properties configuration -->

    <cm:property-placeholder id="myblueprint.placeholder" persistent-id="">
            <cm:property name="foo" value="foo"/>
            <cm:property name="bar" value="bar"/>


In the example above we additionally use the OSGi Compendium Configuration Admin Service to optionally override the particular values of the list. Thanks to Admin Service we can change the value of the particular tokens even without redeploying the Blueprint bundle containing the list definition (we can override the token values by editing the KARAF_HOME/etc/ file).

The zip file attached to the hereby article contains runnable test example demonstrating the described concept.


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.