1 8 package org.codehaus.loom.components.application; 9 10 import java.io.File ; 11 import java.io.InputStream ; 12 import org.apache.avalon.framework.logger.Logger; 13 import org.apache.excalibur.instrument.InstrumentManager; 14 import org.codehaus.loom.components.instrument.NoopInstrumentManager; 15 import org.codehaus.loom.components.util.profile.PartitionProfile; 16 import org.codehaus.loom.interfaces.ApplicationContext; 17 import org.codehaus.spice.alchemist.logger.LoggerAlchemist; 18 19 23 class MockApplicationContext 24 implements ApplicationContext 25 { 26 private final PartitionProfile m_sarMetaData; 27 private final org.codehaus.dna.Logger m_logger; 28 29 public MockApplicationContext( final PartitionProfile sarMetaData, 30 final org.codehaus.dna.Logger logger ) 31 { 32 m_sarMetaData = sarMetaData; 33 m_logger = logger; 34 } 35 36 public PartitionProfile getPartitionProfile() 37 { 38 return m_sarMetaData; 39 } 40 41 public void requestShutdown() 42 { 43 } 45 46 public void exportObject( String name, Object object ) 47 throws Exception 48 { 49 } 51 52 public void unexportObject( String name ) 53 throws Exception 54 { 55 } 57 58 public ClassLoader getClassLoader() 59 { 60 return getClass().getClassLoader(); 61 } 62 63 public InputStream getResourceAsStream( final String name ) 64 { 65 return getClass().getClassLoader().getResourceAsStream( name ); 66 } 67 68 public File getHomeDirectory() 69 { 70 return new File ( "." ); 71 } 72 73 public Logger getLogger( String name ) 74 { 75 return LoggerAlchemist.toAvalonLogger( m_logger ); 76 } 77 78 public InstrumentManager getInstrumentManager() 79 { 80 return new NoopInstrumentManager(); 81 } 82 83 public String getInstrumentableName( String component ) 84 { 85 return component; 86 } 87 } 88 | Popular Tags |