1 17 18 package tutorial; 19 20 import java.util.Map ; 21 import java.io.File ; 22 23 import org.apache.avalon.framework.context.Context; 24 import org.apache.avalon.framework.context.DefaultContext; 25 import org.apache.avalon.framework.context.ContextException; 26 27 28 32 public class DemoContextProvider extends DefaultContext implements DemoContext 33 { 34 35 40 public DemoContextProvider( Context context ) 41 { 42 super( context ); 43 } 44 45 49 public String getName() 50 { 51 try 52 { 53 return (String ) super.get( "urn:avalon:name" ); 54 } 55 catch( ContextException ce ) 56 { 57 throw new RuntimeException ( ce.toString() ); 59 } 60 } 61 62 66 public String getPartition() 67 { 68 try 69 { 70 return (String ) super.get( "urn:avalon:partition" ); 71 } 72 catch( ContextException ce ) 73 { 74 throw new RuntimeException ( ce.toString() ); 76 } 77 } 78 79 83 public File getHomeDirectory() 84 { 85 try 86 { 87 return (File ) super.get( "urn:avalon:home" ); 88 } 89 catch( ContextException ce ) 90 { 91 throw new RuntimeException ( ce.toString() ); 93 } 94 } 95 96 97 101 public File getWorkingDirectory() 102 { 103 try 104 { 105 return (File ) super.get( "urn:avalon:temp" ); 106 } 107 catch( ContextException ce ) 108 { 109 throw new RuntimeException ( ce.toString() ); 111 } 112 } 113 } 114 | Popular Tags |