001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 */ 019package org.nuxeo.osgi.services; 020 021import org.nuxeo.osgi.OSGiAdapter; 022import org.osgi.framework.Bundle; 023import org.osgi.service.packageadmin.ExportedPackage; 024import org.osgi.service.packageadmin.PackageAdmin; 025import org.osgi.service.packageadmin.RequiredBundle; 026 027/** 028 * Dummy implementation of {@link PackageAdmin} service. Only {@link PackageAdmin#getBundles(String, String)} is 029 * implemented 030 * 031 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 032 */ 033public class PackageAdminImpl implements PackageAdmin { 034 035 protected OSGiAdapter osgi; 036 037 public PackageAdminImpl(OSGiAdapter osgi) { 038 this.osgi = osgi; 039 } 040 041 @Override 042 public Bundle[] getBundles(String symbolicName, String versionRange) { 043 return new Bundle[] { osgi.getBundle(symbolicName) }; 044 } 045 046 @Override 047 public ExportedPackage[] getExportedPackages(Bundle bundle) { 048 throw new UnsupportedOperationException("Not implemented"); 049 } 050 051 @Override 052 public ExportedPackage[] getExportedPackages(String name) { 053 throw new UnsupportedOperationException("Not implemented"); 054 } 055 056 @Override 057 public ExportedPackage getExportedPackage(String name) { 058 throw new UnsupportedOperationException("Not implemented"); 059 } 060 061 @Override 062 public void refreshPackages(Bundle[] bundles) { 063 throw new UnsupportedOperationException("Not implemented"); 064 } 065 066 @Override 067 public boolean resolveBundles(Bundle[] bundles) { 068 throw new UnsupportedOperationException("Not implemented"); 069 } 070 071 @Override 072 public RequiredBundle[] getRequiredBundles(String symbolicName) { 073 throw new UnsupportedOperationException("Not implemented"); 074 } 075 076 @Override 077 public Bundle[] getFragments(Bundle bundle) { 078 return osgi.getRegistry().getFragments(bundle.getSymbolicName()); 079 } 080 081 @Override 082 public Bundle[] getHosts(Bundle bundle) { 083 throw new UnsupportedOperationException("Not implemented"); 084 } 085 086 @Override 087 public Bundle getBundle(Class clazz) { 088 throw new UnsupportedOperationException("Not implemented"); 089 } 090 091 @Override 092 public int getBundleType(Bundle bundle) { 093 throw new UnsupportedOperationException("Not implemented"); 094 } 095 096}