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/05/10 00:08:33 UTC
svn commit: r169368 - in /incubator/apollo/trunk/src:
java/org/apache/ws/resource/tool/Wsdl2Java.java
java/org/apache/ws/resource/tool/Wsdl2JavaTask.java
templates/build.properties.vm templates/build.xml.vm
test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
Author: ips
Date: Mon May 9 15:08:32 2005
New Revision: 169368
URL: http://svn.apache.org/viewcvs?rev=169368&view=rev
Log:
disabled outputs of benign Velocity warnings/errors by setting a couple Velocity config props; escaped Ant vars in Velocity build.* templates; removed support for -debug option from Wsdl2Java
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java
incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java
incubator/apollo/trunk/src/templates/build.properties.vm
incubator/apollo/trunk/src/templates/build.xml.vm
incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
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?rev=169368&r1=169367&r2=169368&view=diff
==============================================================================
--- 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 Mon May 9 15:08:32 2005
@@ -299,8 +299,7 @@
*/
protected void addPortType2JavaInfo( PortType2JavaInfo ptInfo )
{
- m_portTypeInfoMap.put( ptInfo.getName(),
- ptInfo );
+ m_portTypeInfoMap.put( ptInfo.getName(), ptInfo );
}
private static void checkForRequiredOption( CommandLine cmdLine,
@@ -327,10 +326,6 @@
LongOpts.VERBOSE,
false,
MSG.getMessage( Keys.OPT_ENABLE_VERBOSE ) );
- CMD_LINE_OPTIONS.addOption( Opts.DEBUG,
- LongOpts.DEBUG,
- false,
- MSG.getMessage( Keys.OPT_ENABLE_DEBUG ) );
}
private String getJarFileName( File wsdlFile )
@@ -388,20 +383,13 @@
for ( int i = 0; i < propertyNames.length; i++ )
{
QName propertyName = propertyNames[i];
- String propName = propertyName.getLocalPart().toUpperCase();
- int count = 2;
- while ( propMap.containsKey( propName ) )
- {
- propName = propName + count;
- count++;
- }
-
+ String propName = getJavaConstantName( propertyName, propMap );
propMap.put( propName, propertyName );
}
props.setPropertyMap( propMap );
}
- //tell the service props which props we implemement for the user..
+ // define the names of the resource props that we initialize for the user...
props.addImplementedProperty(org.apache.ws.resource.lifetime.v2004_06.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME);
props.addImplementedProperty(org.apache.ws.resource.lifetime.v2004_06.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_CURRENT_TIME);
props.addImplementedProperty(org.apache.ws.resource.lifetime.v2004_11.porttype.ScheduledResourceTerminationPortType.PROP_QNAME_TERMINATION_TIME);
@@ -456,12 +444,11 @@
props.setNamespaceVersionHolder(org.apache.ws.resource.properties.v2004_11.impl.NamespaceVersionHolderImpl.class);
}
-
- /**
- * These props are for JIRA Apollo-4 and could be added to context obj
- * The question is whether the service name here should be the real wsdl
+ /*
+ * These props are for JIRA APOLLO-4 and could be added to context obj
+ * The question is whether the service name here should be the real wsdl
* service name or the service name as we use it...
- **/
+ */
String portName = resourceDef.getPort().getName();
props.setPortName(portName);
QName portTypeQName = resourceDef.getPortType().getQName();
@@ -471,6 +458,16 @@
return props;
}
+ private String getJavaConstantName( QName propertyName, Map propMap )
+ {
+ String constName = propertyName.getLocalPart().toUpperCase();
+ for ( int count = 2; propMap.containsKey( constName ); count++ )
+ {
+ constName += count;
+ }
+ return constName;
+ }
+
protected String getWebbappName()
{
return WEBAPP_NAME;
@@ -508,15 +505,16 @@
{
wsdlFile
} );
- scompParams.setDownload( true );
scompParams.setClasspath( m_classpath );
+ scompParams.setDownload( true ); // download remote xsd inputs/imports
+ scompParams.setDebug( true ); // compile w/ debug symbols
scompParams.setVerbose( m_options.isVerbose() );
- scompParams.setDebug( m_options.isDebug() );
+ scompParams.setQuiet( ! m_options.isVerbose() );
final boolean beNoisy = true;
XmlErrorPrinter xErrorListener = new XmlErrorPrinter( beNoisy, null );
scompParams.setErrorListener( xErrorListener );
File jarDir = new File( m_xmlbeansDir, "lib" );
- jarDir.mkdirs( );
+ jarDir.mkdirs();
String wsdlJarFileName = getJarFileName( wsdlFile );
scompParams.setOutputJar( new File( jarDir, wsdlJarFileName ) );
try
@@ -574,6 +572,10 @@
{
// configure to use Commons Logging for logging
Velocity.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, CommonsLogLogSystem.class.getName() );
+ // don't log warnings for invalid variable references
+ Velocity.setProperty( RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID, "false" );
+ // don't load any global macro libraries (override default of "VM_global_library.vm")
+ Velocity.setProperty( RuntimeConstants.VM_LIBRARY, "" );
// configure to use classpath-based resource loader
Velocity.addProperty( RuntimeConstants.RESOURCE_LOADER, "classpath" );
String resourceLoaderBaseKey = "classpath." + RuntimeConstants.RESOURCE_LOADER + ".";
@@ -594,7 +596,7 @@
* ResourceNotFoundException : if it doesn't find the template
* ParseErrorException : if there is something wrong with the VTL
* Exception : if something else goes wrong (this is generally
- * indicative of as serious problem...)
+ * indicative of a serious problem...)
*/
try
{
@@ -624,7 +626,7 @@
* @param context
* @return VelocityContext
*/
- protected VelocityContext updateVelociyContext(VelocityContext context,ResourceDefinition resourceDef)
+ protected VelocityContext updateVelocityContext(VelocityContext context,ResourceDefinition resourceDef)
{
return context;
}
@@ -638,8 +640,8 @@
{
VelocityContext context = new VelocityContext();
ServiceProperties props = buildServiceProperties( resourceDef, wsdlFile, serviceDir );
- context.put( "generated", props );//add this here
- updateVelociyContext(context,resourceDef);
+ context.put( "generated", props );
+ updateVelocityContext(context,resourceDef);
//generate files
File packageDir = getPackageDir( resourceDef.getDefinition().getTargetNamespace(), serviceDir );
@@ -649,77 +651,18 @@
outputFile = new File( packageDir, capitalizedServiceName + "Service.java" );
- //only generate if it doesn't exist
if ( !outputFile.exists() )
{
processTemplate( context, "templates/Service.vm", outputFile );
}
- //generate fault classes
- Iterator customOperations = props.getCustomMappings().values().iterator();
- while (customOperations.hasNext())
- {
- OperationInfo oparationInfo = (OperationInfo) customOperations.next();
- //need to determine if fault is instanceof BaseFault
- Iterator faultIterator = oparationInfo.getFaults().values().iterator();
- while (faultIterator.hasNext())
- {
- Fault fault = (Fault) faultIterator.next();
- Message message = fault.getMessage();
- Map parts = message.getParts();
- if (parts.size() != 1)
- {
- throw new RuntimeException( "Wsdl fault message should have exactly one part." );
- }
- Part part = (Part) parts.values().iterator().next();
-
- QName faultName = part.getTypeName();
- boolean isType=true;
- if (faultName == null)
- {
- faultName = part.getElementName();
- isType = false;
- }
- if (faultName == null)
- {
- throw new RuntimeException( "Wsdl fault maeesage part should have either an element or a type." );
- }
-
- String exceptionFaultName = StringUtils.capitalize(faultName.getLocalPart()) + "Exception";
- //ok heres the file we'll generate
- outputFile = new File(packageDir, exceptionFaultName + ".java");
- context.put("faultName", exceptionFaultName);
-
- if (!outputFile.exists())
- {
- try
- {
- if (isBaseFaultExtension(faultName, isType))
- {
- processTemplate(context, "templates/BaseFaultExtension.vm", outputFile);
- }
- else
- {
- processTemplate(context, "templates/CustomFault.vm", outputFile);
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException( "Unable to generate Wsdl fault. Cause: " + e.getLocalizedMessage() );
- }
- }
-
- }
-
- }
-
+ generateFaultClasses( context, props, packageDir );
outputFile = new File( packageDir, "Abstract" + capitalizedServiceName + "Resource.java" );
processTemplate( context, "templates/AbstractResource.vm", outputFile );
outputFile = new File( packageDir, capitalizedServiceName + "Resource.java" );
- //only generate if it doesn't exist
if ( !outputFile.exists() )
{
processTemplate( context, "templates/Resource.vm", outputFile );
@@ -727,13 +670,11 @@
outputFile = new File( packageDir, capitalizedServiceName + "Home.java" );
- //only generate if it doesn't exist
if ( !outputFile.exists() )
{
processTemplate( context, "templates/Home.vm", outputFile );
}
- //only if they implemented properties does this make sense.
if ( resourceDef.hasProperties() )
{
outputFile = new File( packageDir, capitalizedServiceName + "PropertyQNames.java" );
@@ -762,6 +703,66 @@
}
}
+ private void generateFaultClasses( VelocityContext context, ServiceProperties props, File packageDir )
+ throws Exception
+ {
+ File outputFile;
+ Iterator customOperations = props.getCustomMappings().values().iterator();
+ while (customOperations.hasNext())
+ {
+ OperationInfo oparationInfo = (OperationInfo) customOperations.next();
+ //need to determine if fault is instanceof BaseFault
+ Iterator faultIterator = oparationInfo.getFaults().values().iterator();
+ while (faultIterator.hasNext())
+ {
+ Fault fault = (Fault) faultIterator.next();
+ Message message = fault.getMessage();
+ Map parts = message.getParts();
+ if (parts.size() != 1)
+ {
+ throw new Exception( "WSDL fault message should have exactly one part." );
+ }
+ Part part = (Part) parts.values().iterator().next();
+
+ QName faultName = part.getTypeName();
+ boolean isType=true;
+ if (faultName == null)
+ {
+ faultName = part.getElementName();
+ isType = false;
+ }
+ if (faultName == null)
+ {
+ throw new Exception( "WSDL fault message part should have either an element or a type." );
+ }
+
+ String exceptionFaultName = StringUtils.capitalize(faultName.getLocalPart()) + "Exception";
+ //ok here's the file we'll generate
+ outputFile = new File(packageDir, exceptionFaultName + ".java");
+ context.put("faultName", exceptionFaultName);
+
+ if (!outputFile.exists())
+ {
+ try
+ {
+ if (isBaseFaultExtension(faultName, isType))
+ {
+ processTemplate(context, "templates/BaseFaultExtension.vm", outputFile);
+ }
+ else
+ {
+ processTemplate(context, "templates/CustomFault.vm", outputFile);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Exception( "Unable to generate WSDL fault. Cause: " + e, e );
+ }
+ }
+ }
+ }
+ }
+
/**
* Determines if the passed in QName is for a type which extends
* BaseFault.
@@ -824,11 +825,6 @@
/**
* DOCUMENT_ME
*/
- String DEBUG = "debug";
-
- /**
- * DOCUMENT_ME
- */
String CLASSPATH = "classpath";
}
@@ -870,32 +866,11 @@
public static class Wsdl2JavaOptions
{
private boolean m_verbose;
- private boolean m_debug;
-
- /**
- * DOCUMENT_ME
- *
- * @param debug DOCUMENT_ME
- */
- public void setDebug( boolean debug )
- {
- m_debug = debug;
- }
-
- /**
- * DOCUMENT_ME
- *
- * @return DOCUMENT_ME
- */
- public boolean isDebug()
- {
- return m_debug;
- }
/**
- * DOCUMENT_ME
+ * Enable/disable verbose output.
*
- * @param verbose DOCUMENT_ME
+ * @param verbose option indicating whether or not to enable verbose output
*/
public void setVerbose( boolean verbose )
{
@@ -903,9 +878,9 @@
}
/**
- * DOCUMENT_ME
+ * Returns true if verbose output is enabled, or false otherwise.
*
- * @return DOCUMENT_ME
+ * @return true if verbose output is enabled, or false otherwise
*/
public boolean isVerbose()
{
@@ -926,29 +901,26 @@
private URLClassLoader getGeneratedXmlBeanClassloader()
{
- File dir = new File(m_xmlbeansDir, "lib");
- File[] files = dir.listFiles(new FilenameFilter(){
+ File libDir = new File(m_xmlbeansDir, "lib");
+ File[] jarFiles = libDir.listFiles(new FilenameFilter(){
public boolean accept(File dir, String name)
{
- if(name.endsWith("jar")) return true;
- return false;
+ return name.endsWith(".jar");
}
});
- URL[] urls = new URL[files.length];
- for (int i = 0; i < files.length; i++)
+ URL[] urls = new URL[jarFiles.length];
+ for (int i = 0; i < jarFiles.length; i++)
{
try
{
- urls[i] = files[i].toURL();
+ urls[i] = jarFiles[i].toURL();
}
- catch (MalformedURLException e)
+ catch (MalformedURLException murle)
{
- throw new RuntimeException( "Unable to load XmlBeans-generated jars and convert to URLs. Cause: " + e.getLocalizedMessage() );
+ throw new RuntimeException( "Unable to load XMLBeans-generated jars and convert to URLs. Cause: " + murle, murle );
}
-
}
- return new URLClassLoader(urls, this.getClass().getClassLoader());
-
+ return new URLClassLoader(urls, this.getClass().getClassLoader());
}
-}
\ No newline at end of file
+}
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java?rev=169368&r1=169367&r2=169368&view=diff
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java Mon May 9 15:08:32 2005
@@ -47,7 +47,6 @@
private File m_outputDir;
private Path m_classpath;
private Boolean m_verbose;
- private Boolean m_debug;
public void setOutputDir( File outputDir )
{
@@ -105,10 +104,12 @@
* DOCUMENT_ME
*
* @param debug DOCUMENT_ME
+ *
+ * @deprecated
*/
public void setDebug( boolean debug )
{
- m_debug = Boolean.valueOf( debug );
+ // this attribute is no longer used
}
/**
@@ -212,10 +213,6 @@
if ( m_verbose != null )
{
options.setVerbose( m_verbose.booleanValue() );
- }
- if ( m_debug != null )
- {
- options.setDebug( m_debug.booleanValue() );
}
File[] classpathFiles = Wsdl2Java.toFileArray( m_classpath.toString() );
File[] wsdlFiles = (File[]) m_wsdls.toArray( new File[0] );
Modified: incubator/apollo/trunk/src/templates/build.properties.vm
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/templates/build.properties.vm?rev=169368&r1=169367&r2=169368&view=diff
==============================================================================
--- incubator/apollo/trunk/src/templates/build.properties.vm (original)
+++ incubator/apollo/trunk/src/templates/build.properties.vm Mon May 9 15:08:32 2005
@@ -1,13 +1,11 @@
-#set( $endpointURL = $generated.EndpointURL )
-
-endpoint.url=${endpointURL}
+endpoint.url = $generated.EndpointURL
# Uncomment and modify the below lines if you would like to deploy to a
# webapp located somewhere other than the default location of
-# ../webapps/${generated.WebappName} (e.g. ${env.CATALINA_HOME}/webapps/${generated.WebappName} )
-#${generated.WebappName}.webapp.dir=
+# ../webapps/$generated.WebappName (e.g. \${env.CATALINA_HOME}/webapps/$generated.WebappName )
+#$generated.WebappName.webapp.dir =
# Uncomment and modify the below lines if you require a proxy to connect to external web sites
-#http.proxyHost=proxy.xyz.com
-#http.proxyPort=8088
-#http.nonProxyHosts=localhost
+#http.proxyHost = proxy.xyz.com
+#http.proxyPort = 8088
+#http.nonProxyHosts = localhost
Modified: incubator/apollo/trunk/src/templates/build.xml.vm
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/templates/build.xml.vm?rev=169368&r1=169367&r2=169368&view=diff
==============================================================================
--- incubator/apollo/trunk/src/templates/build.xml.vm (original)
+++ incubator/apollo/trunk/src/templates/build.xml.vm Mon May 9 15:08:32 2005
@@ -28,10 +28,10 @@
<echo>Using webapp dir: ${${generated.WebappName}.webapp.dir}</echo>
<path id="${serviceName}.classpath.id">
<pathelement location="${${generated.WebappName}.webapp.dir}/WEB-INF/classes" />
- <fileset dir="${${generated.WebappName}.webapp.dir}/WEB-INF/lib" includes="*.jar" />
- <fileset dir="${jar.dir}" />
- <pathelement location="${activation.jar}" />
- <pathelement location="${mail.jar}" />
+ <fileset dir="\${${generated.WebappName}.webapp.dir}/WEB-INF/lib" includes="*.jar" />
+ <fileset dir="\${jar.dir}" />
+ <pathelement location="\${activation.jar}" />
+ <pathelement location="\${mail.jar}" />
</path>
<property name="${serviceName}.classpath" refid="${serviceName}.classpath.id" />
@@ -40,40 +40,40 @@
<target name="compile"
depends="init"
description="compile all classes below classes directory">
- <mkdir dir="${classes.dir}" />
- <javac srcdir="${src.dir}"
- destdir="${classes.dir}"
+ <mkdir dir="\${classes.dir}" />
+ <javac srcdir="\${src.dir}"
+ destdir="\${classes.dir}"
classpathref="${serviceName}.classpath.id"
debug="on"
excludes="xmlbeans/**"/>
- <copy todir="${classes.dir}">
- <fileset dir="${src.dir}" excludes="**/*.java,**/package.html" />
+ <copy todir="\${classes.dir}">
+ <fileset dir="\${src.dir}" excludes="**/*.java,**/package.html" />
</copy>
</target>
<target name="deploy"
depends="init"
- description="deploys the ${endpointServiceName} service to the ${${generated.WebappName}.webapp.dir} webapp">
+ description="deploys the ${endpointServiceName} service to the \${${generated.WebappName}.webapp.dir} webapp">
- <copy file="${wsdl.file}" todir="${${generated.WebappName}.webapp.dir}/WEB-INF/classes/wsdl" overwrite="true" verbose="true" />
- <echo>Deploying ${endpointServiceName} classes to ${${generated.WebappName}.webapp.dir}/WEB-INF/classes/...</echo>
+ <copy file="\${wsdl.file}" todir="${${generated.WebappName}.webapp.dir}/WEB-INF/classes/wsdl" overwrite="true" verbose="true" />
+ <echo>Deploying ${endpointServiceName} classes to \${${generated.WebappName}.webapp.dir}/WEB-INF/classes/...</echo>
<copy todir="${${generated.WebappName}.webapp.dir}/WEB-INF/classes">
- <fileset dir="${classes.dir}" />
+ <fileset dir="\${classes.dir}" />
</copy>
- <copy file="${jar.dir}/${jarFile}" todir="${${generated.WebappName}.webapp.dir}/WEB-INF/lib" />
+ <copy file="\${jar.dir}/${jarFile}" todir="\${${generated.WebappName}.webapp.dir}/WEB-INF/lib" />
<!-- update server-config.wsdd using WsddUpdater -->
<taskdef name="wsddUpdater" classname="org.apache.ws.util.platform.axis.tool.WsddUpdater" classpathref="${serviceName}.classpath.id" />
- <property name="config.wsdd" location="${${generated.WebappName}.webapp.dir}/WEB-INF/server-config.wsdd" /> <!-- normalize path -->
- <wsddUpdater configWsdd="${config.wsdd}">
- <wsddPaths dir="${src.dir}" includes="**/${serviceName}_deploy.wsdd" />
+ <property name="config.wsdd" location="\${${generated.WebappName}.webapp.dir}/WEB-INF/server-config.wsdd" /> <!-- normalize path -->
+ <wsddUpdater configWsdd="\${config.wsdd}">
+ <wsddPaths dir="\${src.dir}" includes="**/${serviceName}_deploy.wsdd" />
</wsddUpdater>
<!-- update jndi-config.wsdd using JndiConfigUpdater -->
<taskdef name="jndiUpdater" classname="org.apache.ws.util.jndi.tools.JndiConfigUpdater" classpathref="${serviceName}.classpath.id" />
- <property name="jndi.config" location="${${generated.WebappName}.webapp.dir}/WEB-INF/classes/jndi-config.xml" /> <!-- normalize path -->
- <jndiUpdater jndiConfig="${jndi.config}">
- <jndiConfigPaths dir="${src.dir}" includes="**/${serviceName}_jndi-config.xml" />
+ <property name="jndi.config" location="\${${generated.WebappName}.webapp.dir}/WEB-INF/classes/jndi-config.xml" /> <!-- normalize path -->
+ <jndiUpdater jndiConfig="\${jndi.config}">
+ <jndiConfigPaths dir="\${src.dir}" includes="**/${serviceName}_jndi-config.xml" />
</jndiUpdater>
</target>
@@ -82,19 +82,19 @@
description="sends a request to the ${endpointServiceName} service">
<ant antfile="soapclient.xml">
- <property name="url" value="${endpoint.url}" />
+ <property name="url" value="\${endpoint.url}" />
</ant>
</target>
<target name="clean" description="delete the generated source and class files">
- <delete dir="${classes.dir}" />
+ <delete dir="\${classes.dir}" />
</target>
<target name="usage">
<java classname="org.apache.tools.ant.Main">
<arg value="-buildfile" />
- <arg value="${ant.file}" />
+ <arg value="\${ant.file}" />
<arg value="-projecthelp" />
</java>
</target>
Modified: incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java?rev=169368&r1=169367&r2=169368&view=diff
==============================================================================
--- incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java (original)
+++ incubator/apollo/trunk/src/test/org/apache/ws/resource/properties/AbstractResourcePropertiesTestCase.java Mon May 9 15:08:32 2005
@@ -115,6 +115,7 @@
scompParams.setClassesDir( CLASSES_DIR );
scompParams.setXsdFiles( new File[] {xsdFile} );
scompParams.setDownload( true );
+ scompParams.setQuiet( true );
XmlErrorPrinter errorPrinter = new XmlErrorPrinter(true, null);
scompParams.setErrorListener( errorPrinter );
SRC_DIR.mkdirs(); // necessary?
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org