*/
package org.opendaylight.openflowplugin.test;
-import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import javax.inject.Inject;
import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
@Singleton
+@Component(service = { })
public class OpenflowpluginTestActivator implements AutoCloseable {
- private static final Logger LOG = LoggerFactory
- .getLogger(OpenflowpluginTestActivator.class);
-
- private RpcProviderService rpcRegistry;
private final OpenflowpluginTestServiceProvider provider;
private final OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider();
private final OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider();
public static final String NODE_ID = "foo:node:1";
+ @Activate
+ @Inject
public OpenflowpluginTestActivator(@Reference DataBroker dataBroker,
+ @Reference RpcProviderService rpcRegistry,
@Reference NotificationService notificationService,
@Reference NotificationPublishService notificationPublishService, BundleContext ctx) {
provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationPublishService);
- OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider(
- dataBroker, notificationService, ctx);
- this.cmdProvider = openflowpluginTestCommandProvider;
- OpenflowpluginGroupTestCommandProvider openflowpluginGroupTestCommandProvider =
- new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
- this.cmdGroupProvider = openflowpluginGroupTestCommandProvider;
- OpenflowpluginMeterTestCommandProvider openflowpluginMeterTestCommandProvider =
- new OpenflowpluginMeterTestCommandProvider(dataBroker, ctx);
- this.cmdMeterProvider = openflowpluginMeterTestCommandProvider;
- OpenflowpluginTableFeaturesTestCommandProvider openflowpluginTableFeaturesTestCommandProvider =
- new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
- this.cmdTableProvider = openflowpluginTableFeaturesTestCommandProvider;
- OpenflowpluginStatsTestCommandProvider openflowpluginStatsTestCommandProvider =
- new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
- this.cmdStatsProvider = openflowpluginStatsTestCommandProvider;
- OpenflowpluginTestNodeConnectorNotification openflowpluginTestNodeConnectorNotification =
- new OpenflowpluginTestNodeConnectorNotification(notificationService);
- this.cmdNodeConnectorNotification = openflowpluginTestNodeConnectorNotification;
- OpenflowpluginTestTopologyNotification openflowpluginTestTopologyNotification =
- new OpenflowpluginTestTopologyNotification(notificationService);
- this.cmdTopologyNotification = openflowpluginTestTopologyNotification;
- OpenflowPluginBulkTransactionProvider openflowPluginBulkTransactionProvider =
- new OpenflowPluginBulkTransactionProvider(dataBroker, ctx);
- this.bulkCmdProvider = openflowPluginBulkTransactionProvider;
- OpenflowPluginBulkGroupTransactionProvider openflowPluginBulkGroupTransactionProvider =
- new OpenflowPluginBulkGroupTransactionProvider(dataBroker, ctx);
- this.groupCmdProvider = openflowPluginBulkGroupTransactionProvider;
- }
+ cmdProvider = new OpenflowpluginTestCommandProvider(dataBroker, notificationService, ctx);
+ cmdGroupProvider = new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
+ cmdMeterProvider = new OpenflowpluginMeterTestCommandProvider(dataBroker, ctx);
+ cmdTableProvider = new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
+ cmdStatsProvider = new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
+ cmdNodeConnectorNotification = new OpenflowpluginTestNodeConnectorNotification(notificationService);
+ cmdTopologyNotification = new OpenflowpluginTestTopologyNotification(notificationService);
+ bulkCmdProvider = new OpenflowPluginBulkTransactionProvider(dataBroker, ctx);
+ groupCmdProvider = new OpenflowPluginBulkGroupTransactionProvider(dataBroker, ctx);
- @PostConstruct
- 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();
+ cmdProvider.init();
+ cmdGroupProvider.init();
+ cmdMeterProvider.init();
+ cmdTableProvider.init();
+ cmdStatsProvider.init();
+ cmdNodeConnectorNotification.init();
+ cmdTopologyNotification.init();
+ bulkCmdProvider.init();
+ groupCmdProvider.init();
}
@Override
@PreDestroy
- @SuppressWarnings("checkstyle:IllegalCatch")
+ @Deactivate
public void close() {
- try {
- provider.close();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- LOG.error("Stopping bundle OpenflowpluginTestActivator failed.", e);
- }
+ provider.close();
}
}