Author: ips Date: Thu Jan 6 14:54:32 2005 New Revision: 124460 URL: http://svn.apache.org/viewcvs?view=rev&rev=124460 Log: classpath option is now mandatory and we validate that it contains both xbean.jar and wsrf-xbeans.jar
Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java?view=diff&rev=124460&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java&r1=124459&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java&r2=124460 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/i18n/Keys.java Thu Jan 6 14:54:32 2005 @@ -65,7 +65,7 @@ String OPT_CLASSPATH_SENT_TO_XMLBEANS = "OPT_CLASSPATH_SENT_TO_XMLBEANS"; /** - * @msg WARN: Passed-in array of WSDL files is empty. + * @msg No WSDL files were specified. Nothing to do. */ String WARN_EMPTY_WSDLS = "WARN_EMPTY_WSDLS"; Modified: incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java?view=diff&rev=124460&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java&r1=124459&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java&r2=124460 ============================================================================== --- incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java (original) +++ incubator/apollo/trunk/src/java/org/apache/ws/resource/lifetime/ResourceNotDestroyedException.java Thu Jan 6 14:54:32 2005 @@ -15,64 +15,47 @@ *=============================================================================*/ package org.apache.ws.resource.lifetime; - -/*=============================================================================* - * Copyright 2004 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. - *=============================================================================*/ - /** - * LOG-DONE - * TODO + * LOG-DONE TODO * * @author Ian P. Springer (Hewlett-Packard Company) */ public class ResourceNotDestroyedException - extends Exception + extends Exception { - private Object m_resourceId; - private String m_serviceName; + private Object m_resourceId; + private String m_serviceName; + + /** + * @param resourceId + * @param serviceName + */ + public ResourceNotDestroyedException( Object resourceId, + String serviceName ) + { + super( serviceName + " resource with Id " + resourceId + " could not be destroyed." ); + m_resourceId = resourceId; + m_serviceName = serviceName; + } - /** - * @param resourceId - * @param serviceName - */ - public ResourceNotDestroyedException( Object resourceId, - String serviceName ) - { - super( serviceName + " resource with Id " + resourceId + " could not be destroyed." ); - m_resourceId = resourceId; - m_serviceName = serviceName; - } + /** + * DOCUMENT_ME + * + * @return DOCUMENT_ME + */ + public Object getResourceId() + { + return m_resourceId; + } - /** - * DOCUMENT_ME - * - * @return DOCUMENT_ME - */ - public Object getResourceId( ) - { - return m_resourceId; - } + /** + * DOCUMENT_ME + * + * @return DOCUMENT_ME + */ + public String getServiceName() + { + return m_serviceName; + } - /** - * DOCUMENT_ME - * - * @return DOCUMENT_ME - */ - public String getServiceName( ) - { - return m_serviceName; - } } 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=124460&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java&r1=124459&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2Java.java&r2=124460 ============================================================================== --- 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 Thu Jan 6 14:54:32 2005 @@ -41,6 +41,8 @@ import org.apache.ws.util.i18n.Messages; import org.apache.xmlbeans.impl.common.XmlErrorPrinter; import org.apache.xmlbeans.impl.tool.SchemaCompiler; +import org.apache.xmlbeans.XmlObject; +import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetResourcePropertyDocument; import javax.wsdl.Definition; import javax.wsdl.Service; @@ -57,6 +59,9 @@ import java.util.List; import java.util.Map; import java.util.StringTokenizer; +import java.net.URLClassLoader; +import java.net.URL; +import java.net.MalformedURLException; /** * Generates Java Web service types and skeletons from a WSRF WSDL. @@ -86,16 +91,19 @@ private File m_xBeanSrcOutputDir; private File m_classesOutputDir; private File m_libOutputDir; + private File[] m_classpath; /** * Creates a new [EMAIL PROTECTED] Wsdl2Java} object. * * @param wsdlFiles DOCUMENT_ME * @param outputDir DOCUMENT_ME + * @param classpathFiles * @param options DOCUMENT_ME */ public Wsdl2Java( File[] wsdlFiles, File outputDir, + File[] classpathFiles, Wsdl2JavaOptions options ) throws Exception { m_wsdlFiles = wsdlFiles; @@ -108,12 +116,46 @@ m_xBeanSrcOutputDir = new File( outputDir, "src/xmlbeans" ); m_classesOutputDir = new File( outputDir, "classes" ); m_libOutputDir = new File( outputDir, "lib" ); + m_classpath = classpathFiles; + validateClasspath(); m_options = ( options != null ) ? options : new Wsdl2JavaOptions(); m_wsdlReader = WSDLFactory.newInstance().newWSDLReader(); initVelocity(); initPortTypeInfoMap(); } + private void validateClasspath() + throws MalformedURLException + { + URLClassLoader cpClassLoader = new URLClassLoader( toURLs( m_classpath ), null ); + try + { + cpClassLoader.loadClass( XmlObject.class.getName() ); + } + catch ( ClassNotFoundException cnfe ) + { + throw new IllegalStateException( "Specified classpath must contain the XMLBeans runtime jar (e.g. xbean-v1HEAD-SNAPSHOT-20041129.jar)" ); + } + try + { + cpClassLoader.loadClass( GetResourcePropertyDocument.class.getName() ); + } + catch ( ClassNotFoundException cnfe ) + { + throw new IllegalStateException( "Specified classpath must contain the WSRF generated XMLBeans jar (e.g. wsrf-xbeans-SNAPSHOT.jar)" ); + } + } + + private URL[] toURLs( File[] files ) throws MalformedURLException + { + URL[] urls = new URL[files.length]; + for ( int i = 0; i < files.length; i++ ) + { + urls[i] = files[i].toURL(); + } + return urls; + } + /** * DOCUMENT_ME * @@ -186,15 +228,12 @@ { CommandLine cmdLine = new PosixParser().parse( CMD_LINE_OPTIONS, args, true ); checkForRequiredOption( cmdLine, Opts.OUTPUT_DIR ); + checkForRequiredOption( cmdLine, Opts.CLASSPATH ); File outputDir = new File( cmdLine.getOptionValue( Opts.OUTPUT_DIR ) ); + File[] classpathFiles = toFileArray( cmdLine.getOptionValue( Opts.CLASSPATH ) ); Wsdl2JavaOptions options = new Wsdl2Java.Wsdl2JavaOptions(); - if ( cmdLine.hasOption( Opts.CLASSPATH ) ) - { - options.setClasspath( cmdLine.getOptionValue( Opts.CLASSPATH ) ); - } - if ( cmdLine.hasOption( Opts.VERBOSE ) ) { options.setVerbose( Boolean.valueOf( cmdLine.getOptionValue( Opts.VERBOSE ) ).booleanValue() ); @@ -216,7 +255,7 @@ System.out.println( MSG.getMessage( Keys.WSDL4J_PASSED_ARGUMENTS, Integer.toString( wsdlFiles.length ), outputDir ) ); - new Wsdl2Java( wsdlFiles, outputDir, options ).generate(); + new Wsdl2Java( wsdlFiles, outputDir, classpathFiles, options ).generate(); } catch ( Exception e ) { @@ -309,7 +348,8 @@ String targetNamespace = resourceDef.getDefinition().getTargetNamespace(); props.setPackageName( GenerationUtils.getJavaPackageName( targetNamespace ) ); String serviceName = resourceDef.getName(); - String upperCaseServiceName = getUpperCaseServiceName( serviceName ); + String capitalizedServiceName = StringUtils.capitalize( serviceName ); + String upperCaseServiceName = capitalizedServiceName; props.setServiceName( upperCaseServiceName ); props.setJarDir( m_libOutputDir.getAbsolutePath() ); props.setSrcDir( m_javaSrcOutputDir.getAbsolutePath() ); @@ -357,7 +397,6 @@ { props.addResourceIncludeFile( ptInfo.getResourceTemplateFileName() ); } - if ( ptInfo.getServiceTemplateFileName() != null ) { props.addServiceIncludeFile( ptInfo.getServiceTemplateFileName() ); @@ -380,7 +419,7 @@ wsdlFile } ); scompParams.setDownload( true ); - scompParams.setClasspath( m_options.getClasspath() ); + scompParams.setClasspath( m_classpath ); scompParams.setVerbose( m_options.isVerbose() ); scompParams.setDebug( m_options.isDebug() ); final boolean beNoisy = true; @@ -477,7 +516,7 @@ File wsdlFile ) throws Exception { - String serviceName = getUpperCaseServiceName( resourceDef.getName() ); + String capitalizedServiceName = StringUtils.capitalize( resourceDef.getName() ); try { VelocityContext context = new VelocityContext(); @@ -491,10 +530,10 @@ //generate files File packageDir = getPackageDir( resourceDef.getDefinition().getTargetNamespace() ); packageDir.mkdirs(); - File outputFile = new File( packageDir, "Abstract" + serviceName + "Service.java" ); + File outputFile = new File( packageDir, "Abstract" + capitalizedServiceName + "Service.java" ); processTemplate( context, "templates/AbstractService.vm", outputFile ); - outputFile = new File( packageDir, serviceName + "Service.java" ); + outputFile = new File( packageDir, capitalizedServiceName + "Service.java" ); //only generate if it doesn't exist if ( !outputFile.exists() ) @@ -502,10 +541,10 @@ processTemplate( context, "templates/Service.vm", outputFile ); } - outputFile = new File( packageDir, "Abstract" + serviceName + "Resource.java" ); + outputFile = new File( packageDir, "Abstract" + capitalizedServiceName + "Resource.java" ); processTemplate( context, "templates/AbstractResource.vm", outputFile ); - outputFile = new File( packageDir, serviceName + "Resource.java" ); + outputFile = new File( packageDir, capitalizedServiceName + "Resource.java" ); //only generate if it doesn't exist if ( !outputFile.exists() ) @@ -513,7 +552,7 @@ processTemplate( context, "templates/Resource.vm", outputFile ); } - outputFile = new File( packageDir, serviceName + "Home.java" ); + outputFile = new File( packageDir, capitalizedServiceName + "Home.java" ); //only generate if it doesn't exist if ( !outputFile.exists() ) @@ -524,17 +563,17 @@ //only if they implemented properties does this make sense. if ( resourceDef.hasProperties() ) { - outputFile = new File( packageDir, serviceName + "PropertyQNames.java" ); + outputFile = new File( packageDir, capitalizedServiceName + "PropertyQNames.java" ); processTemplate( context, "templates/PropertyQNames.vm", outputFile ); } - outputFile = new File( packageDir, serviceName + "_deploy.wsdd" ); + outputFile = new File( packageDir, capitalizedServiceName + "_deploy.wsdd" ); processTemplate( context, "templates/deploy.vm", outputFile ); - outputFile = new File( packageDir, serviceName + "_jndi-config.xml" ); + outputFile = new File( packageDir, capitalizedServiceName + "_jndi-config.xml" ); processTemplate( context, "templates/jndi.vm", outputFile ); - outputFile = new File( packageDir, serviceName + "CustomOperationsPortType.java" ); + outputFile = new File( packageDir, capitalizedServiceName + "CustomOperationsPortType.java" ); processTemplate( context, "templates/CustomOperationsPortType.vm", outputFile ); outputFile = new File( m_javaSrcOutputDir.getParentFile().getParentFile(), "build.xml" ); @@ -549,12 +588,6 @@ } } - private String getUpperCaseServiceName( String name ) - { - String serviceName = StringUtils.capitalize( name ); - return serviceName; - } - /** * DOCUMENT_ME * @@ -623,44 +656,6 @@ { private boolean m_verbose; private boolean m_debug; - private File[] m_classpath; - - /** - * DOCUMENT_ME - * - * @param classpath DOCUMENT_ME - */ - public void setClasspath( File[] classpath ) - { - m_classpath = classpath; - } - - /** - * DOCUMENT_ME - * - * @param classpath DOCUMENT_ME - */ - public void setClasspath( String classpath ) - { - List classpathItems = new ArrayList(); - for ( StringTokenizer tokenizer = new StringTokenizer( classpath, File.pathSeparator ); - tokenizer.hasMoreTokens(); ) - { - classpathItems.add( new File( tokenizer.nextToken() ) ); - } - - m_classpath = (File[]) classpathItems.toArray( new File[0] ); - } - - /** - * DOCUMENT_ME - * - * @return DOCUMENT_ME - */ - public File[] getClasspath() - { - return m_classpath; - } /** * DOCUMENT_ME @@ -702,4 +697,16 @@ return m_verbose; } } + + static File[] toFileArray( String classpath ) + { + List classpathItems = new ArrayList(); + for ( StringTokenizer tokenizer = new StringTokenizer( classpath, File.pathSeparator ); + tokenizer.hasMoreTokens(); ) + { + classpathItems.add( new File( tokenizer.nextToken() ) ); + } + return (File[]) classpathItems.toArray( new File[0] ); + } + } 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?view=diff&rev=124460&p1=incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java&r1=124459&p2=incubator/apollo/trunk/src/java/org/apache/ws/resource/tool/Wsdl2JavaTask.java&r2=124460 ============================================================================== --- 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 Thu Jan 6 14:54:32 2005 @@ -211,11 +211,6 @@ throws BuildException { Wsdl2Java.Wsdl2JavaOptions options = new Wsdl2Java.Wsdl2JavaOptions(); - if ( m_classpath != null ) - { - options.setClasspath( m_classpath.toString() ); - } - if ( m_verbose != null ) { options.setVerbose( m_verbose.booleanValue() ); @@ -224,10 +219,10 @@ { options.setDebug( m_debug.booleanValue() ); } - + File[] classpathFiles = Wsdl2Java.toFileArray( m_classpath.toString() ); try { - Wsdl2Java wsdl2Java = new Wsdl2Java( (File[]) m_wsdls.toArray( new File[0] ), m_outputDir, options ); + Wsdl2Java wsdl2Java = new Wsdl2Java( (File[]) m_wsdls.toArray( new File[0] ), m_outputDir, classpathFiles, options ); wsdl2Java.generate(); } catch ( Exception e ) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
