1 22 package org.jboss.kernel.plugins.bootstrap.basic; 23 24 import org.jboss.kernel.Kernel; 25 import org.jboss.kernel.plugins.bootstrap.AbstractKernelInitializer; 26 import org.jboss.kernel.plugins.registry.AbstractKernelRegistryEntry; 27 import org.jboss.kernel.spi.config.KernelConfigurator; 28 import org.jboss.kernel.spi.dependency.KernelController; 29 import org.jboss.kernel.spi.event.KernelEventManager; 30 import org.jboss.kernel.spi.metadata.KernelMetaDataRepository; 31 import org.jboss.kernel.spi.registry.KernelBus; 32 import org.jboss.kernel.spi.registry.KernelRegistry; 33 import org.jboss.kernel.spi.registry.KernelRegistryEntry; 34 35 41 public class BasicKernelInitializer extends AbstractKernelInitializer 42 { 43 48 public BasicKernelInitializer() throws Exception 49 { 50 } 51 52 public void initKernel(Kernel kernel) throws Throwable 53 { 54 KernelMetaDataRepository metaDataRepository = createKernelMetaDataRepository(kernel); 55 if (trace) 56 log.trace("Using MetaDataRepository: " + metaDataRepository); 57 kernel.setMetaDataRepository(metaDataRepository); 58 59 KernelRegistry registry = createKernelRegistry(kernel); 60 if (trace) 61 log.trace("Using Registry: " + registry); 62 registry.setKernel(kernel); 63 kernel.setRegistry(registry); 64 65 KernelEventManager eventManager = createKernelEventManager(kernel); 66 if (trace) 67 log.trace("Using EventManager: " + eventManager); 68 eventManager.setKernel(kernel); 69 kernel.setEventManager(eventManager); 70 71 KernelBus bus = createKernelBus(kernel); 72 if (trace) 73 log.trace("Using Bus: " + bus); 74 bus.setKernel(kernel); 75 kernel.setBus(bus); 76 77 KernelConfigurator configurator = createKernelConfigurator(kernel); 78 if (trace) 79 log.trace("Using Configurator: " + configurator); 80 configurator.setKernel(kernel); 81 kernel.setConfigurator(configurator); 82 83 KernelController controller = createKernelController(kernel); 84 if (trace) 85 log.trace("Using Controller: " + controller); 86 controller.setKernel(kernel); 87 kernel.setController(controller); 88 89 register(kernel, KernelConstants.KERNEL_CONFIG_NAME, kernel.getConfig()); 91 register(kernel, KernelConstants.KERNEL_INITIALIZER_NAME, this); 92 register(kernel, KernelConstants.KERNEL_NAME, kernel); 93 register(kernel, KernelConstants.KERNEL_REGISTRY_NAME, registry); 94 register(kernel, KernelConstants.KERNEL_EVENT_MANAGER_NAME, eventManager); 95 register(kernel, KernelConstants.KERNEL_BUS_NAME, bus); 96 register(kernel, KernelConstants.KERNEL_CONFIGURATOR_NAME, configurator); 97 register(kernel, KernelConstants.KERNEL_CONTROLLER_NAME, controller); 98 register(kernel, KernelConstants.KERNEL_METADATA_REPOSITORY_NAME, metaDataRepository); 99 } 100 101 108 protected KernelBus createKernelBus(Kernel kernel) throws Throwable 109 { 110 return kernel.getConfig().createKernelBus(); 111 } 112 113 120 protected KernelConfigurator createKernelConfigurator(Kernel kernel) throws Throwable 121 { 122 return kernel.getConfig().createKernelConfigurator(); 123 } 124 125 132 protected KernelController createKernelController(Kernel kernel) throws Throwable 133 { 134 return kernel.getConfig().createKernelController(); 135 } 136 137 144 protected KernelEventManager createKernelEventManager(Kernel kernel) throws Throwable 145 { 146 return kernel.getConfig().createKernelEventManager(); 147 } 148 149 156 protected KernelRegistry createKernelRegistry(Kernel kernel) throws Throwable 157 { 158 return kernel.getConfig().createKernelRegistry(); 159 } 160 161 168 protected KernelMetaDataRepository createKernelMetaDataRepository(Kernel kernel) throws Throwable 169 { 170 return kernel.getConfig().createKernelMetaDataRepository(); 171 } 172 173 181 protected void register(Kernel kernel, String name, Object object) throws Throwable 182 { 183 register(kernel, getName(name), object); 184 } 185 186 194 protected void register(Kernel kernel, Object name, Object object) throws Throwable 195 { 196 KernelRegistryEntry entry = createKernelRegistryEntry(kernel, object); 197 KernelRegistry registry = kernel.getRegistry(); 198 registry.registerEntry(name, entry); 199 } 200 201 208 protected Object getName(String name) throws Throwable 209 { 210 return name; 211 } 212 213 221 protected KernelRegistryEntry createKernelRegistryEntry(Kernel kernel, Object object) throws Throwable 222 { 223 return new AbstractKernelRegistryEntry(object); 228 } 229 } 230 | Popular Tags |