import org.opendaylight.controller.sal.binding.dom.serializer.api.ValueWithQName
import org.opendaylight.controller.sal.binding.dom.serializer.api.DataContainerCodec
import org.opendaylight.yangtools.binding.generator.util.Types
+import org.osgi.framework.BundleContext
+import java.util.Hashtable
+import org.osgi.framework.ServiceRegistration
-class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaServiceListener {
+class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaServiceListener, AutoCloseable {
@Property
ClassPool pool;
val promisedTypeDefinitions = HashMultimap.<Type, SettableFuture<GeneratedTypeBuilder>>create;
val promisedSchemas = HashMultimap.<Type, SettableFuture<SchemaNode>>create;
+
+ ServiceRegistration<SchemaServiceListener> listenerRegistration
override onGlobalContextUpdated(SchemaContext arg0) {
recreateBindingContext(arg0);
}
}
- public def void start() {
+ public def void start(BundleContext ctx) {
binding = new TransformerGenerator(pool);
registry = new LazyGeneratedCodecRegistry()
registry.generator = binding
binding.typeToDefinition = typeToDefinition
binding.typeToSchemaNode = typeToSchemaNode
binding.typeDefinitions = typeDefinitions
-
+ if(ctx !== null) {
+ listenerRegistration = ctx.registerService(SchemaServiceListener,this,new Hashtable<String,String>());
+ }
}
private def getTypeDefinition(Type type) {
}
promisedSchemas.removeAll(builder);
}
+
+ override close() throws Exception {
+ listenerRegistration?.unregister();
+ }
+
}