import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.applications.frsync.NodeListener;
/**
* Top provider of forwarding rules synchronization functionality.
*/
-public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareProvider {
+public class ForwardingRulesSyncProvider implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesSyncProvider.class);
private static final String FRS_EXECUTOR_PREFIX = "FRS-executor-";
private final ListeningExecutorService syncThreadPool;
- public ForwardingRulesSyncProvider(final BindingAwareBroker broker,
- final DataBroker dataBroker,
+ public ForwardingRulesSyncProvider(final DataBroker dataBroker,
final RpcConsumerRegistry rpcRegistry,
final ClusterSingletonServiceProvider clusterSingletonService) {
Preconditions.checkNotNull(rpcRegistry, "RpcConsumerRegistry can not be null!");
.setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
.build());
syncThreadPool = MoreExecutors.listeningDecorator(executorService);
- broker.registerProvider(this);
}
- @Override
- public void onSessionInitiated(final ProviderContext providerContext) {
+ public void init() {
final TableForwarder tableForwarder = new TableForwarder(salTableService);
final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
- <reference id="broker" interface="org.opendaylight.controller.sal.binding.api.BindingAwareBroker"/>
<reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
<reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
<reference id="clusterSingletonService" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
<bean id="frSync" class="org.opendaylight.openflowplugin.applications.frsync.impl.ForwardingRulesSyncProvider"
- destroy-method="close">
- <argument ref="broker"/>
+ init-method="init" destroy-method="close">
<argument ref="dataBroker"/>
<argument ref="rpcRegistry"/>
<argument ref="clusterSingletonService"/>
</bean>
-</blueprint>
\ No newline at end of file
+</blueprint>
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
@Mock
private RpcConsumerRegistry rpcRegistry;
@Mock
- private BindingAwareBroker broker;
- @Mock
- private ProviderContext providerContext;
- @Mock
private ClusterSingletonServiceProvider clusterSingletonService;
@Before
return Mockito.mock(serviceType);
});
- provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry, clusterSingletonService);
+ provider = new ForwardingRulesSyncProvider(dataBroker, rpcRegistry, clusterSingletonService);
Mockito.verify(rpcRegistry).getRpcService(SalTableService.class);
Mockito.verify(rpcRegistry).getRpcService(SalFlatBatchService.class);
- Mockito.verify(broker).registerProvider(provider);
}
@Test
- public void testOnSessionInitiated() throws Exception {
- provider.onSessionInitiated(providerContext);
+ public void testInit() throws Exception {
+ provider.init();
Mockito.verify(dataBroker, Mockito.times(2)).registerDataTreeChangeListener(
Matchers.<DataTreeIdentifier<FlowCapableNode>>any(),
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
@Mock
- private BindingAwareBroker.ProviderContext rpcProviderRegistry;
+ private RpcProviderRegistry rpcProviderRegistry;
@Mock
private DeviceState deviceState;
@Mock
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
private RpcManagerImpl rpcManager;
@Mock
- private ProviderContext rpcProviderRegistry;
+ private RpcProviderRegistry rpcProviderRegistry;
@Mock
private DeviceContext deviceContext;
@Mock
@Mock
private KeyedInstanceIdentifier<Node, NodeKey> nodePath;
- private NodeId nodeId = new NodeId("openflow-junit:1");
+ private final NodeId nodeId = new NodeId("openflow-junit:1");
@Before
public void setUp() {
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
- <configuration>
- <instructions>
- <Embed-Transitive>
- false
- </Embed-Transitive>
- <Bundle-Activator>
- org.opendaylight.openflowplugin.learningswitch.Activator
- </Bundle-Activator>
- </instructions>
- <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
- </configuration>
</plugin>
</plugins>
</build>
<artifactId>infrautils-util</artifactId>
<version>${infrautils.version}</version>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
-
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
+++ /dev/null
-/**
- * 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.openflowplugin.learningswitch;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareConsumer;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.openflowplugin.learningswitch.multi.LearningSwitchManagerMultiImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Learning switch activator
- * Activator is derived from AbstractBindingAwareConsumer, which takes care
- * of looking up MD-SAL in Service Registry and registering consumer
- * when MD-SAL is present.
- */
-public class Activator extends AbstractBindingAwareConsumer implements AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
- private LearningSwitchManager learningSwitch;
-
- @Override
- protected void startImpl(BundleContext context) {
- LOG.info("startImpl() passing");
- }
-
- /**
- * Invoked when consumer is registered to the MD-SAL.
- */
- @Override
- public void onSessionInitialized(ConsumerContext session) {
- LOG.info("inSessionInitialized() passing");
- /**
- * We create instance of our LearningSwitchManager
- * and set all required dependencies,
- *
- * which are
- * Data Broker (data storage service) - for configuring flows and reading stored switch state
- * PacketProcessingService - for sending out packets
- * NotificationService - for receiving notifications such as packet in.
- */
- learningSwitch = new LearningSwitchManagerMultiImpl();
- learningSwitch.setDataBroker(session.getSALService(DataBroker.class));
- learningSwitch.setPacketProcessingService(session.getRpcService(PacketProcessingService.class));
- learningSwitch.setNotificationService(session.getSALService(NotificationService.class));
- learningSwitch.start();
- }
-
- @Override
- public void close() {
- LOG.info("close() passing");
- if (learningSwitch != null) {
- learningSwitch.stop();
- }
- }
-
- @Override
- protected void stopImpl(BundleContext context) {
- close();
- super.stopImpl(context);
- }
-}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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"/>
+ <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationService"/>
+
+ <odl:rpc-service id="packetProcessingService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
+
+ <bean id="learningSwitch" class="org.opendaylight.openflowplugin.learningswitch.multi.LearningSwitchManagerMultiImpl"
+ init-method="start" destroy-method="stop">
+ <property name="dataBroker" ref="dataBroker"/>
+ <property name="notificationService" ref="notificationService"/>
+ <property name="packetProcessingService" ref="packetProcessingService"/>
+ </bean>
+
+</blueprint>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
- <configuration>
- <instructions>
- <Embed-Transitive>
- false
- </Embed-Transitive>
- <Bundle-Activator>
- org.opendaylight.openflowplugin.samples.sample.bundles.Activator
- </Bundle-Activator>
- </instructions>
- <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
- </configuration>
</plugin>
</plugins>
</build>
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.AbstractBrokerAwareActivator;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleControlType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Sample bundles activator.
+ * Sample DataTreeChangeListener.
*/
-public class Activator extends AbstractBrokerAwareActivator implements BindingAwareConsumer,
- ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
+public class SampleFlowCapableNodeListener implements ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SampleFlowCapableNodeListener.class);
private static final BundleId BUNDLE_ID = new BundleId(1L);
private static final BundleFlags BUNDLE_FLAGS = new BundleFlags(true, true);
private static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor();
- private DataBroker dataBroker;
- private SalBundleService bundleService;
+ private final DataBroker dataBroker;
+ private final SalBundleService bundleService;
+ private ListenerRegistration<?> listenerReg;
+
+ public SampleFlowCapableNodeListener(DataBroker dataBroker, SalBundleService bundleService) {
+ this.dataBroker = dataBroker;
+ this.bundleService = bundleService;
+ }
@Override
- public void close() throws Exception {
+ public void close() {
LOG.debug("close() passing");
+ if (listenerReg != null) {
+ listenerReg.close();
+ }
}
- @Override
- public void onSessionInitialized(ConsumerContext consumerContext) {
+ public void init() {
LOG.debug("inSessionInitialized() passing");
- dataBroker = consumerContext.getSALService(DataBroker.class);
final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
.augmentation(FlowCapableNode.class);
final DataTreeIdentifier<FlowCapableNode> identifier =
new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, path);
- dataBroker.registerDataTreeChangeListener(identifier, Activator.this);
- bundleService = consumerContext.getRpcService(SalBundleService.class);
+ listenerReg = dataBroker.registerDataTreeChangeListener(identifier, SampleFlowCapableNodeListener.this);
}
@Override
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> modifications) {
- for (DataTreeModification modification : modifications) {
+ for (DataTreeModification<FlowCapableNode> modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
LOG.info("Node connected: {}",
modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
}, EXECUTOR);
}
- @Override
- protected void onBrokerAvailable(BindingAwareBroker bindingAwareBroker, BundleContext bundleContext) {
- LOG.debug("onBrokerAvailable() passing");
- bindingAwareBroker.registerConsumer(this);
- }
-
private static List<Message> createMessages(NodeRef nodeRef) {
List<Message> messages = new ArrayList<>();
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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:rpc-service id="salBundleService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.SalBundleService"/>
+
+ <bean id="sampleListener" class="org.opendaylight.openflowplugin.samples.sample.bundles.SampleFlowCapableNodeListener"
+ init-method="init" destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="salBundleService"/>
+ </bean>
+
+</blueprint>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
- <configuration>
- <instructions>
- <Embed-Transitive>
- false
- </Embed-Transitive>
- <Bundle-Activator>
- org.opendaylight.openflowplugin.openflow.samples.consumer.Activator
- </Bundle-Activator>
- </instructions>
- <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
- </configuration>
</plugin>
</plugins>
</build>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>yang-binding</artifactId>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-util</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
+++ /dev/null
-/**
- * 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.openflowplugin.openflow.samples.consumer;
-
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareConsumer;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-
-public class Activator extends AbstractBindingAwareConsumer {
-
- @Override
- public void onSessionInitialized(ConsumerContext session) {
- SalFlowService flowService = session.getRpcService(SalFlowService.class);
- new SimpleDropFirewall(flowService).start();
- }
-}
this.flowService = flowService;
}
- public void start() {
- }
-
public boolean addFlow(AddFlowInput flow) throws InterruptedException,
ExecutionException, TimeoutException {
Future<RpcResult<AddFlowOutput>> result = flowService.addFlow(flow);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <odl:rpc-service id="salFlowService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService"/>
+
+ <bean id="simpleDropFirewall" class="org.opendaylight.openflowplugin.openflow.samples.consumer.SimpleDropFirewall">
+ <argument ref="salFlowService"/>
+ </bean>
+
+</blueprint>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-service</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-base</artifactId>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>${maven.bundle.version}</version>
<extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Activator>org.opendaylight.openflowplugin.test.OpenflowpluginTestActivator</Bundle-Activator>
- <Embed-Dependency>commons-lang</Embed-Dependency>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- </instructions>
- </configuration>
</plugin>
</plugins>
</build>
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
@SuppressWarnings("checkstyle:MethodName")
public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvider {
private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginBulkGroupTransactionProvider.class);
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private final String originalFlowName = "Foo";
private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
private Node testNode12;
private final String originalGroupName = "Foo";
- private NotificationService notificationService;
+ private final NotificationService notificationService;
- public OpenflowPluginBulkGroupTransactionProvider(BundleContext ctx) {
+ public OpenflowPluginBulkGroupTransactionProvider(DataBroker dataBroker, NotificationService notificationService,
+ BundleContext ctx) {
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationService;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- notificationService = session.getSALService(NotificationService.class);
+ public void init() {
notificationService.registerNotificationListener(nodeErrorListener);
- dataBroker = session.getSALService(DataBroker.class);
ctx.registerService(CommandProvider.class.getName(), this, null);
createTestFlow(createTestNode(null), null, null);
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
public class OpenflowPluginBulkTransactionProvider implements CommandProvider {
private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginBulkTransactionProvider.class);
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private final String originalFlowName = "Foo";
private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
- private NotificationService notificationService;
+ private final NotificationService notificationService;
- public OpenflowPluginBulkTransactionProvider(BundleContext ctx) {
+ public OpenflowPluginBulkTransactionProvider(DataBroker dataBroker, NotificationService notificationService,
+ BundleContext ctx) {
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationService;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- notificationService = session.getSALService(NotificationService.class);
+ public void init() {
notificationService.registerNotificationListener(nodeErrorListener);
- dataBroker = session.getSALService(DataBroker.class);
ctx.registerService(CommandProvider.class.getName(), this, null);
createTestFlow(createTestNode(null), null, null);
}
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
public class OpenflowpluginGroupTestCommandProvider implements CommandProvider {
private static final String ORIGINAL_GROUP_NAME = "Foo";
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private Group testGroup;
private Node testNode;
- public OpenflowpluginGroupTestCommandProvider(BundleContext ctx) {
+ public OpenflowpluginGroupTestCommandProvider(DataBroker dataBroker, BundleContext ctx) {
+ this.dataBroker = dataBroker;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- dataBroker = session.getSALService(DataBroker.class);
+ public void init() {
ctx.registerService(CommandProvider.class.getName(), this, null);
createTestNode();
}
package org.opendaylight.openflowplugin.test;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
}
public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
- final ProviderContext ctx) {
- RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx
- .<SalGroupService>addRoutedRpcImplementation(
+ final RpcProviderRegistry rpcRegistry) {
+ RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation(
SalGroupService.class, this);
setGroupRegistration(addRoutedRpcImplementation);
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
public class OpenflowpluginMeterTestCommandProvider implements CommandProvider {
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginMeterTestCommandProvider.class);
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private Meter testMeter;
private Meter testMeter1;
private final String originalMeterName = "Foo";
private final String updatedMeterName = "Bar";
private final MeterEventListener meterEventListener = new MeterEventListener();
- private NotificationService notificationService;
+ private final NotificationService notificationService;
private Registration listener1Reg;
- public OpenflowpluginMeterTestCommandProvider(BundleContext ctx) {
+ public OpenflowpluginMeterTestCommandProvider(DataBroker dataBroker, NotificationService notificationService,
+ BundleContext ctx) {
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationService;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- dataBroker = session.getSALService(DataBroker.class);
+ public void init() {
ctx.registerService(CommandProvider.class.getName(), this, null);
- notificationService = session.getSALService(NotificationService.class);
// For switch events
listener1Reg = notificationService.registerNotificationListener(meterEventListener);
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
}
public ObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(
- final ProviderContext ctx) {
+ final RpcProviderRegistry rpcRegistry) {
- RoutedRpcRegistration<SalMeterService> addRoutedRpcImplementation = ctx
- .<SalMeterService>addRoutedRpcImplementation(
+ RoutedRpcRegistration<SalMeterService> addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation(
SalMeterService.class, this);
setMeterRegistration(addRoutedRpcImplementation);
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginStatsTestCommandProvider.class);
- private DataBroker dataProviderService;
+ private final DataBroker dataProviderService;
private final BundleContext ctx;
- public OpenflowpluginStatsTestCommandProvider(BundleContext ctx) {
+ public OpenflowpluginStatsTestCommandProvider(DataBroker dataProviderService, BundleContext ctx) {
+ this.dataProviderService = dataProviderService;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- dataProviderService = session.getSALService(DataBroker.class);
+ public void init() {
ctx.registerService(CommandProvider.class.getName(), this, null);
}
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
@SuppressWarnings("checkstyle:MethodName")
public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandProvider {
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private Node testNode;
- public OpenflowpluginTableFeaturesTestCommandProvider(BundleContext ctx) {
+ public OpenflowpluginTableFeaturesTestCommandProvider(DataBroker dataBroker, BundleContext ctx) {
+ this.dataBroker = dataBroker;
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
- dataBroker = session.getSALService(DataBroker.class);
+ public void init() {
ctx.registerService(CommandProvider.class.getName(), this, null);
// createTestNode();
// createTestTableFeatures();
package org.opendaylight.openflowplugin.test;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
}
public ObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(
- final ProviderContext ctx) {
- RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx
- .<SalTableService>addRoutedRpcImplementation(
+ final RpcProviderRegistry rpcRegistry) {
+ RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation(
SalTableService.class, this);
setTableRegistration(addRoutedRpcImplementation);
package org.opendaylight.openflowplugin.test;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class OpenflowpluginTestActivator extends AbstractBindingAwareProvider {
+public class OpenflowpluginTestActivator implements AutoCloseable {
private static final Logger LOG = LoggerFactory
.getLogger(OpenflowpluginTestActivator.class);
- private static OpenflowpluginTestServiceProvider provider = new OpenflowpluginTestServiceProvider();
- private static OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider();
- private static OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider();
- private static OpenflowpluginTableFeaturesTestServiceProvider tableProvider =
+ private DataBroker dataBroker;
+ private NotificationProviderService notificationService;
+ private RpcProviderRegistry rpcRegistry;
+ private final OpenflowpluginTestServiceProvider provider;
+ private final OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider();
+ private final OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider();
+ private final OpenflowpluginTableFeaturesTestServiceProvider tableProvider =
new OpenflowpluginTableFeaturesTestServiceProvider();
- private OpenflowpluginTestCommandProvider cmdProvider;
+ private final OpenflowpluginTestCommandProvider cmdProvider;
- private OpenflowpluginGroupTestCommandProvider cmdGroupProvider;
+ private final OpenflowpluginGroupTestCommandProvider cmdGroupProvider;
- private OpenflowpluginMeterTestCommandProvider cmdMeterProvider;
+ private final OpenflowpluginMeterTestCommandProvider cmdMeterProvider;
- private OpenflowpluginTableFeaturesTestCommandProvider cmdTableProvider;
+ private final OpenflowpluginTableFeaturesTestCommandProvider cmdTableProvider;
- private OpenflowpluginStatsTestCommandProvider cmdStatsProvider;
+ private final OpenflowpluginStatsTestCommandProvider cmdStatsProvider;
- private OpenflowpluginTestNodeConnectorNotification cmdNodeConnectorNotification;
+ private final OpenflowpluginTestNodeConnectorNotification cmdNodeConnectorNotification;
- private OpenflowpluginTestTopologyNotification cmdTopologyNotification;
+ private final OpenflowpluginTestTopologyNotification cmdTopologyNotification;
- private OpenflowPluginBulkTransactionProvider bulkCmdProvider;
+ private final OpenflowPluginBulkTransactionProvider bulkCmdProvider;
- private OpenflowPluginBulkGroupTransactionProvider groupCmdProvider;
+ private final OpenflowPluginBulkGroupTransactionProvider groupCmdProvider;
public static final String NODE_ID = "foo:node:1";
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.sal.binding.api.BindingAwareProvider#
- * onSessionInitiated
- * (org.opendaylight.controller.sal.binding.api.BindingAwareBroker
- * .ProviderContext)
- */
- @Override
- public void onSessionInitiated(ProviderContext session) {
- DataBroker salService = session
- .<DataBroker>getSALService(DataBroker.class);
- OpenflowpluginTestActivator.provider.setDataService(salService);
-
- NotificationProviderService salService1 = session
- .<NotificationProviderService>getSALService(NotificationProviderService.class);
-
- OpenflowpluginTestActivator.provider
- .setNotificationService(salService1);
- OpenflowpluginTestActivator.provider.start();
- OpenflowpluginTestActivator.provider.register(session);
-
- OpenflowpluginTestActivator.groupProvider.register(session);
- OpenflowpluginTestActivator.meterProvider.register(session);
- OpenflowpluginTestActivator.tableProvider.register(session);
-
- this.cmdProvider.onSessionInitiated(session);
- this.cmdGroupProvider.onSessionInitiated(session);
- this.cmdMeterProvider.onSessionInitiated(session);
- this.cmdTableProvider.onSessionInitiated(session);
- this.cmdStatsProvider.onSessionInitiated(session);
- this.cmdNodeConnectorNotification.onSessionInitiated(session);
- this.cmdTopologyNotification.onSessionInitiated(session);
- this.bulkCmdProvider.onSessionInitiated(session);
- this.groupCmdProvider.onSessionInitiated(session);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opendaylight.controller.sal.binding.api.AbstractBrokerAwareActivator
- * #startImpl(org.osgi.framework.BundleContext)
- */
- @Override
- public void startImpl(final BundleContext ctx) {
- super.startImpl(ctx);
-
+ public OpenflowpluginTestActivator(DataBroker dataBroker, NotificationProviderService notificationService,
+ BundleContext ctx) {
+ provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationService);
OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider(
- ctx);
+ dataBroker, notificationService, ctx);
this.cmdProvider = openflowpluginTestCommandProvider;
OpenflowpluginGroupTestCommandProvider openflowpluginGroupTestCommandProvider =
- new OpenflowpluginGroupTestCommandProvider(ctx);
+ new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
this.cmdGroupProvider = openflowpluginGroupTestCommandProvider;
OpenflowpluginMeterTestCommandProvider openflowpluginMeterTestCommandProvider =
- new OpenflowpluginMeterTestCommandProvider(ctx);
+ new OpenflowpluginMeterTestCommandProvider(dataBroker, notificationService, ctx);
this.cmdMeterProvider = openflowpluginMeterTestCommandProvider;
OpenflowpluginTableFeaturesTestCommandProvider openflowpluginTableFeaturesTestCommandProvider =
- new OpenflowpluginTableFeaturesTestCommandProvider(ctx);
+ new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
this.cmdTableProvider = openflowpluginTableFeaturesTestCommandProvider;
OpenflowpluginStatsTestCommandProvider openflowpluginStatsTestCommandProvider =
- new OpenflowpluginStatsTestCommandProvider(ctx);
+ new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
this.cmdStatsProvider = openflowpluginStatsTestCommandProvider;
OpenflowpluginTestNodeConnectorNotification openflowpluginTestNodeConnectorNotification =
- new OpenflowpluginTestNodeConnectorNotification(ctx);
+ new OpenflowpluginTestNodeConnectorNotification(notificationService);
this.cmdNodeConnectorNotification = openflowpluginTestNodeConnectorNotification;
OpenflowpluginTestTopologyNotification openflowpluginTestTopologyNotification =
- new OpenflowpluginTestTopologyNotification(ctx);
+ new OpenflowpluginTestTopologyNotification(notificationService);
this.cmdTopologyNotification = openflowpluginTestTopologyNotification;
OpenflowPluginBulkTransactionProvider openflowPluginBulkTransactionProvider =
- new OpenflowPluginBulkTransactionProvider(ctx);
+ new OpenflowPluginBulkTransactionProvider(dataBroker, notificationService, ctx);
this.bulkCmdProvider = openflowPluginBulkTransactionProvider;
OpenflowPluginBulkGroupTransactionProvider openflowPluginBulkGroupTransactionProvider =
- new OpenflowPluginBulkGroupTransactionProvider(ctx);
+ new OpenflowPluginBulkGroupTransactionProvider(dataBroker, notificationService, ctx);
this.groupCmdProvider = openflowPluginBulkGroupTransactionProvider;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opendaylight.controller.sal.binding.api.AbstractBrokerAwareActivator
- * #stopImpl(org.osgi.framework.BundleContext)
- */
+ public void init() {
+ provider.register(rpcRegistry);
+
+ groupProvider.register(rpcRegistry);
+ meterProvider.register(rpcRegistry);
+ tableProvider.register(rpcRegistry);
+
+ this.cmdProvider.init();
+ this.cmdGroupProvider.init();
+ this.cmdMeterProvider.init();
+ this.cmdTableProvider.init();
+ this.cmdStatsProvider.init();
+ this.cmdNodeConnectorNotification.init();
+ this.cmdTopologyNotification.init();
+ this.bulkCmdProvider.init();
+ this.groupCmdProvider.init();
+ }
+
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
- protected void stopImpl(final BundleContext context) {
-
+ public void close() {
try {
- OpenflowpluginTestActivator.provider.close();
+ provider.close();
} catch (Exception e) {
// TODO Auto-generated catch block
LOG.error("Stopping bundle OpenflowpluginTestActivator failed.", e);
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
- private DataBroker dataBroker;
+ private final DataBroker dataBroker;
private final BundleContext ctx;
private static final String ORIGINAL_FLOW_NAME = "Foo";
private static final String UPDATED_FLOW_NAME = "Bar";
private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
- private NotificationService notificationService;
+ private final NotificationService notificationService;
- public OpenflowpluginTestCommandProvider(final BundleContext ctx) {
+ public OpenflowpluginTestCommandProvider(final DataBroker dataBroker, final NotificationService notificationService,
+ final BundleContext ctx) {
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationService;
this.ctx = ctx;
}
- public void onSessionInitiated(final ProviderContext session) {
- notificationService = session.getSALService(NotificationService.class);
+ public void init() {
// For switch events
notificationService.registerNotificationListener(flowEventListener);
notificationService.registerNotificationListener(nodeErrorListener);
- dataBroker = session.getSALService(DataBroker.class);
ctx.registerService(CommandProvider.class.getName(), this, null);
createTestFlow(createTestNode(null), null, null);
}
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
-import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestNodeConnectorNotification.class);
private final PortEventListener portEventListener = new PortEventListener();
- private NotificationService notificationService;
+ private final NotificationService notificationService;
- public OpenflowpluginTestNodeConnectorNotification(BundleContext ctx) {
+ public OpenflowpluginTestNodeConnectorNotification(NotificationService notificationService) {
+ this.notificationService = notificationService;
}
- public void onSessionInitiated(ProviderContext session) {
- notificationService = session.getSALService(NotificationService.class);
+ public void init() {
// For switch events
notificationService.registerNotificationListener(portEventListener);
}
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
private static final Logger LOG = LoggerFactory
.getLogger(OpenflowpluginTestServiceProvider.class);
- private DataBroker dataService;
+ private final DataBroker dataService;
private RoutedRpcRegistration<SalFlowService> flowRegistration;
- private NotificationProviderService notificationProviderService;
+ private final NotificationProviderService notificationProviderService;
+
+ public OpenflowpluginTestServiceProvider(DataBroker dataService,
+ NotificationProviderService notificationProviderService) {
+ this.dataService = dataService;
+ this.notificationProviderService = notificationProviderService;
+ }
/**
* Get data service.
return dataService;
}
- /**
- * Set {@link #dataService}.
- */
- public void setDataService(final DataBroker dataService) {
- this.dataService = dataService;
- }
-
/**
* Get flow registration.
*
return notificationProviderService;
}
- /**
- * Set {@link #notificationProviderService}.
- */
- public void setNotificationService(final NotificationProviderService service) {
- this.notificationProviderService = service;
- }
-
- public void start() {
- OpenflowpluginTestServiceProvider.LOG
- .info("SalFlowServiceProvider Started.");
- }
-
/*
* (non-Javadoc)
*
return null;
}
- public ObjectRegistration<OpenflowpluginTestServiceProvider> register(
- final ProviderContext ctx) {
- RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx
- .<SalFlowService>addRoutedRpcImplementation(
- SalFlowService.class, this);
+ public ObjectRegistration<OpenflowpluginTestServiceProvider> register(RpcProviderRegistry rpcRegistry) {
+ RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation =
+ rpcRegistry.addRoutedRpcImplementation(SalFlowService.class, this);
setFlowRegistration(addRoutedRpcImplementation);
*/
package org.opendaylight.openflowplugin.test;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkOverutilized;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkUtilizationNormal;
-import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestTopologyNotification.class);
private final TopologyEventListener topologyEventListener = new TopologyEventListener();
- private NotificationService notificationService;
+ private final NotificationService notificationService;
- public OpenflowpluginTestTopologyNotification(BundleContext ctx) {
+ public OpenflowpluginTestTopologyNotification(NotificationService notificationService) {
+ this.notificationService = notificationService;
}
- public void onSessionInitiated(ProviderContext session) {
- notificationService = session.getSALService(NotificationService.class);
+ public void init() {
// For switch events
notificationService.registerNotificationListener(topologyEventListener);
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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"/>
+ <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+ <bean id="activator" class="org.opendaylight.openflowplugin.test.OpenflowpluginTestActivator"
+ init-method="init" destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="notificationService"/>
+ <argument ref="blueprintBundleContext"/>
+ </bean>
+</blueprint>