1 17 18 package org.sape.carbon.core.component.startup; 19 20 21 import org.sape.carbon.core.component.ComponentConfiguration; 22 import org.sape.carbon.core.component.Lookup; 23 import org.sape.carbon.core.component.lifecycle.Configurable; 24 import org.sape.carbon.core.component.startup.StartupServiceConfiguration.StartupComponentConfiguration; 25 import org.sape.carbon.core.exception.ExceptionUtility; 26 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 30 39 public class DefaultStartupServiceImpl implements StartupService, Configurable { 40 41 44 private Log log = LogFactory.getLog(this.getClass()); 45 46 47 private StartupComponentConfiguration[] startupComponents; 48 49 52 public void startComponents() { 53 for (int i = 0; i < this.startupComponents.length; i++) { 54 55 StartupComponentConfiguration componentConfig = 56 this.startupComponents[i]; 57 58 59 if (componentConfig.isEnabled()) { 60 if (log.isInfoEnabled()) { 61 log.info("Starting component [" 62 + componentConfig.getComponentName() + "]"); 63 } 64 65 try { 66 Lookup.getInstance().fetchComponent(componentConfig.getComponentName()); 67 68 } catch (Exception e) { 69 if (log.isWarnEnabled()) { 70 log.warn("Could not start component [" 71 + componentConfig.getComponentName() 72 + "], caught exception " 73 + ExceptionUtility.printStackTracesToString(e)); 74 } 75 } 76 } else { 77 if (log.isDebugEnabled()) { 78 log.debug("Startup component disabled [" 79 + componentConfig.getComponentName() + "]"); 80 } 81 } 82 } 83 } 84 85 91 public void configure(ComponentConfiguration configuration) { 92 StartupServiceConfiguration startupConfiguration = 93 (StartupServiceConfiguration) configuration; 94 95 this.startupComponents = 96 startupConfiguration.getStartupComponent(); 97 } 98 99 100 101 } 102 | Popular Tags |