X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2Fimplementation%2FActivator.java;h=0fbf933c17f828038183bb32e4f96d6c84bfa6f2;hp=1e2cd47c9c2d923ac09f3cbc50fc60b9c2a519f0;hb=b1ad203b32b73fc06a856cdfae243986c8037617;hpb=b80124e3f7b11cf2f5e5bd4a6b033d855ff4d0d4 diff --git a/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/Activator.java b/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/Activator.java index 1e2cd47c9c..0fbf933c17 100644 --- a/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/Activator.java +++ b/opendaylight/networkconfiguration/neutron/implementation/src/main/java/org/opendaylight/controller/networkconfig/neutron/implementation/Activator.java @@ -8,196 +8,128 @@ package org.opendaylight.controller.networkconfig.neutron.implementation; -import java.util.Hashtable; -import java.util.Dictionary; +import java.util.ArrayList; +import java.util.List; -import org.apache.felix.dm.Component; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.opendaylight.controller.clustering.services.IClusterContainerServices; -import org.opendaylight.controller.configuration.IConfigurationContainerAware; -import org.opendaylight.controller.configuration.IConfigurationContainerService; -import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD; -import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD; -import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase; +import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class Activator extends ComponentActivatorAbstractBase { +public class Activator implements BundleActivator { protected static final Logger logger = LoggerFactory .getLogger(Activator.class); + private List> registrations = new ArrayList>(); - /** - * Function called when the activator starts just after some - * initializations are done by the - * ComponentActivatorAbstractBase. - * - */ @Override - public void init() { + public void start(BundleContext context) throws Exception { + NeutronRouterInterface neutronRouterInterface = new NeutronRouterInterface(); + ServiceRegistration neutronRouterInterfaceRegistration = context.registerService(INeutronRouterCRUD.class, neutronRouterInterface, null); + if(neutronRouterInterfaceRegistration != null) { + registrations.add(neutronRouterInterfaceRegistration); + } + NeutronPortInterface neutronPortInterface = new NeutronPortInterface(); + ServiceRegistration neutronPortInterfaceRegistration = context.registerService(INeutronPortCRUD.class, neutronPortInterface, null); + if(neutronPortInterfaceRegistration != null) { + registrations.add(neutronPortInterfaceRegistration); + } - } + NeutronSubnetInterface neutronSubnetInterface = new NeutronSubnetInterface(); + ServiceRegistration neutronSubnetInterfaceRegistration = context.registerService(INeutronSubnetCRUD.class, neutronSubnetInterface, null); + if(neutronSubnetInterfaceRegistration != null) { + registrations.add(neutronSubnetInterfaceRegistration); + } - /** - * Function called when the activator stops just before the - * cleanup done by ComponentActivatorAbstractBase - * - */ - @Override - public void destroy() { + NeutronNetworkInterface neutronNetworkInterface = new NeutronNetworkInterface(); + ServiceRegistration neutronNetworkInterfaceRegistration = context.registerService(INeutronNetworkCRUD.class, neutronNetworkInterface, null); + if(neutronNetworkInterfaceRegistration != null) { + registrations.add(neutronNetworkInterfaceRegistration); + } - } + NeutronSecurityGroupInterface neutronSecurityGroupInterface = new NeutronSecurityGroupInterface(); + ServiceRegistration neutronSecurityGroupInterfaceRegistration = context.registerService(INeutronSecurityGroupCRUD.class, neutronSecurityGroupInterface, null); + if(neutronSecurityGroupInterfaceRegistration != null) { + registrations.add(neutronSecurityGroupInterfaceRegistration); + } - /** - * 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 = { NeutronFloatingIPInterface.class, - NeutronRouterInterface.class, - NeutronPortInterface.class, - NeutronSubnetInterface.class, - NeutronNetworkInterface.class, - NeutronSecurityGroupInterface.class, - NeutronSecurityRuleInterface.class}; - return res; - } + NeutronSecurityRuleInterface neutronSecurityRuleInterface = new NeutronSecurityRuleInterface(); + ServiceRegistration neutronSecurityRuleInterfaceRegistration = context.registerService(INeutronSecurityRuleCRUD.class, neutronSecurityRuleInterface, null); + if(neutronSecurityRuleInterfaceRegistration != null) { + registrations.add(neutronSecurityRuleInterfaceRegistration); + } - /** - * 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. - */ - @Override - public void configureInstance(Component c, Object imp, String containerName) { - if (imp.equals(NeutronFloatingIPInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronFloatingIPCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + NeutronFirewallInterface neutronFirewallInterface = new NeutronFirewallInterface(); + ServiceRegistration neutronFirewallInterfaceRegistration = context.registerService(INeutronFirewallCRUD.class, neutronFirewallInterface, null); + if(neutronFirewallInterfaceRegistration != null) { + registrations.add(neutronFirewallInterfaceRegistration); } - if (imp.equals(NeutronRouterInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronRouterCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + + NeutronFirewallPolicyInterface neutronFirewallPolicyInterface = new NeutronFirewallPolicyInterface(); + ServiceRegistration neutronFirewallPolicyInterfaceRegistration = context.registerService(INeutronFirewallPolicyCRUD.class, neutronFirewallPolicyInterface, null); + if(neutronFirewallPolicyInterfaceRegistration != null) { + registrations.add(neutronFirewallPolicyInterfaceRegistration); } - if (imp.equals(NeutronPortInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronPortCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + + NeutronFirewallRuleInterface neutronFirewallRuleInterface = new NeutronFirewallRuleInterface(); + ServiceRegistration neutronFirewallRuleInterfaceRegistration = context.registerService(INeutronFirewallRuleCRUD.class, neutronFirewallRuleInterface, null); + if(neutronFirewallRuleInterfaceRegistration != null) { + registrations.add(neutronFirewallRuleInterfaceRegistration); } - if (imp.equals(NeutronSubnetInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronSubnetCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + + NeutronLoadBalancerInterface neutronLoadBalancerInterface = new NeutronLoadBalancerInterface(); + ServiceRegistration neutronLoadBalancerInterfaceRegistration = context.registerService(INeutronLoadBalancerCRUD.class, neutronLoadBalancerInterface, null); + if(neutronFirewallInterfaceRegistration != null) { + registrations.add(neutronLoadBalancerInterfaceRegistration); } - if (imp.equals(NeutronNetworkInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronNetworkCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + + NeutronLoadBalancerPoolInterface neutronLoadBalancerPoolInterface = new NeutronLoadBalancerPoolInterface(); + ServiceRegistration neutronLoadBalancerPoolInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolCRUD.class, neutronLoadBalancerPoolInterface, null); + if(neutronLoadBalancerPoolInterfaceRegistration != null) { + registrations.add(neutronLoadBalancerPoolInterfaceRegistration); } - if (imp.equals(NeutronSecurityGroupInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronSecurityGroupCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + + NeutronLoadBalancerListenerInterface neutronLoadBalancerListenerInterface = new NeutronLoadBalancerListenerInterface(); + ServiceRegistration neutronLoadBalancerListenerInterfaceRegistration = context.registerService(INeutronLoadBalancerListenerCRUD.class, neutronLoadBalancerListenerInterface, null); + if(neutronLoadBalancerListenerInterfaceRegistration != null) { + registrations.add(neutronLoadBalancerListenerInterfaceRegistration); } - if (imp.equals(NeutronSecurityRuleInterface.class)) { - // export the service - c.setInterface( - new String[] { INeutronSecurityRuleCRUD.class.getName(), - IConfigurationContainerAware.class.getName()}, null); - Dictionary props = new Hashtable(); - props.put("salListenerName", "neutron"); - c.add(createContainerServiceDependency(containerName) - .setService(IClusterContainerServices.class) - .setCallbacks("setClusterContainerService", - "unsetClusterContainerService").setRequired(true)); - c.add(createContainerServiceDependency(containerName).setService( - IConfigurationContainerService.class).setCallbacks( - "setConfigurationContainerService", - "unsetConfigurationContainerService").setRequired(true)); + + NeutronLoadBalancerHealthMonitorInterface neutronLoadBalancerHealthMonitorInterface = new NeutronLoadBalancerHealthMonitorInterface(); + ServiceRegistration neutronLoadBalancerHealthMonitorInterfaceRegistration = context.registerService(INeutronLoadBalancerHealthMonitorCRUD.class, neutronLoadBalancerHealthMonitorInterface, null); + if(neutronLoadBalancerHealthMonitorInterfaceRegistration != null) { + registrations.add(neutronLoadBalancerHealthMonitorInterfaceRegistration); } + + NeutronLoadBalancerPoolMemberInterface neutronLoadBalancerPoolMemberInterface = new NeutronLoadBalancerPoolMemberInterface(); + ServiceRegistration neutronLoadBalancerPoolMemberInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolMemberCRUD.class, neutronLoadBalancerPoolMemberInterface, null); + if(neutronLoadBalancerPoolMemberInterfaceRegistration != null) { + registrations.add(neutronLoadBalancerPoolMemberInterfaceRegistration); + } + + } + + @Override + public void stop(BundleContext context) throws Exception { + for(ServiceRegistration registration : registrations) { + if(registration != null) { + registration.unregister(); + } + } + } -} +} \ No newline at end of file