1 11 12 package org.eclipse.osgi.framework.internal.core; 13 14 import java.io.IOException ; 15 import java.io.InputStream ; 16 import java.net.URL ; 17 import java.security.Permission ; 18 import java.security.ProtectionDomain ; 19 import org.eclipse.osgi.framework.debug.Debug; 20 import org.osgi.framework.*; 21 22 27 28 public class SystemBundle extends BundleHost { 29 30 ProtectionDomain systemDomain; 31 32 40 protected SystemBundle(Framework framework) throws BundleException { 41 super(framework.adaptor.createSystemBundleData(), framework); Constants.setInternalSymbolicName(bundledata.getSymbolicName()); 43 state = Bundle.RESOLVED; 44 context = createContext(); 45 } 46 47 52 protected void load() { 53 SecurityManager sm = System.getSecurityManager(); 54 55 if (sm != null) { 56 systemDomain = getClass().getProtectionDomain(); 57 } 58 } 59 60 67 protected boolean reload(AbstractBundle newBundle) { 68 return (false); 69 } 70 71 76 protected void refresh() { 77 } 79 80 86 protected boolean unload() { 87 return (false); 88 } 89 90 96 protected void close() { 97 context.close(); 98 context = null; 99 100 state = UNINSTALLED; 101 } 102 103 111 protected Class loadClass(String name, boolean checkPermission) throws ClassNotFoundException { 112 if (checkPermission) { 113 framework.checkAdminPermission(this, AdminPermission.CLASS); 114 checkValid(); 115 } 116 return (Class.forName(name)); 117 } 118 119 123 public URL getResource(String name) { 124 return (null); 125 } 126 127 131 protected boolean isUnresolved() { 132 return (false); 133 } 134 135 140 public void start() { 141 framework.checkAdminPermission(this, AdminPermission.EXECUTE); 142 } 143 144 149 protected void resume() { 150 151 framework.startLevelManager.initialize(); 152 153 framework.startLevelManager.launch(framework.startLevelManager.getFrameworkStartLevel()); 154 155 } 156 157 162 public void stop() { 163 framework.checkAdminPermission(this, AdminPermission.EXECUTE); 164 165 if (state == ACTIVE) { 166 Thread shutdown = framework.secureAction.createThread(new Runnable () { 167 public void run() { 168 try { 169 framework.shutdown(); 170 } catch (Throwable t) { 171 framework.adaptor.handleRuntimeError(t); 173 } 174 } 175 }, "System Bundle Shutdown"); 177 shutdown.start(); 178 } 179 } 180 181 186 protected void suspend() { 187 188 framework.startLevelManager.shutdown(); 189 framework.startLevelManager.cleanup(); 190 191 192 framework.packageAdmin.cleanup(); 193 194 if (Debug.DEBUG && Debug.DEBUG_GENERAL) { 195 Debug.println("->Framework shutdown"); } 197 framework.publishBundleEvent(BundleEvent.STOPPED, this); 200 } 201 202 protected void suspend(boolean lock) { 203 } 205 206 212 public void update() { 213 framework.checkAdminPermission(this, AdminPermission.LIFECYCLE); 214 215 if (state == ACTIVE) { 216 Thread restart = framework.secureAction.createThread(new Runnable () { 217 public void run() { 218 framework.shutdown(); 219 220 framework.launch(); 221 } 222 }, "System Bundle Update"); 224 restart.start(); 225 } 226 } 227 228 234 public void update(InputStream in) { 235 update(); 236 237 try { 238 in.close(); 239 } catch (IOException e) { 240 } 242 } 243 244 249 public void uninstall() throws BundleException { 250 framework.checkAdminPermission(this, AdminPermission.LIFECYCLE); 251 252 throw new BundleException(Msg.BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION); 253 } 254 255 263 public boolean hasPermission(Object permission) { 264 if (systemDomain != null) { 265 if (permission instanceof Permission ) { 266 return systemDomain.implies((Permission ) permission); 267 } 268 269 return false; 270 } 271 272 return true; 273 } 274 275 282 protected void unresolvePermissions(AbstractBundle[] refreshedBundles) { 283 } 285 } 286 | Popular Tags |