1 15 package org.apache.examples.annotations.panorama; 16 17 import java.util.ArrayList ; 18 import java.util.List ; 19 20 import org.apache.commons.logging.LogFactory; 21 import org.apache.examples.panorama.startup.impl.Task; 22 import org.apache.examples.panorama.startup.impl.TaskExecutor; 23 import org.apache.hivemind.ErrorLog; 24 import org.apache.hivemind.annotations.AbstractAnnotatedModule; 25 import org.apache.hivemind.annotations.definition.Configuration; 26 import org.apache.hivemind.annotations.definition.Contribution; 27 import org.apache.hivemind.annotations.definition.Service; 28 import org.apache.hivemind.impl.DefaultErrorHandler; 29 import org.apache.hivemind.impl.ErrorLogImpl; 30 import org.apache.hivemind.impl.MessageFormatter; 31 32 public class PanoramaStartupModule extends AbstractAnnotatedModule 33 { 34 35 @Service( id="Startup" ) 36 public Runnable getStartupService() 37 { 38 TaskExecutor executor = new TaskExecutor(); 39 executor.setTasks(configuration("tasks", List .class)); 40 ErrorLog errorLog = new ErrorLogImpl(new DefaultErrorHandler(), LogFactory.getLog(TaskExecutor.class)); 43 executor.setErrorLog(errorLog); 44 executor.setMessages(new MessageFormatter(PanoramaStartupModule.class, "panorama")); 45 executor.setLog(LogFactory.getLog(TaskExecutor.class)); 46 47 return executor; 48 } 49 50 @Configuration( id="tasks" ) 51 public List <Task> getTasks() 52 { 53 return new ArrayList <Task>(); 54 } 55 56 @Contribution( configurationId="hivemind.Startup" ) 57 public void contributeStartupServices(List services) 58 { 59 services.add(service("Startup", Runnable .class)); 60 } 61 62 } 63 | Popular Tags |