Add blueprint wiring to the toaster sample
[controller.git] / opendaylight / md-sal / samples / toaster-provider / src / main / resources / org / opendaylight / blueprint / toaster-provider.xml
diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/resources/org/opendaylight/blueprint/toaster-provider.xml b/opendaylight/md-sal/samples/toaster-provider/src/main/resources/org/opendaylight/blueprint/toaster-provider.xml
new file mode 100644 (file)
index 0000000..01cb313
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+    odl:restart-dependents-on-updates="true" odl:use-default-for-reference-types="true">
+
+  <!-- "restart-dependents-on-updates" is an ODL extension attribute that processes any "property-placeholder"
+       elements and reacts to updates to the corresponding cfg file by restarting this blueprint container any
+       dependent containers that consume OSGi services provided by this container in an atomic and orderly
+       manner.
+
+       "use-default-for-reference-types" is an ODL extension attribute that adds a filter to all services
+       imported via "reference" elements where the "type" property is either not set or set to "default" if
+       the odl:type attribute isn't explicitly specified. This ensures the default implementation is imported
+       if there are other implementations advertised with other types.
+  -->
+
+  <!-- Accesses properties via the etc/org.opendaylight.toaster.cfg file. The properties are made available
+       as variables that can be referenced. The variables are substituted with the actual values read from
+       the cfg file, if present, or the default-properties.
+   -->
+  <cm:property-placeholder persistent-id="org.opendaylight.toaster" update-strategy="none">
+    <cm:default-properties>
+      <cm:property name="databroker-type" value="default"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <!-- Import MD-SAL services. For the DataBroker, we explicitly specify the odl:type which is configurable
+       via the cfg file. In this manner the toaster can be configured to use the default clustered DataBroker
+       or the specialized "pingpong" DataBroker (or any other DataBroker implementation).
+   -->
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="${databroker-type}" />
+  <reference id="notificationService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"/>
+
+  <!-- Create the OpendaylightToaster instance and inject its dependencies -->
+  <bean id="toaster" class="org.opendaylight.controller.sample.toaster.provider.OpendaylightToaster"
+          init-method="register" destroy-method="unregister">
+    <property name="dataProvider" ref="dataBroker"/>
+    <property name="notificationProvider" ref="notificationService"/>
+  </bean>
+
+  <!-- Register the OpendaylightToaster instance as an RPC implementation provider. The "rpc-implementation"
+       element automatically figures out the RpcService interface although it can be explicitly specified.
+   -->
+  <odl:rpc-implementation ref="toaster"/>
+</blueprint>
\ No newline at end of file