plexus-velocity-1.1.8/0000775000175000017500000000000012200126220014212 5ustar ebourgebourgplexus-velocity-1.1.8/pom.xml0000664000175000017500000000360111300354764015547 0ustar ebourgebourg 4.0.0 plexus-components org.codehaus.plexus 1.1.15 plexus-velocity 1.1.8 Plexus Velocity Component scm:svn:http://svn.codehaus.org/plexus/plexus-components/tags/plexus-velocity-1.1.8 scm:svn:https://svn.codehaus.org/plexus/plexus-components/tags/plexus-velocity-1.1.8 http://fisheye.codehaus.org/browse/plexus/plexus-components/tags/plexus-velocity-1.1.8 org.codehaus.plexus plexus-container-default commons-collections commons-collections 3.1 velocity velocity 1.5 plexus-velocity-1.1.8/src/0000775000175000017500000000000012200126220015001 5ustar ebourgebourgplexus-velocity-1.1.8/src/site/0000775000175000017500000000000012200126220015745 5ustar ebourgebourgplexus-velocity-1.1.8/src/site/xdoc/0000775000175000017500000000000012200126220016702 5ustar ebourgebourgplexus-velocity-1.1.8/src/site/xdoc/index.xml0000664000175000017500000000326710777725005020572 0ustar ebourgebourg Plexus Velocity Component Olivier Lamy

A component which provide velocity rendering.


A typical use : VelocityContext context = new VelocityContext(); VelocityComponent velocityComponent = (DefaultVelocityComponent) lookup( VelocityComponent.ROLE ); Template template = velocity.getEngine().getTemplate("path to your template" ); StringWriter writer = new StringWriter(); template.merge( context, writer );

A typical component configuration : org.codehaus.plexus.velocity.VelocityComponent org.codehaus.plexus.velocity.DefaultVelocityComponent runtime.log.logsystem.class org.codehaus.plexus.velocity.Log4JLoggingSystem resource.loader classpath classpath.resource.loader.class org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader ]]>

plexus-velocity-1.1.8/src/test/0000775000175000017500000000000012200126217015766 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/log4j.properties0000664000175000017500000000063110064076330021131 0ustar ebourgebourglog4j.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 plexus-velocity-1.1.8/src/test/resources/0000775000175000017500000000000012200126217020000 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/resources/org/0000775000175000017500000000000012200126217020567 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/resources/org/codehaus/0000775000175000017500000000000012200126217022362 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/resources/org/codehaus/plexus/0000775000175000017500000000000012200126217023702 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/resources/org/codehaus/plexus/velocity/0000775000175000017500000000000012200126217025540 5ustar ebourgebourg././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-velocity-1.1.8/src/test/resources/org/codehaus/plexus/velocity/DefaultVelocityComponentTest.xmlplexus-velocity-1.1.8/src/test/resources/org/codehaus/plexus/velocity/DefaultVelocityComponentTest.x0000664000175000017500000000142010576542103033566 0ustar ebourgebourg org.codehaus.plexus.velocity.VelocityComponent default org.codehaus.plexus.velocity.DefaultVelocityComponent resource.loader classpath classpath.resource.loader.class org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader hello world ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-velocity-1.1.8/src/test/resources/org/codehaus/plexus/velocity/DefaultVelocityComponentTest.vmplexus-velocity-1.1.8/src/test/resources/org/codehaus/plexus/velocity/DefaultVelocityComponentTest.v0000664000175000017500000000005410064076330033562 0ustar ebourgebourgStatic text -- $variable -- More static textplexus-velocity-1.1.8/src/test/java/0000775000175000017500000000000012200126217016707 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/java/org/0000775000175000017500000000000012200126217017476 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/java/org/codehaus/0000775000175000017500000000000012200126217021271 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/java/org/codehaus/plexus/0000775000175000017500000000000012200126217022611 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/java/org/codehaus/plexus/velocity/0000775000175000017500000000000012200126217024447 5ustar ebourgebourgplexus-velocity-1.1.8/src/test/java/org/codehaus/plexus/velocity/DefaultVelocityComponentTest.java0000664000175000017500000000333210645265720033157 0ustar ebourgebourgpackage org.codehaus.plexus.velocity; /* * Copyright 2001-2006 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.StringWriter; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.codehaus.plexus.PlexusTestCase; public class DefaultVelocityComponentTest extends PlexusTestCase { public void testBasic() throws Exception { DefaultVelocityComponent velocity; VelocityContext context; String value; velocity = (DefaultVelocityComponent) lookup( VelocityComponent.ROLE ); // test the properties value = (String) velocity.getEngine().getProperty( "hello" ); assertNotNull( value ); assertEquals( "world", value ); // test the rendering context = new VelocityContext(); context.put( "variable", "Value from context" ); Template template = velocity.getEngine().getTemplate("org/codehaus/plexus/velocity/DefaultVelocityComponentTest.vm" ); StringWriter writer = new StringWriter(); template.merge( context, writer ); assertEquals( "Static text -- Value from context -- More static text", writer.toString() ); } } plexus-velocity-1.1.8/src/main/0000775000175000017500000000000012200126220015725 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/resources/0000775000175000017500000000000012200126220017737 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/resources/META-INF/0000775000175000017500000000000012200126220021077 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/resources/META-INF/plexus/0000775000175000017500000000000012200126220022417 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/resources/META-INF/plexus/components.xml0000664000175000017500000000234610576651441025361 0ustar ebourgebourg org.codehaus.plexus.velocity.VelocityComponent default org.codehaus.plexus.velocity.DefaultVelocityComponent resource.loader classpath,site classpath.resource.loader.class org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader site.resource.loader.class org.codehaus.plexus.velocity.SiteResourceLoader runtime.log.invalid.references false velocimacro.messages.on false resource.manager.logwhenfound false plexus-velocity-1.1.8/src/main/java/0000775000175000017500000000000012200126217016654 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/java/org/0000775000175000017500000000000012200126217017443 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/java/org/codehaus/0000775000175000017500000000000012200126217021236 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/0000775000175000017500000000000012200126217022556 5ustar ebourgebourgplexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/velocity/0000775000175000017500000000000012200126220024406 5ustar ebourgebourg././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/velocity/ContextClassLoaderResourceLoader.javaplexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/velocity/ContextClassLoaderResourceLoader.ja0000664000175000017500000000374411236360171033347 0ustar ebourgebourgpackage org.codehaus.plexus.velocity; /* * Copyright 2001-2006 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.ResourceLoader; import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.commons.collections.ExtendedProperties; public class ContextClassLoaderResourceLoader extends ResourceLoader { public void init( ExtendedProperties configuration) { } public synchronized InputStream getResourceStream( String name ) throws ResourceNotFoundException { InputStream result = null; 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; } } plexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/velocity/VelocityComponent.java0000664000175000017500000000151310645265720030756 0ustar ebourgebourgpackage org.codehaus.plexus.velocity; /* * Copyright 2001-2006 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.velocity.app.VelocityEngine; public interface VelocityComponent { public final static String ROLE = VelocityComponent.class.getName(); VelocityEngine getEngine(); } plexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java0000664000175000017500000001115510666571622032272 0ustar ebourgebourgpackage org.codehaus.plexus.velocity; /* * Copyright 2001-2006 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.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.LogSystem; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.logging.AbstractLogEnabled; /** * A simple velocity component implementation. *

* A typical configuration will look like this: *

 *      
 *        
 *          
 *            runtime.log.logsystem.class
 *            org.codehaus.plexus.velocity.Log4JLoggingSystem
 *          
 *          
 *            runtime.log.logsystem.log4j.category
 *            org.codehaus.plexus.velocity.DefaultVelocityComponentTest
 *          
 *          
 *            resource.loader
 *            classpath
 *          
 *          
 *            classpath.resource.loader.class
 *            org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
 *          
 *        
 *      
 * 
*/ public class DefaultVelocityComponent extends AbstractLogEnabled implements VelocityComponent, Initializable, LogSystem { private VelocityEngine engine; private Properties properties; // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public void initialize() throws InitializationException { engine = new VelocityEngine(); // avoid "unable to find resource 'VM_global_library.vm' in any resource loader." engine.setProperty( "velocimacro.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 + "'." ); } } try { engine.init(); } catch ( Exception e ) { throw new InitializationException( "Cannot start the velocity engine: ", e ); } } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public VelocityEngine getEngine() { return engine; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- private RuntimeServices runtimeServices; public void init( RuntimeServices runtimeServices ) { this.runtimeServices = runtimeServices; } public void logVelocityMessage( int level, String message ) { switch ( level ) { case LogSystem.WARN_ID: getLogger().warn( message ); break; case LogSystem.INFO_ID: // velocity info messages are too verbose, just consider them as debug messages... getLogger().debug( message ); break; case LogSystem.DEBUG_ID: getLogger().debug( message ); break; case LogSystem.ERROR_ID: getLogger().error( message ); break; default: getLogger().debug( message ); break; } } } plexus-velocity-1.1.8/src/main/java/org/codehaus/plexus/velocity/SiteResourceLoader.java0000664000175000017500000000511311277150011031024 0ustar ebourgebourgpackage org.codehaus.plexus.velocity; /* * Copyright 2001-2006 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.ResourceLoader; import org.apache.velocity.exception.ResourceNotFoundException; import java.io.InputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; /** * Alloww you to dynamically add resources that you want to be processed by Velocity. For * example if you want ot generate a site and pull in some random files to be interpolated * by Velocity you can use this resource loader. * * @author Jason van Zyl */ 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; } }