1 17 18 package tutorial; 19 20 import java.io.File ; 21 22 import org.apache.avalon.framework.activity.Disposable; 23 import org.apache.avalon.framework.activity.Initializable; 24 import org.apache.avalon.framework.activity.Executable; 25 import org.apache.avalon.framework.logger.AbstractLogEnabled; 26 27 35 public class StandardComponent extends AbstractLogEnabled 36 implements Contextualizable, Initializable, Executable, Disposable, StandardService 37 { 38 private File m_home; 39 private File m_work; 40 private String m_name; 41 private String m_partition; 42 private String m_message; 43 private StandardContext m_context; 44 45 49 60 public void contextualize( StandardContext context ) 61 { 62 m_context = context; 63 m_home = context.getHomeDirectory(); 64 m_work = context.getWorkingDirectory(); 65 m_name = context.getName(); 66 m_partition = context.getPartitionName(); 67 } 68 69 73 76 public void initialize() throws Exception 77 { 78 m_message = 79 " strategy: " + Contextualizable.class.getName() 80 + "\n context: " + m_context.getClass().getName() 81 + "\n home: " + m_home 82 + "\n work: " + m_work 83 + "\n name: " + m_name 84 + "\n partition: " + m_partition; 85 } 86 87 91 94 public void dispose() 95 { 96 getLogger().debug( "dispose" ); 97 } 98 99 103 106 public void execute() 107 { 108 printMessage(); 109 } 110 111 115 118 public void printMessage() 119 { 120 getLogger().info( "contextualization using a custom strategy\n\n" 121 + m_message + "\n"); 122 } 123 } 124 | Popular Tags |