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 020 package org.apache.xbean.osgi.bundle.util; 021 022 import java.io.File; 023 import java.io.InputStream; 024 import java.util.Dictionary; 025 026 import org.osgi.framework.Bundle; 027 import org.osgi.framework.BundleContext; 028 import org.osgi.framework.BundleException; 029 import org.osgi.framework.BundleListener; 030 import org.osgi.framework.Filter; 031 import org.osgi.framework.FrameworkListener; 032 import org.osgi.framework.InvalidSyntaxException; 033 import org.osgi.framework.ServiceListener; 034 import org.osgi.framework.ServiceReference; 035 import org.osgi.framework.ServiceRegistration; 036 037 /** 038 * BundleContext for DelegatingBundle. 039 * 040 * @version $Rev: 937957 $ $Date: 2010-04-26 10:00:08 +0200 (Mon, 26 Apr 2010) $ 041 */ 042 public class DelegatingBundleContext implements BundleContext { 043 044 private DelegatingBundle bundle; 045 private BundleContext bundleContext; 046 047 public DelegatingBundleContext(DelegatingBundle bundle, BundleContext bundleContext) { 048 this.bundle = bundle; 049 this.bundleContext = bundleContext; 050 } 051 052 public Bundle getBundle() { 053 return bundle; 054 } 055 056 public void addBundleListener(BundleListener arg0) { 057 bundleContext.addBundleListener(arg0); 058 } 059 060 public void addFrameworkListener(FrameworkListener arg0) { 061 bundleContext.addFrameworkListener(arg0); 062 } 063 064 public void addServiceListener(ServiceListener arg0, String arg1) throws InvalidSyntaxException { 065 bundleContext.addServiceListener(arg0, arg1); 066 } 067 068 public void addServiceListener(ServiceListener arg0) { 069 bundleContext.addServiceListener(arg0); 070 } 071 072 public Filter createFilter(String arg0) throws InvalidSyntaxException { 073 return bundleContext.createFilter(arg0); 074 } 075 076 public ServiceReference[] getAllServiceReferences(String arg0, String arg1) 077 throws InvalidSyntaxException { 078 return bundleContext.getAllServiceReferences(arg0, arg1); 079 } 080 081 public Bundle getBundle(long arg0) { 082 return bundleContext.getBundle(arg0); 083 } 084 085 public Bundle[] getBundles() { 086 return bundleContext.getBundles(); 087 } 088 089 public File getDataFile(String arg0) { 090 return bundleContext.getDataFile(arg0); 091 } 092 093 public String getProperty(String arg0) { 094 return bundleContext.getProperty(arg0); 095 } 096 097 public Object getService(ServiceReference arg0) { 098 return bundleContext.getService(arg0); 099 } 100 101 public ServiceReference getServiceReference(String arg0) { 102 return bundleContext.getServiceReference(arg0); 103 } 104 105 public ServiceReference[] getServiceReferences(String arg0, String arg1) 106 throws InvalidSyntaxException { 107 return bundleContext.getServiceReferences(arg0, arg1); 108 } 109 110 public Bundle installBundle(String arg0, InputStream arg1) throws BundleException { 111 return bundleContext.installBundle(arg0, arg1); 112 } 113 114 public Bundle installBundle(String arg0) throws BundleException { 115 return bundleContext.installBundle(arg0); 116 } 117 118 public ServiceRegistration registerService(String arg0, Object arg1, Dictionary arg2) { 119 return bundleContext.registerService(arg0, arg1, arg2); 120 } 121 122 public ServiceRegistration registerService(String[] arg0, Object arg1, Dictionary arg2) { 123 return bundleContext.registerService(arg0, arg1, arg2); 124 } 125 126 public void removeBundleListener(BundleListener arg0) { 127 bundleContext.removeBundleListener(arg0); 128 } 129 130 public void removeFrameworkListener(FrameworkListener arg0) { 131 bundleContext.removeFrameworkListener(arg0); 132 } 133 134 public void removeServiceListener(ServiceListener arg0) { 135 bundleContext.removeServiceListener(arg0); 136 } 137 138 public boolean ungetService(ServiceReference arg0) { 139 return bundleContext.ungetService(arg0); 140 } 141 142 }