You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2005/01/26 01:15:28 UTC
svn commit: r126449 - /incubator/apollo/trunk/maven.xml /incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java /incubator/apollo/trunk/src/java/org/apache/ws/util/velocity/CommonsLogLogSystem.java
Author: ips
Date: Tue Jan 25 16:15:25 2005
New Revision: 126449
URL: http://svn.apache.org/viewcvs?view=rev&rev=126449
Log:
configured Velocity to use Commons Logging instead of Log4J for logging
Added:
incubator/apollo/trunk/src/java/org/apache/ws/util/velocity/CommonsLogLogSystem.java
Modified:
incubator/apollo/trunk/maven.xml
incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java
Modified: incubator/apollo/trunk/maven.xml
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/maven.xml?view=diff&rev=126449&p1=incubator/apollo/trunk/maven.xml&r1=126448&p2=incubator/apollo/trunk/maven.xml&r2=126449
==============================================================================
--- incubator/apollo/trunk/maven.xml (original)
+++ incubator/apollo/trunk/maven.xml Tue Jan 25 16:15:25 2005
@@ -121,10 +121,10 @@
<!-- ================================================================== -->
<postGoal name="war:webapp">
- <!-- Delete the J-WSRF classes that war:webapp copied into WEB-INF/classes/. -->
+ <!-- Delete the Apollo classes that war:webapp copied into WEB-INF/classes/. -->
<delete><fileset dir="${maven.war.webapp.dir}/WEB-INF/classes" excludes="*.*, wsdl" /></delete>
- <!-- Build J-WSRF jar and copy it into WEB-INF/lib/. -->
+ <!-- Build Apollo jar and copy it into WEB-INF/lib/. -->
<j:set var="maven.test.skip" value="true" />
<attainGoal name="jar:jar" />
<copy file="${maven.build.dir}/${maven.final.name}.jar" todir="${maven.war.webapp.dir}/WEB-INF/lib" overwrite="true" verbose="true" />
@@ -148,8 +148,7 @@
<!-- ================================================================== -->
<postGoal name="dist:prepare-bin-filesystem">
- <!-- Delete the project jar that dist:prepare-bin-filesystem placed
- in the dist dir. -->
+ <!-- Delete the Apollo jar that dist:prepare-bin-filesystem placed in the dist dir. -->
<delete file="${maven.dist.bin.assembly.dir}/${maven.final.name}.jar" />
<attainGoal name="war:webapp" />
@@ -181,8 +180,8 @@
<!-- P O S T - G O A L -->
<!-- ================================================================== -->
<postGoal name="dist:prepare-src-filesystem">
- <!-- Delete the faulty maven-ant-plugin-generated build.xml, forcing
- use of Maven to build our sources. -->
+ <!-- Delete the faulty build.xml that was generated by maven-ant-plugin, forcing
+ use of Maven to build our source distribution. -->
<delete file="${maven.dist.src.assembly.dir}/build.xml" />
</postGoal>
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java?view=diff&rev=126449&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java&r1=126448&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java&r2=126449
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java Tue Jan 25 16:15:25 2005
@@ -23,6 +23,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.app.Velocity;
import org.apache.ws.resource.ResourceDefinition;
import org.apache.ws.resource.i18n.Keys;
@@ -38,6 +39,7 @@
import org.apache.ws.resource.tool.velocity.ImplementsListBuilder;
import org.apache.ws.resource.tool.velocity.ServiceProperties;
import org.apache.ws.util.XmlBeanNameUtils;
+import org.apache.ws.util.velocity.CommonsLogLogSystem;
import org.apache.ws.util.i18n.Messages;
import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
@@ -461,12 +463,14 @@
private void initVelocity()
throws Exception
{
- Velocity.addProperty( Velocity.RESOURCE_LOADER, "classpath" );
- Velocity.setProperty( "classpath." + Velocity.RESOURCE_LOADER + ".class",
- "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" );
- Velocity.setProperty( "classpath." + Velocity.RESOURCE_LOADER + ".cache", "false" );
- Velocity.setProperty( "classpath." + Velocity.RESOURCE_LOADER + ".modificationCheckInterval", "2" );
+ Velocity.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, CommonsLogLogSystem.class.getName() );
+ Velocity.addProperty( RuntimeConstants.RESOURCE_LOADER, "classpath" );
+ String resourceLoaderBaseKey = "classpath." + RuntimeConstants.RESOURCE_LOADER + ".";
+ Velocity.setProperty( resourceLoaderBaseKey + "class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" );
+ Velocity.setProperty( resourceLoaderBaseKey + "cache", "false" );
+ Velocity.setProperty( resourceLoaderBaseKey + "modificationCheckInterval", "2" );
Velocity.init();
+ Velocity.s
}
private void processTemplate( VelocityContext context,
@@ -485,10 +489,9 @@
try
{
Template template = Velocity.getTemplate( templateLocation );
-
/*
* Now have the template engine process your template using the
- * data placed into the context. Think of it as a 'merge'
+ * data placed into the context. Think of it as a 'merge'
* of the template and the data to produce the output stream.
*/
FileWriter writer = new FileWriter( outputFile );
@@ -496,8 +499,6 @@
{
template.merge( context, writer );
}
-
- writer.flush();
writer.close();
}
catch ( Exception e )
Added: incubator/apollo/trunk/src/java/org/apache/ws/util/velocity/CommonsLogLogSystem.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/velocity/CommonsLogLogSystem.java?view=auto&rev=126449
==============================================================================
--- (empty file)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/velocity/CommonsLogLogSystem.java Tue Jan 25 16:15:25 2005
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2003 The Apache Software 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.
+ */
+
+package org.apache.ws.util.velocity;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.log.LogSystem;
+
+/**
+ * Redirects Velocity's LogSystem messages to commons-logging
+ * (snarfed from <a href="http://jakarta.apache.org/velocity/tools/generic/">Velocity
+ * Generic Tools</a> project).
+ *
+ * <p>To use, first set up commons-logging, then tell Velocity to use
+ * this class for logging by adding the following to your velocity.properties:
+ *
+ * <code>
+ * runtime.log.logsystem.class = org.apache.velocity.tools.generic.log.CommonsLogLogSystem
+ * </code>
+ * </p>
+ *
+ * <p>You may also set this property to specify what log/name Velocity's
+ * messages should be logged to (example below is default).
+ * <code>
+ * runtime.log.logsystem.commons.logging.name = org.apache.velocity
+ * </code>
+ * </p>
+ *
+ * @author <a href="mailto:nathan@esha.com">Nathan Bubna</a>
+ * @since VelocityTools 1.1
+ * @version $Id: CommonsLogLogSystem.java,v 1.3 2004/02/18 20:10:38 nbubna Exp $
+ */
+public class CommonsLogLogSystem implements LogSystem
+{
+
+ /** Property key for specifying the name for the log instance */
+ public static final String LOGSYSTEM_COMMONS_LOG_NAME =
+ "runtime.log.logsystem.commons.logging.name";
+
+ /** Default name for the commons-logging instance */
+ public static final String DEFAULT_LOG_NAME = "org.apache.velocity";
+
+
+ /** the commons-logging Log instance */
+ protected Log log;
+
+
+ /********** LogSystem methods *************/
+
+ public void init(RuntimeServices rs) throws Exception
+ {
+ String name =
+ (String)rs.getProperty(LOGSYSTEM_COMMONS_LOG_NAME);
+
+ if (name == null)
+ {
+ name = DEFAULT_LOG_NAME;
+ }
+ log = LogFactory.getLog(name);
+ logVelocityMessage(LogSystem.DEBUG_ID,
+ "CommonsLogLogSystem name is '" + name + "'");
+ }
+
+ /**
+ * Send a log message from Velocity.
+ */
+ public void logVelocityMessage(int level, String message)
+ {
+ switch (level)
+ {
+ case LogSystem.WARN_ID:
+ log.warn(message);
+ break;
+ case LogSystem.INFO_ID:
+ log.info(message);
+ break;
+ case LogSystem.DEBUG_ID:
+ log.debug(message);
+ break;
+ case LogSystem.ERROR_ID:
+ log.error(message);
+ break;
+ default:
+ log.debug(message);
+ break;
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org