Extract dom-serializer-api|impl from binding-broker-impl 93/4593/9
authorTony Tkacik <ttkacik@cisco.com>
Sat, 25 Jan 2014 17:29:57 +0000 (18:29 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Sat, 25 Jan 2014 19:45:53 +0000 (20:45 +0100)
Change-Id: I1b2844bfac5062fd15c1f011c3104b3dddb33b51
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
65 files changed:
opendaylight/config/config-manager/pom.xml
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java [new file with mode: 0644]
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/011-remote-zeromq.xml [deleted file]
opendaylight/md-sal/clustered-data-store/integrationtest/src/test/java/org/opendaylight/controller/datastore/ClusteredDataStoreIT.java
opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/controller.xml
opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/logback.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/CodeGenerationException.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RuntimeCodeGenerator.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/XtendHelper.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/ClassGenerator.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/FieldGenerator.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/JavassistUtils.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/MethodGenerator.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/AugmentationCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ChoiceCaseCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ChoiceCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/CodecRegistry.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/DataContainerCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/DomCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/IdentifierCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/IdentitityCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/InstanceIdentifierCodec.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ValueWithQName.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/BindingClassListener.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecMapping.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecTypeUtils.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/GeneratorListener.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/IntermediateMapping.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/StaticFieldInitializer.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingDomConnectorDeployer.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMappingService.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMountPointForwarder.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DeserializationException.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/forward/DomForwardedBindingBrokerImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/ClassLoaderUtils.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/YangSchemaUtils.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/osgi/Activator.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/AbstractDataServiceTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java
opendaylight/md-sal/sal-binding-it/pom.xml
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaService.java
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaServiceListener.java [deleted file]
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/SchemaServiceImpl.java with 96% similarity]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/SchemaServiceActivator.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/SchemaServiceProxy.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend

index b5e73dd..2fd9f08 100644 (file)
             <artifactId>concepts</artifactId>
             <version>${yangtools.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-data-impl</artifactId>
+            <version>${yangtools.version}</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java
new file mode 100644 (file)
index 0000000..06a5826
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.manager.impl.osgi;
+
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Every time factory is added or removed, blank transaction is triggered to handle
+ * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory, org.osgi.framework.BundleContext)}
+ * functionality.
+ */
+public class BindingIndependentMappingServiceTracker implements ServiceTrackerCustomizer<BindingIndependentMappingService, BindingIndependentMappingService> {
+    private static final Logger logger = LoggerFactory.getLogger(BindingIndependentMappingServiceTracker.class);
+
+    private final ConfigManagerActivator activator;
+    private final BundleContext ctx;
+    private BindingIndependentMappingService service;
+
+    public BindingIndependentMappingServiceTracker(BundleContext context, ConfigManagerActivator activator) {
+        this.ctx = context;
+        this.activator = activator;
+    }
+
+    @Override
+    public synchronized BindingIndependentMappingService addingService(
+            ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference) {
+
+        if (service != null) {
+            // FIXME
+            // Second registration appears from
+            // org.opendaylight.controller.config.yang.md.sal.binding.impl.RuntimeMappingModule
+            logger.debug("BindingIndependentMappingService was already added as {}" + " now added as {}",
+                    service, ctx.getService(moduleFactoryServiceReference));
+            return null;
+        }
+
+        BindingIndependentMappingService service = ctx.getService(moduleFactoryServiceReference);
+        this.service = service;
+        CodecRegistry codecRegistry = service.getCodecRegistry();
+        logger.warn("Codec registry acquired {}", codecRegistry);
+        activator.initConfigManager(ctx, codecRegistry);
+        return service;
+    }
+
+    @Override
+    public void modifiedService(ServiceReference <BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService o) {
+        // TODO crash
+    }
+
+    @Override
+    public void removedService(ServiceReference<BindingIndependentMappingService> moduleFactoryServiceReference, BindingIndependentMappingService    o) {
+        // TODO crash
+    }
+}
index be602e5..57aa74c 100644 (file)
@@ -9,11 +9,14 @@ package org.opendaylight.controller.config.manager.impl.osgi;
 
 import java.lang.management.ManagementFactory;
 
+import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
 
 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
 import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator;
 import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -30,11 +33,28 @@ public class ConfigManagerActivator implements BundleActivator {
     private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator;
     private ServiceRegistration configRegistryServiceRegistration;
 
+    private ServiceTracker<BindingIndependentMappingService, BindingIndependentMappingService> tracker;
+
     @Override
     public void start(BundleContext context) throws Exception {
+        BindingIndependentMappingServiceTracker mappingServiceTracker = new BindingIndependentMappingServiceTracker(
+                context, this);
+        tracker = new ServiceTracker<BindingIndependentMappingService, BindingIndependentMappingService>(
+                context, BindingIndependentMappingService.class, mappingServiceTracker);
+
+        logger.debug("Waiting for codec registry");
+
+        tracker.open();
+    }
+
+    void initConfigManager(BundleContext context, CodecRegistry codecRegistry) {
         BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver =
                 new BundleContextBackedModuleFactoriesResolver(context);
         MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+
+
+        // TODO push codecRegistry/IdentityCodec to dependencyResolver
+
         configRegistry = new ConfigRegistryImpl(
                 bundleContextBackedModuleFactoriesResolver, configMBeanServer);
 
@@ -43,7 +63,11 @@ public class ConfigManagerActivator implements BundleActivator {
 
         // register config registry to jmx
         configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer);
-        configRegistryJMXRegistrator.registerToJMX(configRegistry);
+        try {
+            configRegistryJMXRegistrator.registerToJMX(configRegistry);
+        } catch (InstanceAlreadyExistsException e) {
+            throw new RuntimeException("Config Registry was already registered to JMX", e);
+        }
 
         // track bundles containing factories
         BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(configRegistry);
@@ -56,6 +80,11 @@ public class ConfigManagerActivator implements BundleActivator {
 
     @Override
     public void stop(BundleContext context) throws Exception {
+        try {
+            tracker.close();
+        } catch (Exception e) {
+            logger.warn("Exception while closing tracker", e);
+        }
         try {
             configRegistry.close();
         } catch (Exception e) {
index d306b5d..de9ac23 100644 (file)
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
                     <name>hash-map-data-store</name>
                 </module>
-                <module>
-                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store">prefix:dom-clustered-store-impl</type>
-                    <name>cluster-data-store</name>
-                </module>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
                     <name>dom-broker</name>
                                        <name>hash-map-data-store</name>
                                        <provider>/modules/module[type='hash-map-data-store'][name='hash-map-data-store']</provider>
                                </instance>
-                               <instance>
-                                       <name>cluster-data-store</name>
-                                       <provider>/modules/module[type='dom-clustered-store-impl'][name='cluster-data-store']</provider>
-                               </instance>
                        </service>
                        <service>
                                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&amp;revision=2013-10-28</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&amp;revision=2013-10-28</capability>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store?module=odl-sal-dom-clustered-store-cfg&amp;revision=2013-10-28</capability>
     </required-capabilities>
 
 </snapshot>
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/011-remote-zeromq.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/011-remote-zeromq.xml
deleted file mode 100644 (file)
index 2b0e929..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<snapshot>
-
-    <configuration>
-    
-        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-                <module>
-                   <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">prefix:remote-zeromq-rpc-server</type> 
-                   <name>remoter</name>
-                   <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
-                   <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
-                       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
-                       <name>dom-broker</name>
-                   </dom-broker>
-               </module>
-            </modules>
-            
-            <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-            </services>
-        </data>
-
-    </configuration>
-    
-    <required-capabilities>
-        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc?module=odl-sal-dom-rpc-remote-cfg&amp;revision=2013-10-28</capability>
-    </required-capabilities>
-
-</snapshot>
-
index c2fe5f5..a1fa9e3 100644 (file)
@@ -8,6 +8,22 @@
 
 package org.opendaylight.controller.datastore;
 
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Inject;
+
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -27,23 +43,8 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.inject.Inject;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemPackages;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
 @RunWith(PaxExam.class)
+//@ExamReactorStrategy(PerClass.class)
 public class ClusteredDataStoreIT {
     private Logger log = LoggerFactory.getLogger(ClusteredDataStoreIT.class);
     // get the OSGI bundle context
@@ -95,30 +96,10 @@ public class ClusteredDataStoreIT {
                 mavenBundle("org.opendaylight.controller", "sal.implementation").versionAsInProject(),
                 mavenBundle("org.opendaylight.controller", "protocol_plugins.stub").versionAsInProject(),
 
-                // sal-common-impl
-                mavenBundle("org.eclipse.xtend", "org.eclipse.xtend.lib").versionAsInProject(),
-                mavenBundle("org.eclipse.xtext", "org.eclipse.xtext.xbase.lib").versionAsInProject(),
-
-                // clustered-data-store-implementation dependencies
-                mavenBundle("com.google.guava", "guava").versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-core-api").versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-common-api").versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-common-util").versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-common-impl").versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "yang-model-api").versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "yang-binding").versionAsInProject(),
-
-                // sal-common-api dependencies
-                mavenBundle("org.opendaylight.controller", "sal-common").versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "yang-common").versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "concepts").versionAsInProject(),
                 mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
                 // adding new maven bundles
                 mavenBundle("org.mockito", "mockito-all").versionAsInProject(),
 
-                // yang-data-api
-                mavenBundle("org.opendaylight.yangtools", "yang-data-api").versionAsInProject(),
-
                 // needed by hosttracker
                 mavenBundle("org.opendaylight.controller", "clustered-datastore-implementation").versionAsInProject(),
                 mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
index 96cf639..5f43ddc 100644 (file)
@@ -6,22 +6,6 @@
                 <capability>
                     urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store?module=odl-sal-dom-clustered-store-cfg&amp;revision=2013-10-28
                 </capability>
-                <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&amp;revision=2013-10-28</capability>
-                <capability>
-                    urn:opendaylight:params:xml:ns:yang:controller:config?module=config&amp;revision=2013-04-05
-                </capability>
-                <capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
-                <capability>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&amp;revision=2010-10-04</capability>
-                <capability>urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&amp;revision=2013-06-17
-                </capability>
-                <capability>urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&amp;revision=2010-09-24
-                </capability>
-                <capability>urn:ietf:params:netconf:capability:rollback-on-error:1.0</capability>
-                <capability>urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&amp;revision=2010-09-24
-                </capability>
-                <capability>
-                    urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&amp;revision=2013-10-28
-                </capability>
             </required-capabilities>
             <configuration>
 
index 17797dd..50304ff 100644 (file)
         <module>sal-rest-connector</module>
         <module>sal-netconf-connector</module>
 
-        <module>remoterpc-routingtable/implementation</module>
-        <module>sal-remoterpc-connector/implementation</module>
-        <!-- Clustered Data Store -->
-        <module>clustered-data-store/implementation</module>
-
+        
         <module>inventory-manager</module>
         <module>statistics-manager</module>
         <module>topology-manager</module>
 
         <!-- Compability Packages -->
         <module>compatibility</module>
+
+       <!-- Clustering
+       <module>remoterpc-routingtable/implementation</module>
+        <module>sal-remoterpc-connector/implementation</module>
+        <module>clustered-data-store/implementation</module>
+        -->
+        
     </modules>
 
 
@@ -77,7 +80,7 @@
             </activation>
             <modules>
                 <module>sal-binding-it</module>
-                <module>clustered-data-store/integrationtest</module>
+                <!--module>clustered-data-store/integrationtest</module -->
                 <!--module>zeromq-routingtable/integrationtest</module -->
                 <!--module>sal-remoterpc-connector/integrationtest</module -->
                 <!--module>test/sal-rest-connector-it</modulei -->
@@ -91,7 +94,7 @@
                 </property>
             </activation>
             <build>
-                <!-- Put the IDE's build output in a folder other than target, 
+                <!-- Put the IDE's build output in a folder other than target,
                     so that IDE builds don't interact with Maven builds -->
                 <directory>target-ide</directory>
             </build>
                     <artifactId>maven-bundle-plugin</artifactId>
                     <version>${bundle.plugin.version}</version>
                     <extensions>true</extensions>
-                    <!--executions> <execution> <id>bundle-manifest</id> 
-                        <phase>process-classes</phase> <goals> <goal>manifest</goal> </goals> </execution> 
+                    <!--executions> <execution> <id>bundle-manifest</id>
+                        <phase>process-classes</phase> <goals> <goal>manifest</goal> </goals> </execution>
                         </executions -->
                     <configuration>
                         <instructions>
                     <artifactId>jacoco-maven-plugin</artifactId>
                     <version>${jacoco.version}</version>
                 </plugin>
-                <!--This plugin's configuration is used to store Eclipse 
+                <!--This plugin's configuration is used to store Eclipse
                     m2e settings only. It has no influence on the Maven build itself. -->
                 <plugin>
                     <groupId>org.eclipse.m2e</groupId>
index 4cf681f..68358b3 100644 (file)
@@ -72,6 +72,8 @@
                         <phase>generate-sources</phase>
                         <goals>
                             <goal>add-source</goal>
+
+
                         </goals>
                         <configuration>
                             <sources>
@@ -89,6 +91,7 @@
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                        <Bundle-Activator>org.opendaylight.controller.sal.binding.osgi.Activator</Bundle-Activator>
                         <Export-package>
                             org.opendaylight.controller.sal.binding.spi.*,
                         </Export-package>
                             org.opendaylight.controller.sal.binding.codegen,
                             org.opendaylight.controller.sal.binding.codegen.*,
                             org.opendaylight.controller.sal.binding.dom.*,
+                            org.opendaylight.controller.sal.binding.osgi.*,
                         </Private-Package>
                     </instructions>
                 </configuration>
index 185b37b..0ae4336 100644 (file)
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;\r
 \r
 import java.util.concurrent.ExecutorService;\r
-import java.util.concurrent.Executors;\r
-import java.util.concurrent.ScheduledExecutorService;\r
 \r
-import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter;\r
 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;\r
-import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;\r
 import org.opendaylight.controller.sal.binding.impl.RootDataBrokerImpl;\r
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;\r
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;\r
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;\r
 import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedDataBrokerImpl;\r
-import org.opendaylight.controller.sal.core.api.Broker;\r
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;\r
-import org.opendaylight.controller.sal.core.api.data.DataProviderService;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;\r
 import org.osgi.framework.BundleContext;\r
-\r
-import com.google.common.util.concurrent.MoreExecutors;\r
+import org.osgi.framework.ServiceReference;\r
 \r
 /**\r
 *\r
@@ -57,13 +48,13 @@ public final class DataBrokerImplModule extends
     @Override\r
     public java.lang.AutoCloseable createInstance() {\r
         RootDataBrokerImpl dataBindingBroker;\r
-        \r
-        \r
+\r
+\r
         ExecutorService listeningExecutor = SingletonHolder.getDefaultCommitExecutor();\r
-        \r
-        if (getDomBrokerDependency() != null && getMappingServiceDependency() != null) {\r
-            \r
-            dataBindingBroker = createDomConnectedBroker(listeningExecutor);\r
+        BindingIndependentMappingService potentialMapping = resolveMappingServiceDependency();\r
+        if (getDomBrokerDependency() != null && potentialMapping != null) {\r
+\r
+            dataBindingBroker = createDomConnectedBroker(listeningExecutor,potentialMapping);\r
         } else {\r
             dataBindingBroker = createStandAloneBroker(listeningExecutor);\r
         }\r
@@ -71,16 +62,28 @@ public final class DataBrokerImplModule extends
 \r
         return dataBindingBroker;\r
     }\r
+    private BindingIndependentMappingService resolveMappingServiceDependency() {\r
+        if(getMappingService() != null) {\r
+            return getMappingServiceDependency();\r
+        }\r
+        \r
+        ServiceReference<BindingIndependentMappingService> potentialMappingService = bundleContext.getServiceReference(BindingIndependentMappingService.class);\r
+        if(potentialMappingService != null) {\r
+            return bundleContext.getService(potentialMappingService);\r
+        }\r
+        return null;\r
+    }\r
+\r
     private RootDataBrokerImpl createStandAloneBroker(ExecutorService listeningExecutor) {\r
         RootDataBrokerImpl broker = new RootDataBrokerImpl();\r
         broker.setExecutor(listeningExecutor);\r
         return broker;\r
     }\r
 \r
-    private RootDataBrokerImpl createDomConnectedBroker(ExecutorService listeningExecutor) {\r
+    private RootDataBrokerImpl createDomConnectedBroker(ExecutorService listeningExecutor, BindingIndependentMappingService mappingService) {\r
         DomForwardedDataBrokerImpl forwardedBroker = new DomForwardedDataBrokerImpl();\r
         forwardedBroker.setExecutor(listeningExecutor);\r
-        BindingIndependentConnector connector = BindingDomConnectorDeployer.createConnector(getMappingServiceDependency());\r
+        BindingIndependentConnector connector = BindingDomConnectorDeployer.createConnector(mappingService);\r
         getDomBrokerDependency().registerProvider(forwardedBroker, getBundleContext());\r
         ProviderSession domContext = forwardedBroker.getDomProviderContext();\r
         forwardedBroker.setConnector(connector);\r
index 99b7ed8..cef37db 100644 (file)
@@ -9,11 +9,25 @@
  */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
+import java.util.Map.Entry;
+import java.util.Set;
+
 import javassist.ClassPool;
 
 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
+import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 
 import com.google.common.base.Preconditions;
 
@@ -50,12 +64,25 @@ public final class RuntimeMappingModule extends
 
     @Override
     public java.lang.AutoCloseable createInstance() {
+        
+        RuntimeGeneratedMappingServiceProxy potential = tryToReuseGlobalInstance();
+        if(potential != null) {
+            return potential;
+        }
         RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
         service.setPool(SingletonHolder.CLASS_POOL);
-        service.start(getBundleContext());
+        service.init();
         return service;
     }
 
+    private RuntimeGeneratedMappingServiceProxy tryToReuseGlobalInstance() {
+        ServiceReference<BindingIndependentMappingService> serviceRef = getBundleContext().getServiceReference(BindingIndependentMappingService.class);
+        if(serviceRef == null) {
+            return null;
+        }
+        return new RuntimeGeneratedMappingServiceProxy(getBundleContext(),serviceRef);
+    }
+
     private BundleContext getBundleContext() {
         return bundleContext;
     }
@@ -63,4 +90,73 @@ public final class RuntimeMappingModule extends
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
+
+    private static final class RuntimeGeneratedMappingServiceProxy implements //
+    BindingIndependentMappingService, //
+    Delegator<BindingIndependentMappingService>, //
+    AutoCloseable {
+        
+        private BindingIndependentMappingService delegate;
+        private ServiceReference<BindingIndependentMappingService> reference;
+        private BundleContext bundleContext;
+
+        public RuntimeGeneratedMappingServiceProxy(BundleContext bundleContext,
+                ServiceReference<BindingIndependentMappingService> serviceRef) {
+            this.bundleContext = bundleContext;
+            this.reference = serviceRef;
+            this.delegate = bundleContext.getService(serviceRef);
+        }
+
+        public CodecRegistry getCodecRegistry() {
+            return delegate.getCodecRegistry();
+        }
+
+        public CompositeNode toDataDom(DataObject data) {
+            return delegate.toDataDom(data);
+        }
+
+        public Entry<InstanceIdentifier, CompositeNode> toDataDom(
+                Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> entry) {
+            return delegate.toDataDom(entry);
+        }
+
+        public InstanceIdentifier toDataDom(
+                org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path) {
+            return delegate.toDataDom(path);
+        }
+
+        public DataObject dataObjectFromDataDom(
+                org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path,
+                CompositeNode result) throws DeserializationException {
+            return delegate.dataObjectFromDataDom(path, result);
+        }
+
+        public org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> fromDataDom(InstanceIdentifier entry)
+                throws DeserializationException {
+            return delegate.fromDataDom(entry);
+        }
+
+        public Set<QName> getRpcQNamesFor(Class<? extends RpcService> service) {
+            return delegate.getRpcQNamesFor(service);
+        }
+
+        public DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput) {
+            return delegate.dataObjectFromDataDom(inputClass, domInput);
+        }
+        
+        @Override
+        public void close() throws Exception {
+            if(delegate != null) {
+                delegate = null;
+                bundleContext.ungetService(reference);
+                bundleContext= null;
+                reference = null;
+            }
+        }
+
+        @Override
+        public BindingIndependentMappingService getDelegate() {
+            return delegate;
+        }
+    }
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/CodeGenerationException.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/CodeGenerationException.java
deleted file mode 100644 (file)
index 1923040..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.opendaylight.controller.sal.binding.codegen;
-
-public class CodeGenerationException extends RuntimeException{
-
-    public CodeGenerationException() {
-        super();
-    }
-
-    public CodeGenerationException(String message, Throwable cause, boolean enableSuppression,
-            boolean writableStackTrace) {
-        super(message, cause, enableSuppression, writableStackTrace);
-    }
-
-    public CodeGenerationException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public CodeGenerationException(String message) {
-        super(message);
-    }
-
-    public CodeGenerationException(Throwable cause) {
-        super(cause);
-    }
-}
index d9e0983..6723713 100644 (file)
@@ -36,8 +36,8 @@ import java.util.WeakHashMap
 import org.opendaylight.yangtools.yang.binding.annotations.QName
 import org.opendaylight.yangtools.yang.binding.DataContainer
 import org.opendaylight.yangtools.yang.binding.RpcImplementation
-import org.opendaylight.controller.sal.binding.codegen.util.JavassistUtils
-import org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils
+import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils
+import org.opendaylight.yangtools.sal.binding.generator.util.ClassLoaderUtils
 import javassist.LoaderClassPath
 
 class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
@@ -96,7 +96,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
             val supertype = iface.asCtClass
             return supertype.rpcMetadata;
         ]
-        
+
         val instance = <T>withClassLoaderAndLock(iface.classLoader,lock) [ |
             val supertype = iface.asCtClass
             val routerName = iface.routerName;
@@ -104,14 +104,14 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
             if(potentialClass != null) {
                 return potentialClass.newInstance as T;
             }
-            
+
             val targetCls = createClass(iface.routerName, supertype) [
-                
-                
+
+
                 field(DELEGATE_FIELD, iface)
                 //field(REMOTE_INVOKER_FIELD,iface);
                 implementsType(RpcImplementation.asCtClass)
-                
+
                 for (ctx : metadata.contexts) {
                     field(ctx.routingTableField, Map)
                 }
@@ -146,14 +146,14 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
                 ]
             ]
             return targetCls.toClass(iface.classLoader,iface.protectionDomain).newInstance as T
-            
+
         ];
         return new RpcRouterCodegenInstance(routerInstanceName,iface, instance, metadata.contexts,metadata.supportedInputs);
     }
 
     private def RpcServiceMetadata getRpcMetadata(CtClass iface) {
         val metadata = new RpcServiceMetadata;
-        
+
         iface.methods.filter[declaringClass == iface && parameterTypes.size === 1].forEach [ method |
             val routingPair = method.rpcMetadata;
             if (routingPair !== null) {
@@ -168,7 +168,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
     }
 
     private def getRpcMetadata(CtMethod method) {
-        val inputClass = method.parameterTypes.get(0); 
+        val inputClass = method.parameterTypes.get(0);
         return inputClass.rpcMethodMetadata(inputClass,method.name);
     }
 
@@ -232,7 +232,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
             finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>);
     }
 
-    
+
 
 
 
@@ -245,7 +245,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
             val newInvoker = generateListenerInvoker(class1);
             invokerClasses.put(class1, newInvoker);
             return newInvoker
-            
+
         ]
     }
 }
@@ -294,11 +294,11 @@ package class RpcServiceMetadata {
 
     @Property
     val rpcMethods = new HashMap<String, RpcMetadata>();
-    
+
     @Property
     val rpcInputs = new HashMap<Class<? extends DataContainer>, RpcMetadata>();
-    
-    
+
+
     @Property
     val supportedInputs = new HashSet<Class<? extends DataContainer>>();
 }
@@ -319,7 +319,7 @@ package class RpcMetadata {
 
     @Property
     val boolean routeEncapsulated;
-    
+
     @Property
     val CtClass inputType;
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/XtendHelper.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/XtendHelper.java
deleted file mode 100644 (file)
index ca1b634..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.opendaylight.controller.sal.binding.codegen.impl;
-
-import java.util.List;
-
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-
-public class XtendHelper {
-
-    @SuppressWarnings({"rawtypes","unchecked"})
-    public static Iterable<TypeDefinition> getTypes(UnionTypeDefinition definition) {
-        return (Iterable<TypeDefinition>) (List) definition.getTypes();
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/ClassGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/ClassGenerator.java
deleted file mode 100644 (file)
index c4abc32..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.opendaylight.controller.sal.binding.codegen.util;
-
-import javassist.CtClass;
-
-public interface ClassGenerator {
-    void process(CtClass cls);
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/FieldGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/FieldGenerator.java
deleted file mode 100644 (file)
index 2e053f0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.opendaylight.controller.sal.binding.codegen.util;
-
-import javassist.CtField;
-
-public interface FieldGenerator {
-    void process(CtField field);
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/JavassistUtils.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/JavassistUtils.xtend
deleted file mode 100644 (file)
index 74efffa..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.opendaylight.controller.sal.binding.codegen.util
-
-import javassist.CtClass
-import javassist.CtMethod
-import javassist.ClassPool
-import java.util.Arrays
-import static com.google.common.base.Preconditions.*;
-import javassist.CtField
-import javassist.Modifier
-import javassist.NotFoundException
-import javassist.LoaderClassPath
-import javassist.ClassClassPath
-import java.util.concurrent.locks.Lock
-import java.util.concurrent.locks.ReentrantLock
-import org.slf4j.LoggerFactory
-import java.util.HashMap
-import java.util.WeakHashMap
-
-class JavassistUtils {
-
-    private static val LOG = LoggerFactory.getLogger(JavassistUtils);
-
-    private val loaderClassPaths = new WeakHashMap<ClassLoader,LoaderClassPath>();
-
-    ClassPool classPool
-    
-    @Property
-    val Lock lock = new ReentrantLock();
-
-    new(ClassPool pool) {
-        classPool = pool;
-    }
-
-    def void method(CtClass it, Class<?> returnType, String name, Class<?> parameter, MethodGenerator function1) {
-        val method = new CtMethod(returnType.asCtClass, name, Arrays.asList(parameter.asCtClass), it);
-        function1.process(method);
-        it.addMethod(method);
-    }
-    
-        def void method(CtClass it, Class<?> returnType, String name, Class<?> parameter1, Class<?> parameter2,  MethodGenerator function1) {
-        val method = new CtMethod(returnType.asCtClass, name, Arrays.asList(parameter1.asCtClass,parameter2.asCtClass), it);
-        function1.process(method);
-        it.addMethod(method);
-    }
-    
-    
-    def void staticMethod(CtClass it, Class<?> returnType, String name, Class<?> parameter, MethodGenerator function1) {
-        val method = new CtMethod(returnType.asCtClass, name, Arrays.asList(parameter.asCtClass), it);
-        function1.process(method);
-        it.addMethod(method);
-    }
-
-    def void implementMethodsFrom(CtClass target, CtClass source, MethodGenerator function1) {
-        for (method : source.methods) {
-            if (method.declaringClass == source) {
-                val redeclaredMethod = new CtMethod(method, target, null);
-                function1.process(redeclaredMethod);
-                target.addMethod(redeclaredMethod);
-            }
-        }
-    }
-
-    def CtClass createClass(String fqn, ClassGenerator cls) {
-        
-        val target = classPool.makeClass(fqn);
-        cls.process(target);
-        return target;
-    }
-
-    def CtClass createClass(String fqn, CtClass superInterface, ClassGenerator cls) {
-        
-        val target = classPool.makeClass(fqn);
-        target.implementsType(superInterface);
-        cls.process(target);
-        return target;
-    }
-
-    def void implementsType(CtClass it, CtClass supertype) {
-        checkArgument(supertype.interface, "Supertype must be interface");
-        addInterface(supertype);
-    }
-
-    def asCtClass(Class<?> class1) {
-        classPool.get(class1);
-    }
-
-    def CtField field(CtClass it, String name, Class<?> returnValue) {
-        val field = new CtField(returnValue.asCtClass, name, it);
-        field.modifiers = Modifier.PUBLIC
-        addField(field);
-        return field;
-    }
-    
-    def CtField staticField(CtClass it, String name, Class<?> returnValue) {
-        val field = new CtField(returnValue.asCtClass, name, it);
-        field.modifiers = Modifier.PUBLIC + Modifier.STATIC
-        addField(field);
-        return field;
-    }
-
-    def get(ClassPool pool, Class<?> cls) {
-        try {
-            return pool.get(cls.name)
-        } catch (NotFoundException e) {
-            appendClassLoaderIfMissing(cls.classLoader)
-            try {
-                return pool.get(cls.name)
-            } catch (NotFoundException ef) {
-                LOG.warn("Appending ClassClassPath for {}",cls);
-                pool.appendClassPath(new ClassClassPath(cls));
-                
-                return pool.get(cls.name)
-            }
-        }
-    }
-    
-    def void appendClassLoaderIfMissing(ClassLoader loader) {
-        if(loaderClassPaths.containsKey(loader)) {
-            return;
-        }
-        val ctLoader = new LoaderClassPath(loader);
-        classPool.appendClassPath(ctLoader);
-    }
-    
-    def void ensureClassLoader(Class<?> child) {
-        appendClassLoaderIfMissing(child.classLoader);
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/MethodGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/util/MethodGenerator.java
deleted file mode 100644 (file)
index 0eddbd6..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.opendaylight.controller.sal.binding.codegen.util;
-
-import javassist.CtMethod;
-
-public interface MethodGenerator {
-    void process(CtMethod method);
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/AugmentationCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/AugmentationCodec.java
deleted file mode 100644 (file)
index 970e077..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-
-public interface AugmentationCodec<A extends Augmentation<?>> extends DomCodec<A> {
-
-    
-    @Override
-    public CompositeNode serialize(ValueWithQName<A> input);
-    
-    @Override
-    public ValueWithQName<A> deserialize(Node<?> input);
-
-    public QName getAugmentationQName();
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ChoiceCaseCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ChoiceCaseCodec.java
deleted file mode 100644 (file)
index d545b72..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-
-public interface ChoiceCaseCodec<C extends DataContainer> extends DataContainerCodec<C> {
-
-    @Override
-    public CompositeNode serialize(ValueWithQName<C> input);
-    
-    @Override
-    public ValueWithQName<C> deserialize(Node<?> input);
-    
-    public boolean isAcceptable(Node<?> input);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ChoiceCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ChoiceCodec.java
deleted file mode 100644 (file)
index 21bb1cf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.data.api.Node;
-
-public interface ChoiceCodec<C> extends DomCodec<C> {
-
-    @Override
-    public Node<?> serialize(ValueWithQName<C> input);
-    
-    @Override
-    public ValueWithQName<C> deserialize(Node<?> input);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/CodecRegistry.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/CodecRegistry.java
deleted file mode 100644 (file)
index 4565b54..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-
-import java.util.List;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.IdentifierCodec;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-
-public interface CodecRegistry {
-
-    InstanceIdentifierCodec getInstanceIdentifierCodec();
-    
-    IdentitityCodec<?> getIdentityCodec();
-
-    <T extends DataContainer> DataContainerCodec<T> getCodecForDataObject(Class<T> object);
-
-    <T extends Identifiable<?>> IdentifierCodec<?> getIdentifierCodecForIdentifiable(Class<T> object);
-
-    <T extends Identifier<?>> IdentifierCodec<T> getCodecForIdentifier(Class<T> object);
-
-    <T extends Augmentation<?>> AugmentationCodec<T> getCodecForAugmentation(Class<T> object);
-    
-    <T extends BaseIdentity> IdentitityCodec<T> getCodecForIdentity(Class<T> codec);
-
-    Class<?> getClassForPath(List<QName> names);
-
-    IdentifierCodec<?> getKeyCodecForPath(List<QName> names);
-    
-    
-    void bindingClassEncountered(Class<?> cls);
-
-    void putPathToClass(List<QName> names, Class<?> cls);
-
-    public abstract QName getQNameForAugmentation(Class<?> cls);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/DataContainerCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/DataContainerCodec.java
deleted file mode 100644 (file)
index 683faaf..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-
-public interface DataContainerCodec<T extends DataContainer> extends  DomCodec<T> {
-
-
-    @Override
-    public ValueWithQName<T> deserialize(Node<?> input);
-    
-    @Override
-    public CompositeNode serialize(ValueWithQName<T> input);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/DomCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/DomCodec.java
deleted file mode 100644 (file)
index 76969ab..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.Node;
-
-public interface DomCodec<I> extends BindingCodec<Node<?>, ValueWithQName<I>>{
-    
-    
-    @Override
-    public Node<?> serialize(ValueWithQName<I> input);
-    
-    
-    @Override
-    public ValueWithQName<I> deserialize(Node<?> input);
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/IdentifierCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/IdentifierCodec.java
deleted file mode 100644 (file)
index 933b884..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-
-public interface IdentifierCodec<I extends Identifier<?>> extends DomCodec<I> {
-
-    @Override
-    public ValueWithQName<I> deserialize(Node<?> input);
-    
-    @Override
-    public CompositeNode serialize(ValueWithQName<I> input);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/IdentitityCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/IdentitityCodec.java
deleted file mode 100644 (file)
index 0c480f5..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.common.QName;
-
-public interface IdentitityCodec<T extends BaseIdentity> extends BindingCodec<QName, Class<T>>{
-
-    @Override
-    public QName serialize(Class<T> input);
-    
-    @Override
-    public Class<T> deserialize(QName input);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/InstanceIdentifierCodec.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/InstanceIdentifierCodec.java
deleted file mode 100644 (file)
index 7fbb79d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public interface InstanceIdentifierCodec extends BindingCodec<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier,InstanceIdentifier<?>> {
-
-    @Override
-    public org.opendaylight.yangtools.yang.data.api.InstanceIdentifier serialize(InstanceIdentifier<?> input);
-    
-    @Override
-    public InstanceIdentifier<?> deserialize(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier input);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ValueWithQName.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/api/ValueWithQName.java
deleted file mode 100644 (file)
index 442df01..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.api;
-
-import java.util.Map.Entry;
-
-import org.opendaylight.yangtools.yang.common.QName;
-
-public class ValueWithQName<V> implements Entry<QName, V>{
-    
-    final QName qname;
-    final V value;
-    
-    public ValueWithQName(QName qname, V value) {
-        super();
-        this.qname = qname;
-        this.value = value;
-    }
-
-    public QName getQname() {
-        return qname;
-    }
-
-    public V getValue() {
-        return value;
-    }
-    
-    @Override
-    public QName getKey() {
-        return qname;
-    }
-    
-    @Override
-    public V setValue(V value) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((qname == null) ? 0 : qname.hashCode());
-        result = prime * result + ((value == null) ? 0 : value.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        @SuppressWarnings("rawtypes")
-        ValueWithQName other = (ValueWithQName) obj;
-        if (qname == null) {
-            if (other.qname != null)
-                return false;
-        } else if (!qname.equals(other.qname))
-            return false;
-        if (value == null) {
-            if (other.value != null) {
-                return false;
-            }
-        } else if (!value.equals(other.value)) {
-            return false;
-        }
-        return true;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/BindingClassListener.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/BindingClassListener.java
deleted file mode 100644 (file)
index c3f102a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl;
-
-public interface BindingClassListener {
-
-    void onBindingClassCaptured(Class<?> cls);
-    
-    void onBindingClassProcessed(Class<?> cls);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecMapping.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecMapping.java
deleted file mode 100644 (file)
index fa2d32a..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import org.opendaylight.controller.sal.binding.dom.serializer.api.IdentitityCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.InstanceIdentifierCodec;
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CodecMapping {
-
-    private static final Logger LOG = LoggerFactory.getLogger(CodecMapping.class);
-    
-    public static final String INSTANCE_IDENTIFIER_CODEC = "INSTANCE_IDENTIFIER_CODEC";
-    public static final String IDENTITYREF_CODEC = "IDENTITYREF_CODEC";
-    
-    public static final String CLASS_TO_CASE_MAP = "CLASS_TO_CASE";
-    public static final String COMPOSITE_TO_CASE = "COMPOSITE_TO_CASE";
-    public static final String AUGMENTATION_CODEC = "AUGMENTATION_CODEC";
-    
-    public static void setIdentifierCodec(Class<?> obj,InstanceIdentifierCodec codec) {
-        Field instanceIdField;
-        try {
-            instanceIdField = obj.getField(INSTANCE_IDENTIFIER_CODEC);
-            if(obj != null) {
-                instanceIdField.set(null, codec);
-            }
-        } catch (NoSuchFieldException e) {
-           LOG.trace("Instance identifier codec is not needed for {}",obj.getName(),e);
-        } catch (SecurityException | IllegalAccessException e) {
-            LOG.error("Instance identifier could not be set for {}",obj.getName(),e);
-        }
-    }
-
-
-    public static void setIdentityRefCodec(Class<?> obj,IdentitityCodec<?> codec) {
-        Field instanceIdField;
-        try {
-            instanceIdField = obj.getField(IDENTITYREF_CODEC);
-            if(obj != null) {
-                instanceIdField.set(null, codec);
-            }
-        } catch (NoSuchFieldException e) {
-           LOG.trace("Instance identifier codec is not needed for {}",obj.getName(),e);
-        } catch (SecurityException | IllegalAccessException e) {
-            LOG.error("Instance identifier could not be set for {}",obj.getName(),e);
-        }
-    }
-
-    public static void setClassToCaseMap(Class<? extends BindingCodec<?,?>> codec,
-            Map<Class<?>,BindingCodec<?,?>> classToCaseRawCodec) {
-        Field instanceIdField;
-        try {
-            instanceIdField = codec.getField(CLASS_TO_CASE_MAP);
-            instanceIdField.set(null, classToCaseRawCodec);
-        } catch (NoSuchFieldException e) {
-            LOG.debug("BUG: Class to case mappping is not needed for {}",codec.getName(),e);
-        } catch (SecurityException | IllegalAccessException e) {
-            LOG.error("Class to case mappping could not be set for {}",codec.getName(),e);
-        }
-    }
-
-    public static void setCompositeNodeToCaseMap(Class<? extends BindingCodec<?,?>> codec,
-            Map<CompositeNode,BindingCodec<?,?>> compositeToCase) {
-        Field instanceIdField;
-        try {
-            instanceIdField = codec.getField(COMPOSITE_TO_CASE);
-            instanceIdField.set(null, compositeToCase);
-        } catch (NoSuchFieldException e) {
-            LOG.debug("BUG: Class to case mappping is not needed for {}",codec.getName(),e);
-        } catch (SecurityException | IllegalAccessException e) {
-            LOG.error("Composite node to case mappping could not be set for {}",codec.getName(),e);
-        }
-    }
-
-    public static void setAugmentationCodec(Class<? extends BindingCodec<?,?>> dataCodec,
-            BindingCodec<?,?> augmentableCodec) {
-            Field instanceIdField;
-            try {
-                instanceIdField = dataCodec.getField(AUGMENTATION_CODEC);
-                instanceIdField.set(null, augmentableCodec);
-            } catch (NoSuchFieldException e) {
-                LOG.debug("BUG: Augmentation codec is not needed for {}",dataCodec.getName(),e);
-            } catch (SecurityException | IllegalAccessException e) {
-                LOG.error("Augmentation codec could not be set for {}",dataCodec.getName(),e);
-            }
-    }
-    
-    
-    public static BindingCodec<?,?> getAugmentationCodec(Class<? extends BindingCodec<?,?>> dataCodec) {
-            Field instanceIdField;
-            try {
-                instanceIdField = dataCodec.getField(AUGMENTATION_CODEC);
-                return (BindingCodec<?,?>) instanceIdField.get(null);
-            } catch (NoSuchFieldException e) {
-                LOG.debug("BUG: Augmentation codec is not needed for {}",dataCodec.getName(),e);
-            } catch (SecurityException | IllegalAccessException e) {
-                LOG.error("Augmentation codec could not be set for {}",dataCodec.getName(),e);
-            }
-            return null;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecTypeUtils.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecTypeUtils.java
deleted file mode 100644 (file)
index d86d2f4..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl;
-
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
-
-public class CodecTypeUtils {
-
-    @SuppressWarnings({"unchecked","rawtypes"})
-    public static IdentifiableItem<?, ?> newIdentifiableItem(Class<?> type, Object key) {
-        Class<? extends Identifiable<?>> identifiableType = (Class<? extends Identifiable<?>>) type;
-        Identifier<? extends Identifiable<?>> identifier = (Identifier<? extends Identifiable<?>>) key;
-        return new IdentifiableItem(identifiableType,identifier);
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/GeneratorListener.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/GeneratorListener.java
deleted file mode 100644 (file)
index 0ac239d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl;
-
-import java.util.Map;
-
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
-
-public interface GeneratorListener {
-
-    
-    
-    void onClassProcessed(Class<?> cl);
-    
-    void onCodecCreated(Class<?> codec);
-    void onValueCodecCreated(Class<?> valueClass,Class<?> valueCodec);
-    void onCaseCodecCreated(Class<?> choiceClass,Class<? extends BindingCodec<Map<QName, Object>,Object>> choiceCodec);
-    void onDataContainerCodecCreated(Class<?> dataClass, Class<?  extends BindingCodec<?,?>> dataCodec);
-
-    void onChoiceCodecCreated(Class<?> choiceClass,
-            Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, ChoiceNode schema);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend
deleted file mode 100644 (file)
index d910372..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl
-
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.controller.sal.binding.dom.serializer.api.CodecRegistry
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
-import org.opendaylight.yangtools.yang.common.QName
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item
-import java.util.Map
-import java.util.WeakHashMap
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
-import java.util.ArrayList
-import org.opendaylight.controller.sal.binding.dom.serializer.api.InstanceIdentifierCodec
-import org.opendaylight.controller.sal.binding.dom.serializer.api.ValueWithQName
-import java.util.HashMap
-import org.slf4j.LoggerFactory
-import java.util.List
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.controller.sal.binding.dom.serializer.api.IdentifierCodec
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
-import org.opendaylight.yangtools.yang.data.api.Node
-import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.opendaylight.yangtools.yang.binding.Augmentable
-import com.google.common.collect.ImmutableList
-import org.opendaylight.yangtools.yang.binding.Augmentation
-import java.util.concurrent.ConcurrentHashMap
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections
-
-class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
-    
-    private static val LOG = LoggerFactory.getLogger(InstanceIdentifierCodecImpl);
-    val CodecRegistry codecRegistry;
-    
-    val Map<Class<?>, Map<List<QName>, Class<?>>> classToPreviousAugment = new WeakHashMap;
-    
-    public new(CodecRegistry registry) {
-        codecRegistry = registry;
-    }
-    
-    
-    override deserialize(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier input) {
-        var Class<?> baType = null
-        val biArgs = input.path
-        val scannedPath = new ArrayList<QName>(biArgs.size);
-        val baArgs = new ArrayList<org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument>(biArgs.size)
-        for(biArg : biArgs) {
-            scannedPath.add(biArg.nodeType);
-            val baArg = deserializePathArgument(biArg,scannedPath)
-            baType = baArg?.type
-            val injectAugment = classToPreviousAugment.get(baType);
-            if(injectAugment != null) {
-                val augment = injectAugment.get(scannedPath) as Class<? extends DataObject>;
-                if(augment != null) {
-                    baArgs.add(new Item(augment));
-                }
-            }
-            baArgs.add(baArg)
-        }
-        val ret = new InstanceIdentifier(baArgs,baType as Class<? extends DataObject>);
-        LOG.debug("DOM Instance Identifier {} deserialized to {}",input,ret);
-        return ret;
-    }
-    
-    private def dispatch org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument deserializePathArgument(NodeIdentifier argument,List<QName> processedPath) {
-        val Class cls = codecRegistry.getClassForPath(processedPath);
-        return new Item(cls);
-    }
-    
-    
-    private def dispatch org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument deserializePathArgument(NodeIdentifierWithPredicates argument,List<QName> processedPath) {
-        val Class type = codecRegistry.getClassForPath(processedPath);
-        val IdentifierCodec codec = codecRegistry.getIdentifierCodecForIdentifiable(type);
-        val value = codec.deserialize(argument.toCompositeNode())?.value;
-        return CodecTypeUtils.newIdentifiableItem(type,value);
-    }
-    
-    def CompositeNode toCompositeNode(NodeIdentifierWithPredicates predicates) {
-        val keyValues = predicates.keyValues.entrySet;
-        val values = new ArrayList<Node<?>>(keyValues.size)
-        for(keyValue : keyValues) {
-            values.add(new SimpleNodeTOImpl(keyValue.key,null,keyValue.value))
-        }
-        return new CompositeNodeTOImpl(predicates.nodeType,null,values);
-    }
-    
-    override serialize(InstanceIdentifier input) {
-        var Class<?> previousAugmentation = null
-        val pathArgs = input.path as List<org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument>
-        var QName previousQName = null;
-        val components = new ArrayList<PathArgument>(pathArgs.size);
-        val qnamePath = new ArrayList<QName>(pathArgs.size);
-        for(baArg : pathArgs) { 
-            
-            if(!Augmentation.isAssignableFrom(baArg.type)) {
-                
-                val biArg = serializePathArgument(baArg,previousQName);
-                previousQName = biArg.nodeType;
-                components.add(biArg);
-                qnamePath.add(biArg.nodeType);
-                val immutableList = ImmutableList.copyOf(qnamePath);
-                codecRegistry.putPathToClass(immutableList,baArg.type);
-                if(previousAugmentation !== null) {
-                    updateAugmentationInjection(baArg.type,immutableList,previousAugmentation)
-                }
-                
-                previousAugmentation = null;
-            } else {
-                previousQName = codecRegistry.getQNameForAugmentation(baArg.type as Class);
-                previousAugmentation = baArg.type;
-            }
-        }
-        val ret = new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(components);
-        LOG.debug("Binding Instance Identifier {} serialized to DOM InstanceIdentifier {}",input,ret);
-        return ret;
-    }
-    
-    def updateAugmentationInjection(Class<? extends DataObject> class1, ImmutableList<QName> list, Class<?> augmentation) {
-        if(classToPreviousAugment.get(class1) == null) {
-            classToPreviousAugment.put(class1,new ConcurrentHashMap());
-        }
-        classToPreviousAugment.get(class1).put(list,augmentation);
-    }
-    
-    private def dispatch PathArgument serializePathArgument(Item argument, QName previousQname) {
-        val type = argument.type;
-        val qname = BindingReflections.findQName(type);
-        if(previousQname == null) {
-            return new NodeIdentifier(qname);
-        }
-        return new NodeIdentifier(QName.create(previousQname,qname.localName));
-    }
-    
-    @SuppressWarnings("rawtypes")
-    private def dispatch PathArgument serializePathArgument(IdentifiableItem argument, QName previousQname) {
-        val Map<QName,Object> predicates = new HashMap();
-        val type = argument.type;
-        val keyCodec = codecRegistry.getIdentifierCodecForIdentifiable(type);
-        val qname = BindingReflections.findQName(type);
-        val combinedInput =  new ValueWithQName(previousQname,argument.key)
-        val compositeOutput = keyCodec.serialize(combinedInput as ValueWithQName);
-        for(outputValue :compositeOutput.value) {
-            predicates.put(outputValue.nodeType,outputValue.value);
-        }
-        if(previousQname == null) {
-            return new NodeIdentifierWithPredicates(qname,predicates);
-        }
-        return new NodeIdentifierWithPredicates(QName.create(previousQname,qname.localName),predicates);
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/IntermediateMapping.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/IntermediateMapping.xtend
deleted file mode 100644 (file)
index 04b8674..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl
-
-import org.opendaylight.yangtools.yang.data.api.Node
-import java.util.Map
-import org.opendaylight.yangtools.yang.common.QName
-import java.util.List
-import java.util.ArrayList
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
-import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
-import com.google.common.base.Preconditions
-
-class IntermediateMapping {
-    
-    
-    
-    static def Node<?> toNode(Map<?,?> map) {
-        if(map instanceof Node<?>) {
-            return map as Node<?>;
-        }
-        val nodeMap = map as Map<QName,Object>;
-        Preconditions.checkArgument(map.size == 1);
-        val elem = nodeMap.entrySet.iterator.next;
-        val qname = elem.key;
-        val value = elem.value;
-        toNodeImpl(qname, value);
-    }
-
-
-    static def dispatch Node<?> toNodeImpl(QName name, List<?> objects) {
-        val values = new ArrayList<Node<?>>(objects.size);
-        for (obj : objects) {
-            if(obj instanceof Node<?>) {
-                values.add(obj as Node<?>);
-            } else if(obj instanceof Map<?,?>) {
-                values.add(toNode(obj as Map<?,?>));
-            }
-        }
-        return new CompositeNodeTOImpl(name, null, values);
-    }
-
-    static def dispatch Node<?> toNodeImpl(QName name, Map<QName, Object> object) {
-        throw new UnsupportedOperationException("Unsupported node hierarchy.");
-    }
-
-    static def dispatch Node<?> toNodeImpl(QName name, Object object) {
-        return new SimpleNodeTOImpl(name, null, object);
-    } 
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java
deleted file mode 100644 (file)
index 89d9b49..0000000
+++ /dev/null
@@ -1,1021 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl;
-
-import java.awt.CompositeContext;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-import org.apache.commons.lang3.text.translate.AggregateTranslator;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.AugmentationCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.ChoiceCaseCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.ChoiceCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.CodecRegistry;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.DataContainerCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.DomCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.IdentifierCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.IdentitityCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.InstanceIdentifierCodec;
-import org.opendaylight.controller.sal.binding.dom.serializer.api.ValueWithQName;
-import org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
-import org.opendaylight.yangtools.binding.generator.util.Types;
-import org.opendaylight.yangtools.concepts.Delegator;
-import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Augmentable;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.BindingCodec;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.Node;
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.UsesNode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static com.google.common.base.Preconditions.*;
-import static org.opendaylight.controller.sal.binding.dom.serializer.impl.IntermediateMapping.*;
-
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleContext;
-import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.CycleDetectingLockFactory.WithExplicitOrdering;
-
-public class LazyGeneratedCodecRegistry implements //
-        CodecRegistry, //
-        SchemaServiceListener, //
-        GeneratorListener {
-
-    private final static Logger LOG = LoggerFactory.getLogger(LazyGeneratedCodecRegistry.class);
-    private final static LateMixinCodec NOT_READY_CODEC = new LateMixinCodec();
-
-    private final InstanceIdentifierCodec instanceIdentifierCodec = new InstanceIdentifierCodecImpl(this);
-    private final IdentityCompositeCodec identityRefCodec = new IdentityCompositeCodec();
-
-    private TransformerGenerator generator;
-
-    // Concrete class to codecs
-    private static final Map<Class<?>, DataContainerCodec<?>> containerCodecs = new WeakHashMap<>();
-    private static final Map<Class<?>, IdentifierCodec<?>> identifierCodecs = new WeakHashMap<>();
-    private static final Map<Class<?>, ChoiceCodecImpl<?>> choiceCodecs = new WeakHashMap<>();
-    private static final Map<Class<?>, ChoiceCaseCodecImpl<?>> caseCodecs = new WeakHashMap<>();
-    private static final Map<Class<?>, AugmentableCompositeCodec> augmentableCodecs = new WeakHashMap<>();
-    private static final Map<Class<?>, AugmentationCodec<?>> augmentationCodecs = new WeakHashMap<>();
-    private static final Map<Class<?>, QName> identityQNames = new WeakHashMap<>();
-    private static final Map<QName, Type> qnamesToIdentityMap = new ConcurrentHashMap<>();
-    /** Binding type to encountered classes mapping **/
-    @SuppressWarnings("rawtypes")
-    private static final Map<Type, WeakReference<Class>> typeToClass = new ConcurrentHashMap<>();
-
-    @SuppressWarnings("rawtypes")
-    private static final ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseCodecs = new ConcurrentHashMap<>();
-
-    private CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
-
-    private static final Map<SchemaPath, GeneratedTypeBuilder> pathToType = new ConcurrentHashMap<>();
-    private static final Map<List<QName>, Type> pathToInstantiatedType = new ConcurrentHashMap<>();
-    private static final Map<Type, QName> typeToQname = new ConcurrentHashMap<>();
-
-    private SchemaContext currentSchema;
-
-    public TransformerGenerator getGenerator() {
-        return generator;
-    }
-
-    public void setGenerator(TransformerGenerator generator) {
-        this.generator = generator;
-    }
-
-    @Override
-    public InstanceIdentifierCodec getInstanceIdentifierCodec() {
-        return instanceIdentifierCodec;
-    }
-
-    @Override
-    public <T extends Augmentation<?>> AugmentationCodec<T> getCodecForAugmentation(Class<T> object) {
-        AugmentationCodec<T> codec = null;
-        @SuppressWarnings("rawtypes")
-        AugmentationCodec potentialCodec = augmentationCodecs.get(object);
-        if (potentialCodec != null) {
-            codec = potentialCodec;
-        } else
-            try {
-                Class<? extends BindingCodec<Map<QName, Object>, Object>> augmentRawCodec = generator
-                        .augmentationTransformerFor(object);
-                BindingCodec<Map<QName, Object>, Object> rawCodec = augmentRawCodec.newInstance();
-                codec = new AugmentationCodecWrapper<T>(rawCodec);
-                augmentationCodecs.put(augmentRawCodec, codec);
-            } catch (InstantiationException e) {
-                LOG.error("Can not instantiate raw augmentation codec {}", object.getSimpleName(), e);
-            } catch (IllegalAccessException e) {
-                LOG.debug("BUG: Constructor for {} is not accessible.", object.getSimpleName(), e);
-            }
-        Class<? extends Augmentable<?>> objectSupertype = getAugmentableArgumentFrom(object);
-        if (objectSupertype != null) {
-            getAugmentableCodec(objectSupertype).addAugmentationCodec(object, codec);
-        } else {
-            LOG.warn("Could not find augmentation target for augmentation {}", object);
-        }
-        return codec;
-    }
-    
-    @Override
-    public QName getQNameForAugmentation(Class<?> cls) {
-        checkArgument(Augmentation.class.isAssignableFrom(cls));
-        return getCodecForAugmentation((Class<? extends Augmentation>)cls).getAugmentationQName();
-    }
-
-    private static Class<? extends Augmentable<?>> getAugmentableArgumentFrom(
-            final Class<? extends Augmentation<?>> augmentation) {
-        try {
-            Class<? extends Augmentable<?>> ret = ClassLoaderUtils.withClassLoader(augmentation.getClassLoader(),
-                    new Callable<Class<? extends Augmentable<?>>>() {
-                        @Override
-                        @SuppressWarnings("unchecked")
-                        public Class<? extends Augmentable<?>> call() throws Exception {
-                            for (java.lang.reflect.Type supertype : augmentation.getGenericInterfaces()) {
-                                if (supertype instanceof ParameterizedType
-                                        && Augmentation.class.equals(((ParameterizedType) supertype).getRawType())) {
-                                    ParameterizedType augmentationGeneric = (ParameterizedType) supertype;
-                                    return (Class<? extends Augmentable<?>>) augmentationGeneric
-                                            .getActualTypeArguments()[0];
-                                }
-                            }
-                            return null;
-                        }
-                    });
-            return ret;
-        } catch (Exception e) {
-            LOG.debug("Could not find augmentable for {} using {}", augmentation, augmentation.getClassLoader(), e);
-            return null;
-        }
-    }
-
-    @Override
-    public Class<?> getClassForPath(List<QName> names) {
-        DataSchemaNode node = getSchemaNode(names);
-        SchemaPath path = node.getPath();
-        Type type = pathToType.get(path);
-        if (type != null) {
-            type = new ReferencedTypeImpl(type.getPackageName(), type.getName());
-        } else {
-            type = pathToInstantiatedType.get(names);
-        }
-        @SuppressWarnings("rawtypes")
-        WeakReference<Class> weakRef = typeToClass.get(type);
-        if (weakRef == null) {
-            LOG.error("Could not find loaded class for path: {} and type: {}", path, type.getFullyQualifiedName());
-        }
-        return weakRef.get();
-    }
-
-    @Override
-    public void putPathToClass(List<QName> names, Class<?> cls) {
-        Type reference = Types.typeForClass(cls);
-        pathToInstantiatedType.put(names, reference);
-        bindingClassEncountered(cls);
-    }
-
-    @Override
-    public IdentifierCodec<?> getKeyCodecForPath(List<QName> names) {
-        @SuppressWarnings("unchecked")
-        Class<? extends Identifiable<?>> cls = (Class<? extends Identifiable<?>>) getClassForPath(names);
-        return getIdentifierCodecForIdentifiable(cls);
-    }
-
-    @Override
-    public <T extends DataContainer> DataContainerCodec<T> getCodecForDataObject(Class<T> type) {
-        @SuppressWarnings("unchecked")
-        DataContainerCodec<T> ret = (DataContainerCodec<T>) containerCodecs.get(type);
-        if (ret != null) {
-            return ret;
-        }
-        Class<? extends BindingCodec<Map<QName, Object>, Object>> newType = generator.transformerFor(type);
-        BindingCodec<Map<QName, Object>, Object> rawCodec = newInstanceOf(newType);
-        DataContainerCodecImpl<T> newWrapper = new DataContainerCodecImpl<>(rawCodec);
-        containerCodecs.put(type, newWrapper);
-        return newWrapper;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public void bindingClassEncountered(Class cls) {
-
-        ConcreteType typeRef = Types.typeForClass(cls);
-        if (typeToClass.containsKey(typeRef)) {
-            return;
-        }
-        LOG.trace("Binding Class {} encountered.", cls);
-        WeakReference<Class> weakRef = new WeakReference<>(cls);
-        typeToClass.put(typeRef, weakRef);
-        if (Augmentation.class.isAssignableFrom(cls)) {
-
-        } else if (DataObject.class.isAssignableFrom(cls)) {
-            @SuppressWarnings({ "unchecked", "unused" })
-            Object cdc = getCodecForDataObject((Class<? extends DataObject>) cls);
-        }
-    }
-
-    @Override
-    public void onClassProcessed(Class<?> cls) {
-        ConcreteType typeRef = Types.typeForClass(cls);
-        if (typeToClass.containsKey(typeRef)) {
-            return;
-        }
-        LOG.trace("Binding Class {} encountered.", cls);
-        WeakReference<Class> weakRef = new WeakReference<>((Class) cls);
-        typeToClass.put(typeRef, weakRef);
-    }
-
-    private DataSchemaNode getSchemaNode(List<QName> path) {
-        QName firstNode = path.get(0);
-        DataNodeContainer previous = currentSchema.findModuleByNamespaceAndRevision(firstNode.getNamespace(),
-                firstNode.getRevision());
-        Iterator<QName> iterator = path.iterator();
-        while (iterator.hasNext()) {
-            QName arg = iterator.next();
-            DataSchemaNode currentNode = previous.getDataChildByName(arg);
-            if (currentNode == null && previous instanceof DataNodeContainer) {
-                currentNode = searchInChoices(previous, arg);
-            }
-            if (currentNode instanceof DataNodeContainer) {
-                previous = (DataNodeContainer) currentNode;
-            } else if (currentNode instanceof LeafSchemaNode || currentNode instanceof LeafListSchemaNode) {
-                checkState(!iterator.hasNext(), "Path tries to nest inside leaf node.");
-                return currentNode;
-            }
-        }
-        return (DataSchemaNode) previous;
-    }
-
-    private DataSchemaNode searchInChoices(DataNodeContainer node, QName arg) {
-        Set<DataSchemaNode> children = node.getChildNodes();
-        for (DataSchemaNode child : children) {
-            if (child instanceof ChoiceNode) {
-                ChoiceNode choiceNode = (ChoiceNode) child;
-                DataSchemaNode potential = searchInCases(choiceNode, arg);
-                if (potential != null) {
-                    return potential;
-                }
-            }
-        }
-        return null;
-    }
-
-    private DataSchemaNode searchInCases(ChoiceNode choiceNode, QName arg) {
-        Set<ChoiceCaseNode> cases = choiceNode.getCases();
-        for (ChoiceCaseNode caseNode : cases) {
-            DataSchemaNode node = caseNode.getDataChildByName(arg);
-            if (node != null) {
-                return node;
-            }
-        }
-        return null;
-    }
-
-    private <T> T newInstanceOf(Class<?> newType) {
-        try {
-            @SuppressWarnings("unchecked")
-            T ret = (T) newType.newInstance();
-            return ret;
-        } catch (InstantiationException e) {
-            throw new IllegalStateException(e);
-        } catch (IllegalAccessException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    @Override
-    public <T extends Identifiable<?>> IdentifierCodec<?> getIdentifierCodecForIdentifiable(Class<T> type) {
-        IdentifierCodec<?> obj = identifierCodecs.get(type);
-        if (obj != null) {
-            return obj;
-        }
-        Class<? extends BindingCodec<Map<QName, Object>, Object>> newCodec = generator
-                .keyTransformerForIdentifiable(type);
-        BindingCodec<Map<QName, Object>, Object> newInstance;
-        newInstance = newInstanceOf(newCodec);
-        IdentifierCodecImpl<?> newWrapper = new IdentifierCodecImpl<>(newInstance);
-        identifierCodecs.put(type, newWrapper);
-        return newWrapper;
-    }
-
-    @Override
-    public IdentitityCodec<?> getIdentityCodec() {
-        return identityRefCodec;
-    }
-
-    @Override
-    public <T extends BaseIdentity> IdentitityCodec<T> getCodecForIdentity(Class<T> codec) {
-        bindingClassEncountered(codec);
-        return identityRefCodec;
-    }
-
-    @Override
-    public void onCodecCreated(Class<?> cls) {
-        CodecMapping.setIdentifierCodec(cls, instanceIdentifierCodec);
-        CodecMapping.setIdentityRefCodec(cls, identityRefCodec);
-    }
-
-    @Override
-    public <T extends Identifier<?>> IdentifierCodec<T> getCodecForIdentifier(Class<T> object) {
-        @SuppressWarnings("unchecked")
-        IdentifierCodec<T> obj = (IdentifierCodec<T>) identifierCodecs.get(object);
-        if (obj != null) {
-            return obj;
-        }
-        Class<? extends BindingCodec<Map<QName, Object>, Object>> newCodec = generator
-                .keyTransformerForIdentifier(object);
-        BindingCodec<Map<QName, Object>, Object> newInstance;
-        newInstance = newInstanceOf(newCodec);
-        IdentifierCodecImpl<T> newWrapper = new IdentifierCodecImpl<>(newInstance);
-        identifierCodecs.put(object, newWrapper);
-        return newWrapper;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public ChoiceCaseCodecImpl getCaseCodecFor(Class caseClass) {
-        ChoiceCaseCodecImpl<?> potential = caseCodecs.get(caseClass);
-        if (potential != null) {
-            return potential;
-        }
-        ConcreteType typeref = Types.typeForClass(caseClass);
-        ChoiceCaseCodecImpl caseCodec = typeToCaseCodecs.get(typeref);
-
-        checkState(caseCodec != null, "Case Codec was not created proactivelly for %s", caseClass.getName());
-        checkState(caseCodec.getSchema() != null, "Case schema is not available for %s", caseClass.getName());
-        @SuppressWarnings("unchecked")
-        Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.getSchema());
-        BindingCodec newInstance = newInstanceOf(newCodec);
-        caseCodec.setDelegate(newInstance);
-        caseCodecs.put(caseClass, caseCodec);
-
-        for (Entry<Class<?>, ChoiceCodecImpl<?>> choice : choiceCodecs.entrySet()) {
-            if (choice.getKey().isAssignableFrom(caseClass)) {
-                choice.getValue().cases.put(caseClass, caseCodec);
-            }
-        }
-        return caseCodec;
-    }
-
-    public void onModuleContextAdded(SchemaContext schemaContext, Module module, ModuleContext context) {
-        pathToType.putAll(context.getChildNodes());
-        qnamesToIdentityMap.putAll(context.getIdentities());
-        for (Entry<QName, GeneratedTOBuilder> identity : context.getIdentities().entrySet()) {
-            typeToQname.put(
-                    new ReferencedTypeImpl(identity.getValue().getPackageName(), identity.getValue().getName()),
-                    identity.getKey());
-        }
-        captureCases(context.getCases(), schemaContext);
-    }
-
-    private void captureCases(Map<SchemaPath, GeneratedTypeBuilder> cases, SchemaContext module) {
-        for (Entry<SchemaPath, GeneratedTypeBuilder> caseNode : cases.entrySet()) {
-            ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode
-                    .getValue().getName());
-
-            pathToType.put(caseNode.getKey(), caseNode.getValue());
-
-            ChoiceCaseNode node = (ChoiceCaseNode) SchemaContextUtil.findDataSchemaNode(module, caseNode.getKey());
-
-            if (node == null) {
-                LOG.error("YANGTools Bug: SchemaNode for {}, with path {} was not found in context.",
-                        typeref.getFullyQualifiedName(), caseNode.getKey());
-                @SuppressWarnings("rawtypes")
-                ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl();
-                typeToCaseCodecs.putIfAbsent(typeref, value);
-                continue;
-            }
-            @SuppressWarnings("rawtypes")
-            ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
-            typeToCaseCodecs.putIfAbsent(typeref, value);
-        }
-    }
-
-    @Override
-    public void onGlobalContextUpdated(SchemaContext context) {
-        currentSchema = context;
-    }
-
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    @Override
-    public void onChoiceCodecCreated(Class<?> choiceClass,
-            Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, ChoiceNode schema) {
-        ChoiceCodec<?> oldCodec = choiceCodecs.get(choiceClass);
-        checkState(oldCodec == null);
-        BindingCodec<Map<QName, Object>, Object> delegate = newInstanceOf(choiceCodec);
-        ChoiceCodecImpl<?> newCodec = new ChoiceCodecImpl(delegate);
-        choiceCodecs.put(choiceClass, newCodec);
-        CodecMapping.setClassToCaseMap(choiceCodec, (Map<Class<?>, BindingCodec<?, ?>>) classToCaseRawCodec);
-        CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
-
-        tryToCreateCasesCodecs(schema);
-
-    }
-
-    private void tryToCreateCasesCodecs(ChoiceNode schema) {
-        for (ChoiceCaseNode caseNode : schema.getCases()) {
-            SchemaPath path = caseNode.getPath();
-            GeneratedTypeBuilder type;
-            if (path != null && (type = pathToType.get(path)) != null) {
-                ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
-                ChoiceCaseCodecImpl partialCodec = typeToCaseCodecs.get(typeref);
-                if (partialCodec.getSchema() == null) {
-                    partialCodec.setSchema(caseNode);
-                }
-
-                Class<?> caseClass = ClassLoaderUtils.tryToLoadClassWithTCCL(type.getFullyQualifiedName());
-                if (caseClass != null) {
-                    getCaseCodecFor(caseClass);
-                }
-            }
-        }
-
-    }
-
-    @Override
-    public void onValueCodecCreated(Class<?> valueClass, Class<?> valueCodec) {
-    }
-
-    @Override
-    public void onCaseCodecCreated(Class<?> choiceClass,
-            Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec) {
-    }
-
-    @Override
-    public void onDataContainerCodecCreated(Class<?> dataClass, Class<? extends BindingCodec<?, ?>> dataCodec) {
-        if (Augmentable.class.isAssignableFrom(dataClass)) {
-            AugmentableCompositeCodec augmentableCodec = getAugmentableCodec(dataClass);
-            CodecMapping.setAugmentationCodec(dataCodec, augmentableCodec);
-        }
-
-    }
-
-    public AugmentableCompositeCodec getAugmentableCodec(Class<?> dataClass) {
-        AugmentableCompositeCodec ret = augmentableCodecs.get(dataClass);
-        if (ret != null) {
-            return ret;
-        }
-        ret = new AugmentableCompositeCodec(dataClass);
-        augmentableCodecs.put(dataClass, ret);
-        return ret;
-    }
-
-    private static abstract class IntermediateCodec<T> implements //
-            DomCodec<T>, Delegator<BindingCodec<Map<QName, Object>, Object>> {
-
-        private final BindingCodec<Map<QName, Object>, Object> delegate;
-
-        @Override
-        public BindingCodec<Map<QName, Object>, Object> getDelegate() {
-            return delegate;
-        }
-
-        public IntermediateCodec(BindingCodec<Map<QName, Object>, Object> delegate) {
-            this.delegate = delegate;
-        }
-
-        @Override
-        public Node<?> serialize(ValueWithQName<T> input) {
-            Map<QName, Object> intermediateOutput = delegate.serialize(input);
-            return toNode(intermediateOutput);
-        }
-    }
-
-    private static class IdentifierCodecImpl<T extends Identifier<?>> //
-            extends IntermediateCodec<T> //
-            implements IdentifierCodec<T> {
-
-        public IdentifierCodecImpl(BindingCodec<Map<QName, Object>, Object> delegate) {
-            super(delegate);
-        }
-
-        @Override
-        public ValueWithQName<T> deserialize(Node<?> input) {
-            QName qname = input.getNodeType();
-            @SuppressWarnings("unchecked")
-            T value = (T) getDelegate().deserialize((Map<QName, Object>) input);
-            return new ValueWithQName<T>(qname, value);
-        }
-
-        @Override
-        public CompositeNode serialize(ValueWithQName<T> input) {
-            return (CompositeNode) super.serialize(input);
-        }
-    }
-
-    private static class DataContainerCodecImpl<T extends DataContainer> //
-            extends IntermediateCodec<T> //
-            implements DataContainerCodec<T> {
-
-        public DataContainerCodecImpl(BindingCodec<Map<QName, Object>, Object> delegate) {
-            super(delegate);
-        }
-
-        @Override
-        public ValueWithQName<T> deserialize(Node<?> input) {
-            if (input == null) {
-                return null;
-            }
-            QName qname = input.getNodeType();
-            @SuppressWarnings("unchecked")
-            T value = (T) getDelegate().deserialize((Map<QName, Object>) input);
-            return new ValueWithQName<T>(qname, value);
-        }
-
-        @Override
-        public CompositeNode serialize(ValueWithQName<T> input) {
-            return (CompositeNode) super.serialize(input);
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static class ChoiceCaseCodecImpl<T extends DataContainer> implements ChoiceCaseCodec<T>, //
-            Delegator<BindingCodec> {
-        private boolean augmenting;
-        private BindingCodec delegate;
-
-        private Set<String> validNames;
-        private Set<QName> validQNames;
-        private ChoiceCaseNode schema;
-
-        public void setSchema(ChoiceCaseNode caseNode) {
-            this.schema = schema;
-            this.schema = caseNode;
-            validNames = new HashSet<>();
-            validQNames = new HashSet<>();
-            for (DataSchemaNode node : caseNode.getChildNodes()) {
-                QName qname = node.getQName();
-                validQNames.add(qname);
-                validNames.add(qname.getLocalName());
-            }
-            augmenting = caseNode.isAugmenting();
-        }
-
-        public ChoiceCaseCodecImpl() {
-            this.delegate = NOT_READY_CODEC;
-        }
-
-        public ChoiceCaseCodecImpl(ChoiceCaseNode caseNode) {
-            this.delegate = NOT_READY_CODEC;
-            setSchema(caseNode);
-        }
-
-        @Override
-        public ValueWithQName<T> deserialize(Node<?> input) {
-            throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
-        }
-
-        @Override
-        public CompositeNode serialize(ValueWithQName<T> input) {
-            throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
-        }
-
-        public BindingCodec getDelegate() {
-            return delegate;
-        }
-
-        public void setDelegate(BindingCodec delegate) {
-            this.delegate = delegate;
-        }
-
-        public ChoiceCaseNode getSchema() {
-            return schema;
-        }
-
-        @Override
-        public boolean isAcceptable(Node<?> input) {
-            if (input instanceof CompositeNode) {
-                if (augmenting) {
-                    return checkAugmenting((CompositeNode) input);
-                } else {
-                    return checkLocal((CompositeNode) input);
-                }
-            }
-            return false;
-        }
-
-        private boolean checkLocal(CompositeNode input) {
-            QName parent = input.getNodeType();
-            for (Node<?> childNode : input.getChildren()) {
-                QName child = childNode.getNodeType();
-                if (!Objects.equals(parent.getNamespace(), child.getNamespace())
-                        || !Objects.equals(parent.getRevision(), child.getRevision())) {
-                    continue;
-                }
-                if (validNames.contains(child.getLocalName())) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        private boolean checkAugmenting(CompositeNode input) {
-            for (Node<?> child : input.getChildren()) {
-                if (validQNames.contains(child.getNodeType())) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    private static class ChoiceCodecImpl<T> implements ChoiceCodec<T> {
-
-        private final BindingCodec<Map<QName, Object>, Object> delegate;
-
-        @SuppressWarnings("rawtypes")
-        private final Map<Class, ChoiceCaseCodecImpl<?>> cases = new WeakHashMap<>();
-
-        private final CaseCompositeNodeMapFacade CompositeToCase;
-
-        public ChoiceCodecImpl(BindingCodec<Map<QName, Object>, Object> delegate) {
-            this.delegate = delegate;
-            this.CompositeToCase = new CaseCompositeNodeMapFacade(cases);
-        }
-
-        @Override
-        public ValueWithQName<T> deserialize(Node<?> input) {
-            throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
-        }
-
-        @Override
-        public Node<?> serialize(ValueWithQName<T> input) {
-            throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
-        }
-
-        public CaseCompositeNodeMapFacade getCompositeToCase() {
-            return CompositeToCase;
-        }
-
-        public Map<Class, ChoiceCaseCodecImpl<?>> getCases() {
-            return cases;
-        }
-
-        public BindingCodec<Map<QName, Object>, Object> getDelegate() {
-            return delegate;
-        }
-
-    }
-
-    @SuppressWarnings("rawtypes")
-    private class CaseClassMapFacade extends MapFacadeBase {
-
-        @Override
-        public Set<java.util.Map.Entry<Class, BindingCodec<Object, Object>>> entrySet() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public BindingCodec get(Object key) {
-            if (key instanceof Class) {
-                Class cls = (Class) key;
-                // bindingClassEncountered(cls);
-                ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls);
-                return caseCodec.getDelegate();
-            }
-            return null;
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static class CaseCompositeNodeMapFacade extends MapFacadeBase<CompositeNode> {
-
-        final Map<Class, ChoiceCaseCodecImpl<?>> choiceCases;
-
-        public CaseCompositeNodeMapFacade(Map<Class, ChoiceCaseCodecImpl<?>> choiceCases) {
-            this.choiceCases = choiceCases;
-        }
-
-        @Override
-        public BindingCodec get(Object key) {
-            if (!(key instanceof CompositeNode)) {
-                return null;
-            }
-            for (java.util.Map.Entry<Class, ChoiceCaseCodecImpl<?>> entry : choiceCases.entrySet()) {
-                ChoiceCaseCodecImpl<?> codec = entry.getValue();
-                if (codec.isAcceptable((CompositeNode) key)) {
-                    return codec.getDelegate();
-                }
-            }
-            return null;
-        }
-
-    }
-
-    /**
-     * This map is used as only facade for {@link BindingCodec} in different
-     * classloaders to retrieve codec dynamicly based on provided key.
-     * 
-     * @param <T>
-     *            Key type
-     */
-    @SuppressWarnings("rawtypes")
-    private static abstract class MapFacadeBase<T> implements Map<T, BindingCodec<?, ?>> {
-
-        @Override
-        public boolean containsKey(Object key) {
-            return get(key) != null;
-        }
-
-        @Override
-        public void clear() {
-            throw notModifiable();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            return super.equals(obj);
-        }
-
-        @Override
-        public BindingCodec remove(Object key) {
-            return null;
-        }
-
-        @Override
-        public int size() {
-            return 0;
-        }
-
-        @Override
-        public Collection<BindingCodec<?, ?>> values() {
-            return Collections.emptySet();
-        }
-
-        private UnsupportedOperationException notModifiable() {
-            return new UnsupportedOperationException("Not externally modifiable.");
-        }
-
-        @Override
-        public BindingCodec<Map<QName, Object>, Object> put(T key, BindingCodec<?, ?> value) {
-            throw notModifiable();
-        }
-
-        @Override
-        public void putAll(Map<? extends T, ? extends BindingCodec<?, ?>> m) {
-            throw notModifiable();
-        }
-
-        @Override
-        public int hashCode() {
-            return super.hashCode();
-        }
-
-        @Override
-        public boolean isEmpty() {
-            return true;
-        }
-
-        @Override
-        public Set<T> keySet() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public Set<java.util.Map.Entry<T, BindingCodec<?, ?>>> entrySet() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public boolean containsValue(Object value) {
-            return false;
-        }
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    private class AugmentableCompositeCodec implements BindingCodec {
-
-        private final Class augmentableType;
-
-        Map<Class, AugmentationCodec<?>> localAugmentationCodecs = new WeakHashMap<>();
-
-        public AugmentableCompositeCodec(Class type) {
-            checkArgument(Augmentable.class.isAssignableFrom(type));
-            augmentableType = type;
-        }
-
-        @Override
-        public Object serialize(Object input) {
-            if (input instanceof Augmentable<?>) {
-
-                Map<Class, Augmentation> augmentations = getAugmentations(input);
-                return serializeImpl(augmentations);
-            }
-            return null;
-        }
-
-        private Map<Class, Augmentation> getAugmentations(Object input) {
-            Field augmentationField;
-            try {
-                augmentationField = input.getClass().getDeclaredField("augmentation");
-                augmentationField.setAccessible(true);
-                Map<Class, Augmentation> augMap = (Map<Class, Augmentation>) augmentationField.get(input);
-                return augMap;
-            } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
-                LOG.debug("Could not read augmentations for {}", input, e);
-            }
-            return Collections.emptyMap();
-        }
-
-        private List serializeImpl(Map<Class, Augmentation> input) {
-            List ret = new ArrayList<>();
-            for (Entry<Class, Augmentation> entry : input.entrySet()) {
-                AugmentationCodec codec = getCodecForAugmentation(entry.getKey());
-                CompositeNode node = codec.serialize(new ValueWithQName(null, entry.getValue()));
-                ret.addAll(node.getChildren());
-            }
-            return ret;
-        }
-
-        public synchronized <T extends Augmentation<?>> void addAugmentationCodec(Class<T> augmentationClass,
-                AugmentationCodec<T> value) {
-            localAugmentationCodecs.put(augmentationClass, value);
-        }
-
-        @Override
-        public Map<Class, Augmentation> deserialize(Object input) {
-            Map<Class, Augmentation> ret = new HashMap<>();
-            if (input instanceof CompositeNode) {
-                List<Entry<Class, AugmentationCodec<?>>> codecs = new ArrayList<>(localAugmentationCodecs.entrySet());
-                for (Entry<Class, AugmentationCodec<?>> codec : codecs) {
-                    ValueWithQName<?> value = codec.getValue().deserialize((CompositeNode) input);
-                    if (value != null && value.getValue() != null) {
-                        ret.put(codec.getKey(), (Augmentation) value.getValue());
-                    }
-                }
-            }
-            return ret;
-        }
-
-        public Class getAugmentableType() {
-            return augmentableType;
-        }
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    private static class LateMixinCodec implements BindingCodec, Delegator<BindingCodec> {
-
-        private BindingCodec delegate;
-
-        @Override
-        public BindingCodec getDelegate() {
-            if (delegate == null) {
-                throw new IllegalStateException("Codec not initialized yet.");
-            }
-            return delegate;
-        }
-
-        @Override
-        public Object deserialize(Object input) {
-            return getDelegate().deserialize(input);
-        }
-
-        @Override
-        public Object serialize(Object input) {
-            return getDelegate().serialize(input);
-        }
-    }
-
-    private static class AugmentationCodecWrapper<T extends Augmentation<?>> implements AugmentationCodec<T>,
-            Delegator<BindingCodec> {
-
-        private BindingCodec delegate;
-        private QName augmentationQName;
-
-        public AugmentationCodecWrapper(BindingCodec<Map<QName, Object>, Object> rawCodec) {
-            this.delegate = rawCodec;
-            this.augmentationQName = BindingReflections.findQName(rawCodec.getClass());
-        }
-
-        @Override
-        public BindingCodec getDelegate() {
-            return delegate;
-        }
-
-        @Override
-        public CompositeNode serialize(ValueWithQName<T> input) {
-            @SuppressWarnings("unchecked")
-            List<Map<QName, Object>> rawValues = (List<Map<QName, Object>>) getDelegate().serialize(input);
-            List<Node<?>> serialized = new ArrayList<>(rawValues.size());
-            for (Map<QName, Object> val : rawValues) {
-                serialized.add(toNode(val));
-            }
-            return new CompositeNodeTOImpl(input.getQname(), null, serialized);
-        }
-
-        @Override
-        @SuppressWarnings("unchecked")
-        public ValueWithQName<T> deserialize(Node<?> input) {
-            Object rawCodecValue = getDelegate().deserialize((Map<QName, Object>) input);
-            return new ValueWithQName<T>(input.getNodeType(), (T) rawCodecValue);
-        }
-        
-        @Override
-        public QName getAugmentationQName() {
-            return augmentationQName;
-        }
-    }
-
-    private class IdentityCompositeCodec implements IdentitityCodec {
-
-        @Override
-        public Object deserialize(Object input) {
-            checkArgument(input instanceof QName);
-            return deserialize((QName) input);
-        }
-
-        @Override
-        public Class<?> deserialize(QName input) {
-            Type type = qnamesToIdentityMap.get(input);
-            if (type == null) {
-                return null;
-            }
-            ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
-            WeakReference<Class> softref = typeToClass.get(typeref);
-            if (softref == null) {
-                return null;
-            }
-            return softref.get();
-        }
-
-        @Override
-        public QName serialize(Class input) {
-            checkArgument(BaseIdentity.class.isAssignableFrom(input));
-            bindingClassEncountered(input);
-            QName qname = identityQNames.get(input);
-            if (qname != null) {
-                return qname;
-            }
-            ConcreteType typeref = Types.typeForClass(input);
-            qname = typeToQname.get(typeref);
-            if (qname != null) {
-                identityQNames.put(input, qname);
-            }
-            return qname;
-        }
-
-        @Override
-        public Object serialize(Object input) {
-            checkArgument(input instanceof Class);
-            return serialize((Class) input);
-        }
-    }
-
-    public boolean isCodecAvailable(Class<? extends DataContainer> cls) {
-        if (containerCodecs.containsKey(cls)) {
-            return true;
-        }
-        if (identifierCodecs.containsKey(cls)) {
-            return true;
-        }
-        if (choiceCodecs.containsKey(cls)) {
-            return true;
-        }
-        if (caseCodecs.containsKey(cls)) {
-            return true;
-        }
-        if (augmentableCodecs.containsKey(cls)) {
-            return true;
-        }
-        if (augmentationCodecs.containsKey(cls)) {
-            return true;
-        }
-        return false;
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend
deleted file mode 100644 (file)
index 7461ba8..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl
-
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.TransformerGenerator
-import javassist.ClassPool
-import org.opendaylight.yangtools.yang.model.api.SchemaContext
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener
-import org.opendaylight.yangtools.sal.binding.generator.impl.BindingGeneratorImpl
-import java.util.Map
-import org.opendaylight.yangtools.sal.binding.model.api.Type
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder
-import org.opendaylight.yangtools.yang.model.api.SchemaNode
-import java.util.concurrent.ConcurrentHashMap
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import java.util.Map.Entry
-import java.util.AbstractMap.SimpleEntry
-import org.opendaylight.yangtools.yang.model.api.SchemaPath
-import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil
-import org.opendaylight.yangtools.yang.binding.DataContainer
-import java.util.concurrent.ConcurrentMap
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
-import com.google.common.collect.HashMultimap
-import com.google.common.util.concurrent.SettableFuture
-import java.util.concurrent.Future
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.LazyGeneratedCodecRegistry
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService
-import org.slf4j.LoggerFactory
-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
-import org.opendaylight.controller.sal.binding.impl.connect.dom.DeserializationException
-import java.util.concurrent.Callable
-import org.opendaylight.yangtools.yang.binding.Augmentation
-import org.opendaylight.controller.sal.binding.impl.util.YangSchemaUtils
-import org.opendaylight.controller.sal.binding.dom.serializer.api.AugmentationCodec
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
-import java.util.ArrayList
-import org.opendaylight.yangtools.yang.data.api.Node
-import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
-import org.opendaylight.yangtools.yang.binding.RpcService
-import java.util.Set
-import org.opendaylight.yangtools.yang.common.QName
-import com.google.common.collect.FluentIterable
-import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil
-
-class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaServiceListener, AutoCloseable {
-
-    @Property
-    ClassPool pool;
-
-    private static val LOG = LoggerFactory.getLogger(RuntimeGeneratedMappingServiceImpl);
-
-    @Property
-    extension TransformerGenerator binding;
-
-    @Property
-    extension LazyGeneratedCodecRegistry registry;
-
-    @Property
-    val ConcurrentMap<Type, Type> typeDefinitions = new ConcurrentHashMap();
-
-    @Property
-    val ConcurrentMap<Type, GeneratedTypeBuilder> typeToDefinition = new ConcurrentHashMap();
-
-    @Property
-    val ConcurrentMap<Type, SchemaNode> typeToSchemaNode = new ConcurrentHashMap();
-    
-    @Property
-    val ConcurrentMap<Type,Set<QName>> serviceTypeToRpc = new ConcurrentHashMap(); 
-
-    val promisedTypeDefinitions = HashMultimap.<Type, SettableFuture<GeneratedTypeBuilder>>create;
-
-    val promisedSchemas = HashMultimap.<Type, SettableFuture<SchemaNode>>create;
-
-    ServiceRegistration<SchemaServiceListener> listenerRegistration
-
-    override onGlobalContextUpdated(SchemaContext arg0) {
-        recreateBindingContext(arg0);
-        registry.onGlobalContextUpdated(arg0);
-    }
-
-    def recreateBindingContext(SchemaContext schemaContext) {
-        val newBinding = new BindingGeneratorImpl();
-        newBinding.generateTypes(schemaContext);
-
-        for (entry : newBinding.moduleContexts.entrySet) {
-
-            registry.onModuleContextAdded(schemaContext, entry.key, entry.value);
-            binding.pathToType.putAll(entry.value.childNodes)
-            val module = entry.key;
-            val context = entry.value;
-            updateBindingFor(context.childNodes, schemaContext);
-            updateBindingFor(context.cases, schemaContext);
-            val namespace = BindingGeneratorUtil.moduleNamespaceToPackageName(module);
-            
-            if(!module.rpcs.empty) {
-            val rpcs = FluentIterable.from(module.rpcs).transform[QName].toSet
-            val serviceClass = new ReferencedTypeImpl(namespace,BindingGeneratorUtil.parseToClassName(module.name)+"Service");
-                serviceTypeToRpc.put(serviceClass,rpcs);
-            }
-
-            val typedefs = context.typedefs;
-            for (typedef : typedefs.entrySet) {
-                val typeRef = new ReferencedTypeImpl(typedef.value.packageName,typedef.value.name)
-                binding.typeDefinitions.put(typeRef, typedef.value as GeneratedType);
-                val schemaNode = YangSchemaUtils.findTypeDefinition(schemaContext,typedef.key);
-                if(schemaNode != null) {
-                    
-                    binding.typeToSchemaNode.put(typeRef,schemaNode);
-                } else {
-                    LOG.error("Type definition for {} is not available",typedef.value);
-                }
-                
-            }
-            val augmentations = context.augmentations;
-            for (augmentation : augmentations) {
-                binding.typeToDefinition.put(augmentation, augmentation);
-            }
-
-            binding.typeToAugmentation.putAll(context.typeToAugmentation);
-        }
-    }
-
-    override CompositeNode toDataDom(DataObject data) {
-        toCompositeNodeImpl(data);
-    }
-
-    override Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> toDataDom(
-        Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry) {
-        
-        try {
-        val key = toDataDom(entry.key)
-        var CompositeNode data;
-        if(Augmentation.isAssignableFrom(entry.key.targetType)) {
-            data = toCompositeNodeImpl(key,entry.value);
-        } else {
-          data = toCompositeNodeImpl(entry.value);
-        }
-        return new SimpleEntry(key, data);
-        
-        } catch (Exception e) {
-            LOG.error("Error during serialization for {}.", entry.key,e);
-            throw e;
-        }
-    }
-
-    private def CompositeNode toCompositeNodeImpl(DataObject object) {
-        val cls = object.implementedInterface;
-        waitForSchema(cls);
-        val codec = registry.getCodecForDataObject(cls) as DataContainerCodec<DataObject>;
-        val ret = codec.serialize(new ValueWithQName(null, object));
-        return ret as CompositeNode;
-    }
-    
-    
-    private def CompositeNode toCompositeNodeImpl(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier identifier,DataObject object) {
-       
-        //val cls = object.implementedInterface;
-        //waitForSchema(cls);
-        val last = identifier.path.last;
-        val codec = registry.getCodecForAugmentation(object.implementedInterface as Class) as AugmentationCodec;
-        val ret = codec.serialize(new ValueWithQName(last.nodeType, object));
-        if(last instanceof NodeIdentifierWithPredicates) {
-            val predicates = last as NodeIdentifierWithPredicates;
-            val newNodes = new ArrayList<Node<?>>(predicates.keyValues.size);
-            for(predicate : predicates.keyValues.entrySet) {
-                newNodes.add(new SimpleNodeTOImpl(predicate.key,null,predicate.value));
-            }
-            newNodes.addAll(ret.children);
-            return new CompositeNodeTOImpl(last.nodeType,null,newNodes);
-        }
-        return ret as CompositeNode;
-    }
-
-    private def void waitForSchema(Class<? extends DataContainer> class1) {
-        if(Augmentation.isAssignableFrom(class1)) {
-            /*  FIXME: We should wait also for augmentations. Currently YANGTools does not provide correct
-             *  mapping between java Augmentation classes and augmentations.
-             */
-            return;
-        }
-        if(registry.isCodecAvailable(class1)) {
-            return;
-        }
-        val ref = Types.typeForClass(class1);
-        getSchemaWithRetry(ref);
-    }
-
-    override org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toDataDom(
-        InstanceIdentifier<? extends DataObject> path) {
-        for (arg : path.path) {
-            waitForSchema(arg.type);
-        }
-        return registry.instanceIdentifierCodec.serialize(path);
-    }
-
-    override dataObjectFromDataDom(InstanceIdentifier<? extends DataObject> path, CompositeNode node) {
-         dataObjectFromDataDom(path.targetType,node) as DataObject;
-    }
-
-    override fromDataDom(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry) {
-        return tryDeserialization[ |
-            registry.instanceIdentifierCodec.deserialize(entry);
-        ]
-    }
-
-    private static def <T> T tryDeserialization(Callable<T> deserializationBlock) throws DeserializationException {
-        try {
-            deserializationBlock.call()
-        } catch (Exception e) {
-
-            // FIXME: Make this block providing more information.
-            throw new DeserializationException(e);
-        }
-    }
-
-    private def void updateBindingFor(Map<SchemaPath, GeneratedTypeBuilder> map, SchemaContext module) {
-        
-        for (entry : map.entrySet) {
-            val schemaNode = SchemaContextUtil.findDataSchemaNode(module, entry.key);
-
-            //LOG.info("{} : {}",entry.key,entry.value.fullyQualifiedName)
-            val typeRef = new ReferencedTypeImpl(entry.value.packageName,entry.value.name)
-            typeToDefinition.put(typeRef, entry.value);
-            if (schemaNode != null) {
-                typeToSchemaNode.put(typeRef, schemaNode);
-                updatePromisedSchemas(typeRef, schemaNode);
-            }
-            
-        }
-    }
-
-    public def void start(BundleContext ctx) {
-        binding = new TransformerGenerator(pool);
-        registry = new LazyGeneratedCodecRegistry()
-        registry.generator = binding
-
-        //binding.staticFieldsInitializer = registry
-        binding.listener = registry
-        binding.typeToDefinition = typeToDefinition
-        binding.typeToSchemaNode = typeToSchemaNode
-        binding.typeDefinitions = typeDefinitions
-        if (ctx !== null) {
-            listenerRegistration = ctx.registerService(SchemaServiceListener, this, new Hashtable<String, String>());
-        }
-    }
-    
-    override getRpcQNamesFor(Class<? extends RpcService> service) {
-        return serviceTypeToRpc.get(new ReferencedTypeImpl(service.package.name,service.simpleName));
-    }
-
-    private def getSchemaWithRetry(Type type) {
-        val typeDef = typeToSchemaNode.get(type);
-        if (typeDef !== null) {
-            return typeDef;
-        }
-        LOG.trace("Thread blocked waiting for schema for: {}",type.fullyQualifiedName)
-        return type.getSchemaInFuture.get();
-    }
-
-    private def Future<SchemaNode> getSchemaInFuture(Type type) {
-        val future = SettableFuture.<SchemaNode>create()
-        promisedSchemas.put(type, future);
-        return future;
-    }
-
-    private def void updatePromisedSchemas(Type builder, SchemaNode schema) {
-        val ref = new ReferencedTypeImpl(builder.packageName, builder.name);
-        val futures = promisedSchemas.get(ref);
-        if (futures === null || futures.empty) {
-            return;
-        }
-        for (future : futures) {
-            future.set(schema);
-        }
-        promisedSchemas.removeAll(builder);
-    }
-
-    override close() throws Exception {
-        listenerRegistration?.unregister();
-    }
-    
-    override dataObjectFromDataDom(Class<? extends DataContainer> container, CompositeNode domData) {
-        return tryDeserialization[ |
-            if (domData == null) {
-                return null;
-            }
-            val transformer = registry.getCodecForDataObject(container);
-            val ret = transformer.deserialize(domData)?.value as DataObject;
-            return ret;
-        ]
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/StaticFieldInitializer.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/StaticFieldInitializer.java
deleted file mode 100644 (file)
index e5b36e1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl;
-
-public interface StaticFieldInitializer {
-
-    void initializeStaticFields(Class<?> cls);
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend
deleted file mode 100644 (file)
index f68f94e..0000000
+++ /dev/null
@@ -1,1566 +0,0 @@
-package org.opendaylight.controller.sal.binding.dom.serializer.impl
-
-import javassist.ClassPool
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
-import org.opendaylight.yangtools.yang.model.api.SchemaNode
-import org.opendaylight.controller.sal.binding.codegen.util.JavassistUtils
-import javassist.CtClass
-import java.util.Map
-import org.opendaylight.yangtools.yang.common.QName
-import javassist.CtField
-import static javassist.Modifier.*
-import static org.opendaylight.controller.sal.binding.dom.serializer.impl.CodecMapping.*
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
-import org.opendaylight.yangtools.sal.binding.model.api.Type
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder
-import org.opendaylight.yangtools.binding.generator.util.Types
-import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType
-import java.util.HashMap
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
-import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode
-import java.util.List
-import java.util.TreeSet
-import com.google.common.base.Joiner
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
-import static org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils.*;
-import org.opendaylight.yangtools.yang.binding.BindingDeserializer
-import org.opendaylight.yangtools.yang.binding.BindingCodec
-import org.slf4j.LoggerFactory
-import org.opendaylight.controller.sal.binding.codegen.CodeGenerationException
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode
-import java.security.ProtectionDomain
-import java.io.File
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty
-import java.util.Map.Entry
-import java.util.AbstractMap.SimpleEntry
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.Augmentation
-import java.util.Iterator
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
-import java.util.concurrent.ConcurrentHashMap
-import static extension org.opendaylight.controller.sal.binding.impl.util.YangSchemaUtils.*;
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl
-import org.opendaylight.yangtools.yang.model.util.ExtendedType
-import org.opendaylight.yangtools.yang.model.util.EnumerationType
-import static com.google.common.base.Preconditions.*
-import org.opendaylight.yangtools.yang.model.api.SchemaPath
-import javassist.CtMethod
-import javassist.CannotCompileException
-import java.util.concurrent.locks.Lock
-import java.util.concurrent.Callable
-import org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition
-import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition
-import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition
-import java.util.HashSet
-import java.util.Collections
-import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit
-import java.util.Set
-import org.opendaylight.controller.sal.binding.codegen.impl.XtendHelper
-
-class TransformerGenerator {
-
-    private static val log = LoggerFactory.getLogger(TransformerGenerator)
-
-    public static val STRING = Types.typeForClass(String);
-    public static val BOOLEAN = Types.typeForClass(Boolean);
-    public static val INTEGER = Types.typeForClass(Integer);
-    public static val INSTANCE_IDENTIFIER = Types.typeForClass(InstanceIdentifier)
-
-    //public static val DECIMAL = Types.typeForClass(Decimal);
-    public static val LONG = Types.typeForClass(Long);
-
-    val ClassPool classPool
-    val extension JavassistUtils utils;
-
-    CtClass BINDING_CODEC
-
-    CtClass ctQName
-
-    @Property
-    var File classFileCapturePath;
-
-    @Property
-    var Map<Type, Type> typeDefinitions = new ConcurrentHashMap();
-
-    @Property
-    var Map<Type, GeneratedTypeBuilder> typeToDefinition = new ConcurrentHashMap();
-
-    @Property
-    var Map<SchemaPath, GeneratedTypeBuilder> pathToType = new ConcurrentHashMap();
-
-    @Property
-    var Map<Type, SchemaNode> typeToSchemaNode = new ConcurrentHashMap();
-
-    @Property
-    var Map<Type, AugmentationSchema> typeToAugmentation = new ConcurrentHashMap();
-
-    @Property
-    var GeneratorListener listener;
-
-    public static val CLASS_TYPE = Types.typeForClass(Class);
-
-    public new(ClassPool pool) {
-        classPool = pool;
-        utils = new JavassistUtils(pool)
-
-        BINDING_CODEC = BindingCodec.asCtClass;
-        ctQName = QName.asCtClass
-    }
-
-    def Class<? extends BindingCodec<Map<QName, Object>, Object>> transformerFor(Class<?> inputType) {
-        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
-            val ret = getGeneratedClass(inputType)
-            if (ret !== null) {
-                listener.onClassProcessed(inputType);
-                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            }
-            val ref = Types.typeForClass(inputType)
-            val node = typeToSchemaNode.get(ref)
-            val typeSpecBuilder = typeToDefinition.get(ref)
-            checkState(typeSpecBuilder !== null, "Could not find typedefinition for %s", inputType.name);
-            val typeSpec = typeSpecBuilder.toInstance();
-            val newret = generateTransformerFor(inputType, typeSpec, node);
-            listener.onClassProcessed(inputType);
-            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        ]
-    }
-
-    def Class<? extends BindingCodec<Map<QName, Object>, Object>> transformerFor(Class<?> inputType, DataSchemaNode node) {
-        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
-            val ret = getGeneratedClass(inputType)
-            if (ret !== null) {
-                listener.onClassProcessed(inputType);
-                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            }
-            val ref = Types.typeForClass(inputType)
-            var typeSpecBuilder = typeToDefinition.get(ref)
-            if (typeSpecBuilder == null) {
-                typeSpecBuilder = pathToType.get(node.path);
-            }
-            var schemaNode = typeToSchemaNode.get(ref);
-            if(schemaNode === null) {
-                schemaNode = node;
-            }
-            checkState(typeSpecBuilder !== null, "Could not find TypeDefinition for %s, $s", inputType.name, node);
-            val typeSpec = typeSpecBuilder.toInstance();
-            val newret = generateTransformerFor(inputType, typeSpec, schemaNode);
-            listener.onClassProcessed(inputType);
-            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        ]
-    }
-
-    def Class<? extends BindingCodec<Map<QName, Object>, Object>> augmentationTransformerFor(Class<?> inputType) {
-        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
-            val ret = getGeneratedClass(inputType)
-            if (ret !== null) {
-                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            }
-            val ref = Types.typeForClass(inputType)
-            val node = typeToAugmentation.get(ref)
-            val typeSpecBuilder = typeToDefinition.get(ref)
-            val typeSpec = typeSpecBuilder.toInstance();
-            val newret = generateAugmentationTransformerFor(inputType, typeSpec, node);
-            listener.onClassProcessed(inputType);
-            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        ]
-    }
-
-    def Class<? extends BindingCodec<Object, Object>> caseCodecFor(Class<?> inputType, ChoiceCaseNode node) {
-        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
-            val ret = getGeneratedClass(inputType)
-            if (ret !== null) {
-                return ret as Class<? extends BindingCodec<Object, Object>>;
-            }
-            val ref = Types.typeForClass(inputType)
-            val typeSpecBuilder = typeToDefinition.get(ref)
-            val typeSpec = typeSpecBuilder.toInstance();
-            val newret = generateCaseCodec(inputType, typeSpec, node);
-            return newret as Class<? extends BindingCodec<Object, Object>>;
-        ]
-    }
-
-    def Class<? extends BindingCodec<Map<QName, Object>, Object>> keyTransformerForIdentifiable(Class<?> parentType) {
-        return withClassLoaderAndLock(parentType.classLoader, lock) [ |
-            val inputName = parentType.name + "Key";
-            val inputType = loadClassWithTCCL(inputName);
-            val ret = getGeneratedClass(inputType)
-            if (ret !== null) {
-                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            }
-            val ref = Types.typeForClass(parentType)
-            val node = typeToSchemaNode.get(ref) as ListSchemaNode
-            val typeSpecBuilder = typeToDefinition.get(ref)
-            val typeSpec = typeSpecBuilder.identifierDefinition;
-            val newret = generateKeyTransformerFor(inputType, typeSpec, node);
-            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        ]
-    }
-
-    def getIdentifierDefinition(GeneratedTypeBuilder builder) {
-        val inst = builder.toInstance
-        val keyMethod = inst.methodDefinitions.findFirst[name == "getKey"]
-        return keyMethod.returnType as GeneratedTransferObject
-    }
-
-    def Class<? extends BindingCodec<Map<QName, Object>, Object>> keyTransformerForIdentifier(Class<?> inputType) {
-        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
-            val ret = getGeneratedClass(inputType)
-            if (ret !== null) {
-                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            }
-            val ref = Types.typeForClass(inputType)
-            val node = typeToSchemaNode.get(ref) as ListSchemaNode
-            val typeSpecBuilder = typeToDefinition.get(ref)
-            val typeSpec = typeSpecBuilder.toInstance();
-            val newret = generateKeyTransformerFor(inputType, typeSpec, node);
-            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        ]
-    }
-
-    private def Class<?> keyTransformerFor(Class<?> inputType, GeneratedType type, ListSchemaNode schema) {
-        return withClassLoaderAndLock(inputType.classLoader, lock) [ |
-            val transformer = getGeneratedClass(inputType)
-            if (transformer != null) {
-                return transformer;
-            }
-            val newret = generateKeyTransformerFor(inputType, type, schema);
-            return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        ]
-    }
-
-    private def Class<?> getGeneratedClass(Class<? extends Object> cls) {
-
-        try {
-            return loadClassWithTCCL(cls.codecClassName)
-        } catch (ClassNotFoundException e) {
-            return null;
-        }
-    }
-
-    private def Class<?> keyTransformer(GeneratedType type, ListSchemaNode node) {
-        val cls = loadClassWithTCCL(type.resolvedName + "Key");
-        keyTransformerFor(cls, type, node);
-    }
-
-    private def serializer(Type type, DataSchemaNode node) {
-        val cls = loadClassWithTCCL(type.resolvedName);
-        transformerFor(cls, node);
-    }
-
-    private def Class<?> valueSerializer(GeneratedTransferObject type, TypeDefinition<?> typeDefinition) {
-        val cls = loadClassWithTCCL(type.resolvedName);
-        val transformer = cls.generatedClass;
-        if (transformer !== null) {
-            return transformer;
-        }
-        var baseType = typeDefinition;
-        while (baseType.baseType != null) {
-            baseType = baseType.baseType;
-        }
-        val finalType = baseType;
-        return withClassLoaderAndLock(cls.classLoader, lock) [ |
-            val valueTransformer = generateValueTransformer(cls, type, finalType);
-            return valueTransformer;
-        ]
-    }
-
-    private def Class<?> valueSerializer(Enumeration type, TypeDefinition<?> typeDefinition) {
-        val cls = loadClassWithTCCL(type.resolvedName);
-        val transformer = cls.generatedClass;
-        if (transformer !== null) {
-            return transformer;
-        }
-
-        return withClassLoaderAndLock(cls.classLoader, lock) [ |
-            val valueTransformer = generateValueTransformer(cls, type);
-            return valueTransformer;
-        ]
-    }
-
-    private def generateKeyTransformerFor(Class<? extends Object> inputType, GeneratedType typeSpec, ListSchemaNode node) {
-        try {
-
-            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
-            val properties = typeSpec.allProperties;
-            val ctCls = createClass(inputType.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                staticQNameField(node.QName);
-                implementsType(BINDING_CODEC)
-                method(Object, "toDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            «QName.name» _resultName;
-                            if($1 != null) {
-                                _resultName = «QName.name».create($1,QNAME.getLocalName());
-                            } else {
-                                _resultName = QNAME;
-                            }
-                            java.util.List _childNodes = new java.util.ArrayList();
-                            «inputType.resolvedName» value = («inputType.name») $2;
-                            «FOR key : node.keyDefinition»
-                                «val propertyName = key.getterName»
-                                «val keyDef = node.getDataChildByName(key)»
-                                «val property = properties.get(propertyName)»
-                                «serializeProperty(keyDef, property, propertyName)»;
-                            «ENDFOR»
-                            return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
-                        }
-                    '''
-                ]
-                method(Object, "fromDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            if($2 == null){
-                                return  null;
-                            }
-                            «QName.name» _localQName = $1;
-                            java.util.Map _compositeNode = (java.util.Map) $2;
-                            boolean _is_empty = true;
-                            «FOR key : node.keyDefinition»
-                                «val propertyName = key.getterName»
-                                «val keyDef = node.getDataChildByName(key)»
-                                «val property = properties.get(propertyName)»
-                                «deserializeProperty(keyDef, property, propertyName)»;
-                            «ENDFOR»
-                            «inputType.resolvedName» _value = new «inputType.name»(«node.keyDefinition.
-                            keyConstructorList»);
-                            return _value;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                            java.util.Map.Entry _input =  (java.util.Map.Entry) $1;
-                            «QName.name» _localQName = («QName.name») _input.getKey();
-                            «inputType.name» _keyValue = («inputType.name») _input.getValue();
-                            return toDomStatic(_localQName,_keyValue);
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''
-                        return fromDomStatic(QNAME,$1);
-                    '''
-                ]
-            ]
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret as Class<? extends BindingCodec<Map<QName,Object>, ?>>;
-        } catch (Exception e) {
-            processException(inputType, e);
-            return null;
-        }
-    }
-
-    private def Class<? extends BindingCodec<Object, Object>> generateCaseCodec(Class<?> inputType, GeneratedType type,
-        ChoiceCaseNode node) {
-        try {
-
-            //log.info("Generating DOM Codec for {} with {}, TCCL is: {}", inputType, inputType.classLoader,Thread.currentThread.contextClassLoader)
-            val ctCls = createClass(type.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                implementsType(BINDING_CODEC)
-                staticQNameField(node.QName);
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                staticField(it, AUGMENTATION_CODEC, BindingCodec)
-                staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                method(Object, "toDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            «QName.name» _resultName = «QName.name».create($1,QNAME.getLocalName());
-                            java.util.List _childNodes = new java.util.ArrayList();
-                            «type.resolvedName» value = («type.resolvedName») $2;
-                            «transformDataContainerBody(type, type.allProperties, node)»
-                            return ($r) _childNodes;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                            java.util.Map.Entry _input = (java.util.Map.Entry) $1;
-                            «QName.name» _localName = QNAME;
-                            if(_input.getKey() != null) {
-                                _localName = («QName.name») _input.getKey();
-                            }
-                            return toDomStatic(_localName,_input.getValue());
-                        }
-                    '''
-                ]
-                method(Object, "fromDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = deserializeBody(type, node)
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''
-                        {
-                            //System.out.println("«type.name»#deserialize: " +$1);
-                            java.util.Map.Entry _input = (java.util.Map.Entry) $1;
-                            return fromDomStatic((«QName.name»)_input.getKey(),_input.getValue());
-                        }
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)  as Class<? extends BindingCodec<Object, Object>>
-            listener?.onDataContainerCodecCreated(inputType, ret);
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret;
-        } catch (Exception e) {
-            processException(inputType, e);
-            return null;
-        }
-    }
-
-    private def dispatch  Class<? extends BindingCodec<Map<QName, Object>, Object>> generateTransformerFor(
-        Class<?> inputType, GeneratedType typeSpec, SchemaNode node) {
-        try {
-
-            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
-            val ctCls = createClass(typeSpec.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                staticQNameField(node.QName);
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                staticField(it, AUGMENTATION_CODEC, BindingCodec)
-                implementsType(BINDING_CODEC)
-                method(Object, "toDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = serializeBodyFacade(typeSpec, node)
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                            java.util.Map.Entry _input = (java.util.Map.Entry) $1;
-                            «QName.name» _localName = QNAME;
-                            if(_input.getKey() != null) {
-                                _localName = («QName.name») _input.getKey();
-                            }
-                            return toDomStatic(_localName,_input.getValue());
-                        }
-                    '''
-                ]
-                method(Object, "fromDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = deserializeBody(typeSpec, node)
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''
-                        return fromDomStatic(QNAME,$1);
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain) as Class<? extends BindingCodec<Map<QName,Object>, Object>>
-            listener?.onDataContainerCodecCreated(inputType, ret);
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret;
-        } catch (Exception e) {
-            processException(inputType, e);
-            return null;
-        }
-    }
-
-    private def Class<? extends BindingCodec<Map<QName, Object>, Object>> generateAugmentationTransformerFor(
-        Class<?> inputType, GeneratedType type, AugmentationSchema node) {
-        try {
-
-            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
-            val properties = type.allProperties
-            val ctCls = createClass(type.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                staticQNameField(node.augmentationQName);
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                staticField(it, AUGMENTATION_CODEC, BindingCodec)
-                staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                implementsType(BINDING_CODEC)
-                method(Object, "toDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            ////System.out.println("Qname " + $1);
-                            ////System.out.println("Value " + $2);
-                            «QName.name» _resultName = «QName.name».create(QNAME,QNAME.getLocalName());
-                            java.util.List _childNodes = new java.util.ArrayList();
-                            «type.resolvedName» value = («type.resolvedName») $2;
-                            «FOR child : node.childNodes»
-                                «var signature = properties.getFor(child)»
-                                ////System.out.println("«signature.key»" + value.«signature.key»());
-                                «serializeProperty(child, signature.value, signature.key)»
-                            «ENDFOR»
-                            return ($r) _childNodes;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                        java.util.Map.Entry _input = (java.util.Map.Entry) $1;
-                        «QName.name» _localName = QNAME;
-                        if(_input.getKey() != null) {
-                            _localName = («QName.name») _input.getKey();
-                        }
-                        return toDomStatic(_localName,_input.getValue());
-                        }
-                    '''
-                ]
-                method(Object, "fromDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            «QName.name» _localQName = QNAME;
-                            
-                            if($2 == null) {
-                            return null;
-                            }
-                            java.util.Map _compositeNode = (java.util.Map) $2;
-                            //System.out.println(_localQName + " " + _compositeNode);
-                            «type.builderName» _builder = new «type.builderName»();
-                            boolean _is_empty = true;
-                            «FOR child : node.childNodes»
-                                «val signature = properties.getFor(child)»
-                                «deserializeProperty(child, signature.value, signature.key)»
-                                _builder.«signature.key.toSetter»(«signature.key»);
-                            «ENDFOR»
-                            if(_is_empty) {
-                                return null;
-                            }
-                            return _builder.build();
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''
-                        return fromDomStatic(QNAME,$1);
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain) as Class<? extends BindingCodec<Map<QName,Object>, Object>>
-            listener?.onDataContainerCodecCreated(inputType, ret);
-            return ret;
-        } catch (Exception e) {
-            processException(inputType, e);
-            return null;
-        }
-    }
-
-    private def dispatch  Class<? extends BindingCodec<Map<QName, Object>, Object>> generateTransformerFor(
-        Class<?> inputType, GeneratedType typeSpec, ChoiceNode node) {
-        try {
-
-            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
-            val ctCls = createClass(typeSpec.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                //staticQNameField(inputType);
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                staticField(it, CLASS_TO_CASE_MAP, Map)
-                staticField(it, COMPOSITE_TO_CASE, Map)
-                //staticField(it,QNAME_TO_CASE_MAP,BindingCodec)
-                implementsType(BINDING_CODEC)
-                method(List, "toDomStatic", QName, Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            if($2 == null) {
-                                return null;
-                            }
-                            «DataObject.name» _baValue = («DataObject.name») $2;
-                            Class _baClass = _baValue.getImplementedInterface();
-                            «BINDING_CODEC.name» _codec =  «CLASS_TO_CASE_MAP».get(_baClass);
-                            if(_codec == null) {
-                                return null;
-                            }
-                            java.util.Map.Entry _input = new «SimpleEntry.name»($1,_baValue);
-                            Object _ret =  _codec.serialize(_input);
-                            ////System.out.println("«typeSpec.name»#toDomStatic: " + _ret);
-                            return («List.name») _ret;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        throw new «UnsupportedOperationException.name»("Direct invocation not supported.");
-                    '''
-                ]
-                method(Object, "fromDomStatic", QName, Map) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            «BINDING_CODEC.name» _codec = («BINDING_CODEC.name») «COMPOSITE_TO_CASE».get($2);
-                            if(_codec != null) {
-                                return _codec.deserialize(new «SimpleEntry.name»($1,$2));
-                            }
-                            return null;
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''
-                        throw new «UnsupportedOperationException.name»("Direct invocation not supported.");
-                    '''
-                ]
-            ]
-
-            val rawRet = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-            val ret = rawRet as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            listener?.onChoiceCodecCreated(inputType, ret, node);
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret;
-        } catch (Exception e) {
-            processException(inputType, e);
-            return null;
-        }
-    }
-
-    private def keyConstructorList(List<QName> qnames) {
-        val names = new TreeSet<String>()
-        for (name : qnames) {
-            val fieldName = name.getterName;
-            names.add(fieldName);
-        }
-        return Joiner.on(",").join(names);
-    }
-
-    private def serializeBodyFacade(GeneratedType type, SchemaNode node) {
-        val ret = serializeBody(type, node);
-        return ret;
-    }
-
-    private def String deserializeBody(GeneratedType type, SchemaNode node) {
-        val ret = deserializeBodyImpl(type, node);
-        return ret;
-    }
-
-    private def deserializeKey(GeneratedType type, ListSchemaNode node) {
-        if (node.keyDefinition != null && !node.keyDefinition.empty) {
-            return '''
-                «type.resolvedName»Key getKey = («type.resolvedName»Key) «keyTransformer(type, node).canonicalName».fromDomStatic(_localQName,_compositeNode);
-                _builder.setKey(getKey);
-            ''';
-        }
-    }
-
-    private def dispatch String deserializeBodyImpl(GeneratedType type, SchemaNode node) '''
-        {
-            «QName.name» _localQName = «QName.name».create($1,QNAME.getLocalName());
-            
-            if($2 == null) {
-                return null;
-            }
-            java.util.Map _compositeNode = (java.util.Map) $2;
-            «type.builderName» _builder = new «type.builderName»();
-            return _builder.build();
-        }
-    '''
-
-    private def dispatch String deserializeBodyImpl(GeneratedType type, ListSchemaNode node) '''
-        {
-            «QName.name» _localQName = «QName.name».create($1,QNAME.getLocalName());
-            if($2 == null) {
-                return null;
-            }
-            java.util.Map _compositeNode = (java.util.Map) $2;
-            //System.out.println(_localQName + " " + _compositeNode);
-            «type.builderName» _builder = new «type.builderName»();
-            «deserializeKey(type, node)»
-            «deserializeDataNodeContainerBody(type, node)»
-            «deserializeAugmentations»
-            return _builder.build();
-        }
-    '''
-
-    private def dispatch String deserializeBodyImpl(GeneratedType type, ContainerSchemaNode node) '''
-        {
-            «QName.name» _localQName = «QName.name».create($1,QNAME.getLocalName());
-            if($2 == null) {
-                return null;
-            }
-            java.util.Map _compositeNode = (java.util.Map) $2;
-            //System.out.println(_localQName + " " + _compositeNode);
-            «type.builderName» _builder = new «type.builderName»();
-            «deserializeDataNodeContainerBody(type, node)»
-            «deserializeAugmentations»
-            return _builder.build();
-        }
-    '''
-
-    private def dispatch String deserializeBodyImpl(GeneratedType type, ChoiceCaseNode node) '''
-        {
-            «QName.name» _localQName = «QName.name».create($1,QNAME.getLocalName());
-            
-            if($2 == null) {
-                return null;
-            }
-            java.util.Map _compositeNode = (java.util.Map) $2;
-            //System.out.println(_localQName + " " + _compositeNode);
-            «type.builderName» _builder = new «type.builderName»();
-            «deserializeDataNodeContainerBody(type, node)»
-            «deserializeAugmentations»
-            return _builder.build();
-        }
-    '''
-
-    private def deserializeDataNodeContainerBody(GeneratedType type, DataNodeContainer node) {
-        deserializeNodeContainerBodyImpl(type, type.allProperties, node);
-    }
-
-    private def deserializeNodeContainerBodyImpl(GeneratedType type, HashMap<String, Type> properties,
-        DataNodeContainer node) {
-        val ret = '''
-            boolean _is_empty = true;
-            «FOR child : node.childNodes»
-                «val signature = properties.getFor(child)»
-                «IF signature !== null»
-                    «deserializeProperty(child, signature.value, signature.key)»
-                    _builder.«signature.key.toSetter»(«signature.key»);
-                «ENDIF»
-            «ENDFOR»
-        '''
-        return ret;
-    }
-
-    def deserializeAugmentations() '''
-        java.util.Map _augmentation = (java.util.Map) «AUGMENTATION_CODEC».deserialize(_compositeNode);
-        if(_augmentation != null) {
-            «Iterator.name» _entries = _augmentation.entrySet().iterator();
-            while(_entries.hasNext()) {
-                java.util.Map.Entry _entry = (java.util.Map.Entry) _entries.next();
-                ////System.out.println("Aug. key:" + _entry.getKey());
-                Class _type = (Class) _entry.getKey();
-                «Augmentation.resolvedName» _value = («Augmentation.name») _entry.getValue();
-                if(_value != null) {
-                    _builder.addAugmentation(_type,_value);
-                }
-            }
-        }
-    '''
-
-    private def dispatch CharSequence deserializeProperty(ListSchemaNode schema, ParameterizedType type,
-        String propertyName) '''
-        java.util.List _dom_«propertyName» = _compositeNode.get(«QName.name».create(_localQName,"«schema.QName.
-            localName»"));
-        ////System.out.println("«propertyName»#deCode"+_dom_«propertyName»);
-        java.util.List «propertyName» = new java.util.ArrayList();
-        if(_dom_«propertyName» != null) {
-            java.util.List _serialized = new java.util.ArrayList();
-            java.util.Iterator _iterator = _dom_«propertyName».iterator();
-            boolean _hasNext = _iterator.hasNext();
-            while(_hasNext) {
-                Object _listItem = _iterator.next();
-                _is_empty = false;
-                ////System.out.println("  item" + _listItem);
-                Object _value = «type.actualTypeArguments.get(0).serializer(schema).resolvedName».fromDomStatic(_localQName,_listItem);
-                ////System.out.println("  value" + _value);
-                «propertyName».add(_value);
-                _hasNext = _iterator.hasNext();
-            }
-        }
-        
-        ////System.out.println(" list" + «propertyName»);
-    '''
-
-    private def dispatch CharSequence deserializeProperty(LeafListSchemaNode schema, ParameterizedType type,
-        String propertyName) '''
-        java.util.List _dom_«propertyName» = _compositeNode.get(«QName.name».create(_localQName,"«schema.QName.
-            localName»"));
-        java.util.List «propertyName» = new java.util.ArrayList();
-        if(_dom_«propertyName» != null) {
-            java.util.List _serialized = new java.util.ArrayList();
-            java.util.Iterator _iterator = _dom_«propertyName».iterator();
-            boolean _hasNext = _iterator.hasNext();
-            while(_hasNext) {
-                _is_empty = false;
-                Object _listItem = _iterator.next();
-                if(_listItem instanceof java.util.Map.Entry) {
-                    Object _innerValue = ((java.util.Map.Entry) _listItem).getValue();
-                    Object _value = «deserializeValue(type.actualTypeArguments.get(0), "_innerValue", schema.type)»;
-                    «propertyName».add(_value);
-                }
-                _hasNext = _iterator.hasNext();
-            }
-        }
-    '''
-
-    private def dispatch CharSequence deserializeProperty(LeafSchemaNode schema, Type type, String propertyName) '''
-        java.util.List _dom_«propertyName»_list = 
-            _compositeNode.get(«QName.name».create(_localQName,"«schema.QName.localName»"));
-        «type.resolvedName» «propertyName» = null;
-        if(_dom_«propertyName»_list != null && _dom_«propertyName»_list.size() > 0) {
-            _is_empty = false;
-            java.util.Map.Entry _dom_«propertyName» = (java.util.Map.Entry) _dom_«propertyName»_list.get(0);
-            Object _inner_value = _dom_«propertyName».getValue();
-            «propertyName» = «deserializeValue(type, "_inner_value", schema.type)»;
-        }
-    '''
-
-    private def dispatch CharSequence deserializeProperty(ContainerSchemaNode schema, Type type,
-        String propertyName) '''
-        java.util.List _dom_«propertyName»_list = 
-            _compositeNode.get(«QName.name».create(_localQName,"«schema.QName.localName»"));
-        «type.resolvedName» «propertyName» = null;
-        if(_dom_«propertyName»_list != null && _dom_«propertyName»_list.size() > 0) {
-            _is_empty = false;
-            java.util.Map _dom_«propertyName» = (java.util.Map) _dom_«propertyName»_list.get(0);
-            «propertyName» =  «type.serializer(schema).resolvedName».fromDomStatic(_localQName,_dom_«propertyName»);
-        }
-    '''
-
-    private def dispatch CharSequence deserializeProperty(ChoiceNode schema, Type type, String propertyName) '''
-        «type.resolvedName» «propertyName» = «type.serializer(schema).resolvedName».fromDomStatic(_localQName,_compositeNode);
-        if(«propertyName» != null) {
-            _is_empty = false;
-        }
-    '''
-
-    private def dispatch String deserializeValue(GeneratedTransferObject type, String domParameter,
-        TypeDefinition<?> typeDefinition) '''
-        («type.resolvedName») «type.valueSerializer(typeDefinition).resolvedName».fromDomValue(«domParameter»)
-    '''
-
-    private def dispatch String deserializeValue(Enumeration type, String domParameter, TypeDefinition<?> typeDefinition) '''
-        («type.resolvedName») «type.valueSerializer(typeDefinition).resolvedName».fromDomValue(«domParameter»)
-    '''
-
-    private def dispatch Class<? extends BindingCodec<Map<QName, Object>, Object>> generateValueTransformer(
-        Class<?> inputType, GeneratedTransferObject typeSpec, TypeDefinition<?> typeDef) {
-        try {
-
-            val returnType = typeSpec.valueReturnType;
-            if (returnType == null) {
-                val ctCls = createDummyImplementation(inputType, typeSpec);
-                val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-                return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-            }
-
-            val ctCls = createClass(typeSpec.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                if (inputType.isYangBindingAvailable) {
-                    implementsType(BINDING_CODEC)
-                    staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                    staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                    implementsType(BindingDeserializer.asCtClass)
-                }
-                method(Object, "toDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    val ctSpec = typeSpec.asCtClass;
-                    bodyChecked = '''
-                        {
-                            ////System.out.println("«inputType.simpleName»#toDomValue: "+$1);
-                            
-                            if($1 == null) {
-                                return null;
-                            }
-                            «typeSpec.resolvedName» _encapsulatedValue = («typeSpec.resolvedName») $1;
-                            ////System.out.println("«inputType.simpleName»#toDomValue:Enc: "+_encapsulatedValue);
-                            «returnType.resolvedName» _value =  _encapsulatedValue.getValue();
-                            ////System.out.println("«inputType.simpleName»#toDomValue:DeEnc: "+_value);
-                            Object _domValue = «serializeValue(returnType, "_value", null)»;
-                            return _domValue;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                            return toDomValue($1);
-                        }
-                    '''
-                ]
-                method(Object, "fromDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            ////System.out.println("«inputType.simpleName»#fromDomValue: "+$1);
-                            
-                            if($1 == null) {
-                                return null;
-                            }
-                            «returnType.resolvedName» _simpleValue = «deserializeValue(returnType, "$1", null)»;
-                            «typeSpec.resolvedName» _value = new «typeSpec.resolvedName»(_simpleValue);
-                            return _value;
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''{
-                            return fromDomValue($1);
-                    }
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        } catch (Exception e) {
-            log.error("Cannot compile DOM Codec for {}", inputType, e);
-            val exception = new CodeGenerationException("Cannot compile Transformator for " + inputType);
-            exception.addSuppressed(e);
-            throw exception;
-        }
-    }
-
-    private def dispatch Class<? extends BindingCodec<Map<QName, Object>, Object>> generateValueTransformer(
-        Class<?> inputType, GeneratedTransferObject typeSpec, UnionTypeDefinition typeDef) {
-        try {
-            val ctCls = createClass(typeSpec.codecClassName) [
-                val properties = typeSpec.allProperties;
-                val getterToTypeDefinition = XtendHelper.getTypes(typeDef).toMap[type | type.QName.getterName];
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                if (inputType.isYangBindingAvailable) {
-                    implementsType(BINDING_CODEC)
-                    staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                    staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                    implementsType(BindingDeserializer.asCtClass)
-                }
-                method(Object, "toDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    val ctSpec = inputType.asCtClass;
-                    
-                    bodyChecked = '''
-                        {
-                            ////System.out.println("«inputType.simpleName»#toDomValue: "+$1);
-                            
-                            if($1 == null) {
-                                return null;
-                            }
-                            «typeSpec.resolvedName» _value = («typeSpec.resolvedName») $1;
-                            «FOR property : properties.entrySet»
-                                «IF property.key != "getValue"»
-                                    «property.value.resolvedName» «property.key» = («property.value.resolvedName») _value.«property.
-                            key»();
-                                    if(«property.key» != null) { 
-                                        return «serializeValue(property.value, property.key, getterToTypeDefinition.get(property.key))»;
-                                    }
-                                «ENDIF»
-                            «ENDFOR»
-                            
-                            return null;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                            return toDomValue($1);
-                        }
-                    '''
-                ]
-                method(Object, "fromDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            ////System.out.println("«inputType.simpleName»#fromDomValue: "+$1);
-                            
-                            if($1 == null) {
-                                return null;
-                            }
-                            if($1 instanceof String) {
-                                String _simpleValue = (String) $1;
-                                return new «typeSpec.resolvedName»(_simpleValue.toCharArray());
-                            }
-                            return null;
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''{
-                            return fromDomValue($1);
-                    }
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        } catch (Exception e) {
-            log.error("Cannot compile DOM Codec for {}", inputType, e);
-            val exception = new CodeGenerationException("Cannot compile Transformator for " + inputType);
-            exception.addSuppressed(e);
-            throw exception;
-        }
-    }
-
-
-    private def dispatch Class<? extends BindingCodec<Map<QName, Object>, Object>> generateValueTransformer(
-        Class<?> inputType, GeneratedTransferObject typeSpec, BitsTypeDefinition typeDef) {
-        try {
-            val ctCls = createClass(typeSpec.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                if (inputType.isYangBindingAvailable) {
-                    implementsType(BINDING_CODEC)
-                    staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                    staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                    implementsType(BindingDeserializer.asCtClass)
-                }
-                method(Object, "toDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    val ctSpec = typeSpec.asCtClass;
-                    bodyChecked = '''
-                        {
-                            ////System.out.println("«inputType.simpleName»#toDomValue: "+$1);
-                            
-                            if($1 == null) {
-                                return null;
-                            }
-                            «typeSpec.resolvedName» _encapsulatedValue = («typeSpec.resolvedName») $1;
-                            «HashSet.resolvedName» _value = new «HashSet.resolvedName»();
-                            //System.out.println("«inputType.simpleName»#toDomValue:Enc: "+_encapsulatedValue);
-                            
-                            «FOR bit : typeDef.bits»
-                                «val getter = bit.getterName()»
-                                if(Boolean.TRUE.equals(_encapsulatedValue.«getter»())) {
-                                    _value.add("«bit.name»");
-                                }
-                            «ENDFOR»
-                            «Set.resolvedName» _domValue =  «Collections.resolvedName».unmodifiableSet(_value);
-                            //System.out.println("«inputType.simpleName»#toDomValue:DeEnc: "+_domValue);
-                            
-                            return _domValue;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        {
-                            return toDomValue($1);
-                        }
-                    '''
-                ]
-                method(Object, "fromDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    val sortedBits = typeDef.bits.sort[o1, o2|o1.propertyName.compareTo(o2.propertyName)]
-                    bodyChecked = '''
-                        {
-                            //System.out.println("«inputType.simpleName»#fromDomValue: "+$1);
-                            
-                            if($1 == null) {
-                                return null;
-                            }
-                            «Set.resolvedName» _domValue = («Set.resolvedName») $1;
-                            «FOR bit : sortedBits»
-                                Boolean «bit.propertyName» = Boolean.valueOf(_domValue.contains("«bit.name»"));
-                            «ENDFOR»
-                            
-                            return new «inputType.resolvedName»(«FOR bit : sortedBits SEPARATOR ","»«bit.propertyName»«ENDFOR»);
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''{
-                            return fromDomValue($1);
-                    }
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
-        } catch (Exception e) {
-            log.error("Cannot compile DOM Codec for {}", inputType, e);
-            val exception = new CodeGenerationException("Cannot compile Transformator for " + inputType);
-            exception.addSuppressed(e);
-            throw exception;
-        }
-    }
-
-    def String getPropertyName(Bit bit) {
-        '''_«BindingGeneratorUtil.parseToValidParamName(bit.name)»'''
-    }
-
-    def String getterName(Bit bit) {
-
-        val paramName = BindingGeneratorUtil.parseToValidParamName(bit.name);
-        return '''is«paramName.toFirstUpper»''';
-    }
-
-    def boolean isYangBindingAvailable(Class<?> class1) {
-        try {
-            val bindingCodecClass = class1.classLoader.loadClass(BINDING_CODEC.name);
-            return bindingCodecClass !== null;
-        } catch (ClassNotFoundException e) {
-            return false;
-        }
-    }
-
-    private def createDummyImplementation(Class<?> object, GeneratedTransferObject typeSpec) {
-        log.trace("Generating Dummy DOM Codec for {} with {}", object, object.classLoader)
-        return createClass(typeSpec.codecClassName) [
-            if (object.isYangBindingAvailable) {
-                implementsType(BINDING_CODEC)
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                implementsType(BindingDeserializer.asCtClass)
-            }
-            //implementsType(BindingDeserializer.asCtClass)
-            method(Object, "toDomValue", Object) [
-                modifiers = PUBLIC + FINAL + STATIC
-                bodyChecked = '''{
-                    if($1 == null) {
-                        return null;
-                    }
-                    return $1.toString();
-                    
-                    }'''
-            ]
-            method(Object, "serialize", Object) [
-                bodyChecked = '''
-                    {
-                        return toDomValue($1);
-                    }
-                '''
-            ]
-            method(Object, "fromDomValue", Object) [
-                modifiers = PUBLIC + FINAL + STATIC
-                bodyChecked = '''return null;'''
-            ]
-            method(Object, "deserialize", Object) [
-                bodyChecked = '''{
-                        return fromDomValue($1);
-                    }
-                    '''
-            ]
-        ]
-    }
-
-    private def Type getValueReturnType(GeneratedTransferObject object) {
-        for (prop : object.properties) {
-            if (prop.name == "value") {
-                return prop.returnType;
-            }
-        }
-        if (object.superType != null) {
-            return getValueReturnType(object.superType);
-        }
-        return null;
-    }
-
-    private def Class<?> generateValueTransformer(Class<?> inputType, Enumeration typeSpec) {
-        try {
-            val typeRef = new ReferencedTypeImpl(typeSpec.packageName, typeSpec.name);
-            val schema = typeToSchemaNode.get(typeRef) as ExtendedType;
-            val enumSchema = schema.baseType as EnumerationType;
-
-            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
-            val ctCls = createClass(typeSpec.codecClassName) [
-                //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                //implementsType(BINDING_CODEC)
-                method(Object, "toDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''{
-                            if($1 == null) {
-                                return null;
-                            }
-                            «typeSpec.resolvedName» _value = («typeSpec.resolvedName») $1;
-                            «FOR en : enumSchema.values»
-                            if(«typeSpec.resolvedName».«BindingGeneratorUtil.parseToClassName(en.name)».equals(_value)) {
-                                return "«en.name»";
-                            }
-                            «ENDFOR»
-                            return null;
-                        }
-                    '''
-                ]
-                method(Object, "serialize", Object) [
-                    bodyChecked = '''
-                        return toDomValue($1);
-                    '''
-                ]
-                method(Object, "fromDomValue", Object) [
-                    modifiers = PUBLIC + FINAL + STATIC
-                    bodyChecked = '''
-                        {
-                            if($1 == null) {
-                                return null;
-                            }
-                            String _value = (String) $1;
-                            «FOR en : enumSchema.values»
-                                if("«en.name»".equals(_value)) {
-                                    return «typeSpec.resolvedName».«BindingGeneratorUtil.parseToClassName(en.name)»;
-                                }
-                            «ENDFOR»
-                            return null;
-                        }
-                    '''
-                ]
-                method(Object, "deserialize", Object) [
-                    bodyChecked = '''
-                        return fromDomValue($1);
-                    '''
-                ]
-            ]
-
-            val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
-            log.debug("DOM Codec for {} was generated {}", inputType, ret)
-            return ret;
-        } catch (CodeGenerationException e) {
-            throw new CodeGenerationException("Cannot compile Transformator for " + inputType, e);
-        } catch (Exception e) {
-            log.error("Cannot compile DOM Codec for {}", inputType, e);
-            val exception = new CodeGenerationException("Cannot compile Transformator for " + inputType);
-            exception.addSuppressed(e);
-            throw exception;
-        }
-
-    }
-
-    def Class<?> toClassImpl(CtClass newClass, ClassLoader loader, ProtectionDomain domain) {
-        val cls = newClass.toClass(loader, domain);
-        if (classFileCapturePath !== null) {
-            newClass.writeFile(classFileCapturePath.absolutePath);
-        }
-        listener?.onCodecCreated(cls);
-        return cls;
-    }
-
-    def debugWriteClass(CtClass class1) {
-        val path = class1.name.replace(".", "/") + ".class"
-
-        val captureFile = new File(classFileCapturePath, path);
-        captureFile.createNewFile
-
-    }
-
-    private def dispatch String deserializeValue(Type type, String domParameter, TypeDefinition<?> typeDef) {
-        if (INSTANCE_IDENTIFIER.equals(type)) {
-            return '''(«InstanceIdentifier.name») «INSTANCE_IDENTIFIER_CODEC».deserialize(«domParameter»)'''
-        } else if (CLASS_TYPE.equals(type)) {
-            return '''(«Class.name») «IDENTITYREF_CODEC».deserialize(«domParameter»)'''
-        }
-        return '''(«type.resolvedName») «domParameter»'''
-
-    }
-
-    /** 
-     * Default catch all
-     * 
-     **/
-    private def dispatch CharSequence deserializeProperty(DataSchemaNode container, Type type, String propertyName) '''
-        «type.resolvedName» «propertyName» = null;
-    '''
-
-    private def dispatch CharSequence deserializeProperty(DataSchemaNode container, GeneratedTypeBuilder type,
-        String propertyName) {
-        _deserializeProperty(container, type.toInstance, propertyName)
-    }
-
-    public static def toSetter(String it) {
-
-        if (startsWith("is")) {
-            return "set" + substring(2);
-        } else if (startsWith("get")) {
-            return "set" + substring(3);
-        }
-        return "set" + it;
-    }
-
-    /* 
-    private def dispatch CharSequence deserializeProperty(DataSchemaNode container,GeneratedType type, String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        if(«propertyName» != null) {
-            Object domValue = «type.serializer».toDomStatic(QNAME,«propertyName»);
-            _childNodes.add(domValue);
-        }
-    '''
-    */
-    private def getBuilderName(GeneratedType type) '''«type.resolvedName»Builder'''
-
-    private def staticQNameField(CtClass it, QName node) {
-        val field = new CtField(ctQName, "QNAME", it);
-        field.modifiers = PUBLIC + FINAL + STATIC;
-        addField(field,
-            '''«QName.asCtClass.name».create("«node.namespace»","«node.formattedRevision»","«node.localName»")''')
-    }
-
-    private def dispatch String serializeBody(GeneratedType type, ListSchemaNode node) '''
-        {
-            «QName.name» _resultName = «QName.name».create($1,QNAME.getLocalName());
-            java.util.List _childNodes = new java.util.ArrayList();
-            «type.resolvedName» value = («type.resolvedName») $2;
-            «transformDataContainerBody(type, type.allProperties, node)»
-            «serializeAugmentations»
-            return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
-        }
-    '''
-
-    private def dispatch String serializeBody(GeneratedType type, ContainerSchemaNode node) '''
-        {
-            «QName.name» _resultName = «QName.name».create($1,QNAME.getLocalName());
-            java.util.List _childNodes = new java.util.ArrayList();
-            «type.resolvedName» value = («type.resolvedName») $2;
-            «transformDataContainerBody(type, type.allProperties, node)»
-            «serializeAugmentations»
-            return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
-        }
-    '''
-
-    private def dispatch String serializeBody(GeneratedType type, ChoiceCaseNode node) '''
-        {
-        «QName.name» _resultName = «QName.name».create($1,QNAME.getLocalName());
-            java.util.List _childNodes = new java.util.ArrayList();
-            «type.resolvedName» value = («type.resolvedName») $2;
-            «transformDataContainerBody(type, type.allProperties, node)»
-            «serializeAugmentations»
-            return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
-        }
-    '''
-
-    private def dispatch String serializeBody(GeneratedType type, SchemaNode node) '''
-        {
-        «QName.name» _resultName = «QName.name».create($1,QNAME.getLocalName());
-            java.util.List _childNodes = new java.util.ArrayList();
-            «type.resolvedName» value = («type.resolvedName») $2;
-            return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
-        }
-    '''
-
-    private def transformDataContainerBody(Type type, Map<String, Type> properties, DataNodeContainer node) {
-        val ret = '''
-            «FOR child : node.childNodes»
-                «val signature = properties.getFor(child)»
-                «IF signature !== null»
-                    ////System.out.println("«type.name»#«signature.key»" + value.«signature.key»());
-                    «serializeProperty(child, signature.value, signature.key)»
-                «ENDIF»
-            «ENDFOR»
-        '''
-        return ret;
-    }
-
-    private def serializeAugmentations() '''
-        java.util.List _augmentations = (java.util.List) «AUGMENTATION_CODEC».serialize(value);
-        if(_augmentations != null) {
-            _childNodes.addAll(_augmentations);
-        }
-    '''
-
-    def Entry<String, Type> getFor(Map<String, Type> map, DataSchemaNode node) {
-        var sig = map.get(node.getterName);
-        if (sig != null) {
-            return new SimpleEntry(node.getterName, sig);
-        }
-        sig = map.get(node.booleanGetterName);
-        if (sig != null) {
-            return new SimpleEntry(node.booleanGetterName, map.get(node.booleanGetterName));
-        }
-        return null;
-    }
-
-    private static def String getBooleanGetterName(DataSchemaNode node) {
-        return "is" + BindingGeneratorUtil.parseToClassName(node.QName.localName);
-    }
-
-    private static def String getGetterName(DataSchemaNode node) {
-        return "get" + BindingGeneratorUtil.parseToClassName(node.QName.localName);
-    }
-
-    private static def String getGetterName(QName node) {
-        return "get" + BindingGeneratorUtil.parseToClassName(node.localName);
-    }
-
-    private def dispatch CharSequence serializeProperty(ListSchemaNode schema, ParameterizedType type,
-        String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        ////System.out.println("«propertyName»:" + «propertyName»);
-        if(«propertyName» != null) {
-            java.util.Iterator _iterator = «propertyName».iterator();
-            boolean _hasNext = _iterator.hasNext();
-            while(_hasNext) {
-                Object _listItem = _iterator.next();
-                Object _domValue = «type.actualTypeArguments.get(0).serializer(schema).resolvedName».toDomStatic(_resultName,_listItem);
-                _childNodes.add(_domValue);
-                _hasNext = _iterator.hasNext();
-            }
-        }
-    '''
-
-    private def dispatch CharSequence serializeProperty(LeafSchemaNode schema, Type type, String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        
-        if(«propertyName» != null) {
-            «QName.name» _qname = «QName.name».create(_resultName,"«schema.QName.localName»");
-            Object _propValue = «serializeValue(type, propertyName, schema.type)»;
-            if(_propValue != null) {
-                Object _domValue = java.util.Collections.singletonMap(_qname,_propValue);
-                _childNodes.add(_domValue);
-            }
-        }
-    '''
-
-    private def dispatch serializeValue(GeneratedTransferObject type, String parameter, TypeDefinition<?> typeDefinition) {
-        '''«type.valueSerializer(typeDefinition).resolvedName».toDomValue(«parameter»)'''
-    }
-
-    private def dispatch serializeValue(Enumeration type, String parameter, TypeDefinition<?> typeDefinition) {
-        '''«type.valueSerializer(typeDefinition).resolvedName».toDomValue(«parameter»)'''
-    }
-
-    private def dispatch serializeValue(Type signature, String property, TypeDefinition<?> typeDefinition) {
-        if (INSTANCE_IDENTIFIER == signature) {
-            return '''«INSTANCE_IDENTIFIER_CODEC».serialize(«property»)'''
-        } else if (CLASS_TYPE.equals(signature)) {
-            return '''(«QName.resolvedName») «IDENTITYREF_CODEC».serialize(«property»)'''
-        }
-        if ("char[]" == signature.name) {
-            return '''new String(«property»)''';
-        }
-        return '''«property»''';
-    }
-
-    private def dispatch CharSequence serializeProperty(LeafListSchemaNode schema, ParameterizedType type,
-        String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        if(«propertyName» != null) {
-            «QName.name» _qname = «QName.name».create(_resultName,"«schema.QName.localName»");
-            java.util.Iterator _iterator = «propertyName».iterator();
-            boolean _hasNext = _iterator.hasNext();
-            while(_hasNext) {
-                Object _listItem = _iterator.next();
-                Object _propValue = «serializeValue(type.actualTypeArguments.get(0), "_listItem", schema.type)»;
-                Object _domValue = java.util.Collections.singletonMap(_qname,_propValue);
-                _childNodes.add(_domValue);
-                _hasNext = _iterator.hasNext();
-            }
-        }
-    '''
-
-    private def dispatch CharSequence serializeProperty(ChoiceNode container, GeneratedType type,
-        String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        if(«propertyName» != null) {
-            java.util.List domValue = «type.serializer(container).resolvedName».toDomStatic(_resultName,«propertyName»);
-            _childNodes.addAll(domValue);
-        }
-    '''
-
-    /** 
-     * Default catch all
-     * 
-     **/
-    private def dispatch CharSequence serializeProperty(DataSchemaNode container, Type type, String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        if(«propertyName» != null) {
-            Object domValue = «propertyName»;
-            _childNodes.add(domValue);
-        }
-    '''
-
-    private def dispatch CharSequence serializeProperty(DataSchemaNode container, GeneratedTypeBuilder type,
-        String propertyName) {
-        serializeProperty(container, type.toInstance, propertyName)
-    }
-
-    private def dispatch CharSequence serializeProperty(DataSchemaNode container, GeneratedType type,
-        String propertyName) '''
-        «type.resolvedName» «propertyName» = value.«propertyName»();
-        if(«propertyName» != null) {
-            Object domValue = «type.serializer(container).resolvedName».toDomStatic(_resultName,«propertyName»);
-            _childNodes.add(domValue);
-        }
-    '''
-
-    private def codecClassName(GeneratedType typeSpec) {
-        return '''«typeSpec.resolvedName»$Broker$Codec$DOM'''
-    }
-
-    private def codecClassName(Class<?> typeSpec) {
-        return '''«typeSpec.name»$Broker$Codec$DOM'''
-    }
-
-    private def HashMap<String, Type> getAllProperties(GeneratedType type) {
-        val ret = new HashMap<String, Type>();
-        type.collectAllProperties(ret);
-        return ret;
-    }
-
-    private def dispatch void collectAllProperties(GeneratedType type, Map<String, Type> set) {
-        for (definition : type.methodDefinitions) {
-            set.put(definition.name, definition.returnType);
-        }
-        for (property : type.properties) {
-            set.put(property.getterName, property.returnType);
-        }
-        for (parent : type.implements) {
-            parent.collectAllProperties(set);
-        }
-    }
-
-    def String getGetterName(GeneratedProperty property) {
-        return "get" + property.name.toFirstUpper
-    }
-
-    private def dispatch void collectAllProperties(Type type, Map<String, Type> set) {
-        // NOOP for generic type.
-    }
-
-    def String getResolvedName(Type type) {
-        return type.asCtClass.name;
-    }
-
-    def String getResolvedName(Class<?> type) {
-        return type.asCtClass.name;
-    }
-
-    def CtClass asCtClass(Type type) {
-        val cls = loadClassWithTCCL(type.fullyQualifiedName)
-        return cls.asCtClass;
-    }
-
-    private def dispatch processException(Class<?> inputType, CodeGenerationException e) {
-        log.error("Cannot compile DOM Codec for {}. One of it's prerequisites was not generated.", inputType);
-        throw e;
-    }
-
-    private def dispatch processException(Class<?> inputType, Exception e) {
-        log.error("Cannot compile DOM Codec for {}", inputType, e);
-        val exception = new CodeGenerationException("Cannot compile Transformator for " + inputType, e);
-        throw exception;
-    }
-
-    private def setBodyChecked(CtMethod method, String body) {
-        try {
-            method.setBody(body);
-        } catch (CannotCompileException e) {
-            log.error("Cannot compile method: {}#{} {}, Reason: {} Body: {}", method.declaringClass, method.name,
-                method.signature, e.message, body)
-            throw e;
-        }
-    }
-
-    private def <V> V withClassLoaderAndLock(ClassLoader cls, Lock lock, Callable<V> function) throws Exception {
-        appendClassLoaderIfMissing(cls);
-        ClassLoaderUtils.withClassLoaderAndLock(cls, lock, function);
-    }
-
-}
-
-@Data
-class PropertyPair {
-
-    String getterName;
-
-    Type type;
-
-    @Property
-    Type returnType;
-    @Property
-    SchemaNode schemaNode;
-}
index 72b96b2..a21b3f1 100644 (file)
@@ -12,6 +12,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
@@ -40,7 +41,7 @@ public class BindingDomConnectorDeployer {
         connector.setMappingService(source.getMappingService());
         return connector;
     }
-    
+
     public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
             ProviderSession domContext) {
         startDataForwarding(connector, baService,
@@ -52,7 +53,7 @@ public class BindingDomConnectorDeployer {
         startRpcForwarding(connector, rpcProviderRegistry, domProviderContext.getService(RpcProvisionRegistry.class));
 
     }
-    
+
     public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService provider,ProviderSession domProviderContext) {
         startNotificationForwarding(connector, provider, domProviderContext.getService(NotificationPublishService.class));
     }
@@ -78,12 +79,12 @@ public class BindingDomConnectorDeployer {
         connector.setDomDataService(domService);
         connector.startDataForwarding();
     }
-    
+
     public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService baService, NotificationPublishService domService) {
         if(connector.isNotificationForwarding()) {
             return;
         }
-        
+
         // FIXME
     }
 
index 5d48548..d2295c4 100644 (file)
@@ -42,6 +42,8 @@ import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl.GlobalRpcRegistrationListener;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl.RouterInstantiationListener;
@@ -96,8 +98,8 @@ public class BindingIndependentConnector implements //
             .builder().toInstance();
 
     private final static Method EQUALS_METHOD;
-    
-    
+
+
     private BindingIndependentMappingService mappingService;
 
     private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
@@ -141,8 +143,8 @@ public class BindingIndependentConnector implements //
     private RpcProviderRegistryImpl baRpcRegistryImpl;
 
     private org.opendaylight.controller.sal.dom.broker.spi.RpcRouter biRouter;
-    
-    
+
+
     static {
         try {
         EQUALS_METHOD = Object.class.getMethod("equals", Object.class);
@@ -458,11 +460,11 @@ public class BindingIndependentConnector implements //
     }
 
     private class DomToBindingCommitHandler implements //
-            RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<?>, DataObject>>, //
+            RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject>>, //
             DataCommitHandler<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> {
 
         @Override
-        public void onRegister(DataCommitHandlerRegistration<InstanceIdentifier<?>, DataObject> registration) {
+        public void onRegister(DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject> registration) {
 
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration
                     .getPath());
@@ -470,7 +472,7 @@ public class BindingIndependentConnector implements //
         }
 
         @Override
-        public void onUnregister(DataCommitHandlerRegistration<InstanceIdentifier<?>, DataObject> registration) {
+        public void onUnregister(DataCommitHandlerRegistration<InstanceIdentifier<? extends DataObject>, DataObject> registration) {
             // NOOP for now
             // FIXME: do registration based on only active commit handlers.
         }
@@ -500,7 +502,7 @@ public class BindingIndependentConnector implements //
     /**
      * Manager responsible for instantiating forwarders responsible for
      * forwarding of RPC invocations from DOM Broker to Binding Aware Broker
-     * 
+     *
      */
     private class DomToBindingRpcForwardingManager implements
             RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>,
@@ -517,17 +519,17 @@ public class BindingIndependentConnector implements //
         public void setRegistryImpl(RpcProviderRegistryImpl registryImpl) {
             this.registryImpl = registryImpl;
         }
-        
+
         @Override
         public void onGlobalRpcRegistered(Class<? extends RpcService> cls) {
             getRpcForwarder(cls, null);
         }
-        
+
         @Override
         public void onGlobalRpcUnregistered(Class<? extends RpcService> cls) {
             // NOOP
         }
-        
+
         @Override
         public void onRpcRouterCreated(RpcRouter<?> router) {
             Class<? extends BaseIdentity> ctx = router.getContexts().iterator().next();
@@ -594,7 +596,7 @@ public class BindingIndependentConnector implements //
 
         /**
          * Constructor for Routed RPC Forwareder.
-         * 
+         *
          * @param service
          * @param context
          */
@@ -628,7 +630,7 @@ public class BindingIndependentConnector implements //
             }
         }
 
-        
+
         @Override
         public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
             if(EQUALS_METHOD.equals(method)) {
@@ -666,7 +668,7 @@ public class BindingIndependentConnector implements //
                 Class<?> cls = rpcServiceType.get();
                 ClassLoader clsLoader = cls.getClassLoader();
                 RpcService proxy = (RpcService) Proxy.newProxyInstance(clsLoader, new Class<?>[] { cls }, this);
-                
+
                 RpcRouter rpcRouter = baRpcRegistryImpl.getRpcRouter(rpcServiceType.get());
                 rpcRouter.registerDefaultService(proxy);
             }
@@ -775,10 +777,10 @@ public class BindingIndependentConnector implements //
             RpcResult<?> bindingResult = result.get();
             return Rpcs.getRpcResult(true);
         }
-        
+
         @Override
         public Future<RpcResult<?>> forwardToDomBroker(DataObject input) {
-            if(biRouter != null) { 
+            if(biRouter != null) {
                 CompositeNode xml = mappingService.toDataDom(input);
                 CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc,ImmutableList.<Node<?>>of(xml));
                 RpcResult<CompositeNode> result = biRouter.invokeRpc(rpc, wrappedXml);
@@ -806,7 +808,7 @@ public class BindingIndependentConnector implements //
             RpcResult<Void> bindingResult = result.get();
             return Rpcs.getRpcResult(bindingResult.isSuccessful(), bindingResult.getErrors());
         }
-        
+
         @Override
         public Future<RpcResult<?>> forwardToDomBroker(DataObject input) {
             return Futures.immediateFuture(null);
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMappingService.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMappingService.java
deleted file mode 100644 (file)
index e16ae48..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-public interface BindingIndependentMappingService {
-
-    CompositeNode toDataDom(DataObject data);
-
-    Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> toDataDom(
-            Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry);
-
-    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toDataDom(InstanceIdentifier<? extends DataObject> path);
-
-    DataObject dataObjectFromDataDom(InstanceIdentifier<? extends DataObject> path, CompositeNode result) throws DeserializationException;
-
-    InstanceIdentifier<?> fromDataDom(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry)  throws DeserializationException;
-    
-    Set<QName> getRpcQNamesFor(Class<? extends RpcService> service);
-
-    DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput);
-
-}
index 630b5fa..604b3b8 100644 (file)
@@ -4,6 +4,8 @@ import java.util.concurrent.ConcurrentMap;
 
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener;
@@ -15,7 +17,7 @@ public class BindingIndependentMountPointForwarder {
     private MountProvisionService domMountService;
     private MountProviderService baMountService;
     private BindingIndependentMappingService mappingService;
-    
+
     private final DomMountPointForwardingManager domForwardingManager = new DomMountPointForwardingManager();
     private final BindingMountPointForwardingManager bindingForwardingManager = new BindingMountPointForwardingManager();
 
@@ -57,11 +59,11 @@ public class BindingIndependentMountPointForwarder {
     private BindingIndependentConnector createForwarder(InstanceIdentifier<?> path, MountProviderInstance baMountPoint,
             MountProvisionInstance domMountPoint) {
         BindingIndependentConnector connector = new BindingIndependentConnector();
-        
+
         connector.setBindingDataService(baMountPoint);
         connector.setBindingRpcRegistry(baMountPoint);
         //connector.setBindingNotificationBroker(baMountPoint);
-        
+
         connector.setDomDataService(domMountPoint);
         connector.setDomRpcRegistry(domMountPoint);
         //connector.setDomNotificationBroker(domMountPoint);
@@ -78,7 +80,7 @@ public class BindingIndependentMountPointForwarder {
             }
             tryToDeployConnector(baPath,domPath);
         } catch (DeserializationException e) {
-            
+
         }
     }
 
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DeserializationException.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DeserializationException.java
deleted file mode 100644 (file)
index 9331899..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-public class DeserializationException extends Exception {
-
-    public DeserializationException() {
-    }
-
-    public DeserializationException(String message) {
-        super(message);
-    }
-
-    public DeserializationException(Throwable cause) {
-        super(cause);
-    }
-
-    public DeserializationException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public DeserializationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
-        super(message, cause, enableSuppression, writableStackTrace);
-    }
-
-}
index c715c67..1f68b34 100644 (file)
@@ -7,8 +7,7 @@ import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.DeserializationException;
+import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
@@ -20,7 +19,7 @@ public class DomForwardedBindingBrokerImpl extends RootBindingAwareBroker implem
 
     private ProviderSession domProviderContext;
     private BindingIndependentConnector connector;
-    
+
     private MountProvisionService domMountService;
 
     private final DomMountPointForwardingManager domForwardingManager = new DomMountPointForwardingManager();
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/ClassLoaderUtils.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/ClassLoaderUtils.java
deleted file mode 100644 (file)
index e0eb102..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.util;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.locks.Lock;
-
-import static com.google.common.base.Preconditions.*;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.List;
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-
-public final class ClassLoaderUtils {
-
-    private ClassLoaderUtils() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-
-    public static <V> V withClassLoader(ClassLoader cls, Callable<V> function) throws Exception {
-        return withClassLoaderAndLock(cls, Optional.<Lock> absent(), function);
-    }
-
-    public static <V> V withClassLoaderAndLock(ClassLoader cls, Lock lock, Callable<V> function) throws Exception {
-        checkNotNull(lock, "Lock should not be null");
-        return withClassLoaderAndLock(cls, Optional.of(lock), function);
-    }
-
-    public static <V> V withClassLoaderAndLock(ClassLoader cls, Optional<Lock> lock, Callable<V> function)
-            throws Exception {
-        checkNotNull(cls, "Classloader should not be null");
-        checkNotNull(function, "Function should not be null");
-        if (lock.isPresent()) {
-            lock.get().lock();
-        }
-        ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
-        try {
-            Thread.currentThread().setContextClassLoader(cls);
-            return function.call();
-        } finally {
-            Thread.currentThread().setContextClassLoader(oldCls);
-            if (lock.isPresent()) {
-                lock.get().unlock();
-            }
-        }
-    }
-
-    public static Object construct(Constructor<? extends Object> constructor, List<Object> objects)
-            throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-        Object[] initargs = objects.toArray(new Object[] {});
-        return constructor.newInstance(initargs);
-    }
-
-    public static Class<?> loadClassWithTCCL(String name) throws ClassNotFoundException {
-        if ("byte[]".equals(name)) {
-            return byte[].class;
-        } else if("char[]".equals(name)) {
-            return char[].class;
-        }
-        try {
-            return Thread.currentThread().getContextClassLoader().loadClass(name);
-        } catch (ClassNotFoundException e) {
-            String[] components = name.split("\\.");
-            String potentialOuter;
-            int length = components.length;
-            if (length > 2 && (potentialOuter = components[length - 2]) != null && Character.isUpperCase(potentialOuter.charAt(0))) {
-                
-                    String outerName = Joiner.on(".").join(Arrays.asList(components).subList(0, length - 1));
-                    String innerName = outerName + "$" + components[length-1];
-                    return Thread.currentThread().getContextClassLoader().loadClass(innerName);
-            } else {
-                throw e;
-            }
-        }
-    }
-
-    public static Class<?> tryToLoadClassWithTCCL(String fullyQualifiedName) {
-        try {
-            return loadClassWithTCCL(fullyQualifiedName);
-        } catch (ClassNotFoundException e) {
-            return null;
-        }
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/YangSchemaUtils.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/YangSchemaUtils.java
deleted file mode 100644 (file)
index 1426089..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.util;
-
-import java.util.List;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-
-import com.google.common.base.Preconditions;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-public class YangSchemaUtils {
-
-    public static final String AUGMENT_IDENTIFIER = "augment-identifier";
-
-
-    public YangSchemaUtils() {
-        throw new UnsupportedOperationException("Helper class. Instantiation is prohibited");
-    }
-
-
-    public static QName getAugmentationQName(AugmentationSchema augmentation) {
-        Preconditions.checkNotNull(augmentation, "Augmentation must not be null.");
-        QName identifier = getAugmentationIdentifier(augmentation);
-        if(identifier != null) {
-            return identifier;
-        }
-        for(DataSchemaNode child : augmentation.getChildNodes()) {
-            // FIXME: Return true name
-            return QName.create(child.getQName(), "foo_augment");
-        }
-        // FIXME: Allways return a qname with module namespace.
-        return null;
-    }
-
-    public static QName getAugmentationIdentifier(AugmentationSchema augmentation) {
-        for(UnknownSchemaNode extension : augmentation.getUnknownSchemaNodes()) {
-            if(AUGMENT_IDENTIFIER.equals(extension.getNodeType().getLocalName())) {
-                return extension.getQName();
-            }
-        }
-        return null;
-    }
-
-
-    public static TypeDefinition<?> findTypeDefinition(SchemaContext context, SchemaPath path) {
-        List<QName> arguments = path.getPath();
-        QName first = arguments.get(0);
-        QName typeQName = arguments.get(arguments.size() -1);
-        DataNodeContainer previous = context.findModuleByNamespaceAndRevision(first.getNamespace(), first.getRevision());
-        if(previous == null) {
-            return null;
-        }
-        Preconditions.checkArgument(arguments.size() == 1);
-        for (QName qName : arguments) {
-            //previous.getDataChildByName(qName);
-        }
-        for(TypeDefinition<?> typedef : previous.getTypeDefinitions()) {
-            if(typedef.getQName().equals(typeQName)) {
-                return typedef;
-            }
-        }
-        return null;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/osgi/Activator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/osgi/Activator.java
new file mode 100644 (file)
index 0000000..e846f24
--- /dev/null
@@ -0,0 +1,43 @@
+package org.opendaylight.controller.sal.binding.osgi;
+
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Hashtable;
+
+public class Activator implements BundleActivator {
+
+    private ServiceRegistration<?> reg;
+    private ServiceRegistration<SchemaServiceListener> listenerReg;
+    private ServiceRegistration<BindingIndependentMappingService> mappingReg;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+                RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
+        service.setPool(SingletonHolder.CLASS_POOL);
+        service.init();
+        startRuntimeMappingService(service, context);
+    }
+
+    private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) {
+        Hashtable<String, String> properties = new Hashtable<String, String>();
+        listenerReg = context.registerService(SchemaServiceListener.class, service, properties);
+        mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties);
+        
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        if(listenerReg != null) {
+            listenerReg.unregister();
+        }
+        if(mappingReg != null) {
+            mappingReg.unregister();
+        }
+    }
+}
index b0d1629..b95cb73 100644 (file)
@@ -18,7 +18,7 @@ module opendaylight-sal-binding-broker-impl {
 
     identity binding-dom-mapping-service {
         base config:service-type;
-        config:java-class "org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService";
+        config:java-class "org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService";
     }
 
 
index 633506f..30ec8f3 100644 (file)
@@ -1,36 +1,17 @@
 package org.opendaylight.controller.sal.binding.test;
 
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javassist.ClassPool;
-
 import org.junit.After;
 import org.junit.Before;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
 import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
 import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
 import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import org.reflections.Reflections;
-import org.reflections.scanners.ResourcesScanner;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Predicate;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 
@@ -52,7 +33,7 @@ public abstract class AbstractDataServiceTest {
         factory.setStartWithParsedSchema(getStartWithSchema());
         testContext = factory.getTestContext();
         testContext.start();
-        
+
         baDataService = testContext.getBindingDataBroker();
         biDataService = testContext.getDomDataBroker();
         dataStore = testContext.getDomDataStore();
index 37a9c27..544d6c9 100644 (file)
@@ -8,20 +8,15 @@ import java.util.concurrent.Future;
 
 import javassist.ClassPool;
 
-import org.eclipse.xtext.xbase.lib.Pure;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
 import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
 import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
-import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingDomConnectorDeployer;
 import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentConnector;
-import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
 import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
@@ -31,7 +26,6 @@ import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
 import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
-import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
 import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
 import org.opendaylight.controller.sal.dom.broker.MountPointManagerImpl;
 import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
@@ -40,9 +34,11 @@ import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapt
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker;
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
@@ -55,7 +51,6 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 
 import static com.google.common.base.Preconditions.*;
 
@@ -221,7 +216,7 @@ public class BindingTestContext implements AutoCloseable, SchemaContextProvider
         checkState(classPool != null, "ClassPool needs to be present");
         mappingServiceImpl = new RuntimeGeneratedMappingServiceImpl();
         mappingServiceImpl.setPool(classPool);
-        mappingServiceImpl.start(null);
+        mappingServiceImpl.init();
     }
 
     public void updateYangSchema(String[] files) {
index 8b2c89a..595a0b3 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.14.1</version>
+                <configuration>
+                    <reuseForks>false</reuseForks>
+                </configuration>
+            </plugin>
         </plugins>
         <pluginManagement>
             <plugins>
index b4f6bea..94d2269 100644 (file)
@@ -38,13 +38,13 @@ public class TestHelper {
 
     public static Option configMinumumBundles() {
         return new DefaultCompositeOption(
+                mavenBundle(CONTROLLER, "config-api").versionAsInProject(), // //
+                bindingAwareSalBundles(),
                 mavenBundle("commons-codec", "commons-codec").versionAsInProject(),
 
-                mavenBundle(CONTROLLER, "config-api").versionAsInProject(), // //
                 mavenBundle(CONTROLLER, "protocol-framework").versionAsInProject(), //
                 mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), // //
                 mavenBundle("commons-io", "commons-io").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "config-api").versionAsInProject(), //
                 mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), //
                 mavenBundle(CONTROLLER, "yang-jmx-generator").versionAsInProject(), //
                 mavenBundle(CONTROLLER, "yang-store-api").versionAsInProject(), //
@@ -83,20 +83,16 @@ public class TestHelper {
 
     public static Option bindingAwareSalBundles() {
         return new DefaultCompositeOption( //
-                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-binding-util").versionAsInProject(), //
+                mdSalCoreBundles(),
+                
                 mavenBundle("org.javassist", "javassist").versionAsInProject(), // //
-                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // //
-
+                
                 mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS, "yang-model-util").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS, "yang-parser-api").versionAsInProject(), //
                 mavenBundle(YANGTOOLS, "yang-parser-impl").versionAsInProject(),
-
                 mavenBundle(YANGTOOLS, "binding-generator-spi").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS, "binding-model-api").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS, "binding-generator-util").versionAsInProject(), //
@@ -105,12 +101,20 @@ public class TestHelper {
                 mavenBundle(YANGTOOLS, "binding-generator-api").versionAsInProject(), mavenBundle(YANGTOOLS,
                         "binding-generator-spi").versionAsInProject(), //
                 mavenBundle(YANGTOOLS, "binding-generator-impl").versionAsInProject(),
-
+                mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), // //
+                
                 mavenBundle(CONTROLLER, "sal-core-api").versionAsInProject().update(), //
+                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-binding-util").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // //
+
+
+                
                 mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), // //
                 mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), //
 
-                mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), // //
 
                 systemProperty("netconf.tcp.address").value("0.0.0.0"), //
                 systemProperty("netconf.tcp.port").value("18383"), //
index 302d94b..bf1b169 100644 (file)
@@ -51,9 +51,9 @@ public abstract class AbstractTest {
     public Option[] config() {
         return options(systemProperty("osgi.console").value("2401"), mavenBundle("org.slf4j", "slf4j-api")
                 .versionAsInProject(), //
-                systemProperty("logback.configurationFile").value(
-                        "file:" + PathUtils.getBaseDir()
-                                + "/src/test/resources/logback.xml"),
+//                systemProperty("logback.configurationFile").value(
+//                        "file:" + PathUtils.getBaseDir()
+//                                + "/src/test/resources/logback.xml"),
                 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), //
                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), //
                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), //
index b34c8d4..34e5b1b 100644 (file)
@@ -11,35 +11,36 @@ import org.opendaylight.controller.sal.core.api.BrokerService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 
 public interface SchemaService extends BrokerService {
 
     /**
-     * Registers a YANG module to session and global context 
-     * 
+     * Registers a YANG module to session and global context
+     *
      * @param module
      */
     void addModule(Module module);
-    
+
     /**
      * Unregisters a YANG module from session context
-     * 
+     *
      * @param module
      */
     void removeModule(Module module);
-    
+
     /**
      * Returns session specific YANG schema context
      * @return
      */
     SchemaContext getSessionContext();
-    
+
     /**
      * Returns global schema context
-     * 
+     *
      * @return
      */
     SchemaContext getGlobalContext();
-    
+
     ListenerRegistration<SchemaServiceListener> registerSchemaServiceListener(SchemaServiceListener listener);
 }
diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaServiceListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/model/SchemaServiceListener.java
deleted file mode 100644 (file)
index d76fd4d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.opendaylight.controller.sal.core.api.model;
-
-import java.util.EventListener;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-public interface SchemaServiceListener extends EventListener {
-
-    
-    void onGlobalContextUpdated(SchemaContext context);
-    
-}
index cf2a5b2..eba096c 100644 (file)
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                        <Bundle-Activator>org.opendaylight.controller.sal.dom.broker.osgi.SchemaServiceActivator</Bundle-Activator>
                         <Export-Package>
                             org.opendaylight.controller.sal.dom.broker.spi
                         </Export-Package>
index d61d709..8152cbd 100644 (file)
@@ -1,34 +1,43 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-dom-broker-impl  yang module local name: schema-service-singleton
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 17:01:31 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-dom-broker-impl  yang module local name: schema-service-singleton
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:01:31 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.dom.impl;
 
-import org.opendaylight.controller.sal.dom.broker.SchemaServiceImpl;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl;
+import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 
 /**
 *
 */
-public final class SchemaServiceImplSingletonModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule
-{
+public final class SchemaServiceImplSingletonModule extends
+        org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
 
     BundleContext bundleContext;
-    
-    public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+
+    public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, SchemaServiceImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            SchemaServiceImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
-    
+
     @Override
     public boolean canReuseInstance(AbstractSchemaServiceImplSingletonModule oldModule) {
         return true;
@@ -43,15 +52,69 @@ public final class SchemaServiceImplSingletonModule extends org.opendaylight.con
     }
 
     @Override
-    public void validate(){
+    public void validate() {
         super.validate();
     }
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        SchemaServiceImpl newInstance = new SchemaServiceImpl();
+        ServiceReference<SchemaService> ref = getBundleContext().getServiceReference(SchemaService.class);
+        if (ref != null) {
+            return new GlobalSchemaServiceProxy(getBundleContext(), ref);
+        }
+
+        GlobalBundleScanningSchemaServiceImpl newInstance = new GlobalBundleScanningSchemaServiceImpl();
         newInstance.setContext(getBundleContext());
         newInstance.start();
         return newInstance;
     }
+
+    public class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, Delegator<SchemaService> {
+
+        private BundleContext bundleContext;
+        private ServiceReference<SchemaService> reference;
+        private SchemaService delegate;
+
+        public GlobalSchemaServiceProxy(BundleContext bundleContext, ServiceReference<SchemaService> ref) {
+            this.bundleContext = bundleContext;
+            this.reference = ref;
+            this.delegate = bundleContext.getService(reference);
+        }
+
+        @Override
+        public void close() throws Exception {
+            if (delegate != null) {
+                delegate = null;
+                bundleContext.ungetService(reference);
+                reference = null;
+                bundleContext = null;
+            }
+        }
+
+        public void addModule(Module arg0) {
+            delegate.addModule(arg0);
+        }
+
+        public SchemaContext getGlobalContext() {
+            return delegate.getGlobalContext();
+        }
+
+        public SchemaContext getSessionContext() {
+            return delegate.getSessionContext();
+        }
+
+        public ListenerRegistration<SchemaServiceListener> registerSchemaServiceListener(SchemaServiceListener arg0) {
+            return delegate.registerSchemaServiceListener(arg0);
+        }
+
+        public void removeModule(Module arg0) {
+            delegate.removeModule(arg0);
+        }
+
+        @Override
+        public SchemaService getDelegate() {
+            return delegate;
+        }
+
+    }
 }
index b5737a5..53fa4d0 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.controller.sal.core.api.data.DataBrokerService
 import org.opendaylight.controller.sal.core.api.data.DataProviderService
 import org.opendaylight.controller.sal.core.api.data.DataStore
 import org.opendaylight.controller.sal.core.api.model.SchemaService
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
 import org.opendaylight.controller.sal.core.api.mount.MountService
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter
@@ -13,13 +13,13 @@ import java.net.URL;
 import java.util.Enumeration;
 
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 import org.opendaylight.yangtools.yang.parser.impl.util.URLSchemaContextResolver;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -36,15 +36,15 @@ import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSet.Builder;
 
-public class SchemaServiceImpl implements //
+public class GlobalBundleScanningSchemaServiceImpl implements //
         SchemaContextProvider, //
         SchemaService, //
         ServiceTrackerCustomizer<SchemaServiceListener, SchemaServiceListener>, //
         AutoCloseable {
-    private static final Logger logger = LoggerFactory.getLogger(SchemaServiceImpl.class);
+    private static final Logger logger = LoggerFactory.getLogger(GlobalBundleScanningSchemaServiceImpl.class);
 
     private ListenerRegistry<SchemaServiceListener> listeners;
-    
+
     private BundleContext context;
     private BundleScanner scanner = new BundleScanner();
 
@@ -78,7 +78,7 @@ public class SchemaServiceImpl implements //
             listeners = new ListenerRegistry<>();
         }
 
-        listenerTracker = new ServiceTracker<>(context, SchemaServiceListener.class, SchemaServiceImpl.this);
+        listenerTracker = new ServiceTracker<>(context, SchemaServiceListener.class, GlobalBundleScanningSchemaServiceImpl.this);
         bundleTracker = new BundleTracker<ImmutableSet<Registration<URL>>>(context, BundleEvent.RESOLVED
                         | BundleEvent.UNRESOLVED, scanner);
         bundleTracker.open();
@@ -200,7 +200,7 @@ public class SchemaServiceImpl implements //
 
         SchemaServiceListener listener = context.getService(reference);
         SchemaContext _ctxContext = getGlobalContext();
-        if (_ctxContext != null) {
+        if (getContext() != null && _ctxContext != null) {
             listener.onGlobalContextUpdated(_ctxContext);
         }
         return listener;
index 8dc65e2..039bd5d 100644 (file)
@@ -1,17 +1,9 @@
 package org.opendaylight.controller.sal.dom.broker.impl;
 
-import java.awt.PageAttributes.OriginType;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Set;
 import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicLong;
 
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
@@ -19,19 +11,15 @@ import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.impl.AbstractDataModification;
 import org.opendaylight.controller.md.sal.common.impl.util.AbstractLockableDelegator;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.util.YangDataOperations;
 import org.opendaylight.yangtools.yang.util.YangSchemaUtils;
 import org.slf4j.Logger;
@@ -41,7 +29,6 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 
 import static com.google.common.base.Preconditions.*;
-import org.opendaylight.yangtools.yang.util.YangDataOperations;
 
 public class SchemaAwareDataStoreAdapter extends AbstractLockableDelegator<DataStore> implements //
         DataStore, //
@@ -321,7 +308,6 @@ public class SchemaAwareDataStoreAdapter extends AbstractLockableDelegator<DataS
         @Override
         protected CompositeNode mergeOperationalData(InstanceIdentifier path, CompositeNode stored,
                 CompositeNode modified) {
-            // TODO Auto-generated method stub
             return mergeData(path, stored, modified, false);
         }
     }
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/SchemaServiceActivator.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/SchemaServiceActivator.java
new file mode 100644 (file)
index 0000000..617b13b
--- /dev/null
@@ -0,0 +1,30 @@
+package org.opendaylight.controller.sal.dom.broker.osgi;
+
+import java.util.Hashtable;
+
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class SchemaServiceActivator implements BundleActivator {
+
+    
+    private ServiceRegistration<SchemaService> schemaServiceReg;
+    private GlobalBundleScanningSchemaServiceImpl schemaService;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        schemaService = new GlobalBundleScanningSchemaServiceImpl();
+        schemaService.setContext(context);
+        schemaService.start();
+        schemaServiceReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String,String>());
+    }
+    
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        schemaServiceReg.unregister();
+        schemaService.close();
+    }
+}
index 8938bf2..7ac65ff 100644 (file)
@@ -1,7 +1,7 @@
 package org.opendaylight.controller.sal.dom.broker.osgi;
 
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -40,6 +40,6 @@ public class SchemaServiceProxy extends AbstractBrokerServiceProxy<SchemaService
         return registration;
     }
 
-    
-    
+
+
 }
index 1bceee8..9546447 100644 (file)
@@ -8,7 +8,7 @@ import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.Provider;
 import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
 import org.opendaylight.controller.sal.core.api.mount.MountService;
 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
@@ -22,7 +22,7 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
 public class RestconfProvider implements BundleActivator, Provider, ServiceTrackerCustomizer<Broker, Broker> {
 
     public final static String NOT_INITALIZED_MSG = "Restconf is not initialized yet. Please try again later";
-    
+
     private ListenerRegistration<SchemaServiceListener> listenerRegistration;
     private ServiceTracker<Broker, Broker> brokerServiceTrancker;
     private BundleContext bundleContext;
index b268103..9a61b43 100644 (file)
@@ -10,7 +10,7 @@ import java.util.HashMap
 import java.util.List
 import java.util.Map
 import java.util.concurrent.ConcurrentHashMap
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener
 import org.opendaylight.controller.sal.core.api.mount.MountService
 import org.opendaylight.controller.sal.rest.impl.RestUtil
 import org.opendaylight.controller.sal.rest.impl.RestconfProvider
@@ -49,7 +49,7 @@ class ControllerContext implements SchemaServiceListener {
 
     @Property
     var SchemaContext globalSchema;
-    
+
     @Property
     var MountService mountService;
 
@@ -104,7 +104,7 @@ class ControllerContext implements SchemaServiceListener {
         val modules = schema.modules.filter[m|m.name == moduleName]
         return modules.filterLatestModule
     }
-    
+
     private def filterLatestModule(Iterable<Module> modules) {
         var latestModule = modules.head
         for (module : modules) {
@@ -114,26 +114,26 @@ class ControllerContext implements SchemaServiceListener {
         }
         return latestModule
     }
-    
+
     def findModuleByName(String moduleName) {
         checkPreconditions
         checkArgument(moduleName !== null && !moduleName.empty)
         return globalSchema.getLatestModule(moduleName)
     }
-    
+
     def findModuleByName(MountInstance mountPoint, String moduleName) {
         checkArgument(moduleName !== null && mountPoint !== null)
         val mountPointSchema = mountPoint.schemaContext;
         return mountPointSchema?.getLatestModule(moduleName);
     }
-    
+
     def findModuleByNamespace(URI namespace) {
         checkPreconditions
         checkArgument(namespace !== null)
         val moduleSchemas = globalSchema.findModuleByNamespace(namespace)
         return moduleSchemas?.filterLatestModule
     }
-    
+
     def findModuleByNamespace(MountInstance mountPoint, URI namespace) {
         checkArgument(namespace !== null && mountPoint !== null)
         val mountPointSchema = mountPoint.schemaContext;
@@ -180,7 +180,7 @@ class ControllerContext implements SchemaServiceListener {
         }
         return moduleName
     }
-    
+
     def findModuleNameByNamespace(MountInstance mountPoint, URI namespace) {
         val module = mountPoint.findModuleByNamespace(namespace);
         return module?.name
@@ -196,7 +196,7 @@ class ControllerContext implements SchemaServiceListener {
         }
         return namespace
     }
-    
+
     def findNamespaceByModuleName(MountInstance mountPoint, String moduleName) {
         val module = mountPoint.findModuleByName(moduleName)
         return module?.namespace
@@ -263,7 +263,7 @@ class ControllerContext implements SchemaServiceListener {
         if(object === null) return "";
         return URLEncoder.encode(object.toString)
     }
-    
+
     private def InstanceIdWithSchemaNode collectPathArguments(InstanceIdentifierBuilder builder, List<String> strings,
         DataNodeContainer parentNode, MountInstance mountPoint) {
         checkNotNull(strings)
@@ -273,7 +273,7 @@ class ControllerContext implements SchemaServiceListener {
         if (strings.empty) {
             return new InstanceIdWithSchemaNode(builder.toInstance, parentNode as DataSchemaNode, mountPoint)
         }
-        
+
         val nodeName = strings.head.toNodeName
         val moduleName = strings.head.toModuleName
         var DataSchemaNode targetNode = null
@@ -283,45 +283,45 @@ class ControllerContext implements SchemaServiceListener {
                 if (mountPoint !== null) {
                     throw new ResponseException(BAD_REQUEST, "Restconf supports just one mount point in URI.")
                 }
-                
+
                 if (mountService === null) {
-                    throw new ResponseException(SERVICE_UNAVAILABLE, "MountService was not found. " 
+                    throw new ResponseException(SERVICE_UNAVAILABLE, "MountService was not found. "
                         + "Finding behind mount points does not work."
                     )
                 }
-                
+
                 val partialPath = builder.toInstance;
                 val mount = mountService.getMountPoint(partialPath)
                 if (mount === null) {
                     LOG.debug("Instance identifier to missing mount point: {}", partialPath)
                     throw new ResponseException(BAD_REQUEST, "Mount point does not exist.")
                 }
-                
+
                 val mountPointSchema = mount.schemaContext;
                 if (mountPointSchema === null) {
                     throw new ResponseException(BAD_REQUEST, "Mount point does not contain any schema with modules.")
                 }
-                
+
                 if (strings.size == 1) { // any data node is not behind mount point
                     return new InstanceIdWithSchemaNode(InstanceIdentifier.builder().toInstance, mountPointSchema, mount)
                 }
-                
+
                 val moduleNameBehindMountPoint = strings.get(1).toModuleName()
                 if (moduleNameBehindMountPoint === null) {
                     throw new ResponseException(BAD_REQUEST,
                         "First node after mount point in URI has to be in format \"moduleName:nodeName\"")
                 }
-                
+
                 val moduleBehindMountPoint = mountPointSchema.getLatestModule(moduleNameBehindMountPoint)
                 if (moduleBehindMountPoint === null) {
                     throw new ResponseException(BAD_REQUEST,
                         "URI has bad format. \"" + moduleName + "\" module does not exist in mount point.")
                 }
-                
+
                 return collectPathArguments(InstanceIdentifier.builder(), strings.subList(1, strings.size),
                     moduleBehindMountPoint, mount);
             }
-            
+
             var Module module = null;
             if (mountPoint === null) {
                 module = globalSchema.getLatestModule(moduleName)
@@ -338,8 +338,8 @@ class ControllerContext implements SchemaServiceListener {
             }
             targetNode = parentNode.findInstanceDataChild(nodeName, module.namespace)
             if (targetNode === null) {
-                throw new ResponseException(BAD_REQUEST, "URI has bad format. Possible reasons:\n" + 
-                    "1. \"" + strings.head + "\" was not found in parent data node.\n" + 
+                throw new ResponseException(BAD_REQUEST, "URI has bad format. Possible reasons:\n" +
+                    "1. \"" + strings.head + "\" was not found in parent data node.\n" +
                     "2. \"" + strings.head + "\" is behind mount point. Then it should be in format \"/" + MOUNT + "/" + strings.head + "\".")
             }
         } else { // string without module name
@@ -348,7 +348,7 @@ class ControllerContext implements SchemaServiceListener {
                 throw new ResponseException(BAD_REQUEST, "URI has bad format. \"" + nodeName + "\" was not found in parent data node.\n")
             }
         }
-        
+
         // Number of consumed elements
         var consumed = 1;
         if (targetNode instanceof ListSchemaNode) {
@@ -367,7 +367,7 @@ class ControllerContext implements SchemaServiceListener {
 
                 // key value cannot be NULL
                 if (uriKeyValue.equals(NULL_VALUE)) {
-                    throw new ResponseException(BAD_REQUEST, "URI has bad format. List \"" + listNode.QName.localName 
+                    throw new ResponseException(BAD_REQUEST, "URI has bad format. List \"" + listNode.QName.localName
                         + "\" cannot contain \"null\" value as a key."
                     )
                 }
@@ -397,7 +397,7 @@ class ControllerContext implements SchemaServiceListener {
         } else {
             potentialNode = container.childNodes.filter[n|n.QName.localName == name && n.QName.namespace == moduleNamespace].head
         }
-        
+
         if (potentialNode.instantiatedDataSchema) {
             return potentialNode;
         }
@@ -410,7 +410,7 @@ class ControllerContext implements SchemaServiceListener {
         }
         return null;
     }
-    
+
     static def boolean isInstantiatedDataSchema(DataSchemaNode node) {
         switch node {
             LeafSchemaNode: return true
@@ -426,7 +426,7 @@ class ControllerContext implements SchemaServiceListener {
         checkArgument(node instanceof LeafSchemaNode);
         val urlDecoded = URLDecoder.decode(uriValue);
         val typedef = (node as LeafSchemaNode).type;
-        
+
         var decoded = TypeDefinitionAwareCodec.from(typedef)?.deserialize(urlDecoded)
         if(decoded === null) {
             var baseType = RestUtil.resolveBaseTypeFrom(typedef)