Make neutron a simple osgi app
[controller.git] / opendaylight / networkconfiguration / neutron / implementation / src / main / java / org / opendaylight / controller / networkconfig / neutron / implementation / Activator.java
1 /*
2  * Copyright IBM Corporation, 2013.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.networkconfig.neutron.implementation;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD;
15 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyCRUD;
16 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD;
17 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
18 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerHealthMonitorCRUD;
19 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
21 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberCRUD;
22 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
23 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
24 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
25 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
26 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
27 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
28 import org.osgi.framework.BundleActivator;
29 import org.osgi.framework.BundleContext;
30 import org.osgi.framework.ServiceRegistration;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34 public class Activator implements BundleActivator {
35     protected static final Logger logger = LoggerFactory
36     .getLogger(Activator.class);
37     private List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
38
39     @Override
40     public void start(BundleContext context) throws Exception {
41         NeutronRouterInterface neutronRouterInterface = new NeutronRouterInterface();
42         ServiceRegistration<INeutronRouterCRUD> neutronRouterInterfaceRegistration = context.registerService(INeutronRouterCRUD.class, neutronRouterInterface, null);
43         if(neutronRouterInterfaceRegistration != null) {
44             registrations.add(neutronRouterInterfaceRegistration);
45         }
46         NeutronPortInterface neutronPortInterface = new NeutronPortInterface();
47         ServiceRegistration<INeutronPortCRUD> neutronPortInterfaceRegistration = context.registerService(INeutronPortCRUD.class, neutronPortInterface, null);
48         if(neutronPortInterfaceRegistration != null) {
49             registrations.add(neutronPortInterfaceRegistration);
50         }
51
52         NeutronSubnetInterface neutronSubnetInterface = new NeutronSubnetInterface();
53         ServiceRegistration<INeutronSubnetCRUD> neutronSubnetInterfaceRegistration = context.registerService(INeutronSubnetCRUD.class, neutronSubnetInterface, null);
54         if(neutronSubnetInterfaceRegistration != null) {
55             registrations.add(neutronSubnetInterfaceRegistration);
56         }
57
58         NeutronNetworkInterface neutronNetworkInterface = new NeutronNetworkInterface();
59         ServiceRegistration<INeutronNetworkCRUD> neutronNetworkInterfaceRegistration = context.registerService(INeutronNetworkCRUD.class, neutronNetworkInterface, null);
60         if(neutronNetworkInterfaceRegistration != null) {
61             registrations.add(neutronNetworkInterfaceRegistration);
62         }
63
64         NeutronSecurityGroupInterface neutronSecurityGroupInterface = new NeutronSecurityGroupInterface();
65         ServiceRegistration<INeutronSecurityGroupCRUD> neutronSecurityGroupInterfaceRegistration = context.registerService(INeutronSecurityGroupCRUD.class, neutronSecurityGroupInterface, null);
66         if(neutronSecurityGroupInterfaceRegistration != null) {
67             registrations.add(neutronSecurityGroupInterfaceRegistration);
68         }
69
70         NeutronSecurityRuleInterface neutronSecurityRuleInterface = new NeutronSecurityRuleInterface();
71         ServiceRegistration<INeutronSecurityRuleCRUD> neutronSecurityRuleInterfaceRegistration = context.registerService(INeutronSecurityRuleCRUD.class, neutronSecurityRuleInterface, null);
72         if(neutronSecurityRuleInterfaceRegistration != null) {
73             registrations.add(neutronSecurityRuleInterfaceRegistration);
74         }
75
76         NeutronFirewallInterface neutronFirewallInterface = new NeutronFirewallInterface();
77         ServiceRegistration<INeutronFirewallCRUD> neutronFirewallInterfaceRegistration = context.registerService(INeutronFirewallCRUD.class, neutronFirewallInterface, null);
78         if(neutronFirewallInterfaceRegistration != null) {
79             registrations.add(neutronFirewallInterfaceRegistration);
80         }
81
82         NeutronFirewallPolicyInterface neutronFirewallPolicyInterface = new NeutronFirewallPolicyInterface();
83         ServiceRegistration<INeutronFirewallPolicyCRUD> neutronFirewallPolicyInterfaceRegistration = context.registerService(INeutronFirewallPolicyCRUD.class, neutronFirewallPolicyInterface, null);
84         if(neutronFirewallPolicyInterfaceRegistration != null) {
85             registrations.add(neutronFirewallPolicyInterfaceRegistration);
86         }
87
88         NeutronFirewallRuleInterface neutronFirewallRuleInterface = new NeutronFirewallRuleInterface();
89         ServiceRegistration<INeutronFirewallRuleCRUD> neutronFirewallRuleInterfaceRegistration = context.registerService(INeutronFirewallRuleCRUD.class, neutronFirewallRuleInterface, null);
90         if(neutronFirewallRuleInterfaceRegistration != null) {
91             registrations.add(neutronFirewallRuleInterfaceRegistration);
92         }
93
94         NeutronLoadBalancerInterface neutronLoadBalancerInterface = new NeutronLoadBalancerInterface();
95         ServiceRegistration<INeutronLoadBalancerCRUD> neutronLoadBalancerInterfaceRegistration = context.registerService(INeutronLoadBalancerCRUD.class, neutronLoadBalancerInterface, null);
96         if(neutronFirewallInterfaceRegistration != null) {
97             registrations.add(neutronLoadBalancerInterfaceRegistration);
98         }
99
100         NeutronLoadBalancerPoolInterface neutronLoadBalancerPoolInterface = new NeutronLoadBalancerPoolInterface();
101         ServiceRegistration<INeutronLoadBalancerPoolCRUD> neutronLoadBalancerPoolInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolCRUD.class, neutronLoadBalancerPoolInterface, null);
102         if(neutronLoadBalancerPoolInterfaceRegistration != null) {
103             registrations.add(neutronLoadBalancerPoolInterfaceRegistration);
104         }
105
106         NeutronLoadBalancerListenerInterface neutronLoadBalancerListenerInterface = new NeutronLoadBalancerListenerInterface();
107         ServiceRegistration<INeutronLoadBalancerListenerCRUD> neutronLoadBalancerListenerInterfaceRegistration = context.registerService(INeutronLoadBalancerListenerCRUD.class, neutronLoadBalancerListenerInterface, null);
108         if(neutronLoadBalancerListenerInterfaceRegistration != null) {
109             registrations.add(neutronLoadBalancerListenerInterfaceRegistration);
110         }
111
112         NeutronLoadBalancerHealthMonitorInterface neutronLoadBalancerHealthMonitorInterface = new NeutronLoadBalancerHealthMonitorInterface();
113         ServiceRegistration<INeutronLoadBalancerHealthMonitorCRUD> neutronLoadBalancerHealthMonitorInterfaceRegistration = context.registerService(INeutronLoadBalancerHealthMonitorCRUD.class, neutronLoadBalancerHealthMonitorInterface, null);
114         if(neutronLoadBalancerHealthMonitorInterfaceRegistration != null) {
115             registrations.add(neutronLoadBalancerHealthMonitorInterfaceRegistration);
116         }
117
118         NeutronLoadBalancerPoolMemberInterface neutronLoadBalancerPoolMemberInterface = new NeutronLoadBalancerPoolMemberInterface();
119         ServiceRegistration<INeutronLoadBalancerPoolMemberCRUD> neutronLoadBalancerPoolMemberInterfaceRegistration = context.registerService(INeutronLoadBalancerPoolMemberCRUD.class, neutronLoadBalancerPoolMemberInterface, null);
120         if(neutronLoadBalancerPoolMemberInterfaceRegistration != null) {
121             registrations.add(neutronLoadBalancerPoolMemberInterfaceRegistration);
122         }
123
124     }
125
126     @Override
127     public void stop(BundleContext context) throws Exception {
128        for(ServiceRegistration registration : registrations) {
129            if(registration != null) {
130                registration.unregister();
131            }
132        }
133
134     }
135 }