Remove global BindingToNormalizedNodeCodec instance 43/40743/7
authorTom Pantelis <tpanteli@brocade.com>
Wed, 22 Jun 2016 20:01:49 +0000 (16:01 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 21 Jul 2016 18:47:47 +0000 (18:47 +0000)
commit1bec49d0736bfd9baad39d7fcdf80a1daac73386
tree9c0a8f4ad81e43a30887057d82814afd8f07db1a
parentaebe2884329d666f661be53e2de3a57e4fcf61f1
Remove global BindingToNormalizedNodeCodec instance

The BindingToNormalizedNodeCodec was made a global static instance for
backwards compatibility for CSS users that inject the binding-dom-mapping-service
identity which defines the provided service as the concrete
BindingToNormalizedNodeCodec class instead of an interface. Therefore
the global static instance was created via blueprint and advertised via
its interfaces and was obtained via the static reference by the
RuntimeMappingModule for use by CSS users. The RuntimeMappingModule must
return an instance of BindingToNormalizedNodeCodec in order to provide
the binding-dom-mapping-service so obtaining the blueprint advertised OSGi
service via its interfaces and casting to BindingToNormalizedNodeCodec
failed b/c Aries creates a service proxy which loses the fact that it's a
BindingToNormalizedNodeCodec instance.

However the global BindingToNormalizedNodeCodec instance is not clean and
is problematic for supporting blueprint container restarts. Aries supports
concrete class proxies so I added an additional service export for the
BindingToNormalizedNodeCodec class in the binding-broker blueprint XML.
In addition, the blueprint XML now calls a new method, "newInstance", on the
BindingToNormalizedNodeCodecFactory to create a new instance and calls a
new method, "registerInstance", to register it with the SchemaService. The
returned ListenerRegistration instance is put into a bean so it can be
closed on destroy. The RuntimeMappingModule now obtains the
BindingToNormalizedNodeCodec instance from the OSGi registry as the other
blueprint-bridged CSS modules do. This eliminates the need for the global
instance.

Change-Id: I969ad5470967a81b37078393701c69d1898086cd
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodecFactory.java
opendaylight/md-sal/sal-binding-broker/src/main/resources/org/opendaylight/blueprint/binding-broker.xml
opendaylight/md-sal/sal-binding-config/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java