BUG-620: replace xtend version of classes with Java versions 71/7271/5
authorRobert Varga <rovarga@cisco.com>
Tue, 20 May 2014 23:08:23 +0000 (16:08 -0700)
committerRobert Varga <rovarga@cisco.com>
Tue, 27 May 2014 18:16:33 +0000 (20:16 +0200)
replace xtend versions of classes with java versions where the java was
generated by hand based on the source of the xtend file as well as leveraging
the code generated from the xtend source

Change-Id: I36a3a61608710543f66c36f7d5179cf976257953
Signed-off-by: David K. Bainbridge <dbainbri.ciena@gmail.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
21 files changed:
opendaylight/md-sal/sal-dom-broker/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/RpcRegistrationWrapper.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.xtend [deleted file]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.xtend [deleted file]

index 162b66bda18c6bb6252c73d5046997ba750f2996..f73ee5c285100511562c810a7d5897923e867b68 100644 (file)
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
     </dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.eclipse.xtend</groupId>
-      <artifactId>org.eclipse.xtend.lib</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
           </instructions>
         </configuration>
       </plugin>
           </instructions>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.eclipse.xtend</groupId>
-        <artifactId>xtend-maven-plugin</artifactId>
-      </plugin>
       <!-- TODO - unite yang-maven-plugin configuration in md-sal-->
       <plugin>
         <groupId>org.opendaylight.yangtools</groupId>
       <!-- TODO - unite yang-maven-plugin configuration in md-sal-->
       <plugin>
         <groupId>org.opendaylight.yangtools</groupId>
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.java
new file mode 100644 (file)
index 0000000..7f83435
--- /dev/null
@@ -0,0 +1,134 @@
+/**
+ * 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.sal.dom.broker;
+
+import java.util.Hashtable;
+
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker;
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
+import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.controller.sal.core.api.mount.MountService;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class BrokerConfigActivator implements AutoCloseable {
+
+    private static InstanceIdentifier ROOT = InstanceIdentifier.builder()
+            .toInstance();
+
+    private DataProviderService dataService;
+
+    private ServiceRegistration<DataBrokerService> dataReg = null;
+    private ServiceRegistration<DataProviderService> dataProviderReg = null;
+    private ServiceRegistration<MountService> mountReg = null;
+    private ServiceRegistration<MountProvisionService> mountProviderReg = null;
+    private SchemaService schemaService = null;
+    private ServiceRegistration<RpcProvisionRegistry> rpcProvisionRegistryReg = null;
+    private MountPointManagerImpl mountService = null;
+
+    private SchemaAwareDataStoreAdapter wrappedStore = null;
+
+    public void start(final BrokerImpl broker, final DataStore store,
+            final DOMDataBroker asyncBroker, final BundleContext context) {
+
+        final Hashtable<String, String> emptyProperties = new Hashtable<String, String>();
+        broker.setBundleContext(context);
+
+        final ServiceReference<SchemaService> serviceRef = context
+                .getServiceReference(SchemaService.class);
+        schemaService = context.<SchemaService> getService(serviceRef);
+
+        broker.setRouter(new SchemaAwareRpcBroker("/", SchemaContextProviders
+                .fromSchemaService(schemaService)));
+
+        if (asyncBroker == null) {
+            dataService = new DataBrokerImpl();
+            dataProviderReg = context.registerService(
+                    DataProviderService.class, dataService, emptyProperties);
+
+            wrappedStore = new SchemaAwareDataStoreAdapter();
+            wrappedStore.changeDelegate(store);
+            wrappedStore.setValidationEnabled(false);
+            context.registerService(SchemaServiceListener.class, wrappedStore,
+                    emptyProperties);
+
+            dataService.registerConfigurationReader(ROOT, wrappedStore);
+            dataService.registerCommitHandler(ROOT, wrappedStore);
+            dataService.registerOperationalReader(ROOT, wrappedStore);
+        } else {
+            BackwardsCompatibleDataBroker compatibleDataBroker = new BackwardsCompatibleDataBroker(
+                    asyncBroker);
+            context.registerService(SchemaServiceListener.class,
+                    compatibleDataBroker, emptyProperties);
+            dataService = compatibleDataBroker;
+        }
+
+        mountService = new MountPointManagerImpl();
+        dataReg = context.registerService(DataBrokerService.class, dataService,
+                emptyProperties);
+        mountReg = context.registerService(MountService.class, mountService,
+                emptyProperties);
+        mountProviderReg = context.registerService(MountProvisionService.class,
+                mountService, emptyProperties);
+
+        rpcProvisionRegistryReg = context
+                .registerService(RpcProvisionRegistry.class,
+                        broker.getRouter(), emptyProperties);
+    }
+
+    @Override
+    public void close() {
+
+        if (dataReg != null) {
+            dataReg.unregister();
+            dataReg = null;
+        }
+        if (dataProviderReg != null) {
+            dataProviderReg.unregister();
+            dataProviderReg = null;
+        }
+        if (mountReg != null) {
+            mountReg.unregister();
+            mountReg = null;
+        }
+        if (mountProviderReg != null) {
+            mountProviderReg.unregister();
+            mountProviderReg = null;
+        }
+        if (rpcProvisionRegistryReg != null) {
+            rpcProvisionRegistryReg.unregister();
+            rpcProvisionRegistryReg = null;
+        }
+    }
+
+    /**
+     * @return the dataService
+     */
+    public DataProviderService getDataService() {
+        return dataService;
+    }
+
+    /**
+     * @param dataService
+     *            the dataService to set
+     */
+    public void setDataService(final DataProviderService dataService) {
+        this.dataService = dataService;
+    }
+}
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
deleted file mode 100644 (file)
index 357a516..0000000
+++ /dev/null
@@ -1,92 +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.sal.dom.broker
-
-import java.util.Hashtable
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
-import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService
-import org.opendaylight.controller.sal.core.api.data.DataProviderService
-import org.opendaylight.controller.sal.core.api.data.DataStore
-import org.opendaylight.controller.sal.core.api.model.SchemaService
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
-import org.opendaylight.controller.sal.core.api.mount.MountService
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener
-import org.osgi.framework.BundleContext
-import org.osgi.framework.ServiceRegistration
-
-class BrokerConfigActivator implements AutoCloseable {
-
-    private static val ROOT = InstanceIdentifier.builder().toInstance();
-
-    @Property
-    private var DataProviderService dataService;
-
-    private var ServiceRegistration<DataBrokerService> dataReg;
-    private var ServiceRegistration<DataProviderService> dataProviderReg;
-    private var ServiceRegistration<MountService> mountReg;
-    private var ServiceRegistration<MountProvisionService> mountProviderReg;
-    private var SchemaService schemaService;
-    private var ServiceRegistration<RpcProvisionRegistry> rpcProvisionRegistryReg;
-    private var MountPointManagerImpl mountService;
-
-    SchemaAwareDataStoreAdapter wrappedStore
-
-    public def void start(BrokerImpl broker, DataStore store, DOMDataBroker asyncBroker,BundleContext context) {
-        val emptyProperties = new Hashtable<String, String>();
-        broker.setBundleContext(context);
-
-        val serviceRef = context.getServiceReference(SchemaService);
-        schemaService = context.getService(serviceRef);
-
-        broker.setRouter(new SchemaAwareRpcBroker("/", SchemaContextProviders.fromSchemaService(schemaService)));
-        
-
-        if(asyncBroker == null) {
-            dataService = new DataBrokerImpl();
-            dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
-    
-            wrappedStore = new SchemaAwareDataStoreAdapter();
-            wrappedStore.changeDelegate(store);
-            wrappedStore.setValidationEnabled(false);
-            context.registerService(SchemaServiceListener, wrappedStore, emptyProperties)
-            
-            dataService.registerConfigurationReader(ROOT, wrappedStore);
-            dataService.registerCommitHandler(ROOT, wrappedStore);
-            dataService.registerOperationalReader(ROOT, wrappedStore);
-        } else {
-            val compatibleDataBroker = new BackwardsCompatibleDataBroker(asyncBroker);
-            context.registerService(SchemaServiceListener,compatibleDataBroker,emptyProperties);
-            dataService = compatibleDataBroker;
-        }
-        
-
-//        
-
-        mountService = new MountPointManagerImpl();
-        dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
-            mountReg = context.registerService(MountService, mountService, emptyProperties);
-        mountProviderReg = context.registerService(MountProvisionService, mountService, emptyProperties);
-
-        rpcProvisionRegistryReg = context.registerService(RpcProvisionRegistry, broker.getRouter(), emptyProperties);
-    }
-
-    override def close() {
-        dataReg?.unregister();
-        dataProviderReg?.unregister();
-        mountReg?.unregister();
-        mountProviderReg?.unregister();
-        rpcProvisionRegistryReg?.unregister();
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java
new file mode 100644 (file)
index 0000000..e4bd034
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * 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.sal.dom.broker;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListenableFuture;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.Consumer;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter;
+import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.controller.sal.core.api.RpcRoutingContext;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation;
+
+public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable {
+    private final static Logger log = LoggerFactory.getLogger(BrokerImpl.class);
+
+    // Broker Generic Context
+    private final Set<ConsumerContextImpl> sessions = Collections
+            .synchronizedSet(new HashSet<ConsumerContextImpl>());
+    private final Set<ProviderContextImpl> providerSessions = Collections
+            .synchronizedSet(new HashSet<ProviderContextImpl>());
+
+    private BundleContext bundleContext = null;
+
+    private AutoCloseable deactivator = null;
+
+    private RpcRouter router = null;
+
+    @Override
+    public ConsumerSession registerConsumer(final Consumer consumer,
+            final BundleContext ctx) {
+        checkPredicates(consumer);
+        log.trace("Registering consumer {}", consumer);
+        final ConsumerContextImpl session = newSessionFor(consumer, ctx);
+        consumer.onSessionInitiated(session);
+        sessions.add(session);
+        return session;
+    }
+
+    @Override
+    public ProviderSession registerProvider(final Provider provider,
+            final BundleContext ctx) {
+        checkPredicates(provider);
+        final ProviderContextImpl session = newSessionFor(provider, ctx);
+        provider.onSessionInitiated(session);
+        providerSessions.add(session);
+        return session;
+    }
+
+    protected Future<RpcResult<CompositeNode>> invokeRpcAsync(final QName rpc,
+            final CompositeNode input) {
+        return router.invokeRpc(rpc, input);
+    }
+
+    // Validation
+    private void checkPredicates(final Provider prov) {
+        Preconditions.checkNotNull(prov, "Provider should not be null.");
+        for (ProviderContextImpl session : providerSessions) {
+            if (prov.equals(session.getProvider()))
+                throw new IllegalStateException("Provider already registered");
+        }
+
+    }
+
+    private void checkPredicates(final Consumer cons) {
+        Preconditions.checkNotNull(cons, "Consumer should not be null.");
+        for (ConsumerContextImpl session : sessions) {
+            if (cons.equals(session.getConsumer()))
+                throw new IllegalStateException("Consumer already registered");
+        }
+    }
+
+    // Private Factory methods
+    private ConsumerContextImpl newSessionFor(final Consumer provider,
+            final BundleContext ctx) {
+        ConsumerContextImpl ret = new ConsumerContextImpl(provider, ctx);
+        ret.setBroker(this);
+        return ret;
+    }
+
+    private ProviderContextImpl newSessionFor(final Provider provider,
+            final BundleContext ctx) {
+        ProviderContextImpl ret = new ProviderContextImpl(provider, ctx);
+        ret.setBroker(this);
+        return ret;
+    }
+
+    protected void consumerSessionClosed(
+            final ConsumerContextImpl consumerContextImpl) {
+        sessions.remove(consumerContextImpl);
+        providerSessions.remove(consumerContextImpl);
+    }
+
+    @Override
+    public void close() throws Exception {
+        if (deactivator != null) {
+            deactivator.close();
+            deactivator = null;
+        }
+    }
+
+    @Override
+    public RpcRegistration addRpcImplementation(final QName rpcType,
+            final RpcImplementation implementation)
+            throws IllegalArgumentException {
+        return router.addRpcImplementation(rpcType, implementation);
+    }
+
+    @Override
+    public RoutedRpcRegistration addRoutedRpcImplementation(
+            final QName rpcType, final RpcImplementation implementation) {
+        return router.addRoutedRpcImplementation(rpcType, implementation);
+    }
+
+    @Override
+    public void setRoutedRpcDefaultDelegate(
+            final RoutedRpcDefaultImplementation defaultImplementation) {
+        router.setRoutedRpcDefaultDelegate(defaultImplementation);
+    }
+
+    @Override
+    public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(
+            final RpcRegistrationListener listener) {
+        return router.addRpcRegistrationListener(listener);
+    }
+
+    @Override
+    public <L extends RouteChangeListener<RpcRoutingContext, InstanceIdentifier>> ListenerRegistration<L> registerRouteChangeListener(
+            final L listener) {
+        return router.registerRouteChangeListener(listener);
+    }
+
+    @Override
+    public Set<QName> getSupportedRpcs() {
+        return router.getSupportedRpcs();
+    }
+
+    @Override
+    public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(
+            final QName rpc, final CompositeNode input) {
+        return router.invokeRpc(rpc, input);
+    }
+
+    /**
+     * @return the bundleContext
+     */
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    /**
+     * @param bundleContext
+     *            the bundleContext to set
+     */
+    public void setBundleContext(final BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    /**
+     * @return the deactivator
+     */
+    public AutoCloseable getDeactivator() {
+        return deactivator;
+    }
+
+    /**
+     * @param deactivator
+     *            the deactivator to set
+     */
+    public void setDeactivator(final AutoCloseable deactivator) {
+        this.deactivator = deactivator;
+    }
+
+    /**
+     * @return the router
+     */
+    public RpcRouter getRouter() {
+        return router;
+    }
+
+    /**
+     * @param router
+     *            the router to set
+     */
+    public void setRouter(final RpcRouter router) {
+        this.router = router;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend
deleted file mode 100644 (file)
index 0ed14c1..0000000
+++ /dev/null
@@ -1,140 +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.sal.dom.broker;
-
-import com.google.common.util.concurrent.ListenableFuture
-import java.util.Collections
-import java.util.HashSet
-import java.util.Set
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener
-import org.opendaylight.controller.sal.core.api.Broker
-import org.opendaylight.controller.sal.core.api.Consumer
-import org.opendaylight.controller.sal.core.api.Provider
-import org.opendaylight.yangtools.yang.common.QName
-import org.opendaylight.yangtools.yang.common.RpcResult
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.osgi.framework.BundleContext
-import org.slf4j.LoggerFactory
-import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
-import org.opendaylight.controller.sal.core.api.RpcImplementation
-import org.opendaylight.controller.sal.core.api.RpcRoutingContext
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation
-
-public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable {
-    private static val log = LoggerFactory.getLogger(BrokerImpl);
-
-    // Broker Generic Context
-    private val Set<ConsumerContextImpl> sessions = Collections.synchronizedSet(new HashSet<ConsumerContextImpl>());
-    private val Set<ProviderContextImpl> providerSessions = Collections.synchronizedSet(
-        new HashSet<ProviderContextImpl>());
-
-    @Property
-    private var BundleContext bundleContext;
-
-    @Property
-    private var AutoCloseable deactivator;
-
-    @Property
-    private var RpcRouter router;
-
-    override registerConsumer(Consumer consumer, BundleContext ctx) {
-        checkPredicates(consumer);
-        log.trace("Registering consumer " + consumer);
-        val session = newSessionFor(consumer, ctx);
-        consumer.onSessionInitiated(session);
-        sessions.add(session);
-        return session;
-    }
-
-    override registerProvider(Provider provider, BundleContext ctx) {
-        checkPredicates(provider);
-
-        val session = newSessionFor(provider, ctx);
-        provider.onSessionInitiated(session);
-        providerSessions.add(session);
-        return session;
-    }
-
-    protected def ListenableFuture<RpcResult<CompositeNode>> invokeRpcAsync(QName rpc, CompositeNode input) {
-        return router.invokeRpc(rpc, input);
-    }
-
-    // Validation
-    private def void checkPredicates(Provider prov) {
-        if (prov == null)
-            throw new IllegalArgumentException("Provider should not be null.");
-        for (ProviderContextImpl session : providerSessions) {
-            if (prov.equals(session.getProvider()))
-                throw new IllegalStateException("Provider already registered");
-        }
-
-    }
-
-    private def void checkPredicates(Consumer cons) {
-        if (cons == null)
-            throw new IllegalArgumentException("Consumer should not be null.");
-        for (ConsumerContextImpl session : sessions) {
-            if (cons.equals(session.getConsumer()))
-                throw new IllegalStateException("Consumer already registered");
-        }
-    }
-
-    // Private Factory methods
-    private def ConsumerContextImpl newSessionFor(Consumer provider, BundleContext ctx) {
-        val ret = new ConsumerContextImpl(provider, ctx);
-        ret.broker = this;
-        return ret;
-    }
-
-    private def ProviderContextImpl newSessionFor(Provider provider, BundleContext ctx) {
-        val ret = new ProviderContextImpl(provider, ctx);
-        ret.broker = this;
-        return ret;
-    }
-
-    protected def void consumerSessionClosed(ConsumerContextImpl consumerContextImpl) {
-        sessions.remove(consumerContextImpl);
-        providerSessions.remove(consumerContextImpl);
-    }
-
-    override close() throws Exception {
-        deactivator?.close();
-    }
-
-    override addRpcImplementation(QName rpcType, RpcImplementation implementation) throws IllegalArgumentException {
-        router.addRpcImplementation(rpcType,implementation);
-    }
-
-    override addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
-        router.addRoutedRpcImplementation(rpcType,implementation);
-    }
-
-    override setRoutedRpcDefaultDelegate(RoutedRpcDefaultImplementation defaultImplementation) {
-        router.setRoutedRpcDefaultDelegate(defaultImplementation);
-    }
-
-    override addRpcRegistrationListener(RpcRegistrationListener listener) {
-        return router.addRpcRegistrationListener(listener);
-    }
-
-    override <L extends RouteChangeListener<RpcRoutingContext, InstanceIdentifier>> registerRouteChangeListener(L listener) {
-        return router.registerRouteChangeListener(listener);
-    }
-
-    override getSupportedRpcs() {
-        return router.getSupportedRpcs();
-    }
-
-    override invokeRpc(QName rpc, CompositeNode input) {
-        return router.invokeRpc(rpc,input)
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java
new file mode 100644 (file)
index 0000000..fa81bc9
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker;
+
+import java.util.Collection;
+import java.util.concurrent.Future;
+
+import javax.annotation.concurrent.GuardedBy;
+
+import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession;
+import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.controller.sal.core.api.Consumer;
+import org.opendaylight.controller.sal.dom.broker.osgi.AbstractBrokerServiceProxy;
+import org.opendaylight.controller.sal.dom.broker.osgi.ProxyFactory;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.MutableClassToInstanceMap;
+
+class ConsumerContextImpl implements ConsumerSession {
+
+    private final ClassToInstanceMap<BrokerService> instantiatedServices = MutableClassToInstanceMap
+            .create();
+    private final BundleContext context;
+    private final Consumer consumer;
+
+    private BrokerImpl broker = null;
+    @GuardedBy("this")
+    private boolean closed = false;
+
+    public ConsumerContextImpl(final Consumer consumer, final BundleContext ctx) {
+        this.consumer = consumer;
+        this.context = ctx;
+    }
+
+    @Override
+    public Future<RpcResult<CompositeNode>> rpc(final QName rpc,
+            final CompositeNode input) {
+        return broker.invokeRpcAsync(rpc, input);
+    }
+
+    @Override
+    public <T extends BrokerService> T getService(final Class<T> service) {
+        final T localProxy = instantiatedServices.getInstance(service);
+        if (localProxy != null) {
+            return localProxy;
+        }
+        final ServiceReference<T> serviceRef = context
+                .getServiceReference(service);
+        if (serviceRef == null) {
+            return null;
+        }
+        final T serviceImpl = context.getService(serviceRef);
+        final T ret = ProxyFactory.createProxy(serviceRef, serviceImpl);
+        if (ret != null) {
+            instantiatedServices.putInstance(service, ret);
+        }
+        return ret;
+    }
+
+    @Override
+    public void close() {
+        synchronized (this) {
+            if (closed) {
+                return;
+            }
+            this.closed = true;
+        }
+
+        Collection<BrokerService> toStop = instantiatedServices.values();
+        for (BrokerService brokerService : toStop) {
+            if (brokerService instanceof AbstractBrokerServiceProxy<?>) {
+                ((AbstractBrokerServiceProxy<?>) brokerService).close();
+            }
+        }
+        broker.consumerSessionClosed(this);
+    }
+
+    @Override
+    public synchronized boolean isClosed() {
+        return closed;
+    }
+
+    /**
+     * @return the broker
+     */
+    public BrokerImpl getBroker() {
+        return broker;
+    }
+
+    /**
+     * @param broker
+     *            the broker to set
+     */
+    public void setBroker(final BrokerImpl broker) {
+        this.broker = broker;
+    }
+
+    /**
+     * @return the _consumer
+     */
+    public Consumer getConsumer() {
+        return consumer;
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend
deleted file mode 100644 (file)
index 813f52b..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker
-
-import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession
-import org.opendaylight.controller.sal.core.api.BrokerService
-import org.opendaylight.controller.sal.core.api.Consumer
-import org.osgi.framework.BundleContext
-import org.opendaylight.yangtools.yang.common.QName
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.opendaylight.controller.sal.dom.broker.osgi.AbstractBrokerServiceProxy
-import com.google.common.collect.ClassToInstanceMap
-import com.google.common.collect.MutableClassToInstanceMap
-import org.opendaylight.controller.sal.dom.broker.osgi.ProxyFactory
-
-class ConsumerContextImpl implements ConsumerSession {
-
-    @Property
-    private val Consumer consumer;
-
-    @Property
-    private var BrokerImpl broker;
-
-    private val ClassToInstanceMap<BrokerService> instantiatedServices = MutableClassToInstanceMap.create();
-    private boolean closed = false;
-
-    private BundleContext context;
-
-    public new(Consumer consumer, BundleContext ctx) {
-        this._consumer = consumer;
-        this.context = ctx;
-    }
-
-    override rpc(QName rpc, CompositeNode input) {
-        return broker.invokeRpcAsync(rpc, input);
-    }
-
-    override <T extends BrokerService> T getService(Class<T> service) {
-        val localProxy = instantiatedServices.getInstance(service);
-        if(localProxy != null) {
-            return localProxy;
-        }
-        val serviceRef = context.getServiceReference(service);
-        if(serviceRef == null) {
-            return null;
-        }
-        val serviceImpl = context.getService(serviceRef);
-        
-        
-        val ret = ProxyFactory.createProxy(serviceRef,serviceImpl);
-        if(ret != null) {
-            instantiatedServices.putInstance(service, ret);
-        }
-        return ret;
-    }
-
-    override close() {
-        val toStop = instantiatedServices.values();
-        this.closed = true;
-        for (BrokerService brokerService : toStop) {
-            if(brokerService instanceof AbstractBrokerServiceProxy<?>) {
-                (brokerService as AutoCloseable).close();
-            } 
-        }
-        broker.consumerSessionClosed(this);
-    }
-
-    override isClosed() {
-        return closed;
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.java
new file mode 100644 (file)
index 0000000..55a6ee7
--- /dev/null
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2014 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.sal.dom.broker;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public class MountPointManagerImpl implements MountProvisionService {
+
+    private final ListenerRegistry<MountProvisionListener> listeners =
+            ListenerRegistry.create();
+    private final ConcurrentMap<InstanceIdentifier, MountPointImpl> mounts =
+            new ConcurrentHashMap<>();
+    private DataProviderService dataBroker = null;
+
+    @Override
+    public MountProvisionInstance createMountPoint(final InstanceIdentifier path) {
+        checkState(!mounts.containsKey(path), "Mount already created");
+        final MountPointImpl mount = new MountPointImpl(path);
+        registerMountPoint(mount);
+        mounts.put(path, mount);
+        notifyMountCreated(path);
+        return mount;
+    }
+
+    public void notifyMountCreated(final InstanceIdentifier identifier) {
+        for (final ListenerRegistration<MountProvisionListener> listener : listeners
+                .getListeners()) {
+            listener.getInstance().onMountPointCreated(identifier);
+        }
+    }
+
+    public Object registerMountPoint(final MountPointImpl impl) {
+        // FIXME: Why is thie commented out? Either we need it or we don't
+        // dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
+        // dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
+        return null;
+    }
+
+    @Override
+    public MountProvisionInstance createOrGetMountPoint(
+            final InstanceIdentifier path) {
+        final MountPointImpl mount = mounts.get(path);
+        if (mount == null) {
+            return createMountPoint(path);
+        }
+        return mount;
+    }
+
+    @Override
+    public MountProvisionInstance getMountPoint(final InstanceIdentifier path) {
+        return mounts.get(path);
+    }
+
+    /**
+     * @return the dataBroker
+     */
+    public DataProviderService getDataBroker() {
+        return dataBroker;
+    }
+
+    /**
+     * @param dataBroker
+     *            the dataBroker to set
+     */
+    public void setDataBroker(final DataProviderService dataBroker) {
+        this.dataBroker = dataBroker;
+    }
+
+    @Override
+    public ListenerRegistration<MountProvisionListener> registerProvisionListener(
+            final MountProvisionListener listener) {
+        return listeners.register(listener);
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/MountPointManagerImpl.xtend
deleted file mode 100644 (file)
index 023f906..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker
-
-
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import java.util.concurrent.ConcurrentMap
-import java.util.concurrent.ConcurrentHashMap
-import static com.google.common.base.Preconditions.*;
-import org.opendaylight.controller.sal.core.api.data.DataProviderService
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener
-import org.opendaylight.yangtools.concepts.util.ListenerRegistry
-
-class MountPointManagerImpl implements MountProvisionService {
-    
-    @Property
-    DataProviderService dataBroker;
-    
-    val ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create()
-    
-    ConcurrentMap<InstanceIdentifier,MountPointImpl> mounts = new ConcurrentHashMap();
-    
-    override createMountPoint(InstanceIdentifier path) {
-        checkState(!mounts.containsKey(path),"Mount already created");
-        val mount = new MountPointImpl(path);
-        registerMountPoint(mount);
-        mounts.put(path,mount);
-        notifyMountCreated(path);
-        return mount;
-    }
-    
-    def notifyMountCreated(InstanceIdentifier identifier) {
-        for(listener : listeners) {
-            listener.instance.onMountPointCreated(identifier);
-        }
-    }
-    
-    def registerMountPoint(MountPointImpl impl) {
-        //dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
-        //dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
-    }
-    
-    override registerProvisionListener(MountProvisionListener listener) {
-        listeners.register(listener)
-    }
-    
-    
-    override createOrGetMountPoint(InstanceIdentifier path) {
-        val mount = mounts.get(path);
-        if(mount === null) {
-            return createMountPoint(path)
-        }
-        return mount;
-    }
-    
-    
-    override getMountPoint(InstanceIdentifier path) {
-        mounts.get(path);
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java
new file mode 100644 (file)
index 0000000..5e8c0e8
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.osgi.framework.BundleContext;
+
+class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession {
+    private final Set<RpcRegistrationWrapper> registrations = new HashSet<>();
+    private final Provider provider;
+
+    public ProviderContextImpl(final Provider provider, final BundleContext ctx) {
+        super(null, ctx);
+        this.provider = provider;
+    }
+
+    @Override
+    public RpcRegistrationWrapper addRpcImplementation(final QName rpcType,
+            final RpcImplementation implementation) throws IllegalArgumentException {
+        final RpcRegistration origReg = getBroker().getRouter()
+                .addRpcImplementation(rpcType, implementation);
+        final RpcRegistrationWrapper newReg = new RpcRegistrationWrapper(
+                origReg);
+        registrations.add(newReg);
+        return newReg;
+    }
+
+    protected boolean removeRpcImplementation(final RpcRegistrationWrapper implToRemove) {
+        return registrations.remove(implToRemove);
+    }
+
+    @Override
+    public void close() {
+        for (final RpcRegistrationWrapper reg : registrations) {
+            reg.close();
+        }
+    }
+
+    @Override
+    public RoutedRpcRegistration addMountedRpcImplementation(
+            final QName rpcType, final RpcImplementation implementation) {
+        throw new UnsupportedOperationException(
+                "TODO: auto-generated method stub");
+    }
+
+    @Override
+    public RoutedRpcRegistration addRoutedRpcImplementation(
+            final QName rpcType, final RpcImplementation implementation) {
+        throw new UnsupportedOperationException(
+                "TODO: auto-generated method stub");
+    }
+
+    @Override
+    public Set<QName> getSupportedRpcs() {
+        return getBroker().getRouter().getSupportedRpcs();
+    }
+
+    @Override
+    public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(
+            final RpcRegistrationListener listener) {
+        return getBroker().getRouter().addRpcRegistrationListener(listener);
+    }
+
+    /**
+     * @return the provider
+     */
+    public Provider getProvider() {
+        return provider;
+    }
+
+    /**
+     * @param provider
+     *            the provider to set
+     */
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend
deleted file mode 100644 (file)
index e641ed1..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker
-
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession
-import org.opendaylight.controller.sal.core.api.Provider
-import org.opendaylight.controller.sal.core.api.RpcImplementation
-import org.opendaylight.yangtools.yang.common.QName
-import org.osgi.framework.BundleContext
-import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener
-import org.opendaylight.yangtools.concepts.Registration
-
-import java.util.Set
-import java.util.HashSet
-
-class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession {
-
-    @Property
-    private val Provider provider;
-
-    private val Set<Registration<?>> registrations = new HashSet();
-
-    new(Provider provider, BundleContext ctx) {
-        super(null, ctx);
-        this._provider = provider;
-    }
-
-    override addRpcImplementation(QName rpcType, RpcImplementation implementation) throws IllegalArgumentException {
-        val origReg = broker.router.addRpcImplementation(rpcType, implementation);
-        val newReg = new RpcRegistrationWrapper(origReg);
-        registrations.add(newReg);
-        return newReg;
-    }
-
-    protected def removeRpcImplementation(RpcRegistrationWrapper implToRemove) throws IllegalArgumentException {
-        registrations.remove(implToRemove);
-    }
-    
-    override close() {
-        
-        for (reg : registrations) {
-            reg.close()
-        }
-        super.close
-    }
-
-    override addMountedRpcImplementation(QName rpcType, RpcImplementation implementation) {
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-    }
-
-    override addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
-        throw new UnsupportedOperationException("TODO: auto-generated method stub")
-    }
-
-    override getSupportedRpcs() {
-        broker.router.supportedRpcs;
-    }
-
-    override addRpcRegistrationListener(RpcRegistrationListener listener) {
-        broker.router.addRpcRegistrationListener(listener);
-    }
-}
-
-class RpcRegistrationWrapper implements RpcRegistration {
-
-
-    @Property
-    val RpcRegistration delegate
-
-    new(RpcRegistration delegate) {
-        _delegate = delegate
-    }
-
-    override getInstance() {
-        delegate.instance
-    }
-
-    override close() {
-        delegate.close
-    }
-
-    override getType() {
-        delegate.type
-    }
-}
-
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/RpcRegistrationWrapper.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/RpcRegistrationWrapper.java
new file mode 100644 (file)
index 0000000..db6c72e
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2014 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.sal.dom.broker;
+
+import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.yangtools.yang.common.QName;
+
+import com.google.common.base.Preconditions;
+
+public class RpcRegistrationWrapper implements RpcRegistration {
+
+    private final RpcRegistration delegate;
+
+    public RpcRegistrationWrapper(final RpcRegistration delegate) {
+        this.delegate = Preconditions.checkNotNull(delegate);
+    }
+
+    @Override
+    public RpcImplementation getInstance() {
+        return delegate.getInstance();
+    }
+
+    @Override
+    public void close() {
+        delegate.close();
+    }
+
+    @Override
+    public QName getType() {
+        return delegate.getType();
+    }
+
+    /**
+     * @return the delegate
+     */
+    public RpcRegistration getDelegate() {
+        return delegate;
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.java
new file mode 100644 (file)
index 0000000..53423f6
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker.impl;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Iterables;
+
+public class DataReaderRouter extends
+AbstractDataReadRouter<InstanceIdentifier, CompositeNode> {
+    private final static Logger LOG = LoggerFactory
+            .getLogger(DataReaderRouter.class);
+    private final static URI NETCONF_NAMESPACE = URI
+            .create("urn:ietf:params:xml:ns:netconf:base:1.0");
+    private final static QName NETCONF_DATA = new QName(NETCONF_NAMESPACE,
+            "data");
+
+    @Override
+    protected CompositeNodeTOImpl merge(final InstanceIdentifier path,
+            final Iterable<CompositeNode> data) {
+        PathArgument pathArgument = Iterables.getLast(path.getPath(), null);
+        boolean empty = true;
+        QName name = (pathArgument == null ? null : pathArgument.getNodeType());
+        final ArrayList<Node<?>> nodes = new ArrayList<Node<?>>();
+        final HashMap<QName, SimpleNode<?>> keyNodes = new HashMap<QName, SimpleNode<?>>();
+        for (final CompositeNode dataBit : data) {
+            try {
+                if (pathArgument != null && dataBit != null) {
+                    empty = false;
+                    final Map<QName, SimpleNode<?>> keyNodesLocal = getKeyNodes(
+                            pathArgument, dataBit);
+                    nodes.addAll(this.childrenWithout(dataBit,
+                            keyNodesLocal.entrySet()));
+                } else if (dataBit != null) {
+                    empty = false;
+                    nodes.addAll(dataBit.getValue());
+                }
+            } catch (IllegalStateException e) {
+                LOG.error("BUG: Readed data for path {} was invalid", path, e);
+            }
+        }
+        if (empty) {
+            return null;
+        }
+        /**
+         * Reading from Root
+         *
+         */
+        if (pathArgument == null) {
+            return new CompositeNodeTOImpl(NETCONF_DATA, null, nodes);
+        }
+        final ArrayList<Node<?>> finalNodes = new ArrayList<Node<?>>(
+                nodes.size() + keyNodes.size());
+        finalNodes.addAll(keyNodes.values());
+        finalNodes.addAll(nodes);
+        return new CompositeNodeTOImpl(name, null, finalNodes);
+    }
+
+    protected Map<QName, SimpleNode<?>> _getKeyNodes(
+            final PathArgument argument, final CompositeNode node) {
+        return Collections.emptyMap();
+    }
+
+    protected Map<QName, SimpleNode<?>> _getKeyNodes(
+            final NodeIdentifierWithPredicates argument,
+            final CompositeNode node) {
+        final HashMap<QName, SimpleNode<?>> ret = new HashMap<QName, SimpleNode<?>>();
+        for (final Entry<QName, Object> keyValue : argument.getKeyValues()
+                .entrySet()) {
+            final List<SimpleNode<?>> simpleNode = node
+                    .getSimpleNodesByName(keyValue.getKey());
+            if (simpleNode != null && !simpleNode.isEmpty()) {
+                checkState(
+                        simpleNode.size() <= 1,
+                        "Only one simple node for key $s is allowed in node $s",
+                        keyValue.getKey(), node);
+                checkState(
+                        simpleNode.get(0).getValue() == keyValue.getValue(),
+                        "Key node must equal to instance identifier value in node $s",
+                        node);
+                ret.put(keyValue.getKey(), simpleNode.get(0));
+            }
+            final List<CompositeNode> compositeNode = node
+                    .getCompositesByName(keyValue.getKey());
+            checkState(compositeNode == null || compositeNode.isEmpty(),
+                    "Key node must be Simple Node, not composite node.");
+        }
+        return ret;
+    }
+
+    public Map<QName, SimpleNode<?>> getKeyNodes(
+            final InstanceIdentifier.PathArgument argument,
+            final CompositeNode node) {
+        if (argument instanceof InstanceIdentifier.NodeIdentifierWithPredicates) {
+            return _getKeyNodes(
+                    (InstanceIdentifier.NodeIdentifierWithPredicates) argument,
+                    node);
+        } else if (argument != null) {
+            return _getKeyNodes(argument, node);
+        } else {
+            throw new IllegalArgumentException("Unhandled parameter types: "
+                    + Arrays.<Object> asList(argument, node).toString());
+        }
+    }
+
+    private Collection<? extends Node<?>> childrenWithout(
+            final CompositeNode node,
+            final Set<Entry<QName, SimpleNode<?>>> entries) {
+        if (entries.isEmpty()) {
+            return node.getValue();
+        }
+        final List<Node<?>> filteredNodes = new ArrayList<Node<?>>();
+        for (final Node<?> scannedNode : node.getValue()) {
+            if (!entries.contains(scannedNode.getNodeType())) {
+                filteredNodes.add(scannedNode);
+            }
+        }
+        return filteredNodes;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataReaderRouter.xtend
deleted file mode 100644 (file)
index 95d0018..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker.impl
-
-import java.net.URI
-import java.util.ArrayList
-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 org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter
-import org.opendaylight.yangtools.yang.common.QName
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument
-import org.opendaylight.yangtools.yang.data.api.Node
-import org.opendaylight.yangtools.yang.data.api.SimpleNode
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
-import org.slf4j.LoggerFactory
-
-import static com.google.common.base.Preconditions.*
-
-class DataReaderRouter extends AbstractDataReadRouter<InstanceIdentifier, CompositeNode> {
-    private static val LOG = LoggerFactory.getLogger(DataReaderRouter);
-    private static val NETCONF_NAMESPACE = URI.create("urn:ietf:params:xml:ns:netconf:base:1.0")
-    private static val NETCONF_DATA = new QName(NETCONF_NAMESPACE,"data");
-
-    override protected merge(InstanceIdentifier path, Iterable<CompositeNode> data) {
-        val pathArgument = path.path.last;
-        var empty = true;
-        var name = pathArgument?.nodeType;
-        val nodes = new ArrayList<Node<?>>();
-        val keyNodes = new HashMap<QName, SimpleNode<?>>();
-        for(dataBit : data) {
-            try {
-                if(pathArgument != null && dataBit != null) {
-                    empty = false;
-                    val keyNodesLocal = getKeyNodes(pathArgument,dataBit);
-                    nodes.addAll(dataBit.childrenWithout(keyNodesLocal.entrySet));
-                } else if (dataBit != null) {
-                    empty = false;
-                    nodes.addAll(dataBit.children)
-                }
-            }   catch (IllegalStateException e) {
-                LOG.error("BUG: Readed data for path {} was invalid",path,e);
-            }
-        }
-        if(empty) {
-            return null;
-        }
-        /**
-         * Reading from Root
-         * 
-         */
-        if(pathArgument == null) {
-            return new CompositeNodeTOImpl(NETCONF_DATA,null,nodes);
-        }
-        val finalNodes = new ArrayList<Node<?>>();
-        finalNodes.addAll(keyNodes.values);
-        finalNodes.addAll(nodes);
-        return new CompositeNodeTOImpl(name,null,finalNodes);
-    }
-    
-    
-    
-    dispatch def Map<QName, SimpleNode<?>> getKeyNodes(PathArgument argument, CompositeNode node) {
-        return Collections.emptyMap();
-    }
-    
-    dispatch def getKeyNodes(NodeIdentifierWithPredicates argument, CompositeNode node) {
-        val ret = new HashMap<QName, SimpleNode<?>>();
-        for (keyValue : argument.keyValues.entrySet) {
-            val simpleNode = node.getSimpleNodesByName(keyValue.key);
-            if(simpleNode !== null && !simpleNode.empty) {
-                checkState(simpleNode.size <= 1,"Only one simple node for key $s is allowed in node $s",keyValue.key,node);
-                checkState(simpleNode.get(0).value == keyValue.value,"Key node must equal to instance identifier value in node $s",node);
-                ret.put(keyValue.key,simpleNode.get(0));
-            }
-            val compositeNode = node.getCompositesByName(keyValue.key);
-            checkState(compositeNode === null || compositeNode.empty,"Key node must be Simple Node, not composite node.");
-        }
-        return ret;
-    }
-    
-    def Collection<? extends Node<?>> childrenWithout(CompositeNode node, Set<Entry<QName, SimpleNode<?>>> entries) {
-        if(entries.empty) {
-            return node.children;
-        }
-        val filteredNodes = new ArrayList<Node<?>>();
-        for(scannedNode : node.children) {
-            if(!entries.contains(scannedNode.nodeType)) {
-                filteredNodes.add(scannedNode);
-            }
-        }
-        return filteredNodes;
-    }
-    
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.java
new file mode 100644 (file)
index 0000000..50dfbe8
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+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.common.util.Rpcs;
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class HashMapDataStore implements DataStore, AutoCloseable {
+    private static final Logger LOG = LoggerFactory
+            .getLogger(HashMapDataStore.class);
+
+    private final Map<InstanceIdentifier, CompositeNode> configuration = new ConcurrentHashMap<InstanceIdentifier, CompositeNode>();
+    private final Map<InstanceIdentifier, CompositeNode> operational = new ConcurrentHashMap<InstanceIdentifier, CompositeNode>();
+
+    @Override
+    public boolean containsConfigurationPath(final InstanceIdentifier path) {
+        return configuration.containsKey(path);
+    }
+
+    @Override
+    public boolean containsOperationalPath(final InstanceIdentifier path) {
+        return operational.containsKey(path);
+    }
+
+    @Override
+    public Iterable<InstanceIdentifier> getStoredConfigurationPaths() {
+        return configuration.keySet();
+    }
+
+    @Override
+    public Iterable<InstanceIdentifier> getStoredOperationalPaths() {
+        return operational.keySet();
+    }
+
+    @Override
+    public CompositeNode readConfigurationData(final InstanceIdentifier path) {
+        LOG.trace("Reading configuration path {}", path);
+        return configuration.get(path);
+    }
+
+    @Override
+    public CompositeNode readOperationalData(InstanceIdentifier path) {
+        LOG.trace("Reading operational path {}", path);
+        return operational.get(path);
+    }
+
+    @Override
+    public DataCommitHandler.DataCommitTransaction<InstanceIdentifier, CompositeNode> requestCommit(
+            final DataModification<InstanceIdentifier, CompositeNode> modification) {
+        return new HashMapDataStoreTransaction(modification, this);
+    }
+
+    public RpcResult<Void> rollback(HashMapDataStoreTransaction transaction) {
+        return Rpcs.<Void> getRpcResult(true, null,
+                Collections.<RpcError> emptySet());
+    }
+
+    public RpcResult<Void> finish(HashMapDataStoreTransaction transaction) {
+        final DataModification<InstanceIdentifier, CompositeNode> modification = transaction
+                .getModification();
+        for (final InstanceIdentifier removal : modification
+                .getRemovedConfigurationData()) {
+            LOG.trace("Removing configuration path {}", removal);
+            remove(configuration, removal);
+        }
+        for (final InstanceIdentifier removal : modification
+                .getRemovedOperationalData()) {
+            LOG.trace("Removing operational path {}", removal);
+            remove(operational, removal);
+        }
+        if (LOG.isTraceEnabled()) {
+            for (final InstanceIdentifier a : modification
+                    .getUpdatedConfigurationData().keySet()) {
+                LOG.trace("Adding configuration path {}", a);
+            }
+            for (final InstanceIdentifier a : modification
+                    .getUpdatedOperationalData().keySet()) {
+                LOG.trace("Adding operational path {}", a);
+            }
+        }
+        configuration.putAll(modification.getUpdatedConfigurationData());
+        operational.putAll(modification.getUpdatedOperationalData());
+
+        return Rpcs.<Void> getRpcResult(true, null,
+                Collections.<RpcError> emptySet());
+    }
+
+    public void remove(final Map<InstanceIdentifier, CompositeNode> map,
+            final InstanceIdentifier identifier) {
+        Set<InstanceIdentifier> affected = new HashSet<InstanceIdentifier>();
+        for (final InstanceIdentifier path : map.keySet()) {
+            if (identifier.contains(path)) {
+                affected.add(path);
+            }
+        }
+        for (final InstanceIdentifier pathToRemove : affected) {
+            LOG.trace("Removed path {}", pathToRemove);
+            map.remove(pathToRemove);
+        }
+    }
+
+    @Override
+    public void close() {
+        // NOOP
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend
deleted file mode 100644 (file)
index 12835cc..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker.impl
-
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
-import org.opendaylight.yangtools.yang.common.RpcResult
-import java.util.Map
-import java.util.concurrent.ConcurrentHashMap
-import org.opendaylight.controller.sal.common.util.Rpcs
-import java.util.Collections
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.opendaylight.controller.sal.core.api.data.DataStore
-import java.util.HashSet
-import org.slf4j.LoggerFactory
-import org.slf4j.Logger
-
-final class HashMapDataStore implements DataStore, AutoCloseable {
-    private val Logger LOG = LoggerFactory.getLogger(HashMapDataStore)
-
-    val Map<InstanceIdentifier, CompositeNode> configuration = new ConcurrentHashMap();
-    val Map<InstanceIdentifier, CompositeNode> operational = new ConcurrentHashMap();
-    
-    
-    
-    override containsConfigurationPath(InstanceIdentifier path) {
-        return configuration.containsKey(path)
-    }
-    
-    override containsOperationalPath(InstanceIdentifier path) {
-        return operational.containsKey(path)
-    }
-    
-    override getStoredConfigurationPaths() {
-        configuration.keySet
-    }
-    
-    override getStoredOperationalPaths() {
-        operational.keySet
-    }
-
-    override readConfigurationData(InstanceIdentifier path) {
-        LOG.trace("Reading configuration path {}", path)
-        configuration.get(path);
-    }
-
-    override readOperationalData(InstanceIdentifier path) {
-        LOG.trace("Reading operational path {}", path)
-        operational.get(path);
-    }
-
-
-
-    override requestCommit(DataModification<InstanceIdentifier, CompositeNode> modification) {
-        return new HashMapDataStoreTransaction(modification, this);
-    }
-
-    def RpcResult<Void> rollback(HashMapDataStoreTransaction transaction) {
-        return Rpcs.getRpcResult(true, null, Collections.emptySet);
-    }
-
-    def RpcResult<Void> finish(HashMapDataStoreTransaction transaction) {
-        val modification = transaction.modification;
-        for (removal : modification.removedConfigurationData) {
-            LOG.trace("Removing configuration path {}", removal)
-            remove(configuration,removal);
-        }
-        for (removal : modification.removedOperationalData) {
-            LOG.trace("Removing operational path {}", removal)
-            remove(operational,removal);
-        }
-        if (LOG.isTraceEnabled()) {
-            for (a : modification.updatedConfigurationData.keySet) {
-                LOG.trace("Adding configuration path {}", a)
-            }
-            for (a : modification.updatedOperationalData.keySet) {
-                LOG.trace("Adding operational path {}", a)
-            }
-        }
-        configuration.putAll(modification.updatedConfigurationData);
-        operational.putAll(modification.updatedOperationalData);
-
-        return Rpcs.getRpcResult(true, null, Collections.emptySet);
-    }
-    
-    def remove(Map<InstanceIdentifier, CompositeNode> map, InstanceIdentifier identifier) {
-        val affected = new HashSet<InstanceIdentifier>();
-        for(path : map.keySet) {
-            if(identifier.contains(path)) {
-                affected.add(path);
-            }
-        }
-        for(pathToRemove : affected) {
-            LOG.trace("Removed path {}", pathToRemove)
-            map.remove(pathToRemove);
-        }
-        
-    }
-
-
-    override close()  {
-        // NOOP
-    }
-    
-}
-
-class HashMapDataStoreTransaction implements // 
-DataCommitTransaction<InstanceIdentifier, CompositeNode> {
-    @Property
-    val DataModification<InstanceIdentifier, CompositeNode> modification
-
-    @Property
-    val HashMapDataStore datastore;
-
-    new(
-        DataModification<InstanceIdentifier, CompositeNode> modify,
-        HashMapDataStore store
-    ) {
-        _modification = modify;
-        _datastore = store;
-    }
-
-    override finish() throws IllegalStateException {
-        datastore.finish(this);
-
-    }
-
-    override getModification() {
-        this._modification;
-    }
-
-    override rollback() throws IllegalStateException {
-        datastore.rollback(this);
-    }
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStoreTransaction.java
new file mode 100644 (file)
index 0000000..bb66594
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker.impl;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public class HashMapDataStoreTransaction implements
+        DataCommitTransaction<InstanceIdentifier, CompositeNode> {
+    private final DataModification<InstanceIdentifier, CompositeNode> modification;
+    private final HashMapDataStore datastore;
+
+    HashMapDataStoreTransaction(
+            final DataModification<InstanceIdentifier, CompositeNode> modify,
+            final HashMapDataStore store) {
+        modification = modify;
+        datastore = store;
+    }
+
+    @Override
+    public RpcResult<Void> finish() throws IllegalStateException {
+        return datastore.finish(this);
+    }
+
+    @Override
+    public DataModification<InstanceIdentifier, CompositeNode> getModification() {
+        return this.modification;
+    }
+
+    @Override
+    public RpcResult<Void> rollback() throws IllegalStateException {
+        return datastore.rollback(this);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.java
new file mode 100644 (file)
index 0000000..c2d6add
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker.osgi;
+
+import java.util.Arrays;
+
+import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.osgi.framework.ServiceReference;
+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.notify.NotificationPublishService;
+import org.opendaylight.controller.sal.core.api.notify.NotificationService;
+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.RpcProvisionRegistry;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+
+@SuppressWarnings("unchecked")
+public class ProxyFactory {
+
+    public static <T extends BrokerService> T createProxy(
+            final ServiceReference<T> serviceRef, final T service) {
+
+        Object _createProxyImpl = ProxyFactory.createProxyImpl(serviceRef,
+                service);
+        return ((T) _createProxyImpl);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final DataBrokerService service) {
+
+        return new DataBrokerServiceProxy(
+                ((ServiceReference<DataBrokerService>) ref), service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final DataProviderService service) {
+
+        return new DataProviderServiceProxy(
+                ((ServiceReference<DataProviderService>) ref), service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final NotificationPublishService service) {
+
+        return new NotificationPublishServiceProxy(
+                ((ServiceReference<NotificationPublishService>) ref), service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final NotificationService service) {
+
+        return new NotificationServiceProxy(
+                ((ServiceReference<NotificationService>) ref), service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final MountProvisionService service) {
+
+        return new MountProviderServiceProxy(
+                ((ServiceReference<MountProvisionService>) ref), service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final SchemaService service) {
+
+        return new SchemaServiceProxy(((ServiceReference<SchemaService>) ref),
+                service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> ref,
+            final RpcProvisionRegistry service) {
+
+        return new RpcProvisionRegistryProxy(
+                ((ServiceReference<RpcProvisionRegistry>) ref), service);
+    }
+
+    private static DOMDataBrokerProxy _createProxyImpl(
+            final ServiceReference<?> ref, final DOMDataBroker service) {
+
+        return new DOMDataBrokerProxy(((ServiceReference<DOMDataBroker>) ref),
+                service);
+    }
+
+    private static Object _createProxyImpl(final ServiceReference<?> reference,
+            final BrokerService service) {
+
+        throw new IllegalArgumentException("Not supported class: "
+                + service.getClass().getName());
+    }
+
+    private static Object createProxyImpl(final ServiceReference<?> ref,
+            final BrokerService service) {
+
+        if (service instanceof DOMDataBroker) {
+            return _createProxyImpl(ref, (DOMDataBroker) service);
+        } else if (service instanceof RpcProvisionRegistry) {
+            return _createProxyImpl(ref, (RpcProvisionRegistry) service);
+        } else if (service instanceof DataProviderService) {
+            return _createProxyImpl(ref, (DataProviderService) service);
+        } else if (service instanceof MountProvisionService) {
+            return _createProxyImpl(ref, (MountProvisionService) service);
+        } else if (service instanceof NotificationPublishService) {
+            return _createProxyImpl(ref, (NotificationPublishService) service);
+        } else if (service instanceof DataBrokerService) {
+            return _createProxyImpl(ref, (DataBrokerService) service);
+        } else if (service instanceof SchemaService) {
+            return _createProxyImpl(ref, (SchemaService) service);
+        } else if (service instanceof NotificationService) {
+            return _createProxyImpl(ref, (NotificationService) service);
+        } else if (service != null) {
+            return _createProxyImpl(ref, service);
+        } else {
+            throw new IllegalArgumentException("Unhandled parameter types: "
+                    + Arrays.<Object> asList(ref, service).toString());
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/ProxyFactory.xtend
deleted file mode 100644 (file)
index d0afc3f..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker.osgi
-
-import org.opendaylight.controller.sal.core.api.BrokerService
-import org.osgi.framework.ServiceReference
-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.notify.NotificationPublishService
-import org.opendaylight.controller.sal.core.api.notify.NotificationService
-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.RpcProvisionRegistry
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
-
-class ProxyFactory {
-
-    static def <T extends BrokerService> T createProxy(ServiceReference<T> serviceRef, T service) {
-        return createProxyImpl(serviceRef, service) as T;
-    }
-
-
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, DataBrokerService service) {
-        new DataBrokerServiceProxy(ref as ServiceReference<DataBrokerService>, service);
-    }
-
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, DataProviderService service) {
-        new DataProviderServiceProxy(ref as ServiceReference<DataProviderService>, service);
-    }
-    
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationPublishService service) {
-        new NotificationPublishServiceProxy(ref as ServiceReference<NotificationPublishService>, service);
-    }
-    
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, NotificationService service) {
-        new NotificationServiceProxy(ref as ServiceReference<NotificationService>, service);
-    }
-
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, MountProvisionService service) {
-        new MountProviderServiceProxy(ref as ServiceReference<MountProvisionService>, service);
-    }
-
-
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, SchemaService service) {
-        new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
-    }
-
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, RpcProvisionRegistry service) {
-        new RpcProvisionRegistryProxy(ref as ServiceReference<RpcProvisionRegistry>, service);
-    }
-    
-    private static def dispatch createProxyImpl(ServiceReference<?> ref, DOMDataBroker service) {
-        new DOMDataBrokerProxy(ref as ServiceReference<DOMDataBroker>, service)
-    }
-    
-
-    private static def dispatch createProxyImpl(ServiceReference<?> reference, BrokerService service) {
-        throw new IllegalArgumentException("Not supported class");
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.java
new file mode 100644 (file)
index 0000000..0f8ce1d
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2014 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.sal.dom.broker.util;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+
+public class YangDataOperations {
+
+    public static CompositeNode merge(final DataSchemaNode schema,
+            final CompositeNode stored, final CompositeNode modified,
+            final boolean config) {
+        if (stored == null) {
+            return modified;
+        }
+
+        Preconditions.checkArgument(schema instanceof ListSchemaNode
+                || schema instanceof ContainerSchemaNode,
+                "Supplied node is not data node container.");
+
+        return YangDataOperations.mergeContainer((DataNodeContainer) schema,
+                stored, modified, config);
+    }
+
+    private static Iterable<? extends Node<?>> _mergeMultiple(
+            final LeafSchemaNode node, final List<Node<?>> original,
+            final List<Node<?>> modified, final boolean configurational) {
+        checkArgument(original.size() == 1);
+        checkArgument(modified.size() == 1);
+
+        return modified;
+    }
+
+    private static Iterable<? extends Node<?>> _mergeMultiple(
+            final LeafListSchemaNode node, final List<Node<?>> original,
+            final List<Node<?>> modified, final boolean configurational) {
+        return modified;
+    }
+
+    private static Iterable<? extends Node<?>> _mergeMultiple(
+            final ContainerSchemaNode node, final List<Node<?>> original,
+            final List<Node<?>> modified, final boolean configurational) {
+        checkArgument(original.size() == 1);
+        checkArgument(modified.size() == 1);
+        return Collections.singletonList(merge(node,
+                (CompositeNode) original.get(0),
+                (CompositeNode) modified.get(0), configurational));
+    }
+
+    private static Iterable<? extends Node<?>> _mergeMultiple(
+            final ListSchemaNode node, final List<Node<?>> original,
+            final List<Node<?>> modified, final boolean configurational) {
+
+        if (node.getKeyDefinition() == null
+                || node.getKeyDefinition().isEmpty()) {
+            return modified;
+        }
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        final Map<Map<QName, Object>, CompositeNode> originalMap = YangDataUtils
+                .toIndexMap((List) original, node.getKeyDefinition());
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        final Map<Map<QName, Object>, CompositeNode> modifiedMap = YangDataUtils
+                .toIndexMap((List) modified, node.getKeyDefinition());
+
+        final List<Node<?>> mergedNodes = new ArrayList<Node<?>>(
+                original.size() + modified.size());
+        for (final Map.Entry<Map<QName, Object>, CompositeNode> entry : modifiedMap
+                .entrySet()) {
+            final CompositeNode originalEntry = originalMap.get(entry.getKey());
+            if (originalEntry != null) {
+                originalMap.remove(entry.getKey());
+                mergedNodes.add(merge(node, originalEntry, entry.getValue(),
+                        configurational));
+            } else {
+                mergedNodes.add(entry.getValue());
+            }
+        }
+        mergedNodes.addAll(originalMap.values());
+        return mergedNodes;
+    }
+
+    private static Iterable<? extends Node<?>> mergeMultiple(
+            final DataSchemaNode node, final List<Node<?>> original,
+            final List<Node<?>> modified, final boolean configurational) {
+        if (node instanceof ContainerSchemaNode) {
+            return _mergeMultiple((ContainerSchemaNode) node, original,
+                    modified, configurational);
+        } else if (node instanceof LeafListSchemaNode) {
+            return _mergeMultiple((LeafListSchemaNode) node, original,
+                    modified, configurational);
+        } else if (node instanceof LeafSchemaNode) {
+            return _mergeMultiple((LeafSchemaNode) node, original, modified,
+                    configurational);
+        } else if (node instanceof ListSchemaNode) {
+            return _mergeMultiple((ListSchemaNode) node, original, modified,
+                    configurational);
+        } else {
+            throw new IllegalArgumentException("Unhandled parameter types: "
+                    + Arrays.<Object> asList(node, original, modified,
+                            configurational).toString());
+        }
+    }
+
+    private static CompositeNode mergeContainer(final DataNodeContainer schema,
+            final CompositeNode stored, final CompositeNode modified,
+            final boolean config) {
+        if (stored == null) {
+            return modified;
+        }
+        Preconditions.checkNotNull(stored);
+        Preconditions.checkNotNull(modified);
+        Preconditions.checkArgument(Objects.equals(stored.getNodeType(),
+                modified.getNodeType()));
+
+        final List<Node<?>> mergedChildNodes = new ArrayList<Node<?>>(stored
+                .getChildren().size() + modified.getChildren().size());
+        final Set<QName> toProcess = new HashSet<QName>(stored.keySet());
+        toProcess.addAll(modified.keySet());
+
+        for (QName qname : toProcess) {
+            final DataSchemaNode schemaChild = schema.getDataChildByName(qname);
+            final List<Node<?>> storedChildren = stored.get(qname);
+            final List<Node<?>> modifiedChildren = modified.get(qname);
+
+            if (modifiedChildren != null && !modifiedChildren.isEmpty()) {
+                if (storedChildren == null || storedChildren.isEmpty()
+                        || schemaChild == null) {
+                    mergedChildNodes.addAll(modifiedChildren);
+                } else {
+                    final Iterable<? extends Node<?>> _mergeMultiple = mergeMultiple(
+                            schemaChild, storedChildren, modifiedChildren,
+                            config);
+                    Iterables.addAll(mergedChildNodes, _mergeMultiple);
+                }
+            } else if (storedChildren != null && !storedChildren.isEmpty()) {
+                mergedChildNodes.addAll(storedChildren);
+            }
+        }
+        return new CompositeNodeTOImpl(stored.getNodeType(), null,
+                mergedChildNodes);
+    }
+}
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.xtend
deleted file mode 100644 (file)
index d80e405..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2014 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.sal.dom.broker.util
-
-import org.opendaylight.yangtools.yang.data.api.CompositeNode
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
-import static com.google.common.base.Preconditions.*;
-import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl
-import java.util.ArrayList
-
-import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
-import org.opendaylight.yangtools.yang.data.api.Node
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
-import java.util.List
-import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode
-import java.util.Collections
-import java.util.HashSet
-import org.opendaylight.yangtools.yang.common.QName
-import static extension org.opendaylight.controller.sal.dom.broker.util.YangDataUtils.*;
-
-class YangDataOperations {
-
-    static def CompositeNode merge(DataSchemaNode schema, CompositeNode stored, CompositeNode modified, boolean config) {
-        if (stored === null) {
-            return modified;
-        }
-
-        if (schema instanceof ListSchemaNode || schema instanceof ContainerSchemaNode) {
-            return mergeContainer(schema as DataNodeContainer, stored, modified, config);
-        }
-        throw new IllegalArgumentException("Supplied node is not data node container.");
-    }
-
-    private static dispatch def Iterable<? extends Node<?>> mergeMultiple(LeafSchemaNode node, List<Node<?>> original,
-        List<Node<?>> modified, boolean configurational) {
-        checkArgument(original.size === 1);
-        checkArgument(modified.size === 1);
-        
-        return modified;
-    }
-
-    private static dispatch def Iterable<? extends Node<?>> mergeMultiple(LeafListSchemaNode node,
-        List<Node<?>> original, List<Node<?>> modified, boolean configurational) {
-        return modified;
-    }
-
-    private static dispatch def Iterable<? extends Node<?>> mergeMultiple(ContainerSchemaNode node,
-        List<Node<?>> original, List<Node<?>> modified, boolean configurational) {
-        checkArgument(original.size === 1);
-        checkArgument(modified.size === 1);
-        return Collections.singletonList(
-            merge(node, original.get(0) as CompositeNode, modified.get(0) as CompositeNode, configurational));
-    }
-
-    private static dispatch def Iterable<? extends Node<?>> mergeMultiple(ListSchemaNode node, List<Node<?>> original,
-        List<Node<?>> modified, boolean configurational) {
-        
-        if(node.keyDefinition === null || node.keyDefinition.empty) {
-            return modified;
-        }
-        val originalMap = (original as List).toIndexMap(node.keyDefinition);
-        val modifiedMap = (modified as List).toIndexMap(node.keyDefinition);
-        
-        val List<Node<?>> mergedNodes = new ArrayList(original.size + modified.size);
-        for(entry : modifiedMap.entrySet) {
-            val originalEntry = originalMap.get(entry.key);
-            if(originalEntry != null) {
-                originalMap.remove(entry.key);
-                mergedNodes.add(merge(node,originalEntry,entry.value,configurational));
-            } else {
-                mergedNodes.add(entry.value);
-            }
-        }
-        mergedNodes.addAll(originalMap.values);
-        return mergedNodes;
-    }
-
-    static private def CompositeNode mergeContainer(DataNodeContainer schema, CompositeNode stored,
-        CompositeNode modified, boolean config) {
-        if (stored == null) {
-            return modified;
-        }
-        checkNotNull(stored)
-        checkNotNull(modified)
-        checkArgument(stored.nodeType == modified.nodeType);
-
-        val mergedChildNodes = new ArrayList<Node<?>>(stored.children.size + modified.children.size);
-        
-        val toProcess = new HashSet<QName>(stored.keySet);
-        toProcess.addAll(modified.keySet);
-        
-        for (qname : toProcess) {
-            val schemaChild = schema.getDataChildByName(qname);
-            val storedChildren = stored.get(qname);
-            val modifiedChildren = modified.get(qname);
-
-            if (modifiedChildren !== null && !modifiedChildren.empty) {
-                if (storedChildren === null || storedChildren.empty || schemaChild === null) {
-                    mergedChildNodes.addAll(modifiedChildren);
-                } else {
-                    mergedChildNodes.addAll(mergeMultiple(schemaChild, storedChildren, modifiedChildren, config));
-                }
-            } else if (storedChildren !== null && !storedChildren.empty) {
-                mergedChildNodes.addAll(storedChildren);
-            }
-        }
-        return new CompositeNodeTOImpl(stored.nodeType, null, mergedChildNodes);
-    }
-
-}