01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.tools.java2wsdl;
19:
20: import java.util.Arrays;
21: import java.util.List;
22:
23: import org.apache.cxf.common.util.StringUtils;
24: import org.apache.cxf.tools.common.toolspec.ToolRunner;
25:
26: public class JavaToWSDL {
27:
28: private String[] args;
29:
30: public JavaToWSDL() {
31: args = new String[0];
32: }
33:
34: public JavaToWSDL(String pargs[]) {
35: args = pargs;
36: }
37:
38: public static void main(String[] args) {
39: JavaToWSDL j2w = new JavaToWSDL(args);
40: try {
41: j2w.run();
42: } catch (Exception ex) {
43: System.err.println("JavaToWSDL Error : " + ex.getMessage());
44: System.err.println();
45: if (j2w.isVerbose()) {
46: ex.printStackTrace();
47: }
48: if (j2w.isExitOnFinish()) {
49: System.exit(1);
50: }
51: }
52: }
53:
54: private boolean isVerbose() {
55: return isSet(new String[] { "-V", "-verbose" });
56: }
57:
58: private boolean isSet(String[] keys) {
59: if (args == null) {
60: return false;
61: }
62: List<String> pargs = Arrays.asList(args);
63:
64: for (String key : keys) {
65: if (pargs.contains(key)) {
66: return true;
67: }
68: }
69: return false;
70: }
71:
72: private void run() throws Exception {
73: ToolRunner.runTool(JavaToWSDLContainer.class,
74: JavaToWSDLContainer.class
75: .getResourceAsStream("java2wsdl.xml"), false,
76: args);
77: }
78:
79: private boolean isExitOnFinish() {
80: String exit = System.getProperty("exitOnFinish");
81: if (StringUtils.isEmpty(exit)) {
82: return false;
83: }
84: return "YES".equalsIgnoreCase(exit)
85: || "TRUE".equalsIgnoreCase(exit);
86: }
87:
88: }
|