X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fimplementation%2Finternal%2FActivator.java;h=98cb3b83ca6347a13e25c1c0674ca53f766a3848;hb=4206a55cd7724e15e3c5b7b5b7c12f78481384cf;hp=99690802e3cdd5e9539c8e0a5c33a18ccec7b3d6;hpb=5ac5f9d4d8f549f152c802de461c766588b992c4;p=controller.git 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 99690802e3..98cb3b83ca 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 @@ -8,6 +8,10 @@ package org.opendaylight.controller.sal.implementation.internal; +import java.util.Dictionary; +import java.util.Hashtable; + +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; @@ -22,46 +26,77 @@ 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 that is used to communicate to dependency manager the list of + * known Global implementations + * + * + * @return An array containing all the CLASS objects that will be + * instantiated in order to get an fully working implementation + * Object */ - public void init() { - + public Object[] getGlobalImplementations() { + Object[] res = { Inventory.class }; + return res; } /** - * Function called when the activator stops just before the cleanup done by - * ComponentActivatorAbstractBase - * + * 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 */ - public void destroy() { + public void configureGlobalInstance(Component c, Object imp) { + if (imp.equals(Inventory.class)) { + Dictionary props = new Hashtable(); + props.put("scope", "Global"); + // export the service + c.setInterface( + new String[] { IPluginOutInventoryService.class.getName(), + IInventoryService.class.getName() }, props); + // Now lets add a service dependency to make sure the + // provider of service exists + c.add(createServiceDependency() + .setService(IListenInventoryUpdates.class, "(scope=Global)") + .setCallbacks("setUpdateService", "unsetUpdateService") + .setRequired(false)); + c.add(createServiceDependency() + .setService(IPluginInInventoryService.class, "(scope=Global)") + .setCallbacks("setPluginService", "unsetPluginService") + .setRequired(false)); + } } /** * 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 */ + @Override public Object[] getImplementations() { Object[] res = { Topology.class, Inventory.class, FlowProgrammerService.class, ReadService.class, @@ -72,7 +107,7 @@ public class Activator extends ComponentActivatorAbstractBase { /** * 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 @@ -84,6 +119,7 @@ public class Activator extends ComponentActivatorAbstractBase { * 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 @@ -121,7 +157,7 @@ public class Activator extends ComponentActivatorAbstractBase { c.add(createContainerServiceDependency(containerName) .setService(IPluginInInventoryService.class) .setCallbacks("setPluginService", "unsetPluginService") - .setRequired(true)); + .setRequired(false)); } if (imp.equals(FlowProgrammerService.class)) { @@ -134,21 +170,29 @@ public class Activator extends ComponentActivatorAbstractBase { .setService(IPluginInFlowProgrammerService.class) .setCallbacks("setService", "unsetService") .setRequired(false)); - c.add(createServiceDependency() + 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(true)); + .setRequired(false)); + + //consumes plugins' reader updates + c.add(createContainerServiceDependency(containerName) + .setService(IReadServiceListener.class) + .setCallbacks("setReaderListener", "unsetReaderListener") + .setRequired(false)); + } /************************/