1 18 19 package org.osgi.service.application; 20 21 import org.osgi.framework.Constants; 22 23 29 public abstract class ApplicationHandle { 30 36 37 41 public static final String APPLICATION_PID = Constants.SERVICE_PID; 42 43 46 public final static String APPLICATION_DESCRIPTOR = "application.descriptor"; 47 48 51 public final static String APPLICATION_STATE = "application.state"; 52 53 57 public final static String RUNNING = "RUNNING"; 58 59 64 public final static String STOPPING = "STOPPING"; 65 66 private final String instanceId; 67 68 private final ApplicationDescriptor descriptor; 69 70 94 protected ApplicationHandle(String instanceId, ApplicationDescriptor descriptor ) { 95 if( (null == instanceId) || (null == descriptor) ) { 96 throw new NullPointerException ("Parameters must not be null!"); 97 } 98 99 this.instanceId = instanceId; 100 this.descriptor = descriptor; 101 } 102 103 109 public final ApplicationDescriptor getApplicationDescriptor() { 110 return descriptor; 111 } 112 113 121 public abstract String getState(); 122 123 129 public final String getInstanceId() { 130 return instanceId; 131 } 132 133 162 public final void destroy() { 163 if (STOPPING.equals(getState())) 164 return; 165 SecurityManager sm = System.getSecurityManager(); 166 if (sm != null) 167 sm.checkPermission(new ApplicationAdminPermission(getApplicationDescriptor(), ApplicationAdminPermission.LIFECYCLE_ACTION)); 168 destroySpecific(); 169 } 170 171 178 protected abstract void destroySpecific(); 179 180 181 } 182 | Popular Tags |