</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 -->
<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>
<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>
+++ /dev/null
-#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&revision=2014-12-10</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&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>
*/
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
+++ /dev/null
-#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;
- }
-
-}
+++ /dev/null
-#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 {
-
-}
--- /dev/null
+#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>
+++ /dev/null
-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;
- }
- }
- }
- }
- }
-}
+++ /dev/null
-#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}();
- }
-}
+++ /dev/null
-#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();
- }
-}