DPML
DPML Metro: Map Entry Directive
HomeUtilitiesStationMetro
Map Entry Directive
Description

Declaration of a context entry wherein nested entries are used to construct an instance of java.util.Map.

Map Attributes
key The entry key (required).
class Optional declaration of a classname to be instantiated using a container resolved map instance. The class must refer to an implementation class that takes a java.util.Map as a single constructor argument and must be assignable to the context entry return type.
Map Nested Elements
entry Defines a key and value to be added to the map instance.
Examples
General Example

The following example demonstrates the creation of three map-based context entries. The first entry demonstrates the default construction wherein the container handles the creation a Map instance using nested entries as map key and value bindings. The second example demonstrates the declaration of an alternative map implementation class (in this case the java.util.TreeMap) which will be instantiated with the resolved map as a single constructor argument. The third example demonstrates the construction of a map containing color values assigned to keys (note that a default implementation class cannot be resolved for map entries - as such the class attribute must be used for any non-string value declaration).

<context>
  <map key="primary">
    <entry key="message" value="Hello from the map entry"/>
    <entry key="foo" value="bar"/>
  </map>
  <map key="secondary" class="java.util.TreeMap">
    <entry key="foo" value="bar"/>
    <entry key="ping" value="pong"/>
  </map>
  <map key="colors">
    <entry key="red" class="java.awt.Color" method="RED"/>
    <entry key="white" class="java.awt.Color" method="WHITE"/>
    <entry key="blue" class="java.awt.Color" method="BLUE"/>
  </map>
</context>