Add blueprint wiring to opendaylight-archetype 61/41161/7
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Thu, 30 Jun 2016 18:29:51 +0000 (14:29 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Thu, 30 Jun 2016 20:34:32 +0000 (16:34 -0400)
Change-Id: I0b219e8da4a1e58d6254c1dff993e8719aa14fd5
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
opendaylight/archetypes/opendaylight-startup/src/main/resources/META-INF/maven/archetype-metadata.xml
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/features/pom.xml
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/features/src/main/features/features.xml
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/config/default-config.xml [deleted file]
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/__packageInPathFormat__/impl/__classPrefix__Provider.java
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__Module.java [deleted file]
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleFactory.java [deleted file]
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml [new file with mode: 0644]
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/yang/__artifactId__-impl.yang [deleted file]
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleFactoryTest.java [deleted file]
opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleTest.java [deleted file]

index 753f70f..fbd2550 100644 (file)
          </includes>
     </fileSet>
     <fileSet filtered="true" encoding="UTF-8">
-        <directory>impl/src/main/config</directory>
+        <directory>impl/src/main/resources/org/opendaylight/blueprint</directory>
         <includes>
             <include>**/*.xml</include>
          </includes>
     </fileSet>
-    <fileSet filtered="true" encoding="UTF-8">
-       <directory>impl/src/main/yang</directory>
-       <includes>
-         <include>**/*.yang</include>
-       </includes>
-     </fileSet>
 
      <!-- api -->
 
index 8ef2fae..1ca2c6d 100644 (file)
@@ -107,13 +107,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>${artifactId}-impl</artifactId>
       <version>${symbol_dollar}{project.version}</version>
     </dependency>
-    <dependency>
-      <groupId>${symbol_dollar}{project.groupId}</groupId>
-      <artifactId>${artifactId}-impl</artifactId>
-      <version>${symbol_dollar}{project.version}</version>
-      <type>xml</type>
-      <classifier>config</classifier>
-    </dependency>
     <dependency>
       <groupId>${symbol_dollar}{project.groupId}</groupId>
       <artifactId>${artifactId}-api</artifactId>
index 42d88b7..9c3555e 100644 (file)
@@ -26,7 +26,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <feature version='${symbol_dollar}{mdsal.version}'>odl-mdsal-broker</feature>
     <feature version='${symbol_dollar}{project.version}'>odl-${artifactId}-api</feature>
     <bundle>mvn:${groupId}/${artifactId}-impl/{{VERSION}}</bundle>
-    <configfile finalname="${configfile.directory}/${artifactId}.xml">mvn:${groupId}/${artifactId}-impl/{{VERSION}}/xml/config</configfile>
   </feature>
   <feature name='odl-${artifactId}-rest' version='${symbol_dollar}{project.version}' description='OpenDaylight :: ${artifactId} :: REST'>
     <feature version="${symbol_dollar}{project.version}">odl-${artifactId}</feature>
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/config/default-config.xml b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/config/default-config.xml
deleted file mode 100644 (file)
index 7f9dc7f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
-Copyright © ${copyrightYear} ${copyright} 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
--->
-<snapshot>
-  <required-capabilities>
-      <capability>urn:opendaylight:params:xml:ns:yang:${artifactId}:impl?module=${artifactId}-impl&amp;revision=2014-12-10</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
-  </required-capabilities>
-  <configuration>
-
-    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:${artifactId}:impl">prefix:${artifactId}</type>
-          <name>${artifactId}-default</name>
-          <broker>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <name>binding-osgi-broker</name>
-          </broker>
-        </module>
-      </modules>
-    </data>
-  </configuration>
-</snapshot>
index c2c8f0d..4d0a820 100644 (file)
  */
 package ${package}.impl;
 
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ${classPrefix}Provider implements BindingAwareProvider, AutoCloseable {
+public class ${classPrefix}Provider {
 
     private static final Logger LOG = LoggerFactory.getLogger(${classPrefix}Provider.class);
 
-    @Override
-    public void onSessionInitiated(ProviderContext session) {
+    private final DataBroker dataBroker;
+
+    public ${classPrefix}Provider(final DataBroker dataBroker) {
+        this.dataBroker = dataBroker;
+    }
+
+    /**
+     * Method called when the blueprint container is created.
+     */
+    public void init() {
         LOG.info("${classPrefix}Provider Session Initiated");
     }
 
-    @Override
-    public void close() throws Exception {
+    /**
+     * Method called when the blueprint container is destroyed.
+     */
+    public void close() {
         LOG.info("${classPrefix}Provider Closed");
     }
-
-}
+}
\ No newline at end of file
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__Module.java b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__Module.java
deleted file mode 100644 (file)
index 694dcda..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-/*
- * Copyright © ${copyrightYear} ${copyright} 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.${artifactId}.impl.rev141210;
-
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import ${package}.impl.${classPrefix}Provider;
-
-public class ${classPrefix}Module extends Abstract${classPrefix}Module {
-
-    public ${classPrefix}Module(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public ${classPrefix}Module(ModuleIdentifier identifier, DependencyResolver dependencyResolver, ${classPrefix}Module oldModule,
-            AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        ${classPrefix}Provider provider = new ${classPrefix}Provider();
-        getBrokerDependency().registerProvider(provider);
-        return provider;
-    }
-
-}
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleFactory.java b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleFactory.java
deleted file mode 100644 (file)
index e10edd6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-/*
- * Copyright © ${copyrightYear} ${copyright} 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.${artifactId}.impl.rev141210;
-
-public class ${classPrefix}ModuleFactory extends Abstract${classPrefix}ModuleFactory {
-
-}
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
new file mode 100644 (file)
index 0000000..95682b5
--- /dev/null
@@ -0,0 +1,27 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright © ${copyrightYear} ${copyright} 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
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+  xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+  odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker"
+    interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+    odl:type="default" />
+
+  <bean id="provider"
+    class="${package}.impl.${classPrefix}Provider"
+    init-method="init" destroy-method="close">
+    <argument ref="dataBroker" />
+  </bean>
+
+</blueprint>
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/yang/__artifactId__-impl.yang b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/main/yang/__artifactId__-impl.yang
deleted file mode 100644 (file)
index 41a74b3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-module ${artifactId}-impl {
-    yang-version 1;
-    namespace "urn:opendaylight:params:xml:ns:yang:${artifactId}:impl";
-    prefix "${artifactId}-impl";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
-
-    description
-        "Service definition for ${artifactId} project";
-
-    revision "2014-12-10" {
-        description
-            "Initial revision";
-    }
-
-    identity ${artifactId} {
-        base config:module-type;
-        config:java-name-prefix ${classPrefix};
-    }
-
-    augment "/config:modules/config:module/config:configuration" {
-        case ${artifactId} {
-            when "/config:modules/config:module/config:type = '${artifactId}'";
-            container broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleFactoryTest.java b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleFactoryTest.java
deleted file mode 100644 (file)
index 40cfc63..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-#set( $factory = "${classPrefix}ModuleFactory" )
-/*
- * Copyright © ${copyrightYear} ${copyright} 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.${artifactId}.impl.rev141210;
-
-import org.junit.Test;
-
-public class ${classPrefix}ModuleFactoryTest {
-    @Test
-    public void testFactoryConstructor() {
-        // ensure no exceptions on construction
-        new ${factory}();
-    }
-}
diff --git a/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleTest.java b/opendaylight/archetypes/opendaylight-startup/src/main/resources/archetype-resources/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/__artifactId__/impl/rev141210/__classPrefix__ModuleTest.java
deleted file mode 100644 (file)
index 6dc299c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
-#set( $module = "${classPrefix}Module" )
-/*
- * Copyright © ${copyrightYear} ${copyright} 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.${artifactId}.impl.rev141210;
-
-import org.junit.Test;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.JmxAttribute;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import ${package}.impl.${classPrefix}Provider;
-
-import javax.management.ObjectName;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ${classPrefix}ModuleTest {
-    @Test
-    public void testCustomValidation() {
-        ${module} module = new ${module}(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
-
-        // ensure no exceptions on validation
-        // currently this method is empty
-        module.customValidation();
-    }
-
-    @Test
-    public void testCreateInstance() throws Exception {
-        // configure mocks
-        DependencyResolver dependencyResolver = mock(DependencyResolver.class);
-        BindingAwareBroker broker = mock(BindingAwareBroker.class);
-        when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
-
-        // create instance of module with injected mocks
-        ${module} module = new ${module}(mock(ModuleIdentifier.class), dependencyResolver);
-
-        // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
-        AutoCloseable closeable = module.getInstance();
-
-        // verify that the module registered the returned provider with the broker
-        verify(broker).registerProvider((${classPrefix}Provider)closeable);
-
-        // ensure no exceptions on close
-        closeable.close();
-    }
-}