RequiredBundleImpl.java

00001 /*
00002  * Copyright (c) 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 org.osgi.framework.Bundle;
00038 import org.osgi.service.packageadmin.RequiredBundle;
00039 import org.osgi.framework.Version;
00040 import java.util.List;
00041 
00046 public class RequiredBundleImpl implements RequiredBundle
00047 {
00048 
00051   private BundlePackages bpkgs;
00052 
00056   RequiredBundleImpl(BundlePackages b) {
00057     bpkgs = b;
00058   }
00059 
00060 
00066   public String getSymbolicName() {
00067     return bpkgs.bundle.symbolicName;
00068   }
00069 
00070 
00077   public Bundle getBundle() {
00078     if (bpkgs.isRegistered()) {
00079       return (Bundle)bpkgs.bundle;
00080     } else {
00081       return null;
00082     }
00083   }
00084 
00085 
00098   public Bundle[] getRequiringBundles() {
00099     if (bpkgs.isRegistered()) {
00100       List rl = bpkgs.getRequiredBy();
00101       Bundle[] res = new Bundle[rl.size()];
00102       for (int i = rl.size() - 1; i >= 0; i--) {
00103         res[i] = ((BundlePackages)rl.get(i)).bundle;
00104       }
00105       return res;
00106     }
00107     return null;
00108   }
00109 
00110 
00118   public Version getVersion() {
00119     return bpkgs.bundle.version;
00120   }
00121 
00122 
00131   public boolean isRemovalPending() {
00132     return bpkgs.bundle.bpkgs != bpkgs;
00133   }
00134 
00135 }

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