diff --git a/pom.xml b/pom.xml
index e6141e8..5125567 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,7 @@ limitations under the License.
plexus-components
org.codehaus.plexus
6.5
+
plexus-velocity
@@ -46,6 +47,7 @@ limitations under the License.
+ 1.7.25
2020-01-20T18:52:37Z
@@ -55,14 +57,20 @@ limitations under the License.
plexus-container-default
- commons-collections
- commons-collections
- 3.2.2
+ org.apache.velocity
+ velocity-engine-core
+ 2.0
- org.apache.velocity
- velocity
- 1.7
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ slf4j-simple
+ ${slf4j.version}
+ test
diff --git a/src/main/java/org/codehaus/plexus/velocity/ContextClassLoaderResourceLoader.java b/src/main/java/org/codehaus/plexus/velocity/ContextClassLoaderResourceLoader.java
deleted file mode 100644
index 5aa2627..0000000
--- a/src/main/java/org/codehaus/plexus/velocity/ContextClassLoaderResourceLoader.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.codehaus.plexus.velocity;
-
-/*
- * Copyright 2001-2016 Codehaus Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.InputStream;
-
-import org.apache.velocity.runtime.resource.Resource;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-import org.apache.velocity.runtime.resource.loader.ResourceLoader;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-import org.apache.commons.collections.ExtendedProperties;
-
-/**
- *
- * @deprecated use {@link ClasspathResourceLoader}
- *
- */
-@Deprecated
-public class ContextClassLoaderResourceLoader
- extends ResourceLoader
-{
- public void init( ExtendedProperties configuration)
- {
- }
-
- public synchronized InputStream getResourceStream( String name )
- throws ResourceNotFoundException
- {
- InputStream result;
-
- if (name == null || name.length() == 0)
- {
- throw new ResourceNotFoundException ("No template name provided");
- }
-
- try
- {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- if ( name.startsWith( "/" ) )
- {
- name = name.substring( 1 );
- }
-
- result = classLoader.getResourceAsStream( name );
- }
- catch( Exception fnfe )
- {
- throw new ResourceNotFoundException( fnfe.getMessage() );
- }
-
- return result;
- }
-
- public boolean isSourceModified(Resource resource)
- {
- return false;
- }
-
- public long getLastModified(Resource resource)
- {
- return 0;
- }
-}
-
diff --git a/src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java b/src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java
index 9d8c2b9..faf2b7e 100644
--- a/src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java
+++ b/src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java
@@ -16,13 +16,10 @@
* limitations under the License.
*/
-import java.util.Enumeration;
import java.util.Properties;
import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.LogChute;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -49,7 +46,7 @@
*/
public class DefaultVelocityComponent
extends AbstractLogEnabled
- implements VelocityComponent, Initializable, LogChute
+ implements VelocityComponent, Initializable
{
private VelocityEngine engine;
@@ -63,24 +60,11 @@ public void initialize()
throws InitializationException
{
engine = new VelocityEngine();
-
// avoid "unable to find resource 'VM_global_library.vm' in any resource loader."
engine.setProperty( RuntimeConstants.VM_LIBRARY, "" );
-
- engine.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this );
-
if ( properties != null )
{
- for ( Enumeration> e = properties.propertyNames(); e.hasMoreElements(); )
- {
- String key = e.nextElement().toString();
-
- String value = properties.getProperty( key );
-
- engine.setProperty( key, value );
-
- getLogger().debug( "Setting property: " + key + " => '" + value + "'." );
- }
+ engine.setProperties( properties );
}
try
@@ -93,86 +77,9 @@ public void initialize()
}
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
public VelocityEngine getEngine()
{
return engine;
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- private RuntimeServices runtimeServices;
- public void init( RuntimeServices runtimeServices )
- {
- this.runtimeServices = runtimeServices;
- }
-
- public void log(int level, String message)
- {
- switch ( level )
- {
- case LogChute.WARN_ID:
- getLogger().warn( message );
- break;
- case LogChute.INFO_ID:
- getLogger().info( message );
- break;
- case LogChute.DEBUG_ID:
- case LogChute.TRACE_ID:
- getLogger().debug( message );
- break;
- case LogChute.ERROR_ID:
- getLogger().error( message );
- break;
- default:
- getLogger().debug( message );
- break;
- }
- }
-
- public void log(int level, String message, Throwable t)
- {
- switch ( level )
- {
- case LogChute.WARN_ID:
- getLogger().warn( message, t );
- break;
- case LogChute.INFO_ID:
- getLogger().info( message, t );
- break;
- case LogChute.DEBUG_ID:
- case LogChute.TRACE_ID:
- getLogger().debug( message, t );
- break;
- case LogChute.ERROR_ID:
- getLogger().error( message, t );
- break;
- default:
- getLogger().debug( message, t );
- break;
- }
- }
-
- public boolean isLevelEnabled( int level )
- {
- switch ( level )
- {
- case LogChute.WARN_ID:
- return getLogger().isWarnEnabled();
- case LogChute.INFO_ID:
- return getLogger().isInfoEnabled();
- case LogChute.DEBUG_ID:
- case LogChute.TRACE_ID:
- return getLogger().isDebugEnabled();
- case LogChute.ERROR_ID:
- return getLogger().isErrorEnabled();
- default:
- return getLogger().isDebugEnabled();
- }
- }
}
diff --git a/src/main/java/org/codehaus/plexus/velocity/SiteResourceLoader.java b/src/main/java/org/codehaus/plexus/velocity/SiteResourceLoader.java
deleted file mode 100644
index d2c2f7b..0000000
--- a/src/main/java/org/codehaus/plexus/velocity/SiteResourceLoader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.codehaus.plexus.velocity;
-
-/*
- * Copyright 2001-2016 Codehaus Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.commons.collections.ExtendedProperties;
-import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
-import org.apache.velocity.runtime.resource.loader.ResourceLoader;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-import java.io.InputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-/**
- * Allows you to dynamically add resources that you want to be processed by Velocity. For
- * example if you want to generate a site and pull in some random files to be interpolated
- * by Velocity you can use this resource loader.
- *
- * @author Jason van Zyl
- * @deprecated use {@link FileResourceLoader}
- */
-@Deprecated
-public class SiteResourceLoader
- extends ResourceLoader
-{
- private static String resource;
-
- private static File resourceDir;
-
- public static void setResource( String staticResource )
- {
- resource = staticResource;
- resourceDir = new File( resource ).getParentFile();
- }
-
- public void init( ExtendedProperties p )
- {
- }
-
- public InputStream getResourceStream( String name )
- throws ResourceNotFoundException
- {
- if ( resource != null )
- {
- try
- {
- File f = new File( resourceDir, name );
- if ( f.exists() )
- {
- return new FileInputStream( f );
- }
- else
- {
- return new FileInputStream( resource );
- }
- }
- catch ( FileNotFoundException e )
- {
- throw new ResourceNotFoundException( "Cannot find resource, make sure you set the right resource." );
- }
- }
-
- return null;
- }
-
- public boolean isSourceModified( org.apache.velocity.runtime.resource.Resource resource )
- {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public long getLastModified( org.apache.velocity.runtime.resource.Resource resource )
- {
- return 0;
- }
-}
-
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 03cbe62..460f9d9 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -16,7 +16,7 @@
A typical use:
VelocityContext context = new VelocityContext();
-VelocityComponent velocityComponent = (DefaultVelocityComponent) lookup( VelocityComponent.ROLE );
+VelocityComponent velocityComponent = (VelocityComponent) lookup( VelocityComponent.ROLE );
Template template = velocityComponent.getEngine().getTemplate( "path to your template" );
StringWriter writer = new StringWriter();
template.merge( context, writer );
@@ -45,7 +45,7 @@ template.merge( context, writer );
]]>
- See Velocity Configuration Keys and Values
+
See Velocity Configuration
reference documentation for details on available configurations.
diff --git a/src/test/log4j.properties b/src/test/log4j.properties
deleted file mode 100644
index 6eb4456..0000000
--- a/src/test/log4j.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-log4j.rootCategory=DEBUG,testlog
-
-# testlog is set to be a File appender using a PatternLayout.
-log4j.appender.testlog = org.apache.log4j.FileAppender
-log4j.appender.testlog.File = test.log
-log4j.appender.testlog.Append = false
-log4j.appender.testlog.Threshold = DEBUG
-log4j.appender.testlog.layout = org.apache.log4j.PatternLayout
-log4j.appender.testlog.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
-