blob: 78769b4c4c8799f92ab4d169ef2fd0040a6888a2 [file] [log] [blame]
Thomas Vachuska33601602014-11-19 03:32:15 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska33601602014-11-19 03:32:15 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onlab.osgi;
17
18import org.osgi.framework.Bundle;
19import org.osgi.framework.BundleContext;
20import org.osgi.framework.ServiceReference;
21import org.osgi.service.component.ComponentContext;
22import org.osgi.service.component.ComponentInstance;
23
24import java.util.Dictionary;
Ray Milkey911c5192015-09-30 10:56:43 -070025import java.util.Enumeration;
Thomas Vachuska33601602014-11-19 03:32:15 -080026
27/**
28 * Adapter implementation of OSGI component context.
29 */
30public class ComponentContextAdapter implements ComponentContext {
Ray Milkey911c5192015-09-30 10:56:43 -070031 private static class MockDictionary extends Dictionary {
32
33 @Override
34 public int size() {
35 return 0;
36 }
37
38 @Override
39 public boolean isEmpty() {
40 return false;
41 }
42
43 @Override
44 public Enumeration keys() {
45 return null;
46 }
47
48 @Override
49 public Enumeration elements() {
50 return null;
51 }
52
53 @Override
54 public Object get(Object key) {
55 return null;
56 }
57
58 @Override
59 public Object put(Object key, Object value) {
60 return null;
61 }
62
63 @Override
64 public Object remove(Object key) {
65 return null;
66 }
67 }
68
Thomas Vachuska33601602014-11-19 03:32:15 -080069 @Override
70 public Dictionary getProperties() {
Ray Milkey911c5192015-09-30 10:56:43 -070071 return new MockDictionary();
Thomas Vachuska33601602014-11-19 03:32:15 -080072 }
73
74 @Override
75 public Object locateService(String name) {
76 return null;
77 }
78
79 @Override
80 public Object locateService(String name, ServiceReference reference) {
81 return null;
82 }
83
84 @Override
85 public Object[] locateServices(String name) {
86 return new Object[0];
87 }
88
89 @Override
90 public BundleContext getBundleContext() {
91 return null;
92 }
93
94 @Override
95 public Bundle getUsingBundle() {
96 return null;
97 }
98
99 @Override
100 public ComponentInstance getComponentInstance() {
101 return null;
102 }
103
104 @Override
105 public void enableComponent(String name) {
106
107 }
108
109 @Override
110 public void disableComponent(String name) {
111
112 }
113
114 @Override
115 public ServiceReference getServiceReference() {
116 return null;
117 }
118}