1 package org.codehaus.mojo.axistools.wsdl2java;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.axis.utils.CLArgsParser;
23 import org.apache.axis.utils.CLOption;
24 import org.apache.axis.utils.CLOptionDescriptor;
25 import org.apache.axis.utils.Messages;
26 import org.apache.axis.wsdl.WSDL2Java;
27 import org.apache.axis.wsdl.gen.WSDL2;
28 import org.codehaus.mojo.axistools.axis.AxisPluginException;
29
30 import java.lang.reflect.Field;
31 import java.util.List;
32
33 /**
34 * @author: jesse
35 * @version: $Id$
36 */
37 public class WSDL2JavaWrapper
38 extends WSDL2Java
39 {
40 public void execute( String args[] )
41 throws AxisPluginException
42 {
43 try
44 {
45 // Extremely ugly hack because the "options" static field in WSDL2Java
46 // shadows the "options" instance field in WSDL2. It is the field
47 // in WSDL2 that we need because the command line options
48 // defined in subclasses get copied to it.
49 // The result is that options defined in WSDL2 ( timeout, Debug )
50 // are not available otherwise. (MOJO-318)
51 Field field = WSDL2.class.getDeclaredField( "options" );
52
53 CLOptionDescriptor[] options = (CLOptionDescriptor[]) field.get( this );
54
55 // Parse the arguments
56 CLArgsParser argsParser = new CLArgsParser( args, options );
57
58 // Print parser errors, if any
59 if ( null != argsParser.getErrorString() )
60 {
61 System.err.println( Messages.getMessage( "error01", argsParser.getErrorString() ) );
62 printUsage();
63 }
64
65 // Get a list of parsed options
66 List clOptions = argsParser.getArguments();
67 int size = clOptions.size();
68
69 // Parse the options and configure the emitter as appropriate.
70 for ( int i = 0; i < size; i++ )
71 {
72 parseOption( (CLOption) clOptions.get( i ) );
73 }
74
75 // validate argument combinations
76
77 validateOptions();
78
79 parser.run( wsdlURI );
80 }
81 catch ( Exception e )
82 {
83 throw new AxisPluginException( "Error running Axis", e );
84 }
85 }
86 }