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;
037import org.osgi.framework.ServiceFactory;
038import org.osgi.framework.ServiceObjects;
039
040/**
041 * BundleContext for DelegatingBundle. 
042 * 
043 * @version $Rev: 1308440 $ $Date: 2012-04-02 19:55:44 +0200 (Mon, 02 Apr 2012) $
044 */
045public class DelegatingBundleContext implements BundleContext {
046
047    private DelegatingBundle bundle;
048    private BundleContext bundleContext;
049    
050    public DelegatingBundleContext(DelegatingBundle bundle, BundleContext bundleContext) {
051        this.bundle = bundle;
052        this.bundleContext = bundleContext;
053    }
054    
055    public Bundle getBundle() {
056        return bundle;
057    }
058        
059    public void addBundleListener(BundleListener arg0) {
060        bundleContext.addBundleListener(arg0);
061    }
062
063    public void addFrameworkListener(FrameworkListener arg0) {
064        bundleContext.addFrameworkListener(arg0);
065    }
066
067    public void addServiceListener(ServiceListener arg0, String arg1) throws InvalidSyntaxException {
068        bundleContext.addServiceListener(arg0, arg1);
069    }
070
071    public void addServiceListener(ServiceListener arg0) {
072        bundleContext.addServiceListener(arg0);
073    }
074
075    public Filter createFilter(String arg0) throws InvalidSyntaxException {
076        return bundleContext.createFilter(arg0);
077    }
078
079    public Bundle getBundle(long arg0) {
080        return bundleContext.getBundle(arg0);
081    }
082
083    public Bundle[] getBundles() {
084        return bundleContext.getBundles();
085    }
086
087    public File getDataFile(String arg0) {
088        return bundleContext.getDataFile(arg0);
089    }
090
091    public String getProperty(String arg0) {
092        return bundleContext.getProperty(arg0);
093    }
094
095    public <S> S getService(ServiceReference<S> reference) {
096        return bundleContext.getService(reference);
097    }
098
099    public ServiceReference<?> getServiceReference(String clazz) {
100        return bundleContext.getServiceReference(clazz);
101    }
102
103    public ServiceReference<?>[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
104        return bundleContext.getServiceReferences(clazz, filter);
105    }
106
107    public <S> ServiceReference<S> getServiceReference(Class<S> clazz) {
108        return bundleContext.getServiceReference(clazz);
109    }
110
111    public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S> clazz, String filter) throws InvalidSyntaxException {
112        return bundleContext.getServiceReferences(clazz, filter);
113    }
114    
115    public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
116        return bundleContext.getAllServiceReferences(clazz, filter);
117    }
118    
119    public Bundle installBundle(String arg0, InputStream arg1) throws BundleException {
120        return bundleContext.installBundle(arg0, arg1);
121    }
122
123    public Bundle installBundle(String arg0) throws BundleException {
124        return bundleContext.installBundle(arg0);
125    }
126
127    public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties) {
128        return bundleContext.registerService(clazz, service, properties);
129    }
130
131    public ServiceRegistration<?> registerService(String[] classes, Object service, Dictionary<String, ?> properties) {
132        return bundleContext.registerService(classes, service, properties);
133    }
134    
135    public <S> ServiceRegistration<S> registerService(Class<S> clazz, S service, Dictionary<String, ?> properties) {
136        return bundleContext.registerService(clazz, service, properties);
137    }
138
139    public void removeBundleListener(BundleListener arg0) {
140        bundleContext.removeBundleListener(arg0);
141    }
142
143    public void removeFrameworkListener(FrameworkListener arg0) {
144        bundleContext.removeFrameworkListener(arg0);
145    }
146
147    public void removeServiceListener(ServiceListener arg0) {
148        bundleContext.removeServiceListener(arg0);
149    }
150
151    public boolean ungetService(ServiceReference<?> reference) {
152        return bundleContext.ungetService(reference);
153    }
154
155    public Bundle getBundle(String location) {
156        return bundleContext.getBundle(location);
157    }
158    public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference) {
159        throw new UnsupportedOperationException();
160    }
161    public <S> ServiceRegistration<S> registerService(Class<S> clazz, ServiceFactory<S> factory, Dictionary<String, ?> properties) {
162        throw new UnsupportedOperationException();
163    }
164
165}