geirm 01/08/07 14:58:19
Modified: src/java/org/apache/velocity/runtime/resource
ContentResource.java Resource.java
ResourceManager.java
src/java/org/apache/velocity/runtime/resource/loader
ClasspathResourceLoader.java
FileResourceLoader.java JarHolder.java
JarResourceLoader.java ResourceLoader.java
ResourceLoaderFactory.java
Log:
Support for separable instances of the runtime engine.
Revision Changes Path
1.5 +2 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ContentResource.java
Index: ContentResource.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ContentResource.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ContentResource.java 2001/04/22 18:11:20 1.4
+++ ContentResource.java 2001/08/07 21:58:18 1.5
@@ -58,8 +58,6 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
-import org.apache.velocity.runtime.Runtime;
-
/**
* This class represent a general text resource that
* may have been retrieved from any number of possible
@@ -67,7 +65,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ContentResource.java,v 1.4 2001/04/22 18:11:20 geirm Exp $
+ * @version $Id: ContentResource.java,v 1.5 2001/08/07 21:58:18 geirm Exp $
*/
public class ContentResource extends Resource
{
@@ -98,7 +96,7 @@
}
catch ( Exception e )
{
- Runtime.error("Cannot process content resource : " + e.toString() );
+ rsvc.error("Cannot process content resource : " + e.toString() );
return false;
}
}
1.8 +21 -5
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/Resource.java
Index: Resource.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/Resource.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Resource.java 2001/07/28 12:05:50 1.7
+++ Resource.java 2001/08/07 21:58:18 1.8
@@ -58,7 +58,9 @@
import java.io.IOException;
import java.io.Writer;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.SimpleNode;
import org.apache.velocity.runtime.resource.loader.ResourceLoader;
@@ -73,10 +75,12 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: Resource.java,v 1.7 2001/07/28 12:05:50 geirm Exp $
+ * @version $Id: Resource.java,v 1.8 2001/08/07 21:58:18 geirm Exp $
*/
public abstract class Resource
{
+ protected RuntimeServices rsvc = null;
+
/**
* The template loader that initially loaded the input
* stream for this template, and knows how to check the
@@ -114,13 +118,25 @@
/**
* Character encoding of this resource
*/
- protected String encoding = Runtime.ENCODING_DEFAULT;
+ protected String encoding = RuntimeConstants.ENCODING_DEFAULT;
/**
* Resource might require ancillary storage of some kind
*/
protected Object data = null;
+ /**
+ * Default constructor
+ */
+ public Resource()
+ {
+ }
+
+ public void setRuntimeServices( RuntimeServices rs )
+ {
+ rsvc = rs;
+ }
+
/**
* Perform any subsequent processing that might need
* to be done by a resource. In the case of a template
@@ -164,11 +180,11 @@
* see if we need to check now
*/
- return (System.currentTimeMillis() >= nextCheck );
+ return ( System.currentTimeMillis() >= nextCheck );
}
/**
- * 'Touch' this template by resetting
+ * 'Touch' this template and thereby resetting
* the nextCheck field.
*/
public void touch()
1.30 +51 -34
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java
Index: ResourceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/ResourceManager.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ResourceManager.java 2001/05/20 21:40:40 1.29
+++ ResourceManager.java 2001/08/07 21:58:18 1.30
@@ -64,7 +64,9 @@
import java.io.IOException;
import org.apache.velocity.Template;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
import org.apache.velocity.runtime.resource.ResourceFactory;
import org.apache.velocity.runtime.resource.loader.ResourceLoader;
import org.apache.velocity.runtime.resource.loader.ResourceLoaderFactory;
@@ -81,7 +83,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Paulo Gaspar</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ResourceManager.java,v 1.29 2001/05/20 21:40:40 geirm Exp $
+ * @version $Id: ResourceManager.java,v 1.30 2001/08/07 21:58:18 geirm Exp $
*/
public class ResourceManager
{
@@ -104,13 +106,13 @@
* Hashtable used to store templates that have been
* processed. Our simple caching mechanism.
*/
- private static Hashtable globalCache = new Hashtable();
+ private Hashtable globalCache = new Hashtable();
/**
* The List of templateLoaders that the Runtime will
* use to locate the InputStream source of a template.
*/
- private static ArrayList resourceLoaders = new ArrayList();
+ private ArrayList resourceLoaders = new ArrayList();
/**
* This is a list of the template input stream source
@@ -120,7 +122,7 @@
*
* <loader-id>.resource.loader.<property> = <value>
*/
- private static ArrayList sourceInitializerList = new ArrayList();
+ private ArrayList sourceInitializerList = new ArrayList();
/**
* This is a map of public name of the template
@@ -132,7 +134,7 @@
* change the resource.path property for the
* file template stream source.
*/
- private static Hashtable sourceInitializerMap = new Hashtable();
+ private Hashtable sourceInitializerMap = new Hashtable();
/**
* Each loader needs a configuration object for
@@ -140,21 +142,31 @@
* or not the configuration objects have been created
* for the resource loaders.
*/
- private static boolean resourceLoaderInitializersActive = false;
+ private boolean resourceLoaderInitializersActive = false;
/**
* switch to turn off log notice when a resource is found for
* the first time.
*/
- private static boolean logWhenFound = true;
-
+ private boolean logWhenFound = true;
+
+ private RuntimeServices rsvc = null;
+
+ public ResourceManager( RuntimeServices rs )
+ {
+ this.rsvc = rs;
+ }
+
/**
* Initialize the ResourceManager. It is assumed
* that assembleSourceInitializers() has been
* called before this is run.
*/
- public static void initialize() throws Exception
+ public void initialize()
+ throws Exception
{
+ rsvc.info("Resource manager initializing.");
+
ResourceLoader resourceLoader;
assembleResourceLoaderInitializers();
@@ -166,15 +178,15 @@
if ( loaderClass == null)
{
- Runtime.error( "Unable to find '"
+ rsvc.error( "Unable to find '"
+
configuration.getString(RESOURCE_LOADER_IDENTIFIER)
+ ".resource.loader.class' specification in
configuation."
+ " This is a critical value. Please adjust
configuration.");
continue;
}
- resourceLoader = ResourceLoaderFactory.getLoader(loaderClass);
- resourceLoader.commonInit(configuration);
+ resourceLoader = ResourceLoaderFactory.getLoader( rsvc, loaderClass);
+ resourceLoader.commonInit( rsvc, configuration);
resourceLoader.init(configuration);
resourceLoaders.add(resourceLoader);
@@ -184,7 +196,7 @@
* now see if this is overridden by configuration
*/
- logWhenFound = Runtime.getBoolean( Runtime.RESOURCE_MANAGER_LOGWHENFOUND,
true );
+ logWhenFound = rsvc.getBoolean(
RuntimeConstants.RESOURCE_MANAGER_LOGWHENFOUND, true );
}
/**
@@ -194,7 +206,7 @@
* will be passed in when initializing the
* the template loader.
*/
- private static void assembleResourceLoaderInitializers()
+ private void assembleResourceLoaderInitializers()
{
if (resourceLoaderInitializersActive)
{
@@ -202,7 +214,7 @@
}
Vector resourceLoaderNames =
- Runtime.getConfiguration().getVector(Runtime.RESOURCE_LOADER);
+ rsvc.getConfiguration().getVector(RuntimeConstants.RESOURCE_LOADER);
for (int i = 0; i < resourceLoaderNames.size(); i++)
{
@@ -215,10 +227,10 @@
* pertaining to a particular loader.
*/
String loaderID =
- resourceLoaderNames.get(i) + "." + Runtime.RESOURCE_LOADER;
+ resourceLoaderNames.get(i) + "." + RuntimeConstants.RESOURCE_LOADER;
ExtendedProperties loaderConfiguration =
- Runtime.getConfiguration().subset(loaderID);
+ rsvc.getConfiguration().subset(loaderID);
/*
* add the loader name token to the initializer if we need it
@@ -253,9 +265,9 @@
* to syntax (or other) error.
* @throws Exception if a problem in parse
*/
- public static Resource getResource(String resourceName, int resourceType,
String encoding )
+ public Resource getResource(String resourceName, int resourceType, String
encoding )
throws ResourceNotFoundException, ParseErrorException, Exception
- {
+ {
/*
* Check to see if the resource was placed in the cache.
* If it was placed in the cache then we will use
@@ -293,7 +305,7 @@
if (!resource.getEncoding().equals( encoding ) )
{
- Runtime.error("Declared encoding for template '" +
resourceName
+ rsvc.error("Declared encoding for template '" +
resourceName
+ "' is different on reload. Old = '" +
resource.getEncoding()
+ "' New = '" + encoding );
@@ -323,21 +335,21 @@
}
catch( ResourceNotFoundException rnfe )
{
- Runtime.error(
+ rsvc.error(
"ResourceManager.getResource() exception: " + rnfe);
throw rnfe;
}
catch( ParseErrorException pee )
{
- Runtime.error(
+ rsvc.error(
"ResourceManager.getResource() exception: " + pee);
throw pee;
}
catch( Exception eee )
{
- Runtime.error(
+ rsvc.error(
"ResourceManager.getResource() exception: " + eee);
throw eee;
@@ -356,6 +368,9 @@
try
{
resource = ResourceFactory.getResource(resourceName, resourceType);
+
+ resource.setRuntimeServices( rsvc );
+
resource.setName( resourceName );
resource.setEncoding( encoding );
@@ -398,8 +413,8 @@
if ( logWhenFound )
{
- Runtime.info("ResourceManager : found " +
resourceName +
- " with loader " +
resourceLoader.getClassName());
+ rsvc.info("ResourceManager : found " +
resourceName +
+ " with loader " +
resourceLoader.getClassName() );
}
howOldItWas = resourceLoader.getLastModified( resource
);
@@ -443,7 +458,7 @@
}
catch( ResourceNotFoundException rnfe2 )
{
- Runtime.error(
+ rsvc.error(
"ResourceManager : unable to find resource '" + resourceName +
"' in any resource loader.");
@@ -451,16 +466,16 @@
}
catch( ParseErrorException pee )
{
- Runtime.error(
+ rsvc.error(
"ResourceManager.getResource() parse exception: " + pee);
throw pee;
}
catch( Exception ee )
{
- Runtime.error(
- "ResourceManager.getResource() exception: " + ee);
-
+ rsvc.error(
+ "ResourceManager.getResource() exception new: " + ee);
+
throw ee;
}
}
@@ -485,10 +500,10 @@
* {@link #getResource(String resourceName, int resourceType,
* String encoding )}
*/
- public static Resource getResource(String resourceName, int resourceType )
+ public Resource getResource(String resourceName, int resourceType )
throws ResourceNotFoundException, ParseErrorException, Exception
{
- return getResource( resourceName, resourceType, Runtime.ENCODING_DEFAULT);
+ return getResource( resourceName, resourceType,
RuntimeConstants.ENCODING_DEFAULT);
}
/**
@@ -500,7 +515,7 @@
* @param resourceName Name of template or content resource
* @return class name of loader than can provide it
*/
- public static String getLoaderNameForResource(String resourceName )
+ public String getLoaderNameForResource(String resourceName )
{
ResourceLoader resourceLoader = null;
@@ -554,3 +569,5 @@
return null;
}
}
+
+
1.6 +5 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java
Index: ClasspathResourceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClasspathResourceLoader.java 2001/05/11 03:59:40 1.5
+++ ClasspathResourceLoader.java 2001/08/07 21:58:18 1.6
@@ -56,7 +56,7 @@
import java.io.InputStream;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.exception.ResourceNotFoundException;
@@ -105,7 +105,7 @@
* work just fine.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ClasspathResourceLoader.java,v 1.5 2001/05/11 03:59:40 geirm Exp $
+ * @version $Id: ClasspathResourceLoader.java,v 1.6 2001/08/07 21:58:18 geirm Exp $
*/
public class ClasspathResourceLoader extends ResourceLoader
{
@@ -115,8 +115,8 @@
*/
public void init( ExtendedProperties configuration)
{
- Runtime.info("ClasspathResourceLoader : initialization starting.");
- Runtime.info("ClasspathResourceLoader : initialization complete.");
+ rsvc.info("ClasspathResourceLoader : initialization starting.");
+ rsvc.info("ClasspathResourceLoader : initialization complete.");
}
/**
@@ -171,3 +171,4 @@
return 0;
}
}
+
1.13 +7 -8
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java
Index: FileResourceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- FileResourceLoader.java 2001/05/11 03:59:41 1.12
+++ FileResourceLoader.java 2001/08/07 21:58:18 1.13
@@ -65,7 +65,7 @@
import java.util.Vector;
import org.apache.velocity.util.StringUtils;
-import org.apache.velocity.runtime.Runtime;
+
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.exception.ResourceNotFoundException;
@@ -78,7 +78,7 @@
* That'll change once we decide how we want to do configuration
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: FileResourceLoader.java,v 1.12 2001/05/11 03:59:41 geirm Exp $
+ * @version $Id: FileResourceLoader.java,v 1.13 2001/08/07 21:58:18 geirm Exp $
*/
public class FileResourceLoader extends ResourceLoader
{
@@ -96,7 +96,7 @@
public void init( ExtendedProperties configuration)
{
- Runtime.info("FileResourceLoader : initialization starting.");
+ rsvc.info("FileResourceLoader : initialization starting.");
paths = configuration.getVector("path");
@@ -108,10 +108,10 @@
for( int i=0; i < sz; i++)
{
- Runtime.info("FileResourceLoader : adding path '" + (String)
paths.get(i) + "'");
+ rsvc.info("FileResourceLoader : adding path '" + (String) paths.get(i)
+ "'");
}
- Runtime.info("FileResourceLoader : initialization complete.");
+ rsvc.info("FileResourceLoader : initialization complete.");
}
/**
@@ -155,7 +155,7 @@
" contains .. and may be trying to access " +
"content outside of template root. Rejected.";
- Runtime.error( "FileResourceLoader : " + msg );
+ rsvc.error( "FileResourceLoader : " + msg );
throw new ResourceNotFoundException ( msg );
}
@@ -191,8 +191,7 @@
String msg = "FileResourceLoader Error: cannot find resource " +
template;
- //Runtime.error(msg);
- throw new ResourceNotFoundException( msg );
+ throw new ResourceNotFoundException( msg );
}
/**
1.7 +13 -9
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java
Index: JarHolder.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/JarHolder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JarHolder.java 2001/05/15 13:10:30 1.6
+++ JarHolder.java 2001/08/07 21:58:18 1.7
@@ -65,7 +65,7 @@
import java.util.Hashtable;
import org.apache.velocity.util.StringUtils;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.exception.ResourceNotFoundException;
@@ -74,7 +74,7 @@
* A small wrapper around a Jar
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
- * @version $Id: JarHolder.java,v 1.6 2001/05/15 13:10:30 geirm Exp $
+ * @version $Id: JarHolder.java,v 1.7 2001/08/07 21:58:18 geirm Exp $
*/
public class JarHolder
{
@@ -82,19 +82,23 @@
private JarFile theJar = null;
private JarURLConnection conn = null;
- public JarHolder( String urlpath )
+ private RuntimeServices rsvc = null;
+
+ public JarHolder( RuntimeServices rs, String urlpath )
{
+ rsvc = rs;
+
this.urlpath=urlpath;
init();
- Runtime.info(" JarHolder : initialized JAR: " + urlpath );
+ rsvc.info(" JarHolder : initialized JAR: " + urlpath );
}
public void init()
{
try
{
- Runtime.info(" JarHolder : attempting to connect to "+ urlpath);
+ rsvc.info(" JarHolder : attempting to connect to "+ urlpath);
URL url = new URL( urlpath );
conn = (JarURLConnection) url.openConnection();
conn.setAllowUserInteraction(false);
@@ -105,7 +109,7 @@
}
catch (Exception e)
{
- Runtime.error(" JarHolder : error establishing connection to JAR "+ e);
+ rsvc.error(" JarHolder : error establishing connection to JAR "+ e);
}
}
@@ -117,12 +121,12 @@
}
catch ( Exception e )
{
- Runtime.error(" JarHolder : error Closing JAR the file " + e);
+ rsvc.error(" JarHolder : error Closing JAR the file " + e);
}
theJar = null;
conn = null;
- Runtime.info(" JarHolder : JAR file closed");
+ rsvc.info(" JarHolder : JAR file closed");
}
public InputStream getResource( String theentry )
@@ -140,7 +144,7 @@
}
catch( Exception fnfe )
{
- Runtime.error(" JarHolder : getResource() error : exception : " + fnfe
);
+ rsvc.error(" JarHolder : getResource() error : exception : " + fnfe );
throw new ResourceNotFoundException( fnfe.getMessage() );
}
1.14 +10 -13
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java
Index: JarResourceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/JarResourceLoader.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- JarResourceLoader.java 2001/05/15 14:09:19 1.13
+++ JarResourceLoader.java 2001/08/07 21:58:18 1.14
@@ -70,11 +70,8 @@
import java.util.Vector;
import org.apache.velocity.util.StringUtils;
-import org.apache.velocity.runtime.Runtime;
import org.apache.velocity.runtime.resource.Resource;
-
import org.apache.velocity.exception.ResourceNotFoundException;
-
import org.apache.commons.collections.ExtendedProperties;
/**
@@ -105,7 +102,7 @@
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dave Bryson</a>
- * @version $Id: JarResourceLoader.java,v 1.13 2001/05/15 14:09:19 geirm Exp $
+ * @version $Id: JarResourceLoader.java,v 1.14 2001/08/07 21:58:18 geirm Exp $
*/
public class JarResourceLoader extends ResourceLoader
{
@@ -128,7 +125,7 @@
*/
public void init( ExtendedProperties configuration)
{
- Runtime.info("JarResourceLoader : initialization starting.");
+ rsvc.info("JarResourceLoader : initialization starting.");
Vector paths = configuration.getVector("path");
@@ -142,34 +139,34 @@
if (paths != null && paths.size() > 0)
{
- Runtime.warn("JarResourceLoader : you are using a deprecated
configuration"
+ rsvc.warn("JarResourceLoader : you are using a deprecated
configuration"
+ " property for the JarResourceLoader ->
'<name>.resource.loader.resource.path'."
+ " Please change to the conventional
'<name>.resource.loader.path'.");
}
}
- Runtime.info("JarResourceLoader # of paths : " + paths.size() );
+ rsvc.info("JarResourceLoader # of paths : " + paths.size() );
for ( int i=0; i<paths.size(); i++ )
{
loadJar( (String)paths.get(i) );
}
- Runtime.info("JarResourceLoader : initialization complete.");
+ rsvc.info("JarResourceLoader : initialization complete.");
}
private void loadJar( String path )
{
- Runtime.info("JarResourceLoader : trying to load: " + path);
+ rsvc.info("JarResourceLoader : trying to load: " + path);
// Check path information
if ( path == null )
{
- Runtime.error("JarResourceLoader : can not load JAR - JAR path is
null");
+ rsvc.error("JarResourceLoader : can not load JAR - JAR path is null");
}
if ( !path.startsWith("jar:") )
{
- Runtime.error("JarResourceLoader : JAR path must start with jar: -> " +
+ rsvc.error("JarResourceLoader : JAR path must start with jar: -> " +
"see java.net.JarURLConnection for information");
}
if ( !path.endsWith("!/") )
@@ -182,7 +179,7 @@
closeJar( path );
// Create a new JarHolder
- JarHolder temp = new JarHolder( path );
+ JarHolder temp = new JarHolder( rsvc, path );
// Add it's entries to the entryCollection
addEntries( temp.getEntries() );
// Add it to the Jar table
@@ -238,7 +235,7 @@
" contains .. and may be trying to access " +
"content outside of template root. Rejected.";
- Runtime.error( "JarResourceLoader : " + msg );
+ rsvc.error( "JarResourceLoader : " + msg );
throw new ResourceNotFoundException ( msg );
}
1.11 +11 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java
Index: ResourceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoader.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ResourceLoader.java 2001/05/11 03:59:42 1.10
+++ ResourceLoader.java 2001/08/07 21:58:18 1.11
@@ -57,7 +57,9 @@
import java.io.InputStream;
import java.util.Map;
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.RuntimeConstants;
+
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.exception.ResourceNotFoundException;
@@ -70,7 +72,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: ResourceLoader.java,v 1.10 2001/05/11 03:59:42 geirm Exp $
+ * @version $Id: ResourceLoader.java,v 1.11 2001/08/07 21:58:18 geirm Exp $
*/
public abstract class ResourceLoader
{
@@ -91,14 +93,18 @@
* purposes.
*/
protected String className = null;
-
+
+ protected RuntimeServices rsvc = null;
+
/**
* This initialization is used by all resource
* loaders and must be called to set up common
* properties shared by all resource loaders
*/
- public void commonInit( ExtendedProperties configuration)
+ public void commonInit( RuntimeServices rs, ExtendedProperties configuration)
{
+ this.rsvc = rs;
+
/*
* these two properties are not required for all loaders.
* For example, for ClasspathLoader, what would cache mean?
@@ -192,3 +198,4 @@
return modificationCheckInterval;
}
}
+
1.5 +5 -5
jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java
Index: ResourceLoaderFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/resource/loader/ResourceLoaderFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ResourceLoaderFactory.java 2001/03/20 01:39:31 1.4
+++ ResourceLoaderFactory.java 2001/08/07 21:58:18 1.5
@@ -54,14 +54,14 @@
* <http://www.apache.org/>.
*/
-import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.util.StringUtils;
/**
* Factory to grab a template loader.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: ResourceLoaderFactory.java,v 1.4 2001/03/20 01:39:31 jon Exp $
+ * @version $Id: ResourceLoaderFactory.java,v 1.5 2001/08/07 21:58:18 geirm Exp $
*/
public class ResourceLoaderFactory
{
@@ -69,7 +69,7 @@
* Gets the loader specified in the configuration file.
* @return TemplateLoader
*/
- public static ResourceLoader getLoader(String loaderClassName)
+ public static ResourceLoader getLoader(RuntimeServices rs, String
loaderClassName)
throws Exception
{
ResourceLoader loader = null;
@@ -79,14 +79,14 @@
loader = ((ResourceLoader)Class.forName(loaderClassName)
.newInstance());
- Runtime.info("Resource Loader Instantiated: " +
+ rs.info("Resource Loader Instantiated: " +
loader.getClass().getName());
return loader;
}
catch( Exception e)
{
- Runtime.error("Problem instantiating the template loader.\n" +
+ rs.error("Problem instantiating the template loader.\n" +
"Look at your properties file and make sure the\n" +
"name of the template loader is correct. Here is the\n" +
"error: " + StringUtils.stackTrace(e));