Merge "HostTracker hosts DB key scheme implementation"
authorGiovanni Meo <gmeo@cisco.com>
Tue, 26 Nov 2013 11:37:38 +0000 (11:37 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 26 Nov 2013 11:37:38 +0000 (11:37 +0000)
116 files changed:
opendaylight/config/config-api/src/main/resources/META-INF/yang/config.yang
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntry.java
opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreSnapshot.java
opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java
opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java
opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/distribution/opendaylight/src/main/resources/configuration/controller.config [new file with mode: 0644]
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/BindingBrokerImplModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplSingletonModule.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplSingletonModuleFactory.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRoutingTableImpl.xtend
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/dom/serializer/impl/BindingClassListener.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecMapping.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/GeneratorListener.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataTransactionImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentMappingService.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/CommitHandlersTransactions.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/ConnectorActivator.java [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DataModificationTracker.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingContext.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/bugfix/DOMCodecBug01Test.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug03Test.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/BrokerIntegrationTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang
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-binding-it/src/test/resources/controller.config [new file with mode: 0644]
opendaylight/md-sal/sal-binding-it/src/test/resources/logback.xml
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandlerRegistration.java [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataModification.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.xtend
opendaylight/md-sal/sal-dom-api/pom.xml
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang [new file with mode: 0644]
opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang [new file with mode: 0644]
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/DomBrokerImplModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/HashMapDataStoreModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/HashMapDataStoreModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerActivator.java [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataTransactionImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/SchemaServiceImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DataProviderServiceProxy.java
opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang [new file with mode: 0644]
opendaylight/md-sal/samples/pom.xml
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/mapping/ObjectMapper.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/mapping/ObjectNameAttributeMappingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/resolving/ObjectNameAttributeResolvingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/toxml/ObjectNameAttributeWritingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Config.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/InstanceConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/InstanceConfigElementResolved.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ModuleConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Services.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigXmlParser.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditStrategyType.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/ServiceTrackerTest.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationRouterImpl.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlNetconfConstants.java
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/editConfig.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/editConfig_none.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/namespaces/editConfig_differentNamespaceTO.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/namespaces/editConfig_sameAttrDifferentNamespaces.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/namespaces/editConfig_sameAttrDifferentNamespacesList.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/namespaces/editConfig_typeNameConfigAttributeMatching.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised1.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised2.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised3.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised4.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised5.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised6.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised7.xml
opendaylight/netconf/netconf-util/src/test/resources/netconfMessages/unrecognised/editConfig_unrecognised8.xml

index 5d6c11f..a0a4292 100644 (file)
@@ -122,9 +122,7 @@ module config {
                  the actual service-type which is actually required.";
 
             mandatory true;
-            type leafref {
-                path "/config:services/config:service/config:type";
-            }
+            type service-type-ref;
         }
 
         leaf name {
index 5900810..70a4edd 100644 (file)
@@ -7,21 +7,8 @@
  */
 package org.opendaylight.controller.config.yangjmxgenerator;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static java.lang.String.format;
-import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Sets;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
 import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
@@ -50,8 +37,20 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Sets;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.lang.String.format;
+import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.createConfigQName;
 
 /**
  * Represents part of yang model that describes a module.
@@ -129,13 +128,13 @@ public class ModuleMXBeanEntry extends AbstractEntry {
     private final String nullableDescription, packageName, javaNamePrefix,
             namespace;
 
-    private final Map<String, String> providedServices;
+    private final Map<String, QName> providedServices;
 
     private Collection<RuntimeBeanEntry> runtimeBeans;
 
     public ModuleMXBeanEntry(IdentitySchemaNode id,
             Map<String, AttributeIfc> yangToAttributes, String packageName,
-            Map<String, String> providedServices2, String javaNamePrefix,
+            Map<String, QName> providedServices2, String javaNamePrefix,
             String namespace, Collection<RuntimeBeanEntry> runtimeBeans) {
         this.globallyUniqueName = id.getQName().getLocalName();
         this.yangToAttributes = yangToAttributes;
@@ -180,7 +179,11 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         return packageName;
     }
 
-    public Map<String, String> getProvidedServices() {
+    /**
+     * @return services implemented by this module. Keys are fully qualified java names of generated
+     * ServiceInterface classes, values are identity local names.
+     */
+    public Map<String, QName> getProvidedServices() {
         return providedServices;
     }
 
@@ -313,7 +316,7 @@ public class ModuleMXBeanEntry extends AbstractEntry {
                     checkState(moduleIdentity != null, "Cannot find identity "
                             + moduleLocalNameFromXPath
                             + " matching augmentation " + augmentation);
-                    Map<String, String> providedServices = findProvidedServices(
+                    Map<String, QName> providedServices = findProvidedServices(
                             moduleIdentity, currentModule, qNamesToSIEs,
                             schemaContext);
 
@@ -493,11 +496,11 @@ public class ModuleMXBeanEntry extends AbstractEntry {
         return yangToAttributes;
     }
 
-    private static Map<String, String> findProvidedServices(
+    private static Map<String, QName> findProvidedServices(
             IdentitySchemaNode moduleIdentity, Module currentModule,
             Map<QName, ServiceInterfaceEntry> qNamesToSIEs,
             SchemaContext schemaContext) {
-        Map<String, String> result = new HashMap<>();
+        Map<String, QName> result = new HashMap<>();
         for (UnknownSchemaNode unknownNode : moduleIdentity
                 .getUnknownSchemaNodes()) {
             if (ConfigConstants.PROVIDED_SERVICE_EXTENSION_QNAME
@@ -506,8 +509,7 @@ public class ModuleMXBeanEntry extends AbstractEntry {
                         .getNodeParameter();
                 ServiceInterfaceEntry sie = findSIE(prefixAndIdentityLocalName,
                         currentModule, qNamesToSIEs, schemaContext);
-                result.put(sie.getFullyQualifiedName(), sie.getQName()
-                        .getLocalName());
+                result.put(sie.getFullyQualifiedName(), sie.getQName());
             }
         }
         return result;
index 40daf40..da8b5e4 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 
 public interface YangStoreSnapshot extends AutoCloseable {
 
-    Map<String, Map<String, ModuleMXBeanEntry>> getModuleMXBeanEntryMap();
+    Map<String/* Namespace from yang file */,
+            Map<String /* Name of module entry from yang file */, ModuleMXBeanEntry>> getModuleMXBeanEntryMap();
 
     Map<String, Entry<Module, String>> getModuleMap();
 
index 2ead596..fcdc10f 100644 (file)
@@ -18,6 +18,8 @@ import com.google.common.collect.Sets;
 import org.opendaylight.controller.config.yang.store.api.YangStoreException;
 import org.opendaylight.controller.config.yang.store.api.YangStoreService;
 import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
+import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
@@ -34,6 +36,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -107,38 +110,42 @@ public class ExtenderYangTracker extends BundleTracker<Object> implements YangSt
                 proposedNewState.putAll(bundle, addedURLs);
 
                 Preconditions.checkArgument(addedURLs.size() > 0, "No change can occur when no URLs are changed");
-                boolean success;
-                String failureReason = null;
+
                 try(YangStoreSnapshotImpl snapshot = createSnapshot(mbeParser, proposedNewState)) {
-                    updateCache(snapshot);
-                    success = true;
+                    onSnapshotSuccess(proposedNewState, snapshot);
                 } catch(YangStoreException e) {
-                    failureReason = e.toString();
-                    success = false;
-                }
-                if (success){
-                    // consistent state
-                    // merge into
-                    consistentBundlesToYangURLs.clear();
-                    consistentBundlesToYangURLs.putAll(proposedNewState);
-                    inconsistentBundlesToYangURLs.clear();
-
-                    logger.info("Yang store updated to new consistent state containing {} yang files", consistentBundlesToYangURLs.size());
-                    logger.trace("Yang store updated to new consistent state containing {}", consistentBundlesToYangURLs);
-                } else {
-                    // inconsistent state
-                    logger.debug("Yang store is falling back on last consistent state containing {}, inconsistent yang files {}, reason {}",
-                            consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, failureReason);
-                    logger.warn("Yang store is falling back on last consistent state containing {} files, inconsistent yang files size is {}, reason {}",
-                            consistentBundlesToYangURLs.size(), inconsistentBundlesToYangURLs.size(), failureReason);
-                    inconsistentBundlesToYangURLs.putAll(bundle, addedURLs);
+                    onSnapshotFailure(bundle, addedURLs, e);
                 }
             }
         }
         return bundle;
     }
 
-    private void updateCache(YangStoreSnapshotImpl snapshot) {
+    private synchronized void onSnapshotFailure(Bundle bundle, List<URL> addedURLs, Exception failureReason) {
+        // inconsistent state
+        inconsistentBundlesToYangURLs.putAll(bundle, addedURLs);
+
+        logger.debug("Yang store is falling back on last consistent state containing {}, inconsistent yang files {}, reason {}",
+                consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, failureReason);
+        logger.warn("Yang store is falling back on last consistent state containing {} files, inconsistent yang files size is {}, reason {}",
+                consistentBundlesToYangURLs.size(), inconsistentBundlesToYangURLs.size(), failureReason.toString());
+        cache.setInconsistentURLsForReporting(inconsistentBundlesToYangURLs.values());
+    }
+
+    private synchronized void onSnapshotSuccess(Multimap<Bundle, URL> proposedNewState, YangStoreSnapshotImpl snapshot) {
+        // consistent state
+        // merge into
+        consistentBundlesToYangURLs.clear();
+        consistentBundlesToYangURLs.putAll(proposedNewState);
+        inconsistentBundlesToYangURLs.clear();
+
+        updateCache(snapshot);
+        cache.setInconsistentURLsForReporting(Collections.<URL> emptySet());
+        logger.info("Yang store updated to new consistent state containing {} yang files", consistentBundlesToYangURLs.size());
+        logger.debug("Yang store updated to new consistent state containing {}", consistentBundlesToYangURLs);
+    }
+
+    private synchronized void updateCache(YangStoreSnapshotImpl snapshot) {
         cache.cacheYangStore(consistentBundlesToYangURLs, snapshot);
     }
 
@@ -153,6 +160,7 @@ public class ExtenderYangTracker extends BundleTracker<Object> implements YangSt
      */
     @Override
     public synchronized void removedBundle(Bundle bundle, BundleEvent event, Object object) {
+        logger.debug("Removed bundle {} {} {}", bundle, event, object);
         inconsistentBundlesToYangURLs.removeAll(bundle);
         consistentBundlesToYangURLs.removeAll(bundle);
     }
@@ -162,9 +170,10 @@ public class ExtenderYangTracker extends BundleTracker<Object> implements YangSt
             throws YangStoreException {
         Optional<YangStoreSnapshot> yangStoreOpt = cache.getSnapshotIfPossible(consistentBundlesToYangURLs);
         if (yangStoreOpt.isPresent()) {
-            logger.trace("Returning cached yang store {}", yangStoreOpt.get());
+            logger.debug("Returning cached yang store {}", yangStoreOpt.get());
             return yangStoreOpt.get();
         }
+
         YangStoreSnapshotImpl snapshot = createSnapshot(mbeParser, consistentBundlesToYangURLs);
         updateCache(snapshot);
         return snapshot;
@@ -205,18 +214,27 @@ public class ExtenderYangTracker extends BundleTracker<Object> implements YangSt
 }
 
 class YangStoreCache {
+    private static final Logger logger = LoggerFactory.getLogger(YangStoreCache.class);
+
+    @GuardedBy("this")
+    private Set<URL> cachedUrls = null;
     @GuardedBy("this")
-    private Set<URL> cachedUrls = Collections.emptySet();
+    private Optional<YangStoreSnapshot> cachedYangStoreSnapshot = getInitialSnapshot();
     @GuardedBy("this")
-    private Optional<YangStoreSnapshotImpl> cachedYangStoreSnapshot = Optional.absent();
+    private Collection<URL> inconsistentURLsForReporting = Collections.emptySet();
 
     synchronized Optional<YangStoreSnapshot> getSnapshotIfPossible(Multimap<Bundle, URL> bundlesToYangURLs) {
         Set<URL> urls = setFromMultimapValues(bundlesToYangURLs);
-        if (cachedUrls != null && cachedUrls.equals(urls)) {
+
+        if (cachedUrls==null || cachedUrls.equals(urls)) {
             Preconditions.checkState(cachedYangStoreSnapshot.isPresent());
             YangStoreSnapshot freshSnapshot = new YangStoreSnapshotImpl(cachedYangStoreSnapshot.get());
+            if (inconsistentURLsForReporting.size() > 0){
+                logger.warn("Some yang URLs are ignored: {}", inconsistentURLsForReporting);
+            }
             return Optional.of(freshSnapshot);
         }
+
         return Optional.absent();
     }
 
@@ -228,7 +246,7 @@ class YangStoreCache {
     }
 
     synchronized void cacheYangStore(Multimap<Bundle, URL> urls,
-                        YangStoreSnapshotImpl yangStoreSnapshot) {
+                                     YangStoreSnapshot yangStoreSnapshot) {
         this.cachedUrls = setFromMultimapValues(urls);
         this.cachedYangStoreSnapshot = Optional.of(yangStoreSnapshot);
     }
@@ -240,4 +258,32 @@ class YangStoreCache {
             cachedYangStoreSnapshot = Optional.absent();
         }
     }
+
+    public synchronized void setInconsistentURLsForReporting(Collection<URL> urls){
+        inconsistentURLsForReporting = urls;
+    }
+
+    private Optional<YangStoreSnapshot> getInitialSnapshot() {
+        YangStoreSnapshot initialSnapshot = new YangStoreSnapshot() {
+            @Override
+            public Map<String, Map<String, ModuleMXBeanEntry>> getModuleMXBeanEntryMap() {
+                return Collections.emptyMap();
+            }
+
+            @Override
+            public Map<String, Map.Entry<Module, String>> getModuleMap() {
+                return Collections.emptyMap();
+            }
+
+            @Override
+            public int countModuleMXBeanEntries() {
+                return 0;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+        return Optional.of(initialSnapshot);
+    }
 }
index 7a5ca7d..ea709e1 100644 (file)
@@ -29,11 +29,15 @@ public class YangStoreSnapshotImpl implements YangStoreSnapshot {
         this.moduleMap = Collections.unmodifiableMap(moduleMap);
     }
 
-    public YangStoreSnapshotImpl(YangStoreSnapshotImpl yangStoreSnapshot) {
-        this.moduleMXBeanEntryMap = yangStoreSnapshot.moduleMXBeanEntryMap;
-        this.moduleMap = yangStoreSnapshot.moduleMap;
+    public YangStoreSnapshotImpl(YangStoreSnapshot yangStoreSnapshot) {
+        this.moduleMXBeanEntryMap = yangStoreSnapshot.getModuleMXBeanEntryMap();
+        this.moduleMap = yangStoreSnapshot.getModuleMap();
     }
 
+    /**
+     * @return all loaded config modules. Key of outer map is namespace of yang file.
+     * Key of inner map is name of module entry. Value is module entry.
+     */
     @Override
     public Map<String, Map<String, ModuleMXBeanEntry>> getModuleMXBeanEntryMap() {
         return moduleMXBeanEntryMap;
index c4c5239..b4054c2 100644 (file)
@@ -9,12 +9,14 @@ package org.opendaylight.controller.config.yang.store.impl;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.config.yang.store.api.YangStoreException;
 import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleListener;
@@ -25,6 +27,7 @@ import java.net.URL;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.Pattern;
 
 import static org.junit.Assert.assertEquals;
@@ -48,8 +51,28 @@ public class ExtenderYangTrackerCustomizerTest {
     @Mock
     private BundleContext bundleContext;
 
+    private Map<String, Map.Entry<Module, String>> moduleMap = Maps.newHashMap();
+
     @Before
     public void setUp() throws YangStoreException {
+
+        moduleMap.put("1", new Map.Entry<Module, String>() {
+            @Override
+            public Module getKey() {
+                return mock(Module.class);
+            }
+
+            @Override
+            public String getValue() {
+                return "v";
+            }
+
+            @Override
+            public String setValue(String value) {
+                return "v";
+            }
+        });
+
         MockitoAnnotations.initMocks(this);
         doNothing().when(bundleContext).addBundleListener(any(BundleListener.class));
         doReturn(new Bundle[0]).when(bundleContext).getBundles();
@@ -59,7 +82,8 @@ public class ExtenderYangTrackerCustomizerTest {
         doReturn(22).when(yangStoreSnapshot).countModuleMXBeanEntries();
         doReturn("mock yang store").when(yangStoreSnapshot).toString();
         doNothing().when(yangStoreSnapshot).close();
-        doReturn(Collections.emptyMap()).when(yangStoreSnapshot).getModuleMap();
+        doReturn(moduleMap).when(yangStoreSnapshot).getModuleMap();
+        doReturn(Collections.emptyMap()).when(yangStoreSnapshot).getModuleMXBeanEntryMap();
     }
 
     @Test
@@ -75,7 +99,7 @@ public class ExtenderYangTrackerCustomizerTest {
 
         returnedStore = tested.getYangStoreSnapshot();
 
-        assertEquals(yangStoreSnapshot, returnedStore);
+        assertEquals(yangStoreSnapshot.getModuleMap(), returnedStore.getModuleMap());
 
         tested.removedBundle(bundle, null, null);
         tested.getYangStoreSnapshot();
@@ -87,7 +111,7 @@ public class ExtenderYangTrackerCustomizerTest {
             tested.getYangStoreSnapshot();
         }
 
-        verify(parser, times(7)).parseYangFiles(anyCollectionOf(InputStream.class));
+        verify(parser, times(5)).parseYangFiles(anyCollectionOf(InputStream.class));
 
         returnedStore = tested.getYangStoreSnapshot();
 
index 1db1d75..bfc3962 100644 (file)
@@ -22,7 +22,9 @@ netconf.tcp.port=8383
 #netconf.tls.keystore=
 #netconf.tls.keystore.password=
 
-netconf.config.persister.storageAdapterClass=org.opendaylight.controller.netconf.persist.impl.NoOpStorageAdapter
+netconf.config.persister.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
+fileStorage=configuration/controller.config
+numberOfBackups=1
 yangstore.blacklist=.*controller.model.*
 
 # Set Default start level for framework
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/controller.config b/opendaylight/distribution/opendaylight/src/main/resources/configuration/controller.config
new file mode 100644 (file)
index 0000000..fa0b589
--- /dev/null
@@ -0,0 +1,129 @@
+//START OF CONFIG-LAST
+<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:dom:impl">prefix:schema-service-singleton</type>
+               <name>yang-schema-service</name>
+       </module>
+       <module>
+               <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:impl">prefix:dom-broker-impl</type>
+               <name>dom-broker</name>
+               <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+                       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
+                       <name>ref_hash-map-data-store</name>
+               </data-store>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
+               <name>binding-broker-impl</name>
+               <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                       <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
+                       <name>ref_binding-notification-broker</name>
+               </notification-service>
+               <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                       <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+                       <name>ref_binding-data-broker</name>
+               </data-broker>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
+               <name>runtime-mapping-singleton</name>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
+               <name>binding-notification-broker</name>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
+               <name>binding-data-broker</name>
+               <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+                       <name>ref_dom-broker</name>
+               </dom-broker>
+               <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+               <name>ref_runtime-mapping-singleton</name>
+               </mapping-service>
+       </module>
+</modules>
+<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+       <service>
+       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+               <instance>
+               <name>ref_yang-schema-service</name>
+               <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
+               <instance>
+                       <name>ref_binding-notification-broker</name>
+                       <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
+               <instance>
+                       <name>ref_hash-map-data-store</name>
+                       <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-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>
+               <instance>
+                       <name>ref_binding-broker-impl</name>
+                       <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
+               <instance>
+                       <name>ref_runtime-mapping-singleton</name>
+                       <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
+               </instance>
+       </service>
+       <service>
+       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+               <instance>
+                       <name>ref_dom-broker</name>
+                       <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+               <instance>
+               <name>ref_binding-data-broker</name>
+               <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
+       </instance>
+       </service>
+</services>
+</data>
+
+//END OF SNAPSHOT
+urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
+urn:ietf:params:netconf:capability:candidate:1.0
+urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
+urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
+urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
+urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
+urn:ietf:params:netconf:capability:rollback-on-error:1.0
+urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
+urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
+urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
+urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
+http://netconfcentral.org/ns/toaster?module=toaster&revision=2009-11-20
+urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
+urn:opendaylight:params:xml:ns:yang:nps-concepts?module=nps-concepts&revision=2013-09-30
+//END OF CONFIG
index c356ff6..a5e5c74 100644 (file)
@@ -16,7 +16,6 @@
 
     <build>
         <plugins>
-        
             <plugin>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>yang-maven-plugin</artifactId>
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java
new file mode 100644 (file)
index 0000000..c3fe5f7
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import org.opendaylight.controller.sal.binding.impl.BindingAwareBrokerImpl;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public final class BindingBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule
+{
+
+    private BundleContext bundleContext;
+
+    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        BindingAwareBrokerImpl broker = new BindingAwareBrokerImpl(getBundleContext());
+        broker.setDataBroker(getDataBrokerDependency());
+        broker.setNotifyBroker(getNotificationServiceDependency());
+        broker.start();
+        return broker;
+    }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..5390251
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public class BindingBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModuleFactory
+{
+
+    
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+        BindingBrokerImplModule module = (BindingBrokerImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+    
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
+        BindingBrokerImplModule module = (BindingBrokerImplModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplSingletonModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplSingletonModule.java
deleted file mode 100644 (file)
index ab94db9..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.yang.md.sal.binding.impl;
-
-import org.opendaylight.controller.sal.binding.impl.BindingAwareBrokerImpl;
-import org.osgi.framework.BundleContext;
-
-import com.google.common.base.Preconditions;
-
-/**
-*
-*/
-public final class BindingBrokerImplSingletonModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplSingletonModule
-{
-
-    private BundleContext bundleContext;
-
-    public BindingBrokerImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public BindingBrokerImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, BindingBrokerImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void validate() {
-        super.validate();
-        Preconditions.checkNotNull(getBundleContext());
-    }
-
-    
-    @Override
-    public boolean canReuseInstance(AbstractBindingBrokerImplSingletonModule oldModule) {
-        return true;
-    }
-    
-    
-    public java.lang.AutoCloseable createInstance() {
-        BindingAwareBrokerImpl broker = new BindingAwareBrokerImpl(getBundleContext());
-        broker.start();
-        return broker;
-    }
-
-    public BundleContext getBundleContext() {
-        return bundleContext;
-    }
-
-    public void setBundleContext(BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplSingletonModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplSingletonModuleFactory.java
deleted file mode 100644 (file)
index b0a6310..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.yang.md.sal.binding.impl;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DependencyResolverFactory;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.spi.Module;
-import org.osgi.framework.BundleContext;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
-*
-*/
-public class BindingBrokerImplSingletonModuleFactory extends
-        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplSingletonModuleFactory {
-
-    private static final String SINGLETON_NAME = "binding-broker-singleton";
-    public static ModuleIdentifier SINGLETON_IDENTIFIER = new ModuleIdentifier(NAME, SINGLETON_NAME);
-
-    @Override
-    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
-        throw new UnsupportedOperationException("Only default instance supported.");
-    }
-
-    @Override
-    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
-            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
-        Module instance = super.createModule(instanceName, dependencyResolver, old, bundleContext);
-        ((BindingBrokerImplSingletonModule)instance).setBundleContext(bundleContext);
-        return instance;
-    }
-
-    @Override
-    public Set<BindingBrokerImplSingletonModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
-            BundleContext bundleContext) {
-
-        DependencyResolver dependencyResolver = dependencyResolverFactory
-                .createDependencyResolver(SINGLETON_IDENTIFIER);
-        BindingBrokerImplSingletonModule instance = new BindingBrokerImplSingletonModule(SINGLETON_IDENTIFIER,
-                dependencyResolver);
-        instance.setBundleContext(bundleContext);
-
-        return Collections.singleton(instance);
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModule.java
new file mode 100644 (file)
index 0000000..8cbfbb6
--- /dev/null
@@ -0,0 +1,83 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-data-broker
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:33:01 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter;
+import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentDataServiceConnector;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+
+import com.google.common.util.concurrent.MoreExecutors;
+
+/**
+*
+*/
+public final class DataBrokerImplModule extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractDataBrokerImplModule {
+
+    private BundleContext bundleContext;
+
+    public DataBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public DataBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            DataBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate() {
+        super.validate();
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        DataBrokerImpl dataBindingBroker = new DataBrokerImpl();
+        
+        // FIXME: obtain via dependency management
+        ExecutorService executor = Executors.newCachedThreadPool();
+        ExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);
+        dataBindingBroker.setExecutor(listeningExecutor);
+
+        
+        
+        Broker domBroker = getDomBrokerDependency();
+        BindingIndependentMappingService mappingService = getMappingServiceDependency();
+        
+        if (domBroker != null && mappingService != null) {
+            BindingIndependentDataServiceConnector runtimeMapping = new BindingIndependentDataServiceConnector();
+            runtimeMapping.setMappingService(mappingService);
+            runtimeMapping.setBaDataService(dataBindingBroker);
+            domBroker.registerProvider(runtimeMapping, getBundleContext());
+        }
+
+        return dataBindingBroker;
+    }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext2) {
+        this.bundleContext = bundleContext2;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..4022dd4
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-data-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public class DataBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractDataBrokerImplModuleFactory
+{
+
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+        DataBrokerImplModule module = (DataBrokerImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+    
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
+        DataBrokerImplModule module = (DataBrokerImplModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModule.java
new file mode 100644 (file)
index 0000000..72231d1
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-notification-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
+
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+/**
+*
+*/
+public final class NotificationBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractNotificationBrokerImplModule
+{
+
+    public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NotificationBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        ExecutorService executor = Executors.newFixedThreadPool(5);
+        ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);
+        NotificationBrokerImpl broker = new NotificationBrokerImpl(listeningExecutor);
+        return broker;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..24ca0bb
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-notification-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+/**
+*
+*/
+public class NotificationBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractNotificationBrokerImplModuleFactory
+{
+
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModule.java
new file mode 100644 (file)
index 0000000..7824da8
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-rpc-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+/**
+*
+*/
+public final class RpcBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRpcBrokerImplModule
+{
+
+    public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, RpcBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        //TODO:implement
+        throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..61c7364
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-rpc-broker
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:33:01 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+/**
+*
+*/
+public class RpcBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRpcBrokerImplModuleFactory
+{
+
+
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java
new file mode 100644 (file)
index 0000000..6537b4c
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 18:20:19 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import javassist.ClassPool;
+
+import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
+import org.osgi.framework.BundleContext;
+
+import com.google.common.base.Preconditions;
+
+/**
+*
+*/
+public final class RuntimeMappingModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModule
+{
+
+    private BundleContext bundleContext;
+
+    public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, RuntimeMappingModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        Preconditions.checkNotNull(bundleContext);
+        // Add custom validation for module attributes here.
+    }
+    
+    @Override
+    public boolean canReuseInstance(AbstractRuntimeMappingModule oldModule) {
+        return true;
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
+        ClassPool pool = new ClassPool(); // Should be default singleton
+        service.setPool(pool);
+        service.start(getBundleContext());
+        return service;
+    }
+
+    private BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModuleFactory.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModuleFactory.java
new file mode 100644 (file)
index 0000000..f104c73
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 18:20:19 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.binding.impl;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DependencyResolverFactory;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public class RuntimeMappingModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModuleFactory
+{
+
+    
+    private static  RuntimeMappingModule SINGLETON = null;
+    private static ModuleIdentifier IDENTIFIER = new ModuleIdentifier(NAME, "runtime-mapping-singleton");
+
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+        throw new UnsupportedOperationException("Only default instance supported");
+    }
+    
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
+        RuntimeMappingModule module = (RuntimeMappingModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+    
+    @Override
+    public Set<RuntimeMappingModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
+            BundleContext bundleContext) {
+        if(SINGLETON == null) {
+            DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(IDENTIFIER);
+            SINGLETON = new RuntimeMappingModule(IDENTIFIER , dependencyResolver);
+            SINGLETON.setBundleContext(bundleContext);
+        }
+        
+        
+        return Collections.singleton(SINGLETON);
+    }
+
+}
index 02da174..116a817 100644 (file)
@@ -30,7 +30,7 @@ class RpcRoutingTableImpl<C extends BaseIdentity,S extends RpcService> implement
     }
     
     
-    override getRoute(InstanceIdentifier nodeInstance) {
+    override getRoute(InstanceIdentifier<? extends Object> nodeInstance) {
         val ret = routes.get(nodeInstance);
         if(ret !== null) {
             return ret;
@@ -44,6 +44,6 @@ class RpcRoutingTableImpl<C extends BaseIdentity,S extends RpcService> implement
     
     @SuppressWarnings("rawtypes")
     override updateRoute(InstanceIdentifier<? extends Object> path, S service) {
-        routes.put(path as InstanceIdentifier,service);
+        routes.put(path as InstanceIdentifier<? extends DataObject>,service);
     }
 }
\ No newline at end of file
index 93c192c..801e498 100644 (file)
@@ -11,7 +11,6 @@ import javassist.ClassPool
 import org.opendaylight.yangtools.yang.binding.RpcService
 
 import javassist.CtClass
-import static com.google.common.base.Preconditions.*
 import javassist.CtMethod
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext
@@ -65,9 +64,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
     }
 
     override <T extends RpcService> getRouterFor(Class<T> iface) {
-        val contexts = new HashSet<Class<? extends BaseIdentity>>
-
-        val instance = <RpcRouterCodegenInstance<T>>withClassLoader(iface.classLoader) [ |
+        val instance = <RpcRouterCodegenInstance<T>>withClassLoaderAndLock(iface.classLoader,lock) [ |
             val supertype = iface.asCtClass
             val metadata = supertype.rpcMetadata;
             val targetCls = createClass(iface.routerName, supertype) [
@@ -210,7 +207,7 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
         ]
         val finalClass = targetCls.toClass(iface.classLoader, iface.protectionDomain)
         return new RuntimeGeneratedInvokerPrototype(supportedNotification,
-            finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener>);
+            finalClass as Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>>);
     }
 
     
@@ -218,13 +215,16 @@ class RuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.co
 
 
     protected def resolveInvokerClass(Class<? extends NotificationListener> class1) {
-        val invoker = invokerClasses.get(class1);
-        if (invoker !== null) {
-            return invoker;
-        }
-        val newInvoker = generateListenerInvoker(class1);
-        invokerClasses.put(class1, newInvoker);
-        return newInvoker
+        return <RuntimeGeneratedInvokerPrototype>withClassLoaderAndLock(class1.classLoader,lock) [|
+            val invoker = invokerClasses.get(class1);
+            if (invoker !== null) {
+                return invoker;
+            }
+            val newInvoker = generateListenerInvoker(class1);
+            invokerClasses.put(class1, newInvoker);
+            return newInvoker
+            
+        ]
     }
 }
 
@@ -235,7 +235,7 @@ package class RuntimeGeneratedInvoker implements NotificationInvoker {
     val NotificationListener delegate;
 
     @Property
-    var org.opendaylight.controller.sal.binding.api.NotificationListener invocationProxy;
+    var org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> invocationProxy;
 
     @Property
     var RuntimeGeneratedInvokerPrototype prototype;
@@ -243,7 +243,7 @@ package class RuntimeGeneratedInvoker implements NotificationInvoker {
     new(NotificationListener delegate, RuntimeGeneratedInvokerPrototype prototype) {
         _delegate = delegate;
         _prototype = prototype;
-        _invocationProxy = prototype.protoClass.newInstance;
+        _invocationProxy = prototype.protoClass.newInstance as org.opendaylight.controller.sal.binding.api.NotificationListener<Notification>;
         RuntimeCodeHelper.setDelegate(_invocationProxy, delegate);
     }
 
@@ -262,7 +262,7 @@ package class RuntimeGeneratedInvokerPrototype {
     val Set<Class<? extends Notification>> supportedNotifications;
 
     @Property
-    val Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener> protoClass;
+    val Class<? extends org.opendaylight.controller.sal.binding.api.NotificationListener<?>> protoClass;
 }
 
 package class RpcServiceMetadata {
index 19e9961..35f4874 100644 (file)
@@ -30,8 +30,8 @@ public class CodecMapping {
         }
     }
 
-    public static void setClassToCaseMap(Class<? extends BindingCodec> codec,
-            Map<Class,BindingCodec> classToCaseRawCodec) {
+    public static void setClassToCaseMap(Class<? extends BindingCodec<?,?>> codec,
+            Map<Class<?>,BindingCodec<?,?>> classToCaseRawCodec) {
         Field instanceIdField;
         try {
             instanceIdField = codec.getField(CLASS_TO_CASE_MAP);
@@ -47,8 +47,8 @@ public class CodecMapping {
         
     }
 
-    public static void setCompositeNodeToCaseMap(Class<? extends BindingCodec> codec,
-            Map<CompositeNode,BindingCodec> compositeToCase) {
+    public static void setCompositeNodeToCaseMap(Class<? extends BindingCodec<?,?>> codec,
+            Map<CompositeNode,BindingCodec<?,?>> compositeToCase) {
         Field instanceIdField;
         try {
             instanceIdField = codec.getField(COMPOSITE_TO_CASE);
@@ -63,7 +63,7 @@ public class CodecMapping {
     }
 
     public static void setAugmentationCodec(Class<? extends BindingCodec<Map<QName, Object>, Object>> dataCodec,
-            BindingCodec augmentableCodec) {
+            BindingCodec<?,?> augmentableCodec) {
             Field instanceIdField;
             try {
                 instanceIdField = dataCodec.getField(AUGMENTATION_CODEC);
index 3f74c9e..0a8ea84 100644 (file)
@@ -9,6 +9,8 @@ public interface GeneratorListener {
 
     
     
+    void onClassProcessed(Class<?> cl);
+    
     void onCodecCreated(Class<?> codec);
     void onValueCodecCreated(Class<?> valueClass,Class<?> valueCodec);
     void onChoiceCodecCreated(Class<?> choiceClass,Class<? extends BindingCodec<Map<QName, Object>,Object>> choiceCodec);
index fd02fde..2706609 100644 (file)
@@ -95,6 +95,7 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
         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;
@@ -111,7 +112,7 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
         return new NodeIdentifierWithPredicates(QName.create(previousQname,qname.localName),predicates);
     }
     
-    def resolveQname(Class class1) {
+    def resolveQname(Class<?> class1) {
         val qname = classToQName.get(class1);
         if(qname !== null) {
             return qname;
@@ -119,5 +120,6 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
         val qnameField = class1.getField("QNAME");
         val qnameValue = qnameField.get(null) as QName;
         classToQName.put(class1,qnameValue);
+        return qnameValue;
     }
 }
\ No newline at end of file
index e8e4c43..b811008 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 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.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
@@ -120,6 +121,9 @@ public class LazyGeneratedCodecRegistry implements //
         ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
         @SuppressWarnings("rawtypes")
         WeakReference<Class> weakRef = typeToClass.get(typeref);
+        if(weakRef == null) {
+            LOG.error("Could not find loaded class for path: {} and type: {}",path,typeref.getFullyQualifiedName());
+        }
         return weakRef.get();
     }
 
@@ -147,9 +151,29 @@ public class LazyGeneratedCodecRegistry implements //
     @Override
     @SuppressWarnings("rawtypes")
     public void bindingClassEncountered(Class cls) {
+        
         ConcreteType typeRef = Types.typeForClass(cls);
+        if(typeToClass.containsKey(typeRef)) {
+            return;
+        }
+        LOG.info("Binding Class {} encountered.",cls);
         WeakReference<Class> weakRef = new WeakReference<>(cls);
         typeToClass.put(typeRef, weakRef);
+        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.info("Binding Class {} encountered.",cls);
+        WeakReference<Class> weakRef = new WeakReference<>((Class) cls);
+        typeToClass.put(typeRef, weakRef);
     }
 
     private DataSchemaNode getSchemaNode(List<QName> path) {
@@ -280,6 +304,12 @@ public class LazyGeneratedCodecRegistry implements //
             ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode
                     .getValue().getName());
             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());
+                continue;
+            }
+
             @SuppressWarnings("rawtypes")
             ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
             typeToCaseNodes.putIfAbsent(typeref, value);
@@ -300,7 +330,7 @@ public class LazyGeneratedCodecRegistry implements //
         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.setClassToCaseMap(choiceCodec, (Map<Class<?>, BindingCodec<?, ?>>) classToCaseRawCodec);
         CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
 
     }
@@ -540,7 +570,7 @@ public class LazyGeneratedCodecRegistry implements //
         public BindingCodec get(Object key) {
             if (key instanceof Class) {
                 Class cls = (Class) key;
-                bindingClassEncountered(cls);
+                //bindingClassEncountered(cls);
                 ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls);
                 return caseCodec.getDelegate();
             }
@@ -557,11 +587,6 @@ public class LazyGeneratedCodecRegistry implements //
             this.choiceCases = choiceCases;
         }
 
-        @Override
-        public Set<java.util.Map.Entry<CompositeNode, BindingCodec>> entrySet() {
-            return null;
-        }
-
         @Override
         public BindingCodec get(Object key) {
             if (false == (key instanceof CompositeNode)) {
@@ -575,6 +600,8 @@ public class LazyGeneratedCodecRegistry implements //
             }
             return null;
         }
+        
+        
     }
 
     /**
@@ -585,7 +612,7 @@ public class LazyGeneratedCodecRegistry implements //
      *            Key type
      */
     @SuppressWarnings("rawtypes")
-    private static abstract class MapFacadeBase<T> implements Map<T, BindingCodec> {
+    private static abstract class MapFacadeBase<T> implements Map<T, BindingCodec<?, ?>> {
 
         @Override
         public boolean containsKey(Object key) {
@@ -613,7 +640,7 @@ public class LazyGeneratedCodecRegistry implements //
         }
 
         @Override
-        public Collection<BindingCodec> values() {
+        public Collection<BindingCodec<?, ?>> values() {
             return null;
         }
 
@@ -622,12 +649,12 @@ public class LazyGeneratedCodecRegistry implements //
         }
 
         @Override
-        public BindingCodec<Map<QName, Object>, Object> put(T key, BindingCodec value) {
+        public BindingCodec<Map<QName, Object>, Object> put(T key, BindingCodec<?,?> value) {
             throw notModifiable();
         }
 
         @Override
-        public void putAll(Map<? extends T, ? extends BindingCodec> m) {
+        public void putAll(Map<? extends T, ? extends BindingCodec<?, ?>> m) {
             throw notModifiable();
         }
 
@@ -647,7 +674,8 @@ public class LazyGeneratedCodecRegistry implements //
         }
 
         @Override
-        public Set<java.util.Map.Entry<T, BindingCodec>> entrySet() {
+        public Set<java.util.Map.Entry<T, BindingCodec<?, ?>>> entrySet() {
+            // TODO Auto-generated method stub
             return null;
         }
 
index 4614c60..0ddc2c8 100644 (file)
@@ -17,18 +17,9 @@ 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 java.util.ArrayList
-import org.opendaylight.yangtools.yang.common.QName
 import org.opendaylight.yangtools.yang.binding.DataContainer
-import static com.google.common.base.Preconditions.*;
-import java.util.List
-import org.opendaylight.yangtools.yang.data.api.Node
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
-import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl
-import org.opendaylight.yangtools.concepts.Delegator
 import java.util.concurrent.ConcurrentMap
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType
-import org.opendaylight.yangtools.yang.binding.BindingCodec
 import com.google.common.collect.HashMultimap
 import com.google.common.util.concurrent.SettableFuture
 import java.util.concurrent.Future
@@ -39,8 +30,11 @@ 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
 
-class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaServiceListener {
+class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaServiceListener, AutoCloseable {
 
     @Property
     ClassPool pool;
@@ -65,6 +59,8 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
     val promisedTypeDefinitions = HashMultimap.<Type, SettableFuture<GeneratedTypeBuilder>>create;
 
     val promisedSchemas = HashMultimap.<Type, SettableFuture<SchemaNode>>create;
+    
+    ServiceRegistration<SchemaServiceListener> listenerRegistration
 
     override onGlobalContextUpdated(SchemaContext arg0) {
         recreateBindingContext(arg0);
@@ -139,6 +135,10 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         val ret = transformer.deserialize(node)?.value as DataObject;
         return ret;
     }
+    
+    override fromDataDom(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry) {
+        return registry.instanceIdentifierCodec.deserialize(entry);
+    }
 
     private def void updateBindingFor(Map<SchemaPath, GeneratedTypeBuilder> map, SchemaContext module) {
         for (entry : map.entrySet) {
@@ -152,7 +152,7 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         }
     }
 
-    public def void start() {
+    public def void start(BundleContext ctx) {
         binding = new TransformerGenerator(pool);
         registry = new LazyGeneratedCodecRegistry()
         registry.generator = binding
@@ -162,7 +162,9 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         binding.typeToDefinition = typeToDefinition
         binding.typeToSchemaNode = typeToSchemaNode
         binding.typeDefinitions = typeDefinitions
-
+        if(ctx !== null) {
+            listenerRegistration = ctx.registerService(SchemaServiceListener,this,new Hashtable<String,String>());
+        }
     }
 
     private def getTypeDefinition(Type type) {
@@ -215,4 +217,9 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         }
         promisedSchemas.removeAll(builder);
     }
+    
+    override close() throws Exception {
+        listenerRegistration?.unregister();
+    }
+    
 }
index 8e059aa..01390d7 100644 (file)
@@ -95,6 +95,7 @@ class TransformerGenerator {
         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)
@@ -102,6 +103,7 @@ class TransformerGenerator {
             val typeSpecBuilder = typeToDefinition.get(ref)
             val typeSpec = typeSpecBuilder.toInstance();
             val newret = generateTransformerFor(inputType, typeSpec, node);
+            listener.onClassProcessed(inputType);
             return newret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
         ]
     }
@@ -117,6 +119,7 @@ class TransformerGenerator {
             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>>;
         ]
     }
@@ -184,7 +187,7 @@ class TransformerGenerator {
         ]
     }
 
-    private def Class getGeneratedClass(Class<? extends Object> cls) {
+    private def Class<?> getGeneratedClass(Class<? extends Object> cls) {
 
         try {
             return loadClassWithTCCL(cls.codecClassName)
@@ -211,13 +214,15 @@ class TransformerGenerator {
         if (transformer !== null) {
             return transformer;
         }
-        val valueTransformer = generateValueTransformer(cls, type);
-        return valueTransformer;
+        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)
+            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
             val properties = typeSpec.allProperties;
             val ctCls = createClass(inputType.codecClassName) [
                 //staticField(Map,"AUGMENTATION_SERIALIZERS");
@@ -235,7 +240,7 @@ class TransformerGenerator {
                                 _resultName = QNAME;
                             }
                             java.util.List _childNodes = new java.util.ArrayList();
-                            «inputType.name» value = («inputType.name») $2;
+                            «inputType.resolvedName» value = («inputType.name») $2;
                             «FOR key : node.keyDefinition»
                                 «val propertyName = key.getterName»
                                 «val keyDef = node.getDataChildByName(key)»
@@ -261,7 +266,7 @@ class TransformerGenerator {
                                 «val property = properties.get(propertyName)»
                                 «deserializeProperty(keyDef, property, propertyName)»;
                             «ENDFOR»
-                            «inputType.name» _value = new «inputType.name»(«node.keyDefinition.keyConstructorList»);
+                            «inputType.resolvedName» _value = new «inputType.name»(«node.keyDefinition.keyConstructorList»);
                             return _value;
                         }
                     '''
@@ -291,10 +296,10 @@ class TransformerGenerator {
         }
     }
 
-    private def Class<? extends BindingCodec<Object, Object>> generateCaseCodec(Class inputType, GeneratedType type,
+    private def Class<? extends BindingCodec<Object, Object>> generateCaseCodec(Class<?> inputType, GeneratedType type,
         ChoiceCaseNode node) {
         try {
-            log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
+            //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)
@@ -308,7 +313,7 @@ class TransformerGenerator {
                             «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.allProperties, node)»
+                            «transformDataContainerBody(type,type.allProperties, node)»
                             return ($r) _childNodes;
                         }
                     '''
@@ -349,9 +354,9 @@ class TransformerGenerator {
     }
 
     private def dispatch  Class<? extends BindingCodec<Map<QName, Object>, Object>> generateTransformerFor(
-        Class inputType, GeneratedType typeSpec, SchemaNode node) {
+        Class<?> inputType, GeneratedType typeSpec, SchemaNode node) {
         try {
-            log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
+            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
             val ctCls = createClass(typeSpec.codecClassName) [
                 //staticField(Map,"AUGMENTATION_SERIALIZERS");
                 staticQNameField(inputType);
@@ -396,9 +401,9 @@ class TransformerGenerator {
     }
 
     private def Class<? extends BindingCodec<Map<QName, Object>, Object>> generateAugmentationTransformerFor(
-        Class inputType, GeneratedType type, AugmentationSchema node) {
+        Class<?> inputType, GeneratedType type, AugmentationSchema node) {
         try {
-            log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
+            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
             val properties = type.allProperties
             val ctCls = createClass(type.codecClassName) [
                 //staticField(Map,"AUGMENTATION_SERIALIZERS");
@@ -446,7 +451,7 @@ class TransformerGenerator {
                             return null;
                             }
                             java.util.Map _compositeNode = (java.util.Map) $2;
-                            ////System.out.println(_localQName + " " + _compositeNode);
+                            //System.out.println(_localQName + " " + _compositeNode);
                             «type.builderName» _builder = new «type.builderName»();
                             «FOR child : node.childNodes»
                                 «val signature = properties.getFor(child)»
@@ -475,9 +480,9 @@ class TransformerGenerator {
     }
 
     private def dispatch  Class<? extends BindingCodec<Map<QName, Object>, Object>> generateTransformerFor(
-        Class inputType, GeneratedType typeSpec, ChoiceNode node) {
+        Class<?> inputType, GeneratedType typeSpec, ChoiceNode node) {
         try {
-            log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
+            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
             val ctCls = createClass(typeSpec.codecClassName) [
                 //staticField(Map,"AUGMENTATION_SERIALIZERS");
                 //staticQNameField(inputType);
@@ -500,7 +505,9 @@ class TransformerGenerator {
                                 return null;
                             }
                             java.util.Map.Entry _input = new «SimpleEntry.name»($1,_baValue);
-                            return (java.util.List) _codec.serialize(_input);
+                            Object _ret =  _codec.serialize(_input);
+                            //System.out.println("«typeSpec.name»#toDomStatic: " + _ret);
+                            return («List.name») _ret;
                         }
                     '''
                 ]
@@ -617,7 +624,7 @@ class TransformerGenerator {
                 return null;
             }
             java.util.Map _compositeNode = (java.util.Map) $2;
-            ////System.out.println(_localQName + " " + _compositeNode);
+            //System.out.println(_localQName + " " + _compositeNode);
             «type.builderName» _builder = new «type.builderName»();
             «deserializeDataNodeContainerBody(type, node)»
             «deserializeAugmentations»
@@ -660,7 +667,7 @@ class TransformerGenerator {
         String propertyName) '''
         java.util.List _dom_«propertyName» = _compositeNode.get(«QName.name».create(_localQName,"«schema.QName.
             localName»"));
-        ////System.out.println("«propertyName»#deCode"+_dom_«propertyName»);
+        //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();
@@ -668,15 +675,15 @@ class TransformerGenerator {
             boolean _hasNext = _iterator.hasNext();
             while(_hasNext) {
                 Object _listItem = _iterator.next();
-                ////System.out.println("  item" + _listItem);
+                //System.out.println("  item" + _listItem);
                 Object _value = «type.actualTypeArguments.get(0).serializer.resolvedName».fromDomStatic(_localQName,_listItem);
-                ////System.out.println("  value" + _value);
+                //System.out.println("  value" + _value);
                 «propertyName».add(_value);
                 _hasNext = _iterator.hasNext();
             }
         }
         
-        ////System.out.println(" list" + «propertyName»);
+        //System.out.println(" list" + «propertyName»);
     '''
 
     private def dispatch CharSequence deserializeProperty(LeafListSchemaNode schema, ParameterizedType type,
@@ -737,29 +744,38 @@ class TransformerGenerator {
 
             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>>;
             }
+            var hasBinding = false;
+            try {
+                val bindingCodecClass = loadClassWithTCCL(BINDING_CODEC.name);
+                hasBinding = bindingCodecClass !== null;
+            } catch (ClassNotFoundException e) {
+                hasBinding = false;
+            }
+            val hasYangBinding = hasBinding
             val ctCls = createClass(typeSpec.codecClassName) [
                 //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                implementsType(BINDING_CODEC)
-                staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
-                implementsType(BindingDeserializer.asCtClass)
+                if(hasYangBinding) {
+                    implementsType(BINDING_CODEC)
+                    staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
+                    implementsType(BindingDeserializer.asCtClass)
+                }
                 method(Object, "toDomValue", Object) [
                     modifiers = PUBLIC + FINAL + STATIC
                     body = '''
                         {
-                            ////System.out.println("«inputType.simpleName»#toDomValue: "+$1);
+                            //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);
+                            //System.out.println("«inputType.simpleName»#toDomValue:Enc: "+_encapsulatedValue);
                             «returnType.resolvedName» _value =  _encapsulatedValue.getValue();
-                            ////System.out.println("«inputType.simpleName»#toDomValue:DeEnc: "+_value);
+                            //System.out.println("«inputType.simpleName»#toDomValue:DeEnc: "+_value);
                             Object _domValue = «serializeValue(returnType, "_value")»;
                             return _domValue;
                         }
@@ -776,7 +792,7 @@ class TransformerGenerator {
                     modifiers = PUBLIC + FINAL + STATIC
                     body = '''
                         {
-                            ////System.out.println("«inputType.simpleName»#fromDomValue: "+$1);
+                            //System.out.println("«inputType.simpleName»#fromDomValue: "+$1);
                             
                             if($1 == null) {
                                 return null;
@@ -849,13 +865,14 @@ class TransformerGenerator {
         return null;
     }
 
-    private def dispatch Class<? extends BindingCodec<Map<QName, Object>, Object>> generateValueTransformer(
+    private def dispatch Class<?> generateValueTransformer(
         Class<?> inputType, Enumeration typeSpec) {
         try {
-            log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
+            //log.info("Generating DOM Codec for {} with {}", inputType, inputType.classLoader)
             val ctCls = createClass(typeSpec.codecClassName) [
                 //staticField(Map,"AUGMENTATION_SERIALIZERS");
-                implementsType(BINDING_CODEC)
+                //implementsType(BINDING_CODEC)
+                
                 method(Object, "toDomValue", Object) [
                     modifiers = PUBLIC + FINAL + STATIC
                     body = '''
@@ -891,7 +908,7 @@ class TransformerGenerator {
 
             val ret = ctCls.toClassImpl(inputType.classLoader, inputType.protectionDomain)
             log.info("DOM Codec for {} was generated {}", inputType, ret)
-            return ret as Class<? extends BindingCodec<Map<QName,Object>, Object>>;
+            return ret;
         } catch (CodeGenerationException e) {
             throw new CodeGenerationException("Cannot compile Transformator for " + inputType, e);
         } catch (Exception e) {
@@ -982,7 +999,7 @@ class TransformerGenerator {
             «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.allProperties, node)»
+            «transformDataContainerBody(type,type.allProperties, node)»
             «serializeAugmentations»
             return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
         }
@@ -993,7 +1010,7 @@ class TransformerGenerator {
             «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.allProperties, node)»
+            «transformDataContainerBody(type,type.allProperties, node)»
             «serializeAugmentations»
             return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
         }
@@ -1004,7 +1021,7 @@ class TransformerGenerator {
         «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.allProperties, node)»
+            «transformDataContainerBody(type,type.allProperties, node)»
             «serializeAugmentations»
             return ($r) java.util.Collections.singletonMap(_resultName,_childNodes);
         }
@@ -1019,11 +1036,11 @@ class TransformerGenerator {
         }
     '''
 
-    private def transformDataContainerBody(Map<String, Type> properties, DataNodeContainer node) {
+    private def transformDataContainerBody(Type type,Map<String, Type> properties, DataNodeContainer node) {
         val ret = '''
             «FOR child : node.childNodes.filter[!augmenting]»
                 «var signature = properties.getFor(child)»
-                //System.out.println("«signature.key»" + value.«signature.key»());
+                //System.out.println("«type.name»#«signature.key»" + value.«signature.key»());
                 «serializeProperty(child, signature.value, signature.key)»
             «ENDFOR»
         '''
@@ -1152,11 +1169,11 @@ class TransformerGenerator {
         return '''«typeSpec.resolvedName»$Broker$Codec$DOM'''
     }
 
-    private def codecClassName(Class typeSpec) {
+    private def codecClassName(Class<?> typeSpec) {
         return '''«typeSpec.name»$Broker$Codec$DOM'''
     }
 
-    private def dispatch HashMap<String, Type> getAllProperties(GeneratedType type) {
+    private def HashMap<String, Type> getAllProperties(GeneratedType type) {
         val ret = new HashMap<String, Type>();
         type.collectAllProperties(ret);
         return ret;
@@ -1186,12 +1203,11 @@ class TransformerGenerator {
         return type.asCtClass.name;
     }
 
-    def String getResolvedName(Class type) {
+    def String getResolvedName(Class<?> type) {
         return type.asCtClass.name;
     }
 
     def CtClass asCtClass(Type type) {
-        val name = type.fullyQualifiedName
         val cls = loadClassWithTCCL(type.fullyQualifiedName)
         return cls.asCtClass;
     }
index 31d5d01..1762aac 100644 (file)
@@ -44,17 +44,18 @@ import static org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils
 import java.util.concurrent.Executors
 import java.util.Collections
 import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.controller.sal.binding.impl.connect.dom.ConnectorActivator
+import java.util.concurrent.locks.ReentrantLock
+import java.util.concurrent.Callable
+import java.util.WeakHashMap
+import javax.annotation.concurrent.GuardedBy
 
 class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
     private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
 
-
     private InstanceIdentifier<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
 
-    private val clsPool = ClassPool.getDefault()
-    private var RuntimeCodeGenerator generator;
-    
+    private static val clsPool = ClassPool.getDefault()
+    public static var RuntimeCodeGenerator generator;
 
     /**
      * Map of all Managed Direct Proxies
@@ -68,28 +69,29 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
      * 
      * 
      */
-    private val Map<Class<? extends RpcService>, RpcRouter<? extends RpcService>> rpcRouters = new ConcurrentHashMap();
+    private val Map<Class<? extends RpcService>, RpcRouter<? extends RpcService>> rpcRouters = new WeakHashMap();
 
     @Property
-    private var NotificationBrokerImpl notifyBroker
-    
+    private var NotificationProviderService notifyBroker
+
     @Property
-    private var DataBrokerImpl dataBroker
-    
+    private var DataProviderService dataBroker
+
     @Property
     var BundleContext brokerBundleContext
-    
+
     ServiceRegistration<NotificationProviderService> notifyProviderRegistration
-    
+
     ServiceRegistration<NotificationService> notifyConsumerRegistration
-    
+
     ServiceRegistration<DataProviderService> dataProviderRegistration
-    
+
     ServiceRegistration<DataBrokerService> dataConsumerRegistration
-    
-    ConnectorActivator connectorActivator
-   
-    
+
+    private val proxyGenerationLock = new ReentrantLock;
+
+    private val routerGenerationLock = new ReentrantLock;
+
     public new(BundleContext bundleContext) {
         _brokerBundleContext = bundleContext;
     }
@@ -99,27 +101,13 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
         initGenerator();
 
         val executor = Executors.newCachedThreadPool;
+
         // Initialization of notificationBroker
         log.info("Starting MD-SAL: Binding Aware Notification Broker");
-        notifyBroker = new NotificationBrokerImpl(executor);
-        notifyBroker.invokerFactory = generator.invokerFactory;
 
         log.info("Starting MD-SAL: Binding Aware Data Broker");
-        dataBroker = new DataBrokerImpl();
-        dataBroker.executor = executor;
 
-        val brokerProperties = newProperties();
-        
-        
         log.info("Starting MD-SAL: Binding Aware Data Broker");
-        notifyProviderRegistration = brokerBundleContext.registerService(NotificationProviderService, notifyBroker,
-            brokerProperties)
-        notifyConsumerRegistration = brokerBundleContext.registerService(NotificationService, notifyBroker, brokerProperties)
-        dataProviderRegistration = brokerBundleContext.registerService(DataProviderService, dataBroker, brokerProperties)
-        dataConsumerRegistration = brokerBundleContext.registerService(DataBrokerService, dataBroker, brokerProperties)
-
-        connectorActivator = new ConnectorActivator(dataBroker,brokerBundleContext);
-        connectorActivator.start();
         log.info("MD-SAL: Binding Aware Broker Started");
     }
 
@@ -163,20 +151,37 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
      * If proxy class does not exist for supplied service class it will be generated automatically.
      */
     private def <T extends RpcService> getManagedDirectProxy(Class<T> service) {
-
         var RpcProxyContext existing = null
+
         if ((existing = managedProxies.get(service)) != null) {
             return existing.proxy
         }
-        val proxyInstance = generator.getDirectProxyFor(service)
-        val rpcProxyCtx = new RpcProxyContext(proxyInstance.class)
-        val properties = new Hashtable<String, String>()
-        rpcProxyCtx.proxy = proxyInstance as RpcService
-
-        properties.salServiceType = SAL_SERVICE_TYPE_CONSUMER_PROXY
-        rpcProxyCtx.registration = brokerBundleContext.registerService(service, rpcProxyCtx.proxy as T, properties)
-        managedProxies.put(service, rpcProxyCtx)
-        return rpcProxyCtx.proxy
+        return withLock(proxyGenerationLock) [ |
+            val maybeProxy = managedProxies.get(service);
+            if (maybeProxy !== null) {
+                return maybeProxy.proxy;
+            }
+            
+            
+            val proxyInstance = generator.getDirectProxyFor(service)
+            val rpcProxyCtx = new RpcProxyContext(proxyInstance.class)
+            val properties = new Hashtable<String, String>()
+            rpcProxyCtx.proxy = proxyInstance as RpcService
+            properties.salServiceType = SAL_SERVICE_TYPE_CONSUMER_PROXY
+            rpcProxyCtx.registration = brokerBundleContext.registerService(service, rpcProxyCtx.proxy as T, properties)
+            managedProxies.put(service, rpcProxyCtx)
+            return rpcProxyCtx.proxy
+        ]
+    }
+
+    private static def <T> T withLock(ReentrantLock lock, Callable<T> method) {
+        try {
+            lock.lock();
+            val ret = method.call;
+            return ret;
+        } finally {
+            lock.unlock();
+        }
     }
 
     /**
@@ -190,7 +195,7 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
 
         val osgiReg = context.bundleContext.registerService(type, service, properties);
         proxy.delegate = service;
-        return new RpcServiceRegistrationImpl<T>(type, service, osgiReg,this);
+        return new RpcServiceRegistrationImpl<T>(type, service, osgiReg, this);
     }
 
     def <T extends RpcService> RoutedRpcRegistration<T> registerRoutedRpcImplementation(Class<T> type, T service,
@@ -208,14 +213,20 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
         }
 
         // We created Router
-        val newRouter = generator.getRouterFor(type);
-        checkState(newRouter !== null);
-        rpcRouters.put(type, newRouter);
-
-        // We create / update Direct Proxy for router
-        val proxy = getManagedDirectProxy(type);
-        proxy.delegate = newRouter.invocationProxy
-        return newRouter;
+        return withLock(routerGenerationLock) [ |
+            val maybeRouter = rpcRouters.get(type);
+            if (maybeRouter !== null) {
+                return maybeRouter as RpcRouter<T>;
+            }
+            
+            val newRouter = generator.getRouterFor(type);
+            checkState(newRouter !== null);
+            rpcRouters.put(type, newRouter);
+            // We create / update Direct Proxy for router
+            val proxy = getManagedDirectProxy(type);
+            proxy.delegate = newRouter.invocationProxy
+            return newRouter;
+        ]
 
     }
 
@@ -230,8 +241,8 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
 
         // Updating internal structure of registration
         routingTable.updateRoute(path, registration.instance)
+
         // Update routing table / send announce to message bus
-        
         val success = paths.put(context, path);
     }
 
@@ -263,32 +274,32 @@ class BindingAwareBrokerImpl implements BindingAwareBroker, AutoCloseable {
             routingTable.removeRoute(path)
         }
     }
-    
+
     protected def <T extends RpcService> void unregisterRpcService(RpcServiceRegistrationImpl<T> registration) {
 
         val type = registration.serviceType;
-        
+
         val proxy = managedProxies.get(type);
-        if(proxy.proxy.delegate === registration.instance) {
+        if (proxy.proxy.delegate === registration.instance) {
             proxy.proxy.delegate = null;
         }
     }
-    
+
     def createDelegate(Class<? extends RpcService> type) {
         getManagedDirectProxy(type);
     }
-    
+
     def getRpcRouters() {
         return Collections.unmodifiableMap(rpcRouters);
     }
-    
+
     override close() {
         dataConsumerRegistration.unregister()
         dataProviderRegistration.unregister()
         notifyConsumerRegistration.unregister()
         notifyProviderRegistration.unregister()
     }
-    
+
 }
 
 class RoutedRpcRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RoutedRpcRegistration<T> {
@@ -332,7 +343,7 @@ class RoutedRpcRegistrationImpl<T extends RpcService> extends AbstractObjectRegi
         checkClosed()
         broker.unregisterPath(this, context, path);
     }
-    
+
     override getServiceType() {
         return router.serviceType;
     }
@@ -343,24 +354,25 @@ class RoutedRpcRegistrationImpl<T extends RpcService> extends AbstractObjectRegi
     }
 
 }
-class RpcServiceRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T>  {
+
+class RpcServiceRegistrationImpl<T extends RpcService> extends AbstractObjectRegistration<T> implements RpcRegistration<T> {
 
     val ServiceRegistration<T> osgiRegistration;
     private var BindingAwareBrokerImpl broker;
-    
+
     @Property
     val Class<T> serviceType;
 
-    public new(Class<T> type, T service, ServiceRegistration<T> osgiReg,BindingAwareBrokerImpl broker) {
+    public new(Class<T> type, T service, ServiceRegistration<T> osgiReg, BindingAwareBrokerImpl broker) {
         super(service);
         this._serviceType = type;
         this.osgiRegistration = osgiReg;
-        this.broker= broker;
+        this.broker = broker;
     }
 
     override protected removeRegistration() {
         broker.unregisterRpcService(this);
         broker = null;
     }
-    
+
 }
index 7a1ca11..2f4510d 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.controller.sal.binding.impl;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
@@ -17,77 +18,85 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 
 
 public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> implements
-        DataProviderService {
+        DataProviderService, AutoCloseable {
 
+    
+    
+    private final AtomicLong nextTransaction = new AtomicLong();
+    
     public DataBrokerImpl() {
         setDataReadRouter(new BindingAwareDataReaderRouter());
     }
 
     @Override
     public DataTransactionImpl beginTransaction() {
-        return new DataTransactionImpl(this);
+        String transactionId = "BA-" + nextTransaction.getAndIncrement();
+        return new DataTransactionImpl(transactionId,this);
     }
 
     @Override
+    @Deprecated
     public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public DataObject getData(InstanceIdentifier<? extends DataObject> data) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public DataObject getConfigurationData(InstanceIdentifier<?> data) {
-        // TODO Auto-generated method stub
-        return null;
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
-        // TODO Auto-generated method stub
-        
+        throw new UnsupportedOperationException("Deprecated");
     }
 
     @Override
+    @Deprecated
     public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path,
             DataChangeListener changeListener) {
-        // TODO Auto-generated method stub
-        
+        throw new UnsupportedOperationException("Deprecated");
     }
     
-    
+    @Override
+    public void close() throws Exception {
+        
+    }
 }
\ No newline at end of file
index f7967be..b0eb9ee 100644 (file)
@@ -15,8 +15,8 @@ public class DataTransactionImpl extends AbstractDataTransaction<InstanceIdentif
     
     
     
-    public DataTransactionImpl(DataBrokerImpl dataBroker) {
-        super(dataBroker);
+    public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) {
+        super(identifier,dataBroker);
     }
 
     @Override
index 887ef82..cf339ee 100644 (file)
@@ -24,19 +24,13 @@ import java.util.Collections
 import org.slf4j.LoggerFactory
 import java.util.concurrent.Callable
 
-class NotificationBrokerImpl implements NotificationProviderService {
+class NotificationBrokerImpl implements NotificationProviderService, AutoCloseable {
 
     val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;
 
     @Property
     var ExecutorService executor;
 
-    @Property
-    var RuntimeCodeGenerator generator;
-
-    @Property
-    var NotificationInvokerFactory invokerFactory;
-
     new(ExecutorService executor) {
         listeners = HashMultimap.create()
         this.executor = executor;
@@ -108,7 +102,7 @@ class NotificationBrokerImpl implements NotificationProviderService {
 
     override registerNotificationListener(
         org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
-        val invoker = invokerFactory.invokerFor(listener);
+        val invoker = BindingAwareBrokerImpl.generator.invokerFactory.invokerFor(listener);
         for (notifyType : invoker.supportedNotifications) {
             listeners.put(notifyType, invoker.invocationProxy)
         }
@@ -125,6 +119,11 @@ class NotificationBrokerImpl implements NotificationProviderService {
             listeners.remove(notifyType, reg.invoker.invocationProxy)
         }
     }
+    
+    override close()  {
+        //FIXME: implement properly.
+    }
+    
 }
 
 class GenericNotificationRegistration<T extends Notification> extends AbstractObjectRegistration<NotificationListener<T>> implements ListenerRegistration<NotificationListener<T>> {
@@ -177,7 +176,9 @@ class NotifyTask implements Callable<Object> {
 
     override call() {
         try {
+            log.info("Delivering notification {} to {}",notification,listener);
             listener.onNotification(notification);
+            log.info("Notification delivered {} to {}",notification,listener);
         } catch (Exception e) {
             log.error("Unhandled exception thrown by listener: {}", listener, e);
         }
index ff897aa..ccd6079 100644 (file)
@@ -1,44 +1,64 @@
 package org.opendaylight.controller.sal.binding.impl.connect.dom;
 
+import java.util.Collection;
 import java.util.Collections;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider;
 import org.opendaylight.controller.sal.common.util.Rpcs;
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
 import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class BindingIndependentDataServiceConnector implements //
         RuntimeDataProvider, //
-        DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
+        Provider {
+
+    private final Logger LOG = LoggerFactory.getLogger(BindingIndependentDataServiceConnector.class);
 
     private static final InstanceIdentifier<? extends DataObject> ROOT = InstanceIdentifier.builder().toInstance();
 
+    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier ROOT_BI = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+            .builder().toInstance();
+
     private BindingIndependentMappingService mappingService;
 
-    private DataBrokerService biDataService;
+    private org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
 
     private DataProviderService baDataService;
 
+    private ConcurrentMap<Object, BindingToDomTransaction> domOpenedTransactions = new ConcurrentHashMap<>();
+    private ConcurrentMap<Object, DomToBindingTransaction> bindingOpenedTransactions = new ConcurrentHashMap<>();
+
+    private BindingToDomCommitHandler bindingToDomCommitHandler = new BindingToDomCommitHandler();
+    private DomToBindingCommitHandler domToBindingCommitHandler = new DomToBindingCommitHandler();
+
+    private Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> baCommitHandlerRegistration;
+
+    private Registration<DataCommitHandler<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode>> biCommitHandlerRegistration;
+
     @Override
     public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
-        // TODO Auto-generated method stub
         org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biPath = mappingService.toDataDom(path);
         CompositeNode result = biDataService.readOperationalData(biPath);
         return mappingService.dataObjectFromDataDom(path, result);
@@ -51,15 +71,7 @@ public class BindingIndependentDataServiceConnector implements //
         return mappingService.dataObjectFromDataDom(path, result);
     }
 
-    @Override
-    public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> requestCommit(
-            DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-
-        DataModificationTransaction translated = translateTransaction(modification);
-        return new WrappedTransaction(translated, modification);
-    }
-
-    private DataModificationTransaction translateTransaction(
+    private DataModificationTransaction createBindingToDomTransaction(
             DataModification<InstanceIdentifier<? extends DataObject>, DataObject> source) {
         DataModificationTransaction target = biDataService.beginTransaction();
         for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : source.getUpdatedConfigurationData()
@@ -74,27 +86,133 @@ public class BindingIndependentDataServiceConnector implements //
                     .toDataDom(entry);
             target.putOperationalData(biEntry.getKey(), biEntry.getValue());
         }
-        for(InstanceIdentifier<? extends DataObject> entry : source.getRemovedConfigurationData()) {
+        for (InstanceIdentifier<? extends DataObject> entry : source.getRemovedConfigurationData()) {
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry);
             target.removeConfigurationData(biEntry);
         }
-        for(InstanceIdentifier<? extends DataObject> entry : source.getRemovedOperationalData()) {
+        for (InstanceIdentifier<? extends DataObject> entry : source.getRemovedOperationalData()) {
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry);
             target.removeOperationalData(biEntry);
         }
         return target;
     }
 
-    private class WrappedTransaction implements
+    private org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction createDomToBindingTransaction(
+            DataModification<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> source) {
+        org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction target = baDataService
+                .beginTransaction();
+        for (Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> entry : source
+                .getUpdatedConfigurationData().entrySet()) {
+            InstanceIdentifier<?> baKey = mappingService.fromDataDom(entry.getKey());
+            DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue());
+            target.putConfigurationData(baKey, baData);
+        }
+        for (Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> entry : source
+                .getUpdatedOperationalData().entrySet()) {
+            InstanceIdentifier<?> baKey = mappingService.fromDataDom(entry.getKey());
+            DataObject baData = mappingService.dataObjectFromDataDom(baKey, entry.getValue());
+            target.putOperationalData(baKey, baData);
+        }
+        for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedConfigurationData()) {
+            InstanceIdentifier<?> baEntry = mappingService.fromDataDom(entry);
+            target.removeConfigurationData(baEntry);
+        }
+        for (org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry : source.getRemovedOperationalData()) {
+            InstanceIdentifier<?> baEntry = mappingService.fromDataDom(entry);
+            target.removeOperationalData(baEntry);
+        }
+        return target;
+    }
+
+    public org.opendaylight.controller.sal.core.api.data.DataProviderService getBiDataService() {
+        return biDataService;
+    }
+
+    public void setBiDataService(org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService) {
+        this.biDataService = biDataService;
+    }
+
+    public DataProviderService getBaDataService() {
+        return baDataService;
+    }
+
+    public void setBaDataService(DataProviderService baDataService) {
+        this.baDataService = baDataService;
+    }
+
+    public void start() {
+        baDataService.registerDataReader(ROOT, this);
+        baCommitHandlerRegistration = baDataService.registerCommitHandler(ROOT, bindingToDomCommitHandler);
+        biCommitHandlerRegistration = biDataService.registerCommitHandler(ROOT_BI, domToBindingCommitHandler);
+        baDataService.registerCommitHandlerListener(domToBindingCommitHandler);
+    }
+
+    public void setMappingService(BindingIndependentMappingService mappingService) {
+        this.mappingService = mappingService;
+    }
+
+    @Override
+    public Collection<ProviderFunctionality> getProviderFunctionality() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public void onSessionInitiated(ProviderSession session) {
+        setBiDataService(session.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
+        start();
+    }
+
+    private class DomToBindingTransaction implements
+            DataCommitTransaction<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> {
+
+        private final org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction backing;
+        private final DataModification<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> modification;
+
+        public DomToBindingTransaction(
+                org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction backing,
+                DataModification<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> modification) {
+            super();
+            this.backing = backing;
+            this.modification = modification;
+            bindingOpenedTransactions.put(backing.getIdentifier(), this);
+        }
+
+        @Override
+        public DataModification<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> getModification() {
+            return modification;
+        }
+
+        @Override
+        public RpcResult<Void> rollback() throws IllegalStateException {
+            // backing.cancel();
+            return Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
+        }
+
+        @Override
+        public RpcResult<Void> finish() throws IllegalStateException {
+            Future<RpcResult<TransactionStatus>> result = backing.commit();
+            try {
+                RpcResult<TransactionStatus> baResult = result.get();
+                return Rpcs.<Void> getRpcResult(baResult.isSuccessful(), null, baResult.getErrors());
+            } catch (InterruptedException e) {
+                throw new IllegalStateException("", e);
+            } catch (ExecutionException e) {
+                throw new IllegalStateException("", e);
+            }
+        }
+    }
+
+    private class BindingToDomTransaction implements
             DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> {
 
         private DataModificationTransaction backing;
         private DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
 
-        public WrappedTransaction(DataModificationTransaction backing,
+        public BindingToDomTransaction(DataModificationTransaction backing,
                 DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
             this.backing = backing;
             this.modification = modification;
+            domOpenedTransactions.put(backing.getIdentifier(), this);
         }
 
         @Override
@@ -106,46 +224,84 @@ public class BindingIndependentDataServiceConnector implements //
         public RpcResult<Void> finish() throws IllegalStateException {
             Future<RpcResult<TransactionStatus>> result = backing.commit();
             try {
-                RpcResult<TransactionStatus> biresult = result.get();
+                RpcResult<TransactionStatus> biResult = result.get();
+                return Rpcs.<Void> getRpcResult(biResult.isSuccessful(), null, biResult.getErrors());
             } catch (InterruptedException e) {
                 throw new IllegalStateException("", e);
             } catch (ExecutionException e) {
                 throw new IllegalStateException("", e);
+            } finally {
+                domOpenedTransactions.remove(backing.getIdentifier());
             }
-            return Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
         }
 
         @Override
         public RpcResult<Void> rollback() throws IllegalStateException {
-            // backing.cancel();
+            domOpenedTransactions.remove(backing.getIdentifier());
             return Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
         }
-
     }
 
-    public DataBrokerService getBiDataService() {
-        return biDataService;
-    }
+    private class BindingToDomCommitHandler implements
+            DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
 
-    public void setBiDataService(DataBrokerService biDataService) {
-        this.biDataService = biDataService;
-    }
+        @Override
+        public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> requestCommit(
+                DataModification<InstanceIdentifier<? extends DataObject>, DataObject> bindingTransaction) {
 
-    public DataProviderService getBaDataService() {
-        return baDataService;
-    }
+            /**
+             * Transaction was created as DOM transaction, in that case we do
+             * not need to forward it back.
+             */
+            if (bindingOpenedTransactions.containsKey(bindingTransaction.getIdentifier())) {
 
-    public void setBaDataService(DataProviderService baDataService) {
-        this.baDataService = baDataService;
+                return CommitHandlersTransactions.allwaysSuccessfulTransaction(bindingTransaction);
+            }
+            DataModificationTransaction domTransaction = createBindingToDomTransaction(bindingTransaction);
+            BindingToDomTransaction wrapped = new BindingToDomTransaction(domTransaction, bindingTransaction);
+            LOG.info("Forwarding Binding Transaction: {} as DOM Transaction: {} .", bindingTransaction.getIdentifier(),
+                    domTransaction.getIdentifier());
+            return wrapped;
+        }
     }
 
-    public void start() {
-        baDataService.registerDataReader(ROOT, this);
-        baDataService.registerCommitHandler(ROOT, this);
-    }
+    private class DomToBindingCommitHandler implements //
+            RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier<?>, DataObject>>, //
+            DataCommitHandler<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> {
 
-    public void setMappingService(BindingIndependentMappingService mappingService) {
-        this.mappingService = mappingService;
-    }
+        @Override
+        public void onRegister(DataCommitHandlerRegistration<InstanceIdentifier<?>, DataObject> registration) {
+            
+            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = mappingService.toDataDom(registration.getPath());
+            // FIXME: do registration based on only active commit handlers.
+            
+        }
 
+        @Override
+        public void onUnregister(DataCommitHandlerRegistration<InstanceIdentifier<?>, DataObject> registration) {
+            // NOOP for now
+            // FIXME: do registration based on only active commit handlers.
+        }
+
+        public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> requestCommit(
+                DataModification<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> domTransaction) {
+            Object identifier = domTransaction.getIdentifier();
+
+            /**
+             * We checks if the transcation was originated in this mapper. If it
+             * was originated in this mapper we are returing allways success
+             * commit hanlder to prevent creating loop in two-phase commit and
+             * duplicating data.
+             */
+            if (domOpenedTransactions.containsKey(identifier)) {
+                return CommitHandlersTransactions.allwaysSuccessfulTransaction(domTransaction);
+            }
+
+            org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction baTransaction = createDomToBindingTransaction(domTransaction);
+            DomToBindingTransaction forwardedTransaction = new DomToBindingTransaction(baTransaction, domTransaction);
+            LOG.info("Forwarding DOM Transaction: {} as Binding Transaction: {}.", domTransaction.getIdentifier(),
+                    baTransaction.getIdentifier());
+            return forwardedTransaction;
+        }
+    }
 }
index 8e61c9b..9e175b8 100644 (file)
@@ -17,6 +17,7 @@ public interface BindingIndependentMappingService {
     org.opendaylight.yangtools.yang.data.api.InstanceIdentifier toDataDom(InstanceIdentifier<? extends DataObject> path);
 
     DataObject dataObjectFromDataDom(InstanceIdentifier<? extends DataObject> path, CompositeNode result);
-    
-    
+
+    InstanceIdentifier<?> fromDataDom(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier entry);
+
 }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/CommitHandlersTransactions.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/CommitHandlersTransactions.java
new file mode 100644 (file)
index 0000000..ea48374
--- /dev/null
@@ -0,0 +1,40 @@
+package org.opendaylight.controller.sal.binding.impl.connect.dom;
+
+import java.util.Collections;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.controller.sal.common.util.Rpcs;
+import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public class CommitHandlersTransactions {
+
+    private static class AllwaysSuccessfulTransaction<P,D> implements DataCommitTransaction<P, D> {
+        
+        private final  DataModification<P, D> modification;
+
+        public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
+            this.modification = modification;
+        }
+        @Override
+        public RpcResult<Void> rollback() throws IllegalStateException {
+            return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
+        }
+        @Override
+        public RpcResult<Void> finish() throws IllegalStateException {
+            return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
+        }
+        
+        @Override
+        public DataModification<P, D> getModification() {
+            return modification;
+        }
+    }
+    
+    
+    public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification)  {
+        return new AllwaysSuccessfulTransaction<>(modification);
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/ConnectorActivator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/ConnectorActivator.java
deleted file mode 100644 (file)
index f69e664..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.opendaylight.controller.sal.binding.impl.connect.dom;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import javassist.ClassPool;
-
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.RuntimeGeneratedMappingServiceImpl;
-import org.opendaylight.controller.sal.binding.dom.serializer.impl.TransformerGenerator;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ConnectorActivator implements Provider, ServiceTrackerCustomizer<Broker, Broker> {
-
-    BindingIndependentDataServiceConnector dataConnector;
-    BindingIndependentMappingService mappingService;
-
-    private final DataProviderService baDataService;
-    private BundleContext context;
-
-    private ServiceTracker<Broker, Broker> brokerTracker;
-
-    public ConnectorActivator(DataProviderService dataService, BundleContext context) {
-        baDataService = dataService;
-        this.context = context;
-        brokerTracker = new ServiceTracker<>(context, Broker.class, this);
-    }
-
-    @Override
-    public Collection<ProviderFunctionality> getProviderFunctionality() {
-        return Collections.emptySet();
-    }
-
-    @Override
-    public void onSessionInitiated(ProviderSession session) {
-
-        RuntimeGeneratedMappingServiceImpl mappingImpl = new RuntimeGeneratedMappingServiceImpl();
-        mappingImpl.setPool(new ClassPool());
-        SchemaService schemaService = (session.getService(SchemaService.class));
-        ClassPool pool = new ClassPool();
-        mappingImpl.setBinding(new TransformerGenerator(pool));
-        mappingImpl.start();
-        schemaService.registerSchemaServiceListener(mappingImpl);
-        mappingService = mappingImpl;
-        dataConnector = new BindingIndependentDataServiceConnector();
-        dataConnector.setBaDataService(baDataService);
-        dataConnector.setBiDataService(session.getService(DataBrokerService.class));
-        dataConnector.setMappingService(mappingService);
-        dataConnector.start();
-    }
-
-    @Override
-    public Broker addingService(ServiceReference<Broker> reference) {
-        Broker br= context.getService(reference);
-        br.registerProvider(this, context);
-        return br;
-    }
-
-    @Override
-    public void modifiedService(ServiceReference<Broker> reference, Broker service) {
-        // NOOP
-    }
-
-    @Override
-    public void removedService(ServiceReference<Broker> reference, Broker service) {
-        // NOOP
-    }
-
-    public void start() {
-        brokerTracker.open();
-    }
-}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DataModificationTracker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/DataModificationTracker.java
new file mode 100644 (file)
index 0000000..3fc377f
--- /dev/null
@@ -0,0 +1,25 @@
+package org.opendaylight.controller.sal.binding.impl.connect.dom;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.yangtools.concepts.Path;
+
+import com.google.common.util.concurrent.JdkFutureAdapters;
+
+public final class DataModificationTracker<P extends Path<P>,D> {
+
+    ConcurrentMap<Object, DataModification<P,D>> trackedTransactions = new ConcurrentHashMap<>();
+    
+    
+    public void startTrackingModification(DataModification<P,D> modification) {
+        trackedTransactions.putIfAbsent(modification.getIdentifier(), modification);
+        
+        
+    }
+    
+    public boolean containsIdentifier(Object identifier) {
+        return trackedTransactions.containsKey(identifier);
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingContext.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingContext.java
new file mode 100644 (file)
index 0000000..e3a7235
--- /dev/null
@@ -0,0 +1,10 @@
+package org.opendaylight.controller.sal.binding.spi;
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public interface RpcRoutingContext<C extends BaseIdentity,S extends RpcService> {
+
+    Class<C> getContextType();
+    Class<S> getServiceType();
+}
index 72bae68..38770c1 100644 (file)
@@ -3,8 +3,10 @@ module opendaylight-sal-binding-broker-impl {
     namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl";
     prefix "binding-impl";
 
-       import config { prefix config; revision-date 2013-04-05; }
-       import opendaylight-md-sal-binding {prefix sal;}
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding {prefix sal;}
+    import opendaylight-md-sal-dom {prefix dom;}
+    import opendaylight-md-sal-common {prefix common;}
 
     description
         "Service definition for Binding Aware MD-SAL.";
@@ -14,39 +16,123 @@ module opendaylight-sal-binding-broker-impl {
             "Initial revision";
     }
 
-    identity binding-broker-impl-singleton {
+    identity binding-dom-mapping-service {
+        base config:service-type;
+        config:java-class "org.opendaylight.controller.sal.binding.impl.connect.dom.BindingIndependentMappingService";
+    }
+
+
+    identity binding-broker-impl {
         base config:module-type;
         config:provided-service sal:binding-broker-osgi-registry;
-        config:java-name-prefix BindingBrokerImplSingleton;
+        config:java-name-prefix BindingBrokerImpl;
+    }
+    
+    identity binding-data-broker {
+        base config:module-type;
+        config:provided-service sal:binding-data-broker;
+        config:provided-service sal:binding-data-consumer-broker;
+        config:java-name-prefix DataBrokerImpl;
     }
-
-    grouping rpc-routing-table {
-        
     
+    identity binding-rpc-broker {
+        base config:module-type;
+        config:provided-service sal:binding-rpc-registry;
+        config:java-name-prefix RpcBrokerImpl;
+    }
+    
+    identity binding-notification-broker {
+        base config:module-type;
+        config:provided-service sal:binding-notification-service;
+        config:provided-service sal:binding-notification-subscription-service;
+        config:java-name-prefix NotificationBrokerImpl;
     }
 
+    identity runtime-generated-mapping {
+        base config:module-type;
+        config:provided-service binding-dom-mapping-service;
+        config:java-name-prefix RuntimeMapping;
+    }
 
-    grouping rpc-router {
-        leaf module {
-            type string;
+    augment "/config:modules/config:module/config:configuration" {
+        case binding-broker-impl {
+            when "/config:modules/config:module/config:type = 'binding-broker-impl'";
+            
+            /*
+            container rpc-registry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity sal:binding-rpc-registry;
+                    }
+                }
+            }*/
+            
+            container data-broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity sal:binding-data-broker;
+                    }
+                }
+            }
+            
+            container notification-service {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity sal:binding-notification-service;
+                    }
+                }
+            } 
         }
-        container routing-tables {
-            list routing-table {
-                uses rpc-routing-table;
+    }
+    
+    augment "/config:modules/config:module/config:configuration" {
+        case binding-data-broker {
+            when "/config:modules/config:module/config:type = 'binding-data-broker'";
+            container dom-broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity dom:dom-broker-osgi-registry;
+                    }
+                }
             }
+            container mapping-service {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity binding-dom-mapping-service;
+                    }
+                }
+            } 
         }
     }
+    
 
+    augment "/config:modules/config:module/config:state" {
+        case runtime-generated-mapping {
+            when "/config:modules/config:module/config:type = 'runtime-generated-mapping'";
+        }
+    }
 
     augment "/config:modules/config:module/config:state" {
-        case binding-broker-impl-singleton {
-            when "/config:modules/config:module/config:type = 'binding-broker-impl-singleton'";
-            
-            container rpc-routers {
-                list rpc-router {
-                    uses rpc-router;
-                }
-            }
+        case binding-data-broker {
+            when "/config:modules/config:module/config:type = 'binding-data-broker'";
+            uses common:data-state;
+        }
+    }
+    augment "/config:modules/config:module/config:state" {
+        case binding-rpc-broker {
+            when "/config:modules/config:module/config:type = 'binding-rpc-broker'";
+            uses common:rpc-state;
+        }
+    }
+    augment "/config:modules/config:module/config:state" {
+        case binding-notification-broker {
+            when "/config:modules/config:module/config:type = 'binding-notification-broker'";
+            uses common:notification-state;
         }
     }
 }
\ No newline at end of file
index 7d8a8f1..5b35861 100644 (file)
@@ -27,7 +27,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 
 public  abstract class AbstractDataServiceTest {
-    protected DataBrokerService biDataService;
+    protected org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
     protected DataProviderService baDataService;
     
     /**
@@ -67,7 +67,7 @@ public  abstract class AbstractDataServiceTest {
         mappingService = mappingServiceImpl;
         File pathname = new File("target/gen-classes-debug");
         //System.out.println("Generated classes are captured in " + pathname.getAbsolutePath());
-        mappingServiceImpl.start();
+        mappingServiceImpl.start(null);
         //mappingServiceImpl.getBinding().setClassFileCapturePath(pathname);
         
         connectorServiceImpl = new BindingIndependentDataServiceConnector();
index 4e7628f..f60ddb9 100644 (file)
@@ -1,22 +1,21 @@
 package org.opendaylight.controller.sal.binding.test.bugfix;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
+
+
 
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
@@ -24,9 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -35,10 +32,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -46,7 +44,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -68,17 +65,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
     private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
             NODE_ID);
 
-    private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder() //
-            .node(Nodes.class) //
-            .toInstance();
-
-    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODES_INSTANCE_ID_BI = //
-    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
-            .node(Nodes.QNAME) //
-            .toInstance();
-
-    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder() //
-            .node(Nodes.class) //
+    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
             .child(Node.class, NODE_KEY).toInstance();
 
     private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
@@ -99,9 +86,8 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
             .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) //
             .toInstance();
     private static final InstanceIdentifier<? extends DataObject> FLOW_INSTANCE_ID_BA = //
-    InstanceIdentifier.builder() //
-            .node(Flows.class) //
-            .node(Flow.class, FLOW_KEY) //
+    InstanceIdentifier.builder(Flows.class) //
+            .child(Flow.class, FLOW_KEY) //
             .toInstance();
 
 
@@ -142,6 +128,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
         ListenableFuture<Void> task3Future = listenablePool.submit(task3);
 
 
+        @SuppressWarnings("unchecked")
         ListenableFuture<List<Void>> compositeFuture = Futures.allAsList(task1Future,task2Future,task3Future);
 
         Thread.sleep(500);
@@ -180,8 +167,6 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
         flow.setKey(FLOW_KEY);
         flow.setMatch(match.build());
         flow.setNode(NODE_REF);
-
-
         InstructionsBuilder instructions = new InstructionsBuilder();
         InstructionBuilder instruction = new InstructionBuilder();
         ApplyActionsBuilder applyActions = new ApplyActionsBuilder();
@@ -191,6 +176,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
         actionList.add(new ActionBuilder().setAction(popMplsAction.build()).build());
 
         applyActions.setAction(actionList );
+        
 
 
         instruction.setInstruction(applyActions.build());
@@ -205,13 +191,37 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
         assertNotNull(ret);
         assertEquals(TransactionStatus.COMMITED, ret.getResult());
     }
+    
+    private void createFlow2() throws Exception {
+        DataModificationTransaction modification = baDataService.beginTransaction();
+        long id = 123;
+        FlowKey key = new FlowKey(id, new NodeRef(NODE_INSTANCE_ID_BA));
+        InstanceIdentifier<?> path1;
+        FlowBuilder flow = new FlowBuilder();
+        flow.setKey(key);
+        MatchBuilder match = new MatchBuilder();
+        Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+        // ipv4Match.setIpv4Destination(new Ipv4Prefix(cliInput.get(4)));
+        match.setLayer4Match(new TcpMatchBuilder().build());
+        flow.setMatch(match.build());
+        DropAction dropAction = new DropActionBuilder().build();
+        //   ActionBuilder action = new ActionBuilder();
+
+        //  List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action> actions = Collections
+             //   .singletonList(action.build());
+        //   flow.setAction(actions);
+        flow.setPriority(2);
+        System.out.println("Putting the configuration Data................");
+        path1 = InstanceIdentifier.builder(Flows.class).child(Flow.class, key).toInstance();
+       // DataObject cls = (DataObject) modification.readConfigurationData(path1);
+        modification.putConfigurationData(path1, flow.build());
+        modification.commit();
+
+    }
 
     private class CreateFlowTask implements Callable<Void> {
 
-        final Object startSyncObject;
-
         public CreateFlowTask(Object startSync) {
-            startSyncObject = startSync;
         }
 
         @Override
@@ -220,6 +230,7 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
                 //startSyncObject.wait();
                 //Thread.sleep(500);
                 createFlow();
+                createFlow2();
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -228,10 +239,10 @@ public class DOMCodecBug01Test extends AbstractDataServiceTest {
     }
 
     private void verifyDataAreStoredProperly() {
-        CompositeNode biFlow = biDataService.readConfigurationData(FLOW_INSTANCE_ID_BI);
+        CompositeNode biFlows = biDataService.readConfigurationData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.of(Flows.QNAME));
+        assertNotNull(biFlows);
+        CompositeNode biFlow = biFlows.getFirstCompositeByName(Flow.QNAME);
         assertNotNull(biFlow);
-        CompositeNode biMatch = biFlow.getFirstCompositeByName(QName.create(Flow.QNAME, Match.QNAME.getLocalName()));
-        assertNotNull(biMatch);
     }
 
 
index 773bab8..4df10bc 100644 (file)
@@ -1,8 +1,6 @@
 package org.opendaylight.controller.sal.binding.test.bugfix;
 
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -13,43 +11,22 @@ import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 
 import static org.junit.Assert.*;
 
 public class DOMCodecBug02Test extends AbstractDataServiceTest {
 
     private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
-    private static final QName FLOW_ID_QNAME = QName.create(Flow.QNAME, "id");
-    private static final QName FLOW_NODE_QNAME = QName.create(Flow.QNAME, "node");
-
-    private static final String FLOW_ID = "foo";
     private static final String NODE_ID = "node:1";
 
     private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
@@ -57,8 +34,7 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
     private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
             NODE_ID);
 
-    private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder() //
-            .node(Nodes.class) //
+    private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
             .toInstance();
 
     private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODES_INSTANCE_ID_BI = //
@@ -66,8 +42,7 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
             .node(Nodes.QNAME) //
             .toInstance();
 
-    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder() //
-            .node(Nodes.class) //
+    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
             .child(Node.class, NODE_KEY).toInstance();
 
     private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
index ae54591..2cd396d 100644 (file)
@@ -1,13 +1,7 @@
 package org.opendaylight.controller.sal.binding.test.bugfix;
-
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
+
 
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
@@ -15,36 +9,24 @@ import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
+
 
 import static org.junit.Assert.*;
 
@@ -58,17 +40,11 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh
     private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
             NODE_ID);
 
-    private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder() //
-            .node(Nodes.class) //
+    private static final InstanceIdentifier<Nodes> NODES_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
             .toInstance();
 
-    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODES_INSTANCE_ID_BI = //
-    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
-            .node(Nodes.QNAME) //
-            .toInstance();
 
-    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder() //
-            .node(Nodes.class) //
+    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(NODES_INSTANCE_ID_BA) //
             .child(Node.class, NODE_KEY).toInstance();
 
     private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
@@ -76,7 +52,6 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh
             .node(Nodes.QNAME) //
             .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
             .toInstance();
-    private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
     private DataChangeEvent<InstanceIdentifier<?>, DataObject> receivedChangeEvent;
 
     
@@ -120,6 +95,49 @@ public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataCh
         verifyNodes(nodes,original);
         
         
+        
+        testAddingNodeConnector();
+        
+        
+        
+        testNodeRemove();
+        
+        
+    }
+
+    private void testAddingNodeConnector() throws Exception {
+        
+        NodeConnectorId ncId = new NodeConnectorId("openflow:1:bar");
+        NodeConnectorKey nodeKey = new NodeConnectorKey(ncId );
+        InstanceIdentifier<NodeConnector> ncInstanceId = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA).child(NodeConnector.class, nodeKey).toInstance();
+        NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
+        ncBuilder.setId(ncId);
+        ncBuilder.setKey(nodeKey);
+        NodeConnector connector = ncBuilder.build();
+        DataModificationTransaction transaction = baDataService.beginTransaction();
+        transaction.putOperationalData(ncInstanceId, connector);
+        RpcResult<TransactionStatus> result = transaction.commit().get();
+        assertEquals(TransactionStatus.COMMITED, result.getResult());
+        Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
+        assertNotNull(node);
+        assertNotNull(node.getNodeConnector());
+        assertFalse(node.getNodeConnector().isEmpty());
+        NodeConnector readedNc = node.getNodeConnector().get(0);
+        assertNotNull(readedNc);
+        
+        
+        
+        
+    }
+
+    private void testNodeRemove() throws Exception {
+        DataModificationTransaction transaction = baDataService.beginTransaction();
+        transaction.removeOperationalData(NODE_INSTANCE_ID_BA);
+        RpcResult<TransactionStatus> result = transaction.commit().get();
+        assertEquals(TransactionStatus.COMMITED, result.getResult());
+        
+        Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
+        assertNull(node);
     }
 
     private void verifyNodes(Nodes nodes,Node original) {
diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/RpcRegistrationNullPointer.java
new file mode 100644 (file)
index 0000000..0c7f039
--- /dev/null
@@ -0,0 +1,8 @@
+package org.opendaylight.controller.sal.binding.test.bugfix;
+
+public class RpcRegistrationNullPointer {
+
+    
+    
+    
+}
index 7706cda..e326fd0 100644 (file)
@@ -63,7 +63,7 @@ public class BrokerIntegrationTest extends AbstractDataServiceTest {
         assertNotNull(result2.getResult());
         assertEquals(TransactionStatus.COMMITED, result.getResult());
 
-        Nodes allNodes = (Nodes) baDataService.readConfigurationData(InstanceIdentifier.builder().node(Nodes.class)
+        Nodes allNodes = (Nodes) baDataService.readConfigurationData(InstanceIdentifier.builder(Nodes.class)
                 .toInstance());
         assertNotNull(allNodes);
         assertNotNull(allNodes.getNode());
@@ -100,7 +100,7 @@ public class BrokerIntegrationTest extends AbstractDataServiceTest {
 
     private static NodeRef createNodeRef(String string) {
         NodeKey key = new NodeKey(new NodeId(string));
-        InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
+        InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
                 .toInstance();
         return new NodeRef(path);
     }
diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/connect/dom/ChangeOriginatedInDomBrokerTest.java
new file mode 100644 (file)
index 0000000..63368bd
--- /dev/null
@@ -0,0 +1,190 @@
+package org.opendaylight.controller.sal.binding.test.connect.dom;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+
+
+
+
+
+
+
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+
+
+
+
+
+
+
+
+
+
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.sal.binding.impl.connect.dom.CommitHandlersTransactions;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
+import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+
+import com.google.common.collect.ImmutableMap;
+
+public class ChangeOriginatedInDomBrokerTest extends AbstractDataServiceTest {
+
+    private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
+    private static final QName FLOW_ID_QNAME = QName.create(Flow.QNAME, "id");
+    private static final QName FLOW_NODE_QNAME = QName.create(Flow.QNAME, "node");
+    private static final long FLOW_ID = 1234;
+    private static final String NODE_ID = "node:1";
+    
+    private DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modificationCapture;
+
+
+    private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID));
+
+    private static final Map<QName, Object> NODE_KEY_BI = Collections.<QName, Object> singletonMap(NODE_ID_QNAME,
+            NODE_ID);
+
+    private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier.builder(Nodes.class) //
+            .child(Node.class, NODE_KEY).toInstance();
+
+    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
+    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
+            .node(Nodes.QNAME) //
+            .nodeWithKey(Node.QNAME, NODE_KEY_BI) //
+            .toInstance();
+    private static final NodeRef NODE_REF = new NodeRef(NODE_INSTANCE_ID_BA);
+
+    private static final FlowKey FLOW_KEY = new FlowKey(FLOW_ID, NODE_REF);
+
+    private static final Map<QName, Object> FLOW_KEY_BI = //
+    ImmutableMap.<QName, Object> of(FLOW_ID_QNAME, FLOW_ID, FLOW_NODE_QNAME, NODE_INSTANCE_ID_BI);
+
+    private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = //
+    org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
+            .node(Flows.QNAME) //
+            .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) //
+            .toInstance();
+    
+    private static final InstanceIdentifier<Flows> FLOWS_PATH_BA = //
+            InstanceIdentifier.builder(Flows.class) //
+                    .toInstance();
+            
+    
+    private static final InstanceIdentifier<Flow> FLOW_INSTANCE_ID_BA = //
+    InstanceIdentifier.builder(Flows.class) //
+            .child(Flow.class, FLOW_KEY) //
+            .toInstance();
+    
+    @Test
+    public void simpleModifyOperation() throws Exception {
+        
+        registerCommitHandler();
+        
+        CompositeNode domflow = createXmlFlow();
+        DataModificationTransaction biTransaction = biDataService.beginTransaction();
+        biTransaction.putConfigurationData(FLOW_INSTANCE_ID_BI, domflow);
+        RpcResult<TransactionStatus> biResult = biTransaction.commit().get();
+        
+        assertNotNull(modificationCapture);
+        Flow flow = (Flow) modificationCapture.getCreatedConfigurationData().get(FLOW_INSTANCE_ID_BA);
+        assertNotNull(flow);
+        assertNotNull(flow.getMatch());
+        assertEquals(TransactionStatus.COMMITED, biResult.getResult());
+        
+    }
+
+    
+
+    private void registerCommitHandler() {
+        DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> flowTestCommitHandler = new DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>() {
+            
+            
+            @Override
+            public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> requestCommit(
+                    DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
+                modificationCapture = modification;
+                return CommitHandlersTransactions.allwaysSuccessfulTransaction(modification);
+            }
+            
+            
+        };
+        Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> registration = baDataService.registerCommitHandler(FLOWS_PATH_BA, flowTestCommitHandler);
+        assertNotNull(registration);
+    }
+    
+    private CompositeNode createXmlFlow() {
+        
+        FlowBuilder flow = new FlowBuilder();
+        MatchBuilder match = new MatchBuilder();
+        VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
+        VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+        VlanId vlanId = new VlanId(10);
+        vlanBuilder.setVlanId(vlanIdBuilder.setVlanId(vlanId).build());
+        match.setVlanMatch(vlanBuilder.build());
+
+        flow.setKey(FLOW_KEY);
+        flow.setMatch(match.build());
+        flow.setNode(NODE_REF);
+        InstructionsBuilder instructions = new InstructionsBuilder();
+        InstructionBuilder instruction = new InstructionBuilder();
+        ApplyActionsBuilder applyActions = new ApplyActionsBuilder();
+        List<Action> actionList = new ArrayList<>();
+        PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
+        popMplsAction.setEthernetType(34);
+        actionList.add(new ActionBuilder().setAction(popMplsAction.build()).build());
+
+        applyActions.setAction(actionList );
+        
+
+
+        instruction.setInstruction(applyActions.build());
+
+
+        List<Instruction> instructionList = Collections.<Instruction>singletonList(instruction.build());
+        instructions.setInstruction(instructionList );
+
+        flow.setInstructions(instructions.build());
+        
+        CompositeNode domFlow = mappingService.toDataDom(flow.build());
+        return domFlow;
+    }
+}
index bf3d7ab..38f0da3 100644 (file)
@@ -23,6 +23,11 @@ module opendaylight-md-sal-binding {
         config:java-class "org.opendaylight.controller.sal.binding.api.data.DataProviderService";
     }
 
+    identity binding-data-consumer-broker {
+        base "config:service-type";
+        config:java-class "org.opendaylight.controller.sal.binding.api.data.DataBrokerService";
+    }
+
     identity binding-rpc-registry {
         base "config:service-type";
         config:java-class "org.opendaylight.controller.sal.binding.api.RpcProviderRegistry";
@@ -33,4 +38,9 @@ module opendaylight-md-sal-binding {
         config:java-class "org.opendaylight.controller.sal.binding.api.NotificationProviderService";
     }
 
+    identity binding-notification-subscription-service {
+        base "config:service-type";
+        config:java-class "org.opendaylight.controller.sal.binding.api.NotificationService";
+    }
+
 }
\ No newline at end of file
index e242b9e..27d4267 100644 (file)
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>sal-parent</artifactId>
-    <groupId>org.opendaylight.controller</groupId>
-    <version>1.0-SNAPSHOT</version>
-  </parent>
-  <artifactId>sal-binding-it</artifactId>
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
-  </scm>
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>sal-parent</artifactId>
+        <groupId>org.opendaylight.controller</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>sal-binding-it</artifactId>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+    </scm>
 
-  <properties>
-    <exam.version>3.0.0</exam.version>
-    <url.version>1.5.0</url.version>
-    <!-- Sonar jacoco plugin to get integration test coverage info -->
-    <sonar.jacoco.reportPath>../sal-binding-broker/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../sal-binding-broker/target/jacoco-it.exec</sonar.jacoco.itReportPath>
-  </properties>
+    <properties>
+        <exam.version>3.0.0</exam.version>
+        <url.version>1.5.0</url.version>
+        <!-- Sonar jacoco plugin to get integration test coverage info -->
+        <sonar.jacoco.reportPath>../sal-binding-broker/target/jacoco.exec</sonar.jacoco.reportPath>
+        <sonar.jacoco.itReportPath>../sal-binding-broker/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+        <netconf.version>0.2.3-SNAPSHOT</netconf.version>
+        <config.version>0.2.3-SNAPSHOT</config.version>
+    </properties>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.ops4j.pax.exam</groupId>
-        <artifactId>maven-paxexam-plugin</artifactId>
-        <version>1.2.4</version>
-        <executions>
-          <execution>
-            <id>generate-config</id>
-            <goals>
-              <goal>generate-depends-file</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-           <groupId>org.jacoco</groupId>
-           <artifactId>jacoco-maven-plugin</artifactId>
-           <configuration>
-             <includes>org.opendaylight.controller.*</includes>
-           </configuration>
-           <executions>
-             <execution>
-               <id>pre-test</id>
-               <goals>
-                 <goal>prepare-agent</goal>
-               </goals>
-             </execution>
-             <execution>
-               <id>post-test</id>
-               <phase>test</phase>
-               <goals>
-                 <goal>report</goal>
-               </goals>
-             </execution>
-           </executions>
-     </plugin>
-    </plugins>
-    <pluginManagement>
-      <plugins>
-        <!--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>
-          <artifactId>lifecycle-mapping</artifactId>
-          <version>1.0.0</version>
-          <configuration>
-            <lifecycleMappingMetadata>
-              <pluginExecutions>
-                <pluginExecution>
-                  <pluginExecutionFilter>
-                    <groupId>
-                      org.ops4j.pax.exam
-                    </groupId>
-                    <artifactId>
-                      maven-paxexam-plugin
-                    </artifactId>
-                    <versionRange>
-                      [1.2.4,)
-                    </versionRange>
-                    <goals>
-                      <goal>
-                        generate-depends-file
-                      </goal>
-                    </goals>
-                  </pluginExecutionFilter>
-                  <action>
-                    <ignore></ignore>
-                  </action>
-                </pluginExecution>
-              </pluginExecutions>
-            </lifecycleMappingMetadata>
-          </configuration>
-        </plugin>
-        <plugin>
-          <groupId>org.jacoco</groupId>
-          <artifactId>jacoco-maven-plugin</artifactId>
-          <version>${jacoco.version}</version>
-          <configuration>
-            <destFile>../sal-binding-broker/target/jacoco-it.exec</destFile>
-            <includes>org.opendaylight.controller.*</includes>
-          </configuration>
-          <executions>
-            <execution>
-              <id>pre-test</id>
-              <goals>
-                <goal>prepare-agent</goal>
-              </goals>
-            </execution>
-            <execution>
-              <id>post-test</id>
-              <configuration>
-                <skip>true</skip>
-              </configuration>
-            </execution>
-          </executions>
-        </plugin>
-      </plugins>
-    </pluginManagement>
-  </build>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>maven-paxexam-plugin</artifactId>
+                <version>1.2.4</version>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <configuration>
+                    <includes>org.opendaylight.controller.*</includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>pre-test</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>post-test</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <pluginManagement>
+            <plugins>
+                <!--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>
+                    <artifactId>lifecycle-mapping</artifactId>
+                    <version>1.0.0</version>
+                    <configuration>
+                        <lifecycleMappingMetadata>
+                            <pluginExecutions>
+                                <pluginExecution>
+                                    <pluginExecutionFilter>
+                                        <groupId>
+                                            org.ops4j.pax.exam
+                                        </groupId>
+                                        <artifactId>
+                                            maven-paxexam-plugin
+                                        </artifactId>
+                                        <versionRange>
+                                            [1.2.4,)
+                                        </versionRange>
+                                        <goals>
+                                            <goal>
+                                                generate-depends-file
+                                            </goal>
+                                        </goals>
+                                    </pluginExecutionFilter>
+                                    <action>
+                                        <ignore></ignore>
+                                    </action>
+                                </pluginExecution>
+                            </pluginExecutions>
+                        </lifecycleMappingMetadata>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <version>${jacoco.version}</version>
+                    <configuration>
+                        <destFile>../sal-binding-broker/target/jacoco-it.exec</destFile>
+                        <includes>org.opendaylight.controller.*</includes>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>pre-test</id>
+                            <goals>
+                                <goal>prepare-agent</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>post-test</id>
+                            <configuration>
+                                <skip>true</skip>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
 
-  <dependencies>
-    <dependency>
-      <groupId>org.opendaylight.yangtools.thirdparty</groupId>
-      <artifactId>xtend-lib-osgi</artifactId>
-      <version>2.4.3</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-binding-broker-impl</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam-container-native</artifactId>
-      <version>${exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam-junit4</artifactId>
-      <version>${exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam</artifactId>
-      <version>${exam.version}</version>
-      <!--  Compile scope here is intentional, it is used
-            in TestHelper class which could be downloaded
-            via nexus and reused in other integration tests.
-      -->
-      <scope>compile</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.ops4j.pax.exam</groupId>
-      <artifactId>pax-exam-link-mvn</artifactId>
-      <version>${exam.version}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>equinoxSDK381</groupId>
-      <artifactId>org.eclipse.osgi</artifactId>
-      <version>3.8.1.v20120830-144521</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>log4j-over-slf4j</artifactId>
-      <version>1.7.2</version>
-    </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-core</artifactId>
-      <version>1.0.9</version>
-    </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
-      <version>1.0.9</version>
-    </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller.model</groupId>
-      <artifactId>model-flow-service</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>config-manager</artifactId>
-      <version>0.2.3-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller.model</groupId>
-      <artifactId>model-flow-management</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>xtend-lib-osgi</artifactId>
+            <version>2.4.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-netconf-connector</artifactId>
+            <version>${netconf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>yang-store-impl</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>logback-config</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-persister-impl</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-persister-file-adapter</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+                <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>netconf-impl</artifactId>
+            <version>${netconf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>netconf-client</artifactId>
+            <version>${netconf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <version>${exam.version}</version>
+            <!-- Compile scope here is intentional, it is used in TestHelper 
+                class which could be downloaded via nexus and reused in other integration 
+                tests. -->
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>equinoxSDK381</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.1.v20120830-144521</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>log4j-over-slf4j</artifactId>
+            <version>1.7.2</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <version>0.2.3-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.opendaylight.yangtools.thirdparty</groupId>
             <artifactId>antlr4-runtime-osgi-nohead</artifactId>
             <version>4.0</version>
-    </dependency>
-  </dependencies>
+        </dependency>
+    </dependencies>
 </project>
index 2f9c397..0eace4d 100644 (file)
@@ -4,9 +4,12 @@ import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.repository;
+import static org.ops4j.pax.exam.CoreOptions.repositories;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.util.PathUtils;
 
 public class TestHelper {
 
@@ -15,62 +18,107 @@ public class TestHelper {
 
     public static final String CONTROLLER_MODELS = "org.opendaylight.controller.model";
     public static final String YANGTOOLS_MODELS = "org.opendaylight.yangtools.model";
+    private static final String OPENDAYLIGHT_SNAPSHOT = "http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/";
+    private static final String OPENDAYLIGHT_RELEASE = "http://nexus.opendaylight.org/content/repositories/opendaylight.release/";
 
     public static Option mdSalCoreBundles() {
         return new DefaultCompositeOption( //
-                mavenBundle(YANGTOOLS, "concepts").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-binding").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common-impl").versionAsInProject(), //
-                
-                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
-                mavenBundle("com.google.guava", "guava").versionAsInProject(), //
+                mavenBundle(YANGTOOLS, "concepts").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS, "yang-binding").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-common").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-common-impl").versionAsInProject(), // //
+
+                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(), //
+                mavenBundle("com.google.guava", "guava").versionAsInProject(), // //
                 mavenBundle(YANGTOOLS + ".thirdparty", "xtend-lib-osgi").versionAsInProject() //
         );
     }
 
     public static Option configMinumumBundles() {
         return new DefaultCompositeOption(
-            mavenBundle(CONTROLLER, "config-api").versionAsInProject(), //
-            mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), //
-            mavenBundle("commons-io", "commons-io").versionAsInProject()
-        );
+                mavenBundle("org.opendaylight.bgpcep", "framework").versionAsInProject(), //
+                mavenBundle("org.opendaylight.bgpcep", "util").versionAsInProject(), //
+                mavenBundle("commons-codec", "commons-codec").versionAsInProject(),
+                
+                mavenBundle(CONTROLLER, "config-api").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), // //
+                mavenBundle("commons-io", "commons-io").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "config-api").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "config-util").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "yang-jmx-generator").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "yang-store-api").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "yang-store-impl").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "logback-config").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "config-persister-api").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "netconf-api").versionAsInProject(), //
+               
+                mavenBundle(CONTROLLER, "netconf-client").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "netconf-util").versionAsInProject(), //
+                mavenBundle(CONTROLLER + ".thirdparty", "ganymed", "1.0-SNAPSHOT"), //
+                mavenBundle(CONTROLLER, "netconf-mapping-api").versionAsInProject(), //
+
+                mavenBundle(CONTROLLER, "config-persister-impl").versionAsInProject(), //
+                
+                mavenBundle("io.netty", "netty-handler").versionAsInProject(), //
+                mavenBundle("io.netty", "netty-codec").versionAsInProject(), //
+                mavenBundle("io.netty", "netty-buffer").versionAsInProject(), //
+                mavenBundle("io.netty", "netty-transport").versionAsInProject(), //
+                mavenBundle("io.netty", "netty-common").versionAsInProject(), //
+                
+                mavenBundle("org.opendaylight.controller.thirdparty", "exificient", "0.9.2-SNAPSHOT"), //
+                
+                mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.xerces", "2.11.0_1"),
+                mavenBundle("org.eclipse.birt.runtime.3_7_1", "org.apache.xml.resolver", "1.2.0"),
+                
+                mavenBundle(CONTROLLER, "config-netconf-connector").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "netconf-impl").versionAsInProject(), //
+                
+                mavenBundle(CONTROLLER, "config-persister-file-adapter").versionAsInProject().noStart());
+            
     }
-    
+
     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("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(),
+                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), // //
+                mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), // //
+                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-type-provider").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "binding-generator-api").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "binding-generator-spi").versionAsInProject(),
+
+                mavenBundle(YANGTOOLS, "binding-generator-spi").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS, "binding-model-api").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS, "binding-generator-util").versionAsInProject(), //
+                mavenBundle(YANGTOOLS, "yang-parser-impl").versionAsInProject(), //
+                mavenBundle(YANGTOOLS, "binding-type-provider").versionAsInProject(), //
+                mavenBundle(YANGTOOLS, "binding-generator-api").versionAsInProject(), mavenBundle(YANGTOOLS,
+                        "binding-generator-spi").versionAsInProject(), //
                 mavenBundle(YANGTOOLS, "binding-generator-impl").versionAsInProject(),
-                
-                
+
                 mavenBundle(CONTROLLER, "sal-core-api").versionAsInProject().update(), //
-                mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), // //
                 mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), //
-                
-                mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject() //
-       );
+
+                mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), // //
+
+                systemProperty("netconf.tcp.address").value("0.0.0.0"), //
+                systemProperty("netconf.tcp.port").value("18383"), //
+                systemProperty("netconf.config.persister.storageAdapterClass").value(
+                        "org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter"), //
+                systemProperty("fileStorage").value(PathUtils.getBaseDir() + "/src/test/resources/controller.config"), //
+                systemProperty("numberOfBackups").value("1") //
+                //systemProperty("yangstore.blacklist").value(".*controller.model.*") //
+
+        );
 
     }
 
@@ -83,8 +131,8 @@ public class TestHelper {
 
     public static Option flowCapableModelBundles() {
         return new DefaultCompositeOption( //
-                mavenBundle(CONTROLLER_MODELS, "model-flow-base").versionAsInProject(), //
-                mavenBundle(CONTROLLER_MODELS, "model-flow-service").versionAsInProject(), //
+                mavenBundle(CONTROLLER_MODELS, "model-flow-base").versionAsInProject(), // //
+                mavenBundle(CONTROLLER_MODELS, "model-flow-service").versionAsInProject(), // //
                 mavenBundle(CONTROLLER_MODELS, "model-inventory").versionAsInProject() //
         );
 
@@ -92,22 +140,18 @@ public class TestHelper {
 
     public static Option baseModelBundles() {
         return new DefaultCompositeOption( //
-                mavenBundle(YANGTOOLS_MODELS, "yang-ext").versionAsInProject(), //
-                mavenBundle(YANGTOOLS_MODELS, "ietf-inet-types").versionAsInProject(), //
-                mavenBundle(YANGTOOLS_MODELS, "ietf-yang-types").versionAsInProject(), //
-                mavenBundle(YANGTOOLS_MODELS, "opendaylight-l2-types").versionAsInProject(), //
+                mavenBundle(YANGTOOLS_MODELS, "yang-ext").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS_MODELS, "ietf-inet-types").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS_MODELS, "ietf-yang-types").versionAsInProject(), // //
+                mavenBundle(YANGTOOLS_MODELS, "opendaylight-l2-types").versionAsInProject(), // //
                 mavenBundle(CONTROLLER_MODELS, "model-inventory").versionAsInProject());
     }
 
     public static Option junitAndMockitoBundles() {
         return new DefaultCompositeOption(
-                // Repository required to load harmcrest (OSGi-fied version).
-                repository("http://repository.springsource.com/maven/bundles/external").id(
-                        "com.springsource.repository.bundles.external"),
-
-                // Mockito
-                mavenBundle("org.mockito", "mockito-all", "1.9.5"),
-                junitBundles(),
+        // Repository required to load harmcrest (OSGi-fied version).
+        // Mockito
+                mavenBundle("org.mockito", "mockito-all", "1.9.5"), junitBundles(),
 
                 /*
                  * Felix has implicit boot delegation enabled by default. It
index 41b1e31..338561a 100644 (file)
@@ -11,6 +11,7 @@ import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.util.Filter;
 import org.ops4j.pax.exam.util.PathUtils;
 import org.osgi.framework.BundleContext;
 
@@ -24,8 +25,9 @@ public abstract class AbstractTest {
     public static final String YANGTOOLS_MODELS = "org.opendaylight.yangtools.model";
 
     @Inject
+    @Filter(timeout=60*1000)
     BindingAwareBroker broker;
-
+    
     @Inject
     BundleContext bundleContext;
 
@@ -55,13 +57,14 @@ public abstract class AbstractTest {
                 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), //
                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), //
                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), //
+                systemProperty("osgi.bundles.defaultStartLevel").value("4"),
 
-                configMinumumBundles(),
+                
                 
                 mdSalCoreBundles(),
 
                 bindingAwareSalBundles(),
-
+                configMinumumBundles(),
                 // BASE Models
                 baseModelBundles(), flowCapableModelBundles(), junitAndMockitoBundles());
     }
diff --git a/opendaylight/md-sal/sal-binding-it/src/test/resources/controller.config b/opendaylight/md-sal/sal-binding-it/src/test/resources/controller.config
new file mode 100644 (file)
index 0000000..28c3bec
--- /dev/null
@@ -0,0 +1,123 @@
+//START OF CONFIG-LAST
+<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:dom:impl">prefix:schema-service-singleton</type>
+               <name>yang-schema-service</name>
+       </module>
+       <module>
+               <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:impl">prefix:dom-broker-impl</type>
+               <name>dom-broker</name>
+               <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+                       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
+                       <name>ref_hash-map-data-store</name>
+               </data-store>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
+               <name>binding-broker-impl</name>
+               <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                       <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
+                       <name>ref_binding-notification-broker</name>
+               </notification-service>
+               <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                       <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+                       <name>ref_binding-data-broker</name>
+               </data-broker>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
+               <name>runtime-mapping-singleton</name>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
+               <name>binding-notification-broker</name>
+       </module>
+       <module>
+               <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
+               <name>binding-data-broker</name>
+               <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+                       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+                       <name>ref_dom-broker</name>
+               </dom-broker>
+               <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+               <name>ref_runtime-mapping-singleton</name>
+               </mapping-service>
+       </module>
+</modules>
+<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+       <service>
+       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+               <instance>
+               <name>ref_yang-schema-service</name>
+               <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
+               <instance>
+                       <name>ref_binding-notification-broker</name>
+                       <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
+               <instance>
+                       <name>ref_hash-map-data-store</name>
+                       <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-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>
+               <instance>
+                       <name>ref_binding-broker-impl</name>
+                       <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
+               <instance>
+                       <name>ref_runtime-mapping-singleton</name>
+                       <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
+               </instance>
+       </service>
+       <service>
+       <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
+               <instance>
+                       <name>ref_dom-broker</name>
+                       <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
+               </instance>
+       </service>
+       <service>
+               <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+               <instance>
+               <name>ref_binding-data-broker</name>
+               <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
+       </instance>
+       </service>
+</services>
+</data>
+
+
+//END OF SNAPSHOT
+urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
+urn:ietf:params:netconf:capability:candidate:1.0
+urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
+urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
+urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
+urn:ietf:params:netconf:capability:rollback-on-error:1.0
+urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
+urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
+//END OF CONFIG
index 2d63ce5..1d17796 100644 (file)
@@ -7,7 +7,10 @@
     </encoder>
   </appender>
 
-  <root level="error">
+
+  <logger name="org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort" level="ERROR"/>
+
+  <root level="info">
     <appender-ref ref="STDOUT" />
   </root>
 </configuration>
diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/RegistrationListener.java
new file mode 100644 (file)
index 0000000..f6efd57
--- /dev/null
@@ -0,0 +1,12 @@
+package org.opendaylight.controller.md.sal.common.api;
+
+import java.util.EventListener;
+
+import org.opendaylight.yangtools.concepts.Registration;
+
+public interface RegistrationListener<T extends Registration<?>> extends EventListener {
+
+    void onRegister(T registration);
+    
+    void onUnregister(T registration);
+}
diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandlerRegistration.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandlerRegistration.java
new file mode 100644 (file)
index 0000000..85db5a0
--- /dev/null
@@ -0,0 +1,9 @@
+package org.opendaylight.controller.md.sal.common.api.data;
+
+import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.concepts.Registration;
+
+public interface DataCommitHandlerRegistration<P extends Path<P>,D> extends Registration<DataCommitHandler<P, D>>{
+
+    P getPath();
+}
index 264d076..7d78fd2 100644 (file)
@@ -7,13 +7,17 @@
  */
 package org.opendaylight.controller.md.sal.common.api.data;
 
-// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments.
-// import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Path;
 import org.opendaylight.yangtools.concepts.Registration;
 
 
-public interface DataProvisionService<P/* extends Path<P> */, D> {
+public interface DataProvisionService<P extends Path<P> , D> {
 
     public Registration<DataCommitHandler<P, D>> registerCommitHandler(P path, DataCommitHandler<P, D> commitHandler);
+    
+    public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<P, D>>> 
+        registerCommitHandlerListener(RegistrationListener<DataCommitHandlerRegistration<P, D>> commitHandlerListener);
 
 }
index c9e1d6e..bee8633 100644 (file)
@@ -179,7 +179,7 @@ public abstract class AbstractDataModification<P /* extends Path<P> */, D> imple
         if (operationalOriginal.containsKey(path)) {
             return true;
         }
-        D data = reader.readConfigurationData(path);
+        D data = reader.readOperationalData(path);
         if (data != null) {
             operationalOriginal.putIfAbsent(path, data);
             return true;
index 74c4e0a..e3d2b56 100644 (file)
@@ -34,12 +34,18 @@ import java.util.Collection
 import com.google.common.collect.FluentIterable;
 import java.util.Set
 import com.google.common.collect.ImmutableList
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration
+import org.opendaylight.controller.md.sal.common.api.RegistrationListener
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry
+import java.util.concurrent.atomic.AtomicLong
 
 abstract class AbstractDataBroker<P extends Path<P>, D, DCL extends DataChangeListener<P, D>> implements DataModificationTransactionFactory<P, D>, //
 DataReader<P, D>, //
 DataChangePublisher<P, D, DCL>, //
 DataProvisionService<P, D> {
 
+    private static val LOG = LoggerFactory.getLogger(AbstractDataBroker);
+
     @Property
     var ExecutorService executor;
 
@@ -47,17 +53,17 @@ DataProvisionService<P, D> {
     var AbstractDataReadRouter<P, D> dataReadRouter;
 
     Multimap<P, DataChangeListenerRegistration<P, D, DCL>> listeners = HashMultimap.create();
-    Multimap<P, DataCommitHandlerRegistration<P, D>> commitHandlers = HashMultimap.create();
-
+    Multimap<P, DataCommitHandlerRegistrationImpl<P, D>> commitHandlers = HashMultimap.create();
+    
+    val ListenerRegistry<RegistrationListener<DataCommitHandlerRegistration<P,D>>> commitHandlerRegistrationListeners = new ListenerRegistry();
     public new() {
     }
 
     protected def /*Iterator<Entry<Collection<DataChangeListenerRegistration<P,D,DCL>>,D>>*/ affectedCommitHandlers(
         HashSet<P> paths) {
-        return FluentIterable.from(commitHandlers.asMap.entrySet)
-            .filter[key.isAffectedBy(paths)] //
-            .transformAndConcat [value] //
-            .transform[instance].toList()
+        return FluentIterable.from(commitHandlers.asMap.entrySet).filter[key.isAffectedBy(paths)] //
+        .transformAndConcat[value] //
+        .transform[instance].toList()
     }
 
     override final readConfigurationData(P path) {
@@ -69,8 +75,16 @@ DataProvisionService<P, D> {
     }
 
     override final registerCommitHandler(P path, DataCommitHandler<P, D> commitHandler) {
-        val registration = new DataCommitHandlerRegistration(path, commitHandler, this);
+        val registration = new DataCommitHandlerRegistrationImpl(path, commitHandler, this);
         commitHandlers.put(path, registration)
+        LOG.info("Registering Commit Handler {} for path: {}",commitHandler,path);
+        for(listener : commitHandlerRegistrationListeners) {
+            try {
+                listener.instance.onRegister(registration);
+            } catch (Exception e) {
+                LOG.error("Unexpected exception in listener {} during invoking onRegister",listener.instance,e);
+            }
+        }
         return registration;
     }
 
@@ -87,13 +101,29 @@ DataProvisionService<P, D> {
 
         return new CompositeObjectRegistration(reader, Arrays.asList(confReg, dataReg));
     }
+    
+    override registerCommitHandlerListener(RegistrationListener<DataCommitHandlerRegistration<P, D>> commitHandlerListener) {
+        val ret = commitHandlerRegistrationListeners.register(commitHandlerListener);
+        
+        return ret;
+    }
+    
 
     protected final def removeListener(DataChangeListenerRegistration<P, D, DCL> registration) {
         listeners.remove(registration.path, registration);
     }
 
-    protected final def removeCommitHandler(DataCommitHandlerRegistration<P, D> registration) {
+    protected final def removeCommitHandler(DataCommitHandlerRegistrationImpl<P, D> registration) {
         commitHandlers.remove(registration.path, registration);
+        
+         LOG.info("Removing Commit Handler {} for path: {}",registration.instance,registration.path);
+        for(listener : commitHandlerRegistrationListeners) {
+            try {
+                listener.instance.onUnregister(registration);
+            } catch (Exception e) {
+                LOG.error("Unexpected exception in listener {} during invoking onUnregister",listener.instance,e);
+            }
+        }
     }
 
     protected final def getActiveCommitHandlers() {
@@ -132,7 +162,7 @@ DataProvisionService<P, D> {
 }
 
 @Data
-package class ListenerStateCapture<P extends Path<P>, D,DCL extends DataChangeListener<P, D>> {
+package class ListenerStateCapture<P extends Path<P>, D, DCL extends DataChangeListener<P, D>> {
 
     @Property
     P path;
@@ -167,7 +197,9 @@ package class DataChangeListenerRegistration<P extends Path<P>, D, DCL extends D
 
 }
 
-package class DataCommitHandlerRegistration<P extends Path<P>, D> extends AbstractObjectRegistration<DataCommitHandler<P, D>> {
+package class DataCommitHandlerRegistrationImpl<P extends Path<P>, D> //
+extends AbstractObjectRegistration<DataCommitHandler<P, D>> //
+implements DataCommitHandlerRegistration<P, D> {
 
     AbstractDataBroker<P, D, ?> dataBroker;
 
@@ -184,10 +216,9 @@ package class DataCommitHandlerRegistration<P extends Path<P>, D> extends Abstra
         dataBroker.removeCommitHandler(this);
         dataBroker = null;
     }
-
 }
 
-package class TwoPhaseCommit<P extends Path<P>, D,DCL extends DataChangeListener<P, D>> implements Callable<RpcResult<TransactionStatus>> {
+package class TwoPhaseCommit<P extends Path<P>, D, DCL extends DataChangeListener<P, D>> implements Callable<RpcResult<TransactionStatus>> {
 
     private static val log = LoggerFactory.getLogger(TwoPhaseCommit);
 
@@ -214,15 +245,18 @@ package class TwoPhaseCommit<P extends Path<P>, D,DCL extends DataChangeListener
 
         val listeners = dataBroker.affectedListenersWithInitialState(affectedPaths);
 
+        val transactionId = transaction.identifier;
+
+        log.info("Transaction: {} Started.",transactionId);
         // requesting commits
-        val Iterable<DataCommitHandler<P, D>> commitHandlers =   dataBroker.affectedCommitHandlers(affectedPaths);
+        val Iterable<DataCommitHandler<P, D>> commitHandlers = dataBroker.affectedCommitHandlers(affectedPaths);
         val List<DataCommitTransaction<P, D>> handlerTransactions = new ArrayList();
         try {
             for (handler : commitHandlers) {
                 handlerTransactions.add(handler.requestCommit(transaction));
             }
         } catch (Exception e) {
-            log.error("Request Commit failded", e);
+            log.error("Transaction: {} Request Commit failed", transactionId,e);
             return rollback(handlerTransactions, e);
         }
         val List<RpcResult<Void>> results = new ArrayList();
@@ -232,25 +266,25 @@ package class TwoPhaseCommit<P extends Path<P>, D,DCL extends DataChangeListener
             }
             listeners.publishDataChangeEvent();
         } catch (Exception e) {
-            log.error("Finish Commit failed", e);
+            log.error("Transaction: {} Finish Commit failed",transactionId, e);
             return rollback(handlerTransactions, e);
         }
-
-        
+        log.info("Transaction: {} Finished succesfully.",transactionId);
         return Rpcs.getRpcResult(true, TransactionStatus.COMMITED, Collections.emptySet());
 
     }
-    
-    def void publishDataChangeEvent(ImmutableList<ListenerStateCapture<P, D,DCL>> listeners) {
-        for(listenerSet : listeners) {
+
+    def void publishDataChangeEvent(ImmutableList<ListenerStateCapture<P, D, DCL>> listeners) {
+        for (listenerSet : listeners) {
             val updatedConfiguration = dataBroker.readConfigurationData(listenerSet.path);
             val updatedOperational = dataBroker.readOperationalData(listenerSet.path);
-            
-            val changeEvent = new DataChangeEventImpl(transaction,listenerSet.initialConfigurationState,listenerSet.initialOperationalState,updatedOperational,updatedConfiguration);
-            for(listener : listenerSet.listeners) {
+
+            val changeEvent = new DataChangeEventImpl(transaction, listenerSet.initialConfigurationState,
+                listenerSet.initialOperationalState, updatedOperational, updatedConfiguration);
+            for (listener : listenerSet.listeners) {
                 try {
                     listener.instance.onDataChanged(changeEvent);
-                    
+
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
@@ -267,6 +301,7 @@ package class TwoPhaseCommit<P extends Path<P>, D,DCL extends DataChangeListener
         return Rpcs.getRpcResult(false, TransactionStatus.FAILED, Collections.emptySet());
     }
 }
+
 public abstract class AbstractDataTransaction<P extends Path<P>, D> extends AbstractDataModification<P, D> {
 
     @Property
@@ -276,9 +311,9 @@ public abstract class AbstractDataTransaction<P extends Path<P>, D> extends Abst
 
     var AbstractDataBroker<P, D, ?> broker;
 
-    protected new(AbstractDataBroker<P, D, ?> dataBroker) {
+    protected new(Object identifier,AbstractDataBroker<P, D, ?> dataBroker) {
         super(dataBroker);
-        _identifier = new Object();
+        _identifier = identifier;
         broker = dataBroker;
         status = TransactionStatus.NEW;
 
index ca923f6..e52a7c3 100644 (file)
@@ -8,11 +8,73 @@
     </parent>
     <artifactId>sal-core-api</artifactId>
     <scm>
-      <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-      <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-      <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
     </scm>
-
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5.9-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>
+                                            urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+                                        </namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>yang-jmx-generator-plugin</artifactId>
+                        <version>0.2.3-SNAPSHOT</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/config</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
     <dependencies>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+            <version>0.2.3-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-api</artifactId>
-            <version>0.5.9-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataStore.java
new file mode 100644 (file)
index 0000000..1062f5e
--- /dev/null
@@ -0,0 +1,12 @@
+package org.opendaylight.controller.sal.core.api.data;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public interface DataStore extends //
+    DataReader<InstanceIdentifier, CompositeNode>,
+    DataCommitHandler<InstanceIdentifier, CompositeNode> {
+
+}
diff --git a/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang b/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-common.yang
new file mode 100644 (file)
index 0000000..004574d
--- /dev/null
@@ -0,0 +1,68 @@
+module opendaylight-md-sal-common {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:common";
+    prefix "md-sal-common";
+    
+    description
+        "Common definition for MD-SAL.";
+    revision "2013-10-28" {
+        description
+            "Initial revision";
+    }
+    
+    grouping rpc-routing-table {
+        
+        leaf routing-context {
+            type string;
+        }
+        list routes {
+            leaf path {
+                type string;
+            }
+            leaf destination {
+                type string;
+            }
+        }
+    
+    }
+
+    grouping rpc-router {
+        leaf module {
+            type string;
+        }
+        container routing-tables {
+            list routing-table {
+                uses rpc-routing-table;
+            }
+        }
+    }
+    
+    grouping rpc-state {
+        list rpc-router {
+            uses rpc-router;
+        }
+    }
+    
+    grouping notification-state {
+        container notifications {
+            leaf published {
+                type uint32;
+            }
+        }
+    }
+    
+    grouping data-state {
+        container transactions {
+            leaf created {
+                type uint32;
+            }
+            leaf successful {
+                type uint32;
+            }
+            leaf failed {
+                type uint32;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang b/opendaylight/md-sal/sal-dom-api/src/main/yang/opendaylight-md-sal-dom.yang
new file mode 100644 (file)
index 0000000..b0417eb
--- /dev/null
@@ -0,0 +1,35 @@
+module opendaylight-md-sal-dom {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom";
+    prefix "md-sal-dom";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    description
+        "Service definition for Binding Aware MD-SAL.";
+    revision "2013-10-28" {
+        description
+            "Initial revision";
+    }
+
+    identity dom-broker-osgi-registry {
+        base "config:service-type";
+        config:java-class "org.opendaylight.controller.sal.core.api.Broker";
+    }
+
+    identity dom-data-broker {
+        base "config:service-type";
+        config:java-class "org.opendaylight.controller.sal.core.api.data.DataProviderService";
+    }
+
+    identity dom-data-store {
+        base "config:service-type";
+        config:java-class "org.opendaylight.controller.sal.core.api.data.DataStore";
+    }
+    
+    identity schema-service {
+        base "config:service-type";
+        config:java-class "org.opendaylight.controller.sal.core.api.model.SchemaService";
+    }
+}
\ No newline at end of file
index 62dbe16..14ab057 100644 (file)
 
     <build>
         <plugins>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5.9-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>
+                                            urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+                                        </namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>yang-jmx-generator-plugin</artifactId>
+                        <version>0.2.3-SNAPSHOT</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            
+            
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
                         <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
-                        <Bundle-Activator>org.opendaylight.controller.sal.dom.broker.BrokerActivator</Bundle-Activator>
                         <Private-Package>
-                            org.opendaylight.controller.sal.dom.broker.*
+                            org.opendaylight.controller.sal.dom.broker.*,
+                            org.opendaylight.controller.config.yang.md.sal.dom.impl
                         </Private-Package>
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.8</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>add-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${project.build.directory}/generated-sources/config</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <groupId>org.eclipse.xtend</groupId>
                 <artifactId>xtend-maven-plugin</artifactId>
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java
new file mode 100644 (file)
index 0000000..9a4fc6d
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-dom-broker-impl  yang module local name: dom-broker-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 20 17:04:41 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.core.api.data.DataStore;
+import org.opendaylight.controller.sal.dom.broker.BrokerConfigActivator;
+import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public final class DomBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomBrokerImplModule
+{
+
+    private BundleContext bundleContext;
+
+    public DomBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public DomBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, DomBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        BrokerImpl broker = new BrokerImpl();
+        BrokerConfigActivator activator = new BrokerConfigActivator();
+        DataStore store = getDataStoreDependency();
+        activator.start(broker, store,getBundleContext());
+        return broker;
+    }
+
+    private BundleContext getBundleContext() {
+        return this.bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModuleFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..8e9e9f6
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: opendaylight-sal-dom-broker-impl  yang module local name: dom-broker-impl
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:04:41 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.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public class DomBrokerImplModuleFactory extends
+        org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomBrokerImplModuleFactory {
+
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+        DomBrokerImplModule module = (DomBrokerImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
+        DomBrokerImplModule module = (DomBrokerImplModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/HashMapDataStoreModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/HashMapDataStoreModule.java
new file mode 100644 (file)
index 0000000..4bcbb08
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-dom-broker-impl  yang module local name: hash-map-data-store
+* 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.impl.HashMapDataStore;
+
+/**
+*
+*/
+public final class HashMapDataStoreModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractHashMapDataStoreModule
+{
+
+    public HashMapDataStoreModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public HashMapDataStoreModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, HashMapDataStoreModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        HashMapDataStore store = new HashMapDataStore();
+        return store;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/HashMapDataStoreModuleFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/HashMapDataStoreModuleFactory.java
new file mode 100644 (file)
index 0000000..b9b6816
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+* Generated file
+
+* Generated from: yang module name: opendaylight-sal-dom-broker-impl  yang module local name: hash-map-data-store
+* 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;
+
+/**
+*
+*/
+public class HashMapDataStoreModuleFactory extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractHashMapDataStoreModuleFactory
+{
+
+
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java
new file mode 100644 (file)
index 0000000..6b597de
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+* 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
+*/
+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.osgi.framework.BundleContext;
+
+/**
+*
+*/
+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) {
+        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) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+    
+    @Override
+    public boolean canReuseInstance(AbstractSchemaServiceImplSingletonModule oldModule) {
+        return true;
+    }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        SchemaServiceImpl newInstance = new SchemaServiceImpl();
+        newInstance.setContext(getBundleContext());
+        newInstance.setParser(new YangParserImpl());
+        newInstance.start();
+        return newInstance;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModuleFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModuleFactory.java
new file mode 100644 (file)
index 0000000..4b73656
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * 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
+ */
+package org.opendaylight.controller.config.yang.md.sal.dom.impl;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DependencyResolverFactory;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public class SchemaServiceImplSingletonModuleFactory extends
+        org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModuleFactory {
+
+    private static final ModuleIdentifier IDENTIFIER = new ModuleIdentifier(NAME, "yang-schema-service");
+    public static SchemaServiceImplSingletonModule SINGLETON;
+
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+        throw new UnsupportedOperationException("Only default instance supported.");
+    }
+
+    @Override
+    public Set<SchemaServiceImplSingletonModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
+            BundleContext bundleContext) {
+        DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(IDENTIFIER);
+
+        if (SINGLETON == null) {
+            SINGLETON = new SchemaServiceImplSingletonModule(IDENTIFIER, dependencyResolver);
+            SINGLETON.setBundleContext(bundleContext);
+        }
+        return Collections.singleton(SINGLETON);
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerActivator.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerActivator.java
deleted file mode 100644 (file)
index 3af645a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.opendaylight.controller.sal.dom.broker;
-
-import java.util.Hashtable;
-
-import org.opendaylight.controller.sal.core.api.Broker;
-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.model.SchemaService;
-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.HashMapDataStore;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class BrokerActivator implements BundleActivator {
-
-    private static final InstanceIdentifier ROOT = InstanceIdentifier.builder().toInstance();
-    BrokerImpl broker;
-    private ServiceRegistration<Broker> brokerReg;
-    private ServiceRegistration<SchemaService> schemaReg;
-    private ServiceRegistration<DataBrokerService> dataReg;
-    private ServiceRegistration<DataProviderService> dataProviderReg;
-    private SchemaServiceImpl schemaService;
-    private DataBrokerImpl dataService;
-    private MountPointManagerImpl mountService;
-    private ServiceRegistration<MountService> mountReg;
-    private ServiceRegistration<MountProvisionService> mountProviderReg;
-    private HashMapDataStore hashMapStore;
-
-    @Override
-    public void start(BundleContext context) throws Exception {
-        Hashtable<String, String> emptyProperties = new Hashtable<String, String>();
-        broker = new BrokerImpl();
-        broker.setBundleContext(context);
-        
-
-        schemaService = new SchemaServiceImpl();
-        schemaService.setContext(context);
-        schemaService.setParser(new YangParserImpl());
-        schemaService.start();
-        schemaReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String, String>());
-        
-        dataService = new DataBrokerImpl();
-        dataService.setExecutor(broker.getExecutor());
-        
-        dataReg = context.registerService(DataBrokerService.class, dataService, emptyProperties);
-        dataProviderReg = context.registerService(DataProviderService.class, dataService, emptyProperties);
-        
-        hashMapStore = new HashMapDataStore();
-        
-        dataService.registerConfigurationReader(ROOT, hashMapStore);
-        dataService.registerCommitHandler(ROOT, hashMapStore);
-        dataService.registerOperationalReader(ROOT, hashMapStore);
-        
-        mountService = new MountPointManagerImpl();
-        mountService.setDataBroker(dataService);
-        
-        mountReg = context.registerService(MountService.class, mountService, emptyProperties);
-        mountProviderReg =  context.registerService(MountProvisionService.class, mountService, emptyProperties);
-        
-        brokerReg = context.registerService(Broker.class, broker, emptyProperties);
-    }
-
-    @Override
-    public void stop(BundleContext context) throws Exception {
-        if (brokerReg != null) {
-            brokerReg.unregister();
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend
new file mode 100644 (file)
index 0000000..a6aa0ce
--- /dev/null
@@ -0,0 +1,67 @@
+package org.opendaylight.controller.sal.dom.broker
+
+import org.osgi.framework.ServiceRegistration
+import org.opendaylight.controller.sal.core.api.model.SchemaService
+import org.opendaylight.controller.sal.core.api.data.DataBrokerService
+import org.opendaylight.controller.sal.core.api.data.DataProviderService
+import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
+import org.opendaylight.controller.sal.core.api.mount.MountService
+import org.osgi.framework.BundleContext
+import java.util.Hashtable
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+import org.opendaylight.controller.sal.core.api.data.DataStore
+
+class BrokerConfigActivator implements AutoCloseable {
+    
+    
+    private static val ROOT = InstanceIdentifier.builder().toInstance();
+    
+    private var ServiceRegistration<SchemaService> schemaReg;
+    private var ServiceRegistration<DataBrokerService> dataReg;
+    private var ServiceRegistration<DataProviderService> dataProviderReg;
+    private var ServiceRegistration<MountService> mountReg;
+    private var ServiceRegistration<MountProvisionService> mountProviderReg;
+    
+    private var SchemaServiceImpl schemaService;
+    private var DataBrokerImpl dataService;
+    private var MountPointManagerImpl mountService;
+
+    public def void start(BrokerImpl broker,DataStore store,BundleContext context) {
+        val emptyProperties = new Hashtable<String, String>();
+        broker.setBundleContext(context);
+        
+
+        schemaService = new SchemaServiceImpl();
+        schemaService.setContext(context);
+        schemaService.setParser(new YangParserImpl());
+        schemaService.start();
+        schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
+        
+        dataService = new DataBrokerImpl();
+        dataService.setExecutor(broker.getExecutor());
+        
+        dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
+        dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
+
+        dataService.registerConfigurationReader(ROOT, store);
+        dataService.registerCommitHandler(ROOT, store);
+        dataService.registerOperationalReader(ROOT, store);
+        
+        mountService = new MountPointManagerImpl();
+        mountService.setDataBroker(dataService);
+        
+        mountReg = context.registerService(MountService, mountService, emptyProperties);
+        mountProviderReg =  context.registerService(MountProvisionService, mountService, emptyProperties);
+    }
+
+    override def close() {
+        schemaReg?.unregister();
+        dataReg?.unregister();
+        dataProviderReg?.unregister();
+        mountReg?.unregister();
+        mountProviderReg?.unregister();
+    }
+    
+}
\ No newline at end of file