BUG-113: switch BGP to proper activators
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / osgi / OSGiBGPExtensionConsumerContext.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  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 package org.opendaylight.protocol.bgp.parser.spi.osgi;
9
10 import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
11 import org.opendaylight.protocol.bgp.parser.spi.AttributeRegistry;
12 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
13 import org.opendaylight.protocol.bgp.parser.spi.CapabilityRegistry;
14 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
15 import org.opendaylight.protocol.bgp.parser.spi.NlriRegistry;
16 import org.opendaylight.protocol.bgp.parser.spi.ParameterRegistry;
17 import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
18 import org.opendaylight.protocol.concepts.AbstractRegistration;
19 import org.osgi.framework.BundleContext;
20 import org.osgi.framework.ServiceRegistration;
21
22 import com.google.common.base.Preconditions;
23
24 class OSGiBGPExtensionConsumerContext implements BGPExtensionConsumerContext {
25         protected final BundleContext bundleContext;
26
27         OSGiBGPExtensionConsumerContext(final BundleContext context) {
28                 this.bundleContext = Preconditions.checkNotNull(context);
29         }
30
31         protected <T> AutoCloseable register(final Class<T> clazz, final T object) {
32                 final ServiceRegistration<T> reg = bundleContext.registerService(clazz, object, null);
33
34                 return new AbstractRegistration() {
35                         @Override
36                         protected void removeRegistration() {
37                                 reg.unregister();
38                         }
39                 };
40         }
41
42         public BundleContext getBundleContext() {
43                 return bundleContext;
44         }
45
46         @Override
47         public AddressFamilyRegistry getAddressFamilyRegistry() {
48                 // TODO Auto-generated method stub
49                 return null;
50         }
51
52         @Override
53         public AttributeRegistry getAttributeRegistry() {
54                 // TODO Auto-generated method stub
55                 return null;
56         }
57
58         @Override
59         public CapabilityRegistry getCapabilityRegistry() {
60                 // TODO Auto-generated method stub
61                 return null;
62         }
63
64         @Override
65         public MessageRegistry getMessageRegistry() {
66                 // TODO Auto-generated method stub
67                 return null;
68         }
69
70         @Override
71         public NlriRegistry getNlriRegistry() {
72                 // TODO Auto-generated method stub
73                 return null;
74         }
75
76         @Override
77         public ParameterRegistry getParameterRegistry() {
78                 // TODO Auto-generated method stub
79                 return null;
80         }
81
82         @Override
83         public SubsequentAddressFamilyRegistry getSubsequentAddressFamilyRegistry() {
84                 // TODO Auto-generated method stub
85                 return null;
86         }
87
88 }