001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.xbean.osgi.bundle.util; 021 022import java.io.File; 023import java.io.InputStream; 024import java.util.Collection; 025import java.util.Dictionary; 026 027import org.osgi.framework.Bundle; 028import org.osgi.framework.BundleContext; 029import org.osgi.framework.BundleException; 030import org.osgi.framework.BundleListener; 031import org.osgi.framework.Filter; 032import org.osgi.framework.FrameworkListener; 033import org.osgi.framework.InvalidSyntaxException; 034import org.osgi.framework.ServiceListener; 035import org.osgi.framework.ServiceReference; 036import org.osgi.framework.ServiceRegistration; 037 038/** 039 * BundleContext for DelegatingBundle. 040 * 041 * @version $Rev: 1308440 $ $Date: 2012-04-02 19:55:44 +0200 (Mon, 02 Apr 2012) $ 042 */ 043public class DelegatingBundleContext implements BundleContext { 044 045 private DelegatingBundle bundle; 046 private BundleContext bundleContext; 047 048 public DelegatingBundleContext(DelegatingBundle bundle, BundleContext bundleContext) { 049 this.bundle = bundle; 050 this.bundleContext = bundleContext; 051 } 052 053 public Bundle getBundle() { 054 return bundle; 055 } 056 057 public void addBundleListener(BundleListener arg0) { 058 bundleContext.addBundleListener(arg0); 059 } 060 061 public void addFrameworkListener(FrameworkListener arg0) { 062 bundleContext.addFrameworkListener(arg0); 063 } 064 065 public void addServiceListener(ServiceListener arg0, String arg1) throws InvalidSyntaxException { 066 bundleContext.addServiceListener(arg0, arg1); 067 } 068 069 public void addServiceListener(ServiceListener arg0) { 070 bundleContext.addServiceListener(arg0); 071 } 072 073 public Filter createFilter(String arg0) throws InvalidSyntaxException { 074 return bundleContext.createFilter(arg0); 075 } 076 077 public Bundle getBundle(long arg0) { 078 return bundleContext.getBundle(arg0); 079 } 080 081 public Bundle[] getBundles() { 082 return bundleContext.getBundles(); 083 } 084 085 public File getDataFile(String arg0) { 086 return bundleContext.getDataFile(arg0); 087 } 088 089 public String getProperty(String arg0) { 090 return bundleContext.getProperty(arg0); 091 } 092 093 public <S> S getService(ServiceReference<S> reference) { 094 return bundleContext.getService(reference); 095 } 096 097 public ServiceReference<?> getServiceReference(String clazz) { 098 return bundleContext.getServiceReference(clazz); 099 } 100 101 public ServiceReference<?>[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException { 102 return bundleContext.getServiceReferences(clazz, filter); 103 } 104 105 public <S> ServiceReference<S> getServiceReference(Class<S> clazz) { 106 return bundleContext.getServiceReference(clazz); 107 } 108 109 public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException { 110 return bundleContext.getServiceReferences(clazz, filter); 111 } 112 113 public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException { 114 return bundleContext.getAllServiceReferences(clazz, filter); 115 } 116 117 public Bundle installBundle(String arg0, InputStream arg1) throws BundleException { 118 return bundleContext.installBundle(arg0, arg1); 119 } 120 121 public Bundle installBundle(String arg0) throws BundleException { 122 return bundleContext.installBundle(arg0); 123 } 124 125 public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties) { 126 return bundleContext.registerService(clazz, service, properties); 127 } 128 129 public ServiceRegistration<?> registerService(String[] classes, Object service, Dictionary<String, ?> properties) { 130 return bundleContext.registerService(classes, service, properties); 131 } 132 133 public <S> ServiceRegistration<S> registerService(Class<S> clazz, S service, Dictionary<String, ?> properties) { 134 return bundleContext.registerService(clazz, service, properties); 135 } 136 137 public void removeBundleListener(BundleListener arg0) { 138 bundleContext.removeBundleListener(arg0); 139 } 140 141 public void removeFrameworkListener(FrameworkListener arg0) { 142 bundleContext.removeFrameworkListener(arg0); 143 } 144 145 public void removeServiceListener(ServiceListener arg0) { 146 bundleContext.removeServiceListener(arg0); 147 } 148 149 public boolean ungetService(ServiceReference<?> reference) { 150 return bundleContext.ungetService(reference); 151 } 152 153 public Bundle getBundle(String location) { 154 return bundleContext.getBundle(location); 155 } 156 157}