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
8 package org.opendaylight.openflowplugin.test;
10 import javax.annotation.PostConstruct;
11 import javax.annotation.PreDestroy;
12 import javax.inject.Singleton;
13 import org.apache.aries.blueprint.annotation.service.Reference;
14 import org.opendaylight.mdsal.binding.api.DataBroker;
15 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
16 import org.opendaylight.mdsal.binding.api.NotificationService;
17 import org.opendaylight.mdsal.binding.api.RpcProviderService;
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 RpcProviderService rpcRegistry;
28 private final OpenflowpluginTestServiceProvider provider;
29 private final OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider();
30 private final OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider();
31 private final OpenflowpluginTableFeaturesTestServiceProvider tableProvider =
32 new OpenflowpluginTableFeaturesTestServiceProvider();
34 private final OpenflowpluginTestCommandProvider cmdProvider;
36 private final OpenflowpluginGroupTestCommandProvider cmdGroupProvider;
38 private final OpenflowpluginMeterTestCommandProvider cmdMeterProvider;
40 private final OpenflowpluginTableFeaturesTestCommandProvider cmdTableProvider;
42 private final OpenflowpluginStatsTestCommandProvider cmdStatsProvider;
44 private final OpenflowpluginTestNodeConnectorNotification cmdNodeConnectorNotification;
46 private final OpenflowpluginTestTopologyNotification cmdTopologyNotification;
48 private final OpenflowPluginBulkTransactionProvider bulkCmdProvider;
50 private final OpenflowPluginBulkGroupTransactionProvider groupCmdProvider;
52 public static final String NODE_ID = "foo:node:1";
54 public OpenflowpluginTestActivator(@Reference DataBroker dataBroker,
55 @Reference NotificationService notificationService,
56 @Reference NotificationPublishService notificationPublishService, BundleContext ctx) {
57 provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationPublishService);
58 OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider(
59 dataBroker, notificationService, ctx);
60 this.cmdProvider = openflowpluginTestCommandProvider;
61 OpenflowpluginGroupTestCommandProvider openflowpluginGroupTestCommandProvider =
62 new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
63 this.cmdGroupProvider = openflowpluginGroupTestCommandProvider;
64 OpenflowpluginMeterTestCommandProvider openflowpluginMeterTestCommandProvider =
65 new OpenflowpluginMeterTestCommandProvider(dataBroker, ctx);
66 this.cmdMeterProvider = openflowpluginMeterTestCommandProvider;
67 OpenflowpluginTableFeaturesTestCommandProvider openflowpluginTableFeaturesTestCommandProvider =
68 new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
69 this.cmdTableProvider = openflowpluginTableFeaturesTestCommandProvider;
70 OpenflowpluginStatsTestCommandProvider openflowpluginStatsTestCommandProvider =
71 new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
72 this.cmdStatsProvider = openflowpluginStatsTestCommandProvider;
73 OpenflowpluginTestNodeConnectorNotification openflowpluginTestNodeConnectorNotification =
74 new OpenflowpluginTestNodeConnectorNotification(notificationService);
75 this.cmdNodeConnectorNotification = openflowpluginTestNodeConnectorNotification;
76 OpenflowpluginTestTopologyNotification openflowpluginTestTopologyNotification =
77 new OpenflowpluginTestTopologyNotification(notificationService);
78 this.cmdTopologyNotification = openflowpluginTestTopologyNotification;
79 OpenflowPluginBulkTransactionProvider openflowPluginBulkTransactionProvider =
80 new OpenflowPluginBulkTransactionProvider(dataBroker, ctx);
81 this.bulkCmdProvider = openflowPluginBulkTransactionProvider;
82 OpenflowPluginBulkGroupTransactionProvider openflowPluginBulkGroupTransactionProvider =
83 new OpenflowPluginBulkGroupTransactionProvider(dataBroker, ctx);
84 this.groupCmdProvider = openflowPluginBulkGroupTransactionProvider;
89 provider.register(rpcRegistry);
91 groupProvider.register(rpcRegistry);
92 meterProvider.register(rpcRegistry);
93 tableProvider.register(rpcRegistry);
95 this.cmdProvider.init();
96 this.cmdGroupProvider.init();
97 this.cmdMeterProvider.init();
98 this.cmdTableProvider.init();
99 this.cmdStatsProvider.init();
100 this.cmdNodeConnectorNotification.init();
101 this.cmdTopologyNotification.init();
102 this.bulkCmdProvider.init();
103 this.groupCmdProvider.init();
108 @SuppressWarnings("checkstyle:IllegalCatch")
109 public void close() {
112 } catch (Exception e) {
113 // TODO Auto-generated catch block
114 LOG.error("Stopping bundle OpenflowpluginTestActivator failed.", e);