KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > components > application > MockApplicationContext


1 /*
2  * Copyright (C) The Loom Group. All rights reserved.
3  *
4  * This software is published under the terms of the Loom
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.loom.components.application;
9
10 import java.io.File JavaDoc;
11 import java.io.InputStream JavaDoc;
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 /**
20  * @author Peter Donald
21  * @version $Revision: 1.3 $ $Date: 2004/06/18 10:51:11 $
22  */

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         //ignore
44
}
45
46     public void exportObject( String JavaDoc name, Object JavaDoc object )
47         throws Exception JavaDoc
48     {
49         //ignore
50
}
51
52     public void unexportObject( String JavaDoc name )
53         throws Exception JavaDoc
54     {
55         //ignore
56
}
57
58     public ClassLoader JavaDoc getClassLoader()
59     {
60         return getClass().getClassLoader();
61     }
62
63     public InputStream JavaDoc getResourceAsStream( final String JavaDoc name )
64     {
65         return getClass().getClassLoader().getResourceAsStream( name );
66     }
67
68     public File JavaDoc getHomeDirectory()
69     {
70         return new File JavaDoc( "." );
71     }
72
73     public Logger getLogger( String JavaDoc name )
74     {
75         return LoggerAlchemist.toAvalonLogger( m_logger );
76     }
77
78     public InstrumentManager getInstrumentManager()
79     {
80         return new NoopInstrumentManager();
81     }
82
83     public String JavaDoc getInstrumentableName( String JavaDoc component )
84     {
85         return component;
86     }
87 }
88
Popular Tags