1 36 package org.ungoverned.oscar; 37 38 import java.io.InputStream ; 39 import java.net.URL ; 40 import java.util.Dictionary ; 41 42 import org.osgi.framework.Bundle; 43 import org.osgi.framework.BundleException; 44 import org.osgi.framework.ServiceReference; 45 46 class BundleImpl implements Bundle 47 { 48 private Oscar m_oscar = null; 49 private BundleInfo m_info = null; 50 51 protected BundleImpl(Oscar oscar, BundleInfo info) 52 { 53 m_oscar = oscar; 54 m_info = info; 55 } 56 57 Oscar getOscar() { 59 return m_oscar; 60 } 61 62 BundleInfo getInfo() { 64 return m_info; 65 } 66 67 void setInfo(BundleInfo info) { 69 m_info = info; 70 } 71 72 public long getBundleId() 73 { 74 return m_oscar.getBundleId(this); 75 } 76 77 public Dictionary getHeaders() 78 { 79 return m_oscar.getBundleHeaders(this); 80 } 81 82 public String getLocation() 83 { 84 return m_oscar.getBundleLocation(this); 85 } 86 87 92 public URL getResource(String name) 93 { 94 return m_oscar.getBundleResource(this, name); 95 } 96 97 103 public ServiceReference[] getRegisteredServices() 104 { 105 Oscar.debug("BundleImpl.getRegisteredServices()"); 106 return m_oscar.getBundleRegisteredServices(this); 107 } 108 109 public ServiceReference[] getServicesInUse() 110 { 111 Oscar.debug("BundleImpl.getServicesInUse()"); 112 return m_oscar.getBundleServicesInUse(this); 113 } 114 115 public int getState() 116 { 117 return m_oscar.getBundleState(this); 118 } 119 120 public boolean hasPermission(Object obj) 121 { 122 return m_oscar.bundleHasPermission(this, obj); 123 } 124 125 public void start() throws BundleException 126 { 127 Oscar.debug("BundleImpl.start() for " + getInfo().getLocation()); 128 m_oscar.startBundle(this); 129 } 130 131 public void update() throws BundleException 132 { 133 update(null); 134 } 135 136 public void update(InputStream is) throws BundleException 137 { 138 Oscar.debug("BundleImpl.update() for " + getInfo().getLocation()); 139 m_oscar.updateBundle(this, is); 140 } 141 142 public void stop() throws BundleException 143 { 144 Oscar.debug("BundleImpl.stop() for " + getInfo().getLocation()); 145 m_oscar.stopBundle(this); 146 } 147 148 public void uninstall() throws BundleException 149 { 150 Oscar.debug("BundleImpl.uninstall() for " + getInfo().getLocation()); 151 m_oscar.uninstallBundle(this); 152 } 153 154 public String toString() 155 { 156 return "[" + getBundleId() +"]"; 157 } 158 } | Popular Tags |