Thomas Vachuska | 3360160 | 2014-11-19 03:32:15 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 3360160 | 2014-11-19 03:32:15 -0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onlab.osgi; |
| 17 | |
| 18 | import org.osgi.framework.Bundle; |
| 19 | import org.osgi.framework.BundleContext; |
| 20 | import org.osgi.framework.ServiceReference; |
| 21 | import org.osgi.service.component.ComponentContext; |
| 22 | import org.osgi.service.component.ComponentInstance; |
| 23 | |
| 24 | import java.util.Dictionary; |
Ray Milkey | 911c519 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 25 | import java.util.Enumeration; |
Thomas Vachuska | 3360160 | 2014-11-19 03:32:15 -0800 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Adapter implementation of OSGI component context. |
| 29 | */ |
| 30 | public class ComponentContextAdapter implements ComponentContext { |
Ray Milkey | 911c519 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 31 | 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 Vachuska | 3360160 | 2014-11-19 03:32:15 -0800 | [diff] [blame] | 69 | @Override |
| 70 | public Dictionary getProperties() { |
Ray Milkey | 911c519 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 71 | return new MockDictionary(); |
Thomas Vachuska | 3360160 | 2014-11-19 03:32:15 -0800 | [diff] [blame] | 72 | } |
| 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 | } |