1 package org.apache.velocity.runtime.resource.loader; 2 3 18 19 import java.io.InputStream ; 20 21 import org.apache.velocity.runtime.resource.Resource; 22 import org.apache.velocity.exception.ResourceNotFoundException; 23 24 import org.apache.commons.collections.ExtendedProperties; 25 26 72 public class ClasspathResourceLoader extends ResourceLoader 73 { 74 75 78 public void init( ExtendedProperties configuration) 79 { 80 rsvc.info("ClasspathResourceLoader : initialization starting."); 81 rsvc.info("ClasspathResourceLoader : initialization complete."); 82 } 83 84 93 public synchronized InputStream getResourceStream( String name ) 94 throws ResourceNotFoundException 95 { 96 InputStream result = null; 97 98 if (name == null || name.length() == 0) 99 { 100 throw new ResourceNotFoundException ("No template name provided"); 101 } 102 103 try 104 { 105 ClassLoader classLoader = this.getClass().getClassLoader(); 106 result= classLoader.getResourceAsStream( name ); 107 } 108 catch( Exception fnfe ) 109 { 110 113 114 throw new ResourceNotFoundException( fnfe.getMessage() ); 115 } 116 117 return result; 118 } 119 120 123 public boolean isSourceModified(Resource resource) 124 { 125 return false; 126 } 127 128 131 public long getLastModified(Resource resource) 132 { 133 return 0; 134 } 135 } 136 137 | Popular Tags |