ExportedPackageImpl.java

00001 /*
00002  * Copyright (c) 2003-2006, KNOPFLERFISH project
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following
00007  * conditions are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  *
00012  * - Redistributions in binary form must reproduce the above
00013  *   copyright notice, this list of conditions and the following
00014  *   disclaimer in the documentation and/or other materials
00015  *   provided with the distribution.
00016  *
00017  * - Neither the name of the KNOPFLERFISH project nor the names of its
00018  *   contributors may be used to endorse or promote products derived
00019  *   from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00027  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00030  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00032  * OF THE POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 package org.knopflerfish.framework;
00036 
00037 import java.util.Collection;
00038 import java.util.List;
00039 
00040 
00041 import org.osgi.framework.*;
00042 import org.osgi.service.packageadmin.ExportedPackage;
00043 
00044 
00061 public class ExportedPackageImpl implements ExportedPackage {
00062 
00063   final private ExportPkg pkg;
00064 
00065   ExportedPackageImpl(ExportPkg pkg) {
00066     this.pkg = pkg;
00067   }
00068 
00069 
00075   public String getName() {
00076     return pkg.name;
00077   }
00078 
00079 
00086   public Bundle getExportingBundle() {
00087     if (pkg.pkg != null) {
00088       return pkg.bpkgs.bundle;
00089     } else {
00090       return null;
00091     }
00092   }
00093 
00094 
00107   public Bundle[] getImportingBundles() {
00108     Collection imps = pkg.getPackageImporters();
00109     if (imps != null) {
00110       int size = imps.size();
00111       List rl = pkg.bpkgs.getRequiredBy(); 
00112       int rsize = rl.size() ;
00113       Bundle[] res = new Bundle[size + rsize];
00114       imps.toArray(res);
00115       for (int i = 0; i < rsize; i++) {
00116         res[size + i] = ((BundlePackages)rl.get(i)).bundle;
00117       }
00118       return res;
00119     } else {
00120       return null;
00121     }
00122   }
00123 
00124   
00132   public String getSpecificationVersion() {
00133     return pkg.version.toString();
00134   }
00135 
00136   
00145   public boolean isRemovalPending() {
00146     // TBD, check this
00147     if (pkg.isProvider()) {
00148       return pkg.zombie;
00149     } else {
00150       return false;
00151     }
00152   }
00153 
00154 
00155   public Version getVersion() {
00156     return pkg.version;
00157   }
00158 
00159 }

Generated on Mon Jan 11 21:19:14 2010 for OpenMobileIS by  doxygen 1.5.4