X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fimplementation%2Finternal%2FActivator.java;h=85d239f4b9e1c52a265e2cb685fcb64925dac3d2;hp=1d7732af4424f48368bd8870c1d59b82d494b043;hb=eed57e2b0afd50823bc882123b6cbac04bcc48d9;hpb=42210c03b0a4c54706320ba9f55794c0abd4d201 diff --git a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java index 1d7732af44..85d239f4b9 100644 --- a/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java +++ b/opendaylight/sal/implementation/src/main/java/org/opendaylight/controller/sal/implementation/internal/Activator.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -9,9 +8,12 @@ package org.opendaylight.controller.sal.implementation.internal; +import org.apache.felix.dm.Component; import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase; +import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener; import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService; import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService; +import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService; import org.opendaylight.controller.sal.inventory.IInventoryService; import org.opendaylight.controller.sal.inventory.IListenInventoryUpdates; import org.opendaylight.controller.sal.inventory.IPluginInInventoryService; @@ -21,47 +23,50 @@ import org.opendaylight.controller.sal.packet.IListenDataPacket; import org.opendaylight.controller.sal.packet.IPluginInDataPacketService; import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService; import org.opendaylight.controller.sal.reader.IPluginInReadService; +import org.opendaylight.controller.sal.reader.IPluginOutReadService; import org.opendaylight.controller.sal.reader.IReadService; +import org.opendaylight.controller.sal.reader.IReadServiceListener; import org.opendaylight.controller.sal.topology.IListenTopoUpdates; import org.opendaylight.controller.sal.topology.IPluginInTopologyService; import org.opendaylight.controller.sal.topology.IPluginOutTopologyService; import org.opendaylight.controller.sal.topology.ITopologyService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.felix.dm.Component; public class Activator extends ComponentActivatorAbstractBase { protected static final Logger logger = LoggerFactory .getLogger(Activator.class); /** - * Function called when the activator starts just after some - * initializations are done by the - * ComponentActivatorAbstractBase. + * Function called when the activator starts just after some initializations + * are done by the ComponentActivatorAbstractBase. * */ + @Override public void init() { } /** - * Function called when the activator stops just before the - * cleanup done by ComponentActivatorAbstractBase + * Function called when the activator stops just before the cleanup done by + * ComponentActivatorAbstractBase * */ + @Override public void destroy() { } /** - * Function that is used to communicate to dependency manager the - * list of known implementations for services inside a container + * Function that is used to communicate to dependency manager the list of + * known implementations for services inside a container * * * @return An array containing all the CLASS objects that will be - * instantiated in order to get an fully working implementation - * Object + * instantiated in order to get an fully working implementation + * Object */ + @Override public Object[] getImplementations() { Object[] res = { Topology.class, Inventory.class, FlowProgrammerService.class, ReadService.class, @@ -70,97 +75,116 @@ public class Activator extends ComponentActivatorAbstractBase { } /** - * Function that is called when configuration of the dependencies - * is required. + * Function that is called when configuration of the dependencies is + * required. * - * @param c dependency manager Component object, used for - * configuring the dependencies exported and imported - * @param imp Implementation class that is being configured, - * needed as long as the same routine can configure multiple - * implementations - * @param containerName The containerName being configured, this allow - * also optional per-container different behavior if needed, usually - * should not be the case though. + * @param c + * dependency manager Component object, used for configuring the + * dependencies exported and imported + * @param imp + * Implementation class that is being configured, needed as long + * as the same routine can configure multiple implementations + * @param containerName + * The containerName being configured, this allow also optional + * per-container different behavior if needed, usually should not + * be the case though. */ + @Override public void configureInstance(Component c, Object imp, String containerName) { if (imp.equals(Topology.class)) { // export the service for Apps and Plugins - c.setInterface(new String[] { - IPluginOutTopologyService.class.getName(), - ITopologyService.class.getName() }, null); + c.setInterface( + new String[] { IPluginOutTopologyService.class.getName(), + ITopologyService.class.getName() }, null); // There can be multiple Topology listeners or there could // be none, hence the dependency is optional - c.add(createContainerServiceDependency(containerName).setService( - IListenTopoUpdates.class).setCallbacks("setUpdateService", - "unsetUpdateService").setRequired(false)); + c.add(createContainerServiceDependency(containerName) + .setService(IListenTopoUpdates.class) + .setCallbacks("setUpdateService", "unsetUpdateService") + .setRequired(false)); // There can be multiple southbound plugins or there could // be none, the dependency is optional - c.add(createContainerServiceDependency(containerName).setService( - IPluginInTopologyService.class).setCallbacks( - "setPluginService", "unsetPluginService") + c.add(createContainerServiceDependency(containerName) + .setService(IPluginInTopologyService.class) + .setCallbacks("setPluginService", "unsetPluginService") .setRequired(false)); } if (imp.equals(Inventory.class)) { // export the service - c.setInterface(new String[] { - IPluginOutInventoryService.class.getName(), - IInventoryService.class.getName() }, null); + c.setInterface( + new String[] { IPluginOutInventoryService.class.getName(), + IInventoryService.class.getName() }, null); // Now lets add a service dependency to make sure the // provider of service exists - c.add(createContainerServiceDependency(containerName).setService( - IListenInventoryUpdates.class).setCallbacks( - "setUpdateService", "unsetUpdateService") + c.add(createContainerServiceDependency(containerName) + .setService(IListenInventoryUpdates.class) + .setCallbacks("setUpdateService", "unsetUpdateService") + .setRequired(false)); + c.add(createContainerServiceDependency(containerName) + .setService(IPluginInInventoryService.class) + .setCallbacks("setPluginService", "unsetPluginService") .setRequired(false)); - c - .add(createContainerServiceDependency(containerName) - .setService(IPluginInInventoryService.class) - .setCallbacks("setPluginService", - "unsetPluginService").setRequired(true)); } if (imp.equals(FlowProgrammerService.class)) { - // It is the provider of IFlowProgrammerService - c.setInterface(IFlowProgrammerService.class.getName(), null); - //It is also the consumer of IPluginInFlowProgrammerService - c.add(createServiceDependency().setService( - IPluginInFlowProgrammerService.class).setCallbacks( - "setService", "unsetService").setRequired(true)); + c.setInterface( + new String[] { IFlowProgrammerService.class.getName(), + IPluginOutFlowProgrammerService.class.getName() }, + null); + + c.add(createServiceDependency() + .setService(IPluginInFlowProgrammerService.class) + .setCallbacks("setService", "unsetService") + .setRequired(false)); + c.add(createContainerServiceDependency(containerName) + .setService(IFlowProgrammerListener.class) + .setCallbacks("setListener", "unsetListener") + .setRequired(false)); } if (imp.equals(ReadService.class)) { - // It is the provider of IReadService - c.setInterface(IReadService.class.getName(), null); + // export services + c.setInterface(new String[] { + IReadService.class.getName(),IPluginOutReadService.class.getName()}, null); + + // It is also the consumer of IPluginInReadService + c.add(createContainerServiceDependency(containerName) + .setService(IPluginInReadService.class) + .setCallbacks("setService", "unsetService") + .setRequired(false)); + + //consumes plugins' reader updates + c.add(createContainerServiceDependency(containerName) + .setService(IReadServiceListener.class) + .setCallbacks("setReaderListener", "unsetReaderListener") + .setRequired(false)); - //It is also the consumer of IPluginInReadService - c.add(createContainerServiceDependency(containerName).setService( - IPluginInReadService.class).setCallbacks("setService", - "unsetService").setRequired(true)); } /************************/ /* DATA PACKET SERVICES */ /************************/ if (imp.equals(DataPacketService.class)) { - c.setInterface(new String[] { - IPluginOutDataPacketService.class.getName(), - IDataPacketService.class.getName() }, null); + c.setInterface( + new String[] { IPluginOutDataPacketService.class.getName(), + IDataPacketService.class.getName() }, null); // Optionally use PluginInDataService if any southbound // protocol plugin exists - c.add(createContainerServiceDependency(containerName).setService( - IPluginInDataPacketService.class).setCallbacks( - "setPluginInDataService", "unsetPluginInDataService") - .setRequired(false)); + c.add(createContainerServiceDependency(containerName) + .setService(IPluginInDataPacketService.class) + .setCallbacks("setPluginInDataService", + "unsetPluginInDataService").setRequired(false)); // Optionally listed to IListenDataPacket services - c.add(createContainerServiceDependency(containerName).setService( - IListenDataPacket.class).setCallbacks( - "setListenDataPacket", "unsetListenDataPacket") - .setRequired(false)); + c.add(createContainerServiceDependency(containerName) + .setService(IListenDataPacket.class) + .setCallbacks("setListenDataPacket", + "unsetListenDataPacket").setRequired(false)); } } }