1 22 package org.jboss.kernel.plugins.bootstrap.basic; 23 24 import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap; 25 import org.jboss.kernel.plugins.config.property.PropertyKernelConfig; 26 import org.jboss.kernel.spi.config.KernelConfig; 27 28 import java.security.AccessController ; 29 import java.security.PrivilegedAction ; 30 import java.util.Properties ; 31 32 39 public class BasicBootstrap extends AbstractBootstrap 40 { 41 47 public static void main(String [] args) throws Exception 48 { 49 BasicBootstrap bootstrap = new BasicBootstrap(); 50 bootstrap.run(); 51 } 52 53 57 public BasicBootstrap() 58 { 59 Properties props = getConfigProperties(); 60 if (props == null) 61 props = getSystemProperties(); 62 final PropertyKernelConfig config = new PropertyKernelConfig(props); 63 PrivilegedAction <?> action = new PrivilegedAction () 64 { 65 public Object run() 66 { 67 setConfig(config); 68 return null; 69 } 70 }; 71 AccessController.doPrivileged(action); 72 } 73 74 80 public BasicBootstrap(final KernelConfig config) throws Exception 81 { 82 PrivilegedAction <?> action = new PrivilegedAction () 83 { 84 public Object run() 85 { 86 setConfig(config); 87 return null; 88 } 89 }; 90 AccessController.doPrivileged(action); 91 } 92 93 98 protected Properties getConfigProperties() 99 { 100 return null; 101 } 102 103 private Properties getSystemProperties() 104 { 105 if (System.getSecurityManager() == null) 106 return System.getProperties(); 107 else 108 { 109 return AccessController.doPrivileged(GetSystemProperties.instance); 110 } 111 } 112 113 private static class GetSystemProperties implements PrivilegedAction <Properties > 114 { 115 private static GetSystemProperties instance = new GetSystemProperties(); 116 117 public Properties run() 118 { 119 return System.getProperties(); 120 } 121 } 122 } 123 | Popular Tags |