2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.test;
11 import javax.annotation.PostConstruct;
12 import javax.annotation.PreDestroy;
13 import javax.inject.Singleton;
14 import org.apache.aries.blueprint.annotation.service.Reference;
15 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
16 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
17 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
18 import org.osgi.framework.BundleContext;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 public class OpenflowpluginTestActivator implements AutoCloseable {
24 private static final Logger LOG = LoggerFactory
25 .getLogger(OpenflowpluginTestActivator.class);
27 private DataBroker dataBroker;
28 private NotificationProviderService notificationService;
29 private RpcProviderRegistry rpcRegistry;
30 private final OpenflowpluginTestServiceProvider provider;
31 private final OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider();
32 private final OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider();
33 private final OpenflowpluginTableFeaturesTestServiceProvider tableProvider =
34 new OpenflowpluginTableFeaturesTestServiceProvider();
36 private final OpenflowpluginTestCommandProvider cmdProvider;
38 private final OpenflowpluginGroupTestCommandProvider cmdGroupProvider;
40 private final OpenflowpluginMeterTestCommandProvider cmdMeterProvider;
42 private final OpenflowpluginTableFeaturesTestCommandProvider cmdTableProvider;
44 private final OpenflowpluginStatsTestCommandProvider cmdStatsProvider;
46 private final OpenflowpluginTestNodeConnectorNotification cmdNodeConnectorNotification;
48 private final OpenflowpluginTestTopologyNotification cmdTopologyNotification;
50 private final OpenflowPluginBulkTransactionProvider bulkCmdProvider;
52 private final OpenflowPluginBulkGroupTransactionProvider groupCmdProvider;
54 public static final String NODE_ID = "foo:node:1";
56 public OpenflowpluginTestActivator(@Reference DataBroker dataBroker,
57 @Reference NotificationProviderService notificationService, BundleContext ctx) {
58 provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationService);
59 OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider(
60 dataBroker, notificationService, ctx);
61 this.cmdProvider = openflowpluginTestCommandProvider;
62 OpenflowpluginGroupTestCommandProvider openflowpluginGroupTestCommandProvider =
63 new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
64 this.cmdGroupProvider = openflowpluginGroupTestCommandProvider;
65 OpenflowpluginMeterTestCommandProvider openflowpluginMeterTestCommandProvider =
66 new OpenflowpluginMeterTestCommandProvider(dataBroker, notificationService, ctx);
67 this.cmdMeterProvider = openflowpluginMeterTestCommandProvider;
68 OpenflowpluginTableFeaturesTestCommandProvider openflowpluginTableFeaturesTestCommandProvider =
69 new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
70 this.cmdTableProvider = openflowpluginTableFeaturesTestCommandProvider;
71 OpenflowpluginStatsTestCommandProvider openflowpluginStatsTestCommandProvider =
72 new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
73 this.cmdStatsProvider = openflowpluginStatsTestCommandProvider;
74 OpenflowpluginTestNodeConnectorNotification openflowpluginTestNodeConnectorNotification =
75 new OpenflowpluginTestNodeConnectorNotification(notificationService);
76 this.cmdNodeConnectorNotification = openflowpluginTestNodeConnectorNotification;
77 OpenflowpluginTestTopologyNotification openflowpluginTestTopologyNotification =
78 new OpenflowpluginTestTopologyNotification(notificationService);
79 this.cmdTopologyNotification = openflowpluginTestTopologyNotification;
80 OpenflowPluginBulkTransactionProvider openflowPluginBulkTransactionProvider =
81 new OpenflowPluginBulkTransactionProvider(dataBroker, notificationService, ctx);
82 this.bulkCmdProvider = openflowPluginBulkTransactionProvider;
83 OpenflowPluginBulkGroupTransactionProvider openflowPluginBulkGroupTransactionProvider =
84 new OpenflowPluginBulkGroupTransactionProvider(dataBroker, notificationService, ctx);
85 this.groupCmdProvider = openflowPluginBulkGroupTransactionProvider;
90 provider.register(rpcRegistry);
92 groupProvider.register(rpcRegistry);
93 meterProvider.register(rpcRegistry);
94 tableProvider.register(rpcRegistry);
96 this.cmdProvider.init();
97 this.cmdGroupProvider.init();
98 this.cmdMeterProvider.init();
99 this.cmdTableProvider.init();
100 this.cmdStatsProvider.init();
101 this.cmdNodeConnectorNotification.init();
102 this.cmdTopologyNotification.init();
103 this.bulkCmdProvider.init();
104 this.groupCmdProvider.init();
109 @SuppressWarnings("checkstyle:IllegalCatch")
110 public void close() {
113 } catch (Exception e) {
114 // TODO Auto-generated catch block
115 LOG.error("Stopping bundle OpenflowpluginTestActivator failed.", e);