1 22 package org.jboss.kernel; 23 24 import org.jboss.kernel.spi.config.KernelConfig; 25 import org.jboss.kernel.spi.config.KernelConfigurator; 26 import org.jboss.kernel.spi.dependency.KernelController; 27 import org.jboss.kernel.spi.event.KernelEventManager; 28 import org.jboss.kernel.spi.metadata.KernelMetaDataRepository; 29 import org.jboss.kernel.spi.registry.KernelBus; 30 import org.jboss.kernel.spi.registry.KernelRegistry; 31 32 41 public class Kernel 42 { 43 44 public static final KernelPermission ACCESS = new KernelPermission("access"); 45 46 47 public static final KernelPermission CONFIGURE = new KernelPermission("configure"); 48 49 50 private static final boolean enablePermissionChecking; 51 52 53 protected KernelBus bus; 54 55 56 protected KernelConfig config; 57 58 59 protected KernelConfigurator configurator; 60 61 62 protected KernelController controller; 63 64 65 protected KernelEventManager eventManager; 66 67 68 protected KernelMetaDataRepository metaDataRepository; 69 70 71 protected KernelRegistry registry; 72 73 static 74 { 75 boolean checkingEnabled = false; 76 try 77 { 78 79 checkingEnabled = Boolean.getBoolean(KernelPermission.class.getName()); 80 } 81 catch (Throwable ignored) 82 { 83 } 84 enablePermissionChecking = checkingEnabled; 85 } 86 87 92 public static void checkAccess() 93 { 94 if (enablePermissionChecking) 95 { 96 SecurityManager sm = System.getSecurityManager(); 97 if (sm != null) 98 sm.checkPermission(ACCESS); 99 } 100 } 101 102 107 public static void checkConfigure() 108 { 109 if (enablePermissionChecking) 110 { 111 SecurityManager sm = System.getSecurityManager(); 112 if (sm != null) 113 sm.checkPermission(CONFIGURE); 114 } 115 } 116 117 123 public KernelBus getBus() 124 { 125 checkAccess(); 126 return bus; 127 } 128 129 135 public void setBus(KernelBus bus) 136 { 137 checkConfigure(); 138 this.bus = bus; 139 } 140 141 147 public KernelConfig getConfig() 148 { 149 checkAccess(); 150 return config; 151 } 152 153 159 public void setConfig(KernelConfig config) 160 { 161 checkConfigure(); 162 this.config = config; 163 } 164 165 171 public KernelConfigurator getConfigurator() 172 { 173 checkAccess(); 174 return configurator; 175 } 176 177 183 public void setConfigurator(KernelConfigurator configurator) 184 { 185 checkConfigure(); 186 this.configurator = configurator; 187 } 188 189 195 public KernelController getController() 196 { 197 checkAccess(); 198 return controller; 199 } 200 201 207 public void setController(KernelController controller) 208 { 209 checkConfigure(); 210 this.controller = controller; 211 } 212 213 219 public KernelEventManager getEventManager() 220 { 221 checkAccess(); 222 return eventManager; 223 } 224 225 231 public void setEventManager(KernelEventManager eventManager) 232 { 233 checkConfigure(); 234 this.eventManager = eventManager; 235 } 236 237 243 public KernelRegistry getRegistry() 244 { 245 checkAccess(); 246 return registry; 247 } 248 249 255 public void setRegistry(KernelRegistry registry) 256 { 257 checkConfigure(); 258 this.registry = registry; 259 } 260 261 267 public KernelMetaDataRepository getMetaDataRepository() 268 { 269 checkAccess(); 270 return metaDataRepository; 271 } 272 273 279 public void setMetaDataRepository(KernelMetaDataRepository metaDataRepository) 280 { 281 checkConfigure(); 282 this.metaDataRepository = metaDataRepository; 283 } 284 } 285 | Popular Tags |