Skip to content

Commit 771f324

Browse files
committed
Upgrade to Velocity Engine 2.0
1 parent d39abbf commit 771f324

File tree

6 files changed

+18
-284
lines changed

6 files changed

+18
-284
lines changed

pom.xml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ limitations under the License.
2121
<artifactId>plexus-components</artifactId>
2222
<groupId>org.codehaus.plexus</groupId>
2323
<version>6.5</version>
24+
<relativePath/>
2425
</parent>
2526

2627
<artifactId>plexus-velocity</artifactId>
@@ -46,6 +47,7 @@ limitations under the License.
4647
</distributionManagement>
4748

4849
<properties>
50+
<slf4j.version>1.7.25</slf4j.version>
4951
<project.build.outputTimestamp>2020-01-20T18:52:37Z</project.build.outputTimestamp>
5052
</properties>
5153

@@ -55,14 +57,20 @@ limitations under the License.
5557
<artifactId>plexus-container-default</artifactId>
5658
</dependency>
5759
<dependency>
58-
<groupId>commons-collections</groupId>
59-
<artifactId>commons-collections</artifactId>
60-
<version>3.2.2</version>
60+
<groupId>org.apache.velocity</groupId>
61+
<artifactId>velocity-engine-core</artifactId>
62+
<version>2.0</version>
6163
</dependency>
6264
<dependency>
63-
<groupId>org.apache.velocity</groupId>
64-
<artifactId>velocity</artifactId>
65-
<version>1.7</version>
65+
<groupId>org.slf4j</groupId>
66+
<artifactId>slf4j-api</artifactId>
67+
<version>${slf4j.version}</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.slf4j</groupId>
71+
<artifactId>slf4j-simple</artifactId>
72+
<version>${slf4j.version}</version>
73+
<scope>test</scope>
6674
</dependency>
6775
</dependencies>
6876

src/main/java/org/codehaus/plexus/velocity/ContextClassLoaderResourceLoader.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
* limitations under the License.
1717
*/
1818

19-
import java.util.Enumeration;
2019
import java.util.Properties;
2120

2221
import org.apache.velocity.app.VelocityEngine;
23-
import org.apache.velocity.runtime.RuntimeServices;
2422
import org.apache.velocity.runtime.RuntimeConstants;
25-
import org.apache.velocity.runtime.log.LogChute;
2623
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
2724
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
2825
import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -49,7 +46,7 @@
4946
*/
5047
public class DefaultVelocityComponent
5148
extends AbstractLogEnabled
52-
implements VelocityComponent, Initializable, LogChute
49+
implements VelocityComponent, Initializable
5350
{
5451
private VelocityEngine engine;
5552

@@ -63,24 +60,11 @@ public void initialize()
6360
throws InitializationException
6461
{
6562
engine = new VelocityEngine();
66-
6763
// avoid "unable to find resource 'VM_global_library.vm' in any resource loader."
6864
engine.setProperty( RuntimeConstants.VM_LIBRARY, "" );
69-
70-
engine.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this );
71-
7265
if ( properties != null )
7366
{
74-
for ( Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); )
75-
{
76-
String key = e.nextElement().toString();
77-
78-
String value = properties.getProperty( key );
79-
80-
engine.setProperty( key, value );
81-
82-
getLogger().debug( "Setting property: " + key + " => '" + value + "'." );
83-
}
67+
engine.setProperties( properties );
8468
}
8569

8670
try
@@ -93,86 +77,9 @@ public void initialize()
9377
}
9478
}
9579

96-
// ----------------------------------------------------------------------
97-
//
98-
// ----------------------------------------------------------------------
99-
10080
public VelocityEngine getEngine()
10181
{
10282
return engine;
10383
}
104-
// ----------------------------------------------------------------------
105-
//
106-
// ----------------------------------------------------------------------
107-
108-
private RuntimeServices runtimeServices;
10984

110-
public void init( RuntimeServices runtimeServices )
111-
{
112-
this.runtimeServices = runtimeServices;
113-
}
114-
115-
public void log(int level, String message)
116-
{
117-
switch ( level )
118-
{
119-
case LogChute.WARN_ID:
120-
getLogger().warn( message );
121-
break;
122-
case LogChute.INFO_ID:
123-
getLogger().info( message );
124-
break;
125-
case LogChute.DEBUG_ID:
126-
case LogChute.TRACE_ID:
127-
getLogger().debug( message );
128-
break;
129-
case LogChute.ERROR_ID:
130-
getLogger().error( message );
131-
break;
132-
default:
133-
getLogger().debug( message );
134-
break;
135-
}
136-
}
137-
138-
public void log(int level, String message, Throwable t)
139-
{
140-
switch ( level )
141-
{
142-
case LogChute.WARN_ID:
143-
getLogger().warn( message, t );
144-
break;
145-
case LogChute.INFO_ID:
146-
getLogger().info( message, t );
147-
break;
148-
case LogChute.DEBUG_ID:
149-
case LogChute.TRACE_ID:
150-
getLogger().debug( message, t );
151-
break;
152-
case LogChute.ERROR_ID:
153-
getLogger().error( message, t );
154-
break;
155-
default:
156-
getLogger().debug( message, t );
157-
break;
158-
}
159-
}
160-
161-
public boolean isLevelEnabled( int level )
162-
{
163-
switch ( level )
164-
{
165-
case LogChute.WARN_ID:
166-
return getLogger().isWarnEnabled();
167-
case LogChute.INFO_ID:
168-
return getLogger().isInfoEnabled();
169-
case LogChute.DEBUG_ID:
170-
case LogChute.TRACE_ID:
171-
return getLogger().isDebugEnabled();
172-
case LogChute.ERROR_ID:
173-
return getLogger().isErrorEnabled();
174-
default:
175-
return getLogger().isDebugEnabled();
176-
}
177-
}
17885
}

src/main/java/org/codehaus/plexus/velocity/SiteResourceLoader.java

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/site/xdoc/index.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<p>A typical use:
1717
<source>
1818
VelocityContext context = new VelocityContext();
19-
VelocityComponent velocityComponent = (DefaultVelocityComponent) lookup( VelocityComponent.ROLE );
19+
VelocityComponent velocityComponent = (VelocityComponent) lookup( VelocityComponent.ROLE );
2020
Template template = velocityComponent.getEngine().getTemplate( "path to your template" );
2121
StringWriter writer = new StringWriter();
2222
template.merge( context, writer );</source>
@@ -45,7 +45,7 @@ template.merge( context, writer );</source>
4545
</configuration>
4646
</component>]]></source>
4747
</p>
48-
<p>See <a href="http://velocity.apache.org/engine/releases/velocity-1.7/developer-guide.html#Velocity_Configuration_Keys_and_Values">Velocity Configuration Keys and Values</a>
48+
<p>See <a href="https://velocity.apache.org/engine/2.0/configuration.html">Velocity Configuration</a>
4949
reference documentation for details on available configurations.</p>
5050
</subsection>
5151
</section>

src/test/log4j.properties

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)