--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.rsvp.spi;
+
+import org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderActivator;
+import org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleRSVPExtensionProviderContext;
+
+public class SimpleRSVPExtensionProviderContextModule extends org.opendaylight.controller.config.yang.rsvp.spi.AbstractSimpleRSVPExtensionProviderContextModule {
+ public SimpleRSVPExtensionProviderContextModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public SimpleRSVPExtensionProviderContextModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.rsvp.spi.SimpleRSVPExtensionProviderContextModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ final class SimpleRSVPExtensionProviderContextAutoCloseable extends SimpleRSVPExtensionProviderContext implements AutoCloseable {
+ @Override
+ public void close() {
+ for (final RSVPExtensionProviderActivator e : getRsvpExtensionDependency()) {
+ e.stop();
+ }
+ }
+ }
+
+ final SimpleRSVPExtensionProviderContextAutoCloseable ret = new SimpleRSVPExtensionProviderContextAutoCloseable();
+ for (final RSVPExtensionProviderActivator e : getRsvpExtensionDependency()) {
+ e.start(ret);
+ }
+ return ret;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.rsvp.spi;
+public class SimpleRSVPExtensionProviderContextModuleFactory extends org.opendaylight.controller.config.yang.rsvp.spi.AbstractSimpleRSVPExtensionProviderContextModuleFactory {
+
+}
--- /dev/null
+// vi: set smarttab et sw=4 tabstop=4:
+module odl-rsvp-parser-spi-cfg {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:rsvp:spi";
+ prefix "rsvp-spi";
+
+ import config { prefix config; revision-date 2013-04-05; }
+
+ organization "Cisco Systems, Inc.";
+
+ contact "Claudio D. Gasparini <cgaspari@cisco.com>";
+
+ description
+ "This module contains the base YANG definitions for
+ RSPV listener implementation.
+
+ Copyright (c)2015 Cisco Systems, Inc. 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";
+
+ revision "2015-08-26" {
+ description
+ "Initial revision";
+ }
+
+ identity consumer-extensions {
+ description
+ "Service representing a RSVP parser extension registry. Extension
+ consumers have this service injected.";
+
+ base "config:service-type";
+ config:java-class "org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionConsumerContext";
+ }
+
+ identity rsvp-extensions {
+ description
+ "Service representing a RSVP parser extension registry. Extension
+ providers have this service injected for registration.";
+
+ base "consumer-extensions";
+ config:java-class "org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderContext";
+ }
+
+ identity rsvp-extension {
+ description
+ "Service representing a RSVP parser extension.";
+
+ base "config:service-type";
+ config:java-class "org.opendaylight.protocol.rsvp.parser.spi.RSVPExtensionProviderActivator";
+ }
+
+ identity rsvp-extensions-impl {
+ base config:module-type;
+ config:provided-service rsvp-extensions;
+ config:java-name-prefix SimpleRSVPExtensionProviderContext;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case rsvp-extensions-impl {
+ when "/config:modules/config:module/config:type = 'rsvp-extensions-impl'";
+
+ list rsvp-extension {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity rsvp-extension;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yang.rsvp.spi;
+
+import java.util.List;
+import javax.management.ObjectName;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+
+public class SimpleRSVPExtensionProviderContextModuleTest extends AbstractConfigTest {
+ private static final String FACTORY_NAME = SimpleRSVPExtensionProviderContextModuleFactory.NAME;
+ private static final String INSTANCE_NAME = "bgp-rsvp-extensions-impl";
+
+ public static ObjectName SimpleRSVPExtensionProviderContextModuleInstance(final ConfigTransactionJMXClient transaction, final List<ObjectName> extensions) throws Exception {
+ final ObjectName objectName = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+ final SimpleRSVPExtensionProviderContextModuleMXBean mxBean = transaction.newMXBeanProxy(objectName, SimpleRSVPExtensionProviderContextModuleMXBean.class);
+ mxBean.setRsvpExtension(extensions);
+ return objectName;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new SimpleRSVPExtensionProviderContextModuleFactory()));
+ }
+
+ @Test
+ public void testCreateBean() throws Exception {
+ final CommitStatus status = createInstance();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 1, 0, 0);
+ }
+
+ @Test
+ public void testReusingOldInstance() throws Exception {
+ createInstance();
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ private CommitStatus createInstance() throws Exception {
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+ return transaction.commit();
+ }
+}
\ No newline at end of file