public List<String> getJavacOptions(List<String> existingOptions, WsimportListener listener) { List<String> result = new ArrayList<String>(); for (String o: javacOptions) { if (o.contains("=") && !o.startsWith("A")) { int i = o.indexOf('='); String key = o.substring(0, i); if (existingOptions.contains(key)) { listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(key)); } else { result.add(key); result.add(o.substring(i + 1)); } } else { if (existingOptions.contains(o)) { listener.message(WscompileMessages.WSCOMPILE_EXISTING_OPTION(o)); } else { result.add(o); } } } return result; }
/** * Obtains an operand and reports an error if it's not there. */ public String requireArgument(String optionName, String[] args, int i) throws BadCommandLineException { //if (i == args.length || args[i].startsWith("-")) { if (args[i].startsWith("-")) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_MISSING_OPTION_ARGUMENT(optionName)); } return args[i]; }
private File getWSDLDownloadDir() { File wsdlDir = new File(options.destDir, WSDL_PATH); boolean created = wsdlDir.mkdirs(); if (options.verbose && !created) { listener.message(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(wsdlDir)); } return wsdlDir; }
serviceName = QName.valueOf(requireArgument(SERVICENAME_OPTION, args, ++i)); if (serviceName.getNamespaceURI() == null || serviceName.getNamespaceURI().length() == 0) { throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_NAMESPACE(args[i])); throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_LOCALNAME(args[i])); portName = QName.valueOf(requireArgument(PORTNAME_OPTION, args, ++i)); if (portName.getNamespaceURI() == null || portName.getNamespaceURI().length() == 0) { throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_NAMESPACE(args[i])); throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_LOCALNAME(args[i])); nonclassDestDir = new File(requireArgument("-r", args, ++i)); if (!nonclassDestDir.exists()) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(nonclassDestDir.getPath()));
out.println(WscompileMessages.WSCOMPILE_CANT_GET_COMPILER(property("java.home"), property("java.version"), property("java.vendor"))); return false; out.println(WscompileMessages.WSCOMPILE_ERROR(WscompileMessages.WSCOMPILE_COMPILATION_FAILED())); return false; endpointClass = classLoader.loadClass(endpoint); } catch (ClassNotFoundException e) { throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoint));
throw new BadCommandLineException(WscompileMessages.WSIMPORT_FAILED_TO_PARSE(catalog, e.getMessage())); String value = args[i].substring(11); if (value.length() == 0) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i])); if(r==0) { throw new BadCommandLineException(WscompileMessages.WSIMPORT_NO_SUCH_JAXB_OPTION(subCmd[0])); implDestDir = new File(requireArgument("-implDestDir", args, ++i)); if (!implDestDir.exists()) throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(implDestDir.getPath())); return 2; } else if (args[i].equals("-implServiceName")) {
if (arg.equals("-version")) { listener.message( WscompileMessages.WSIMPORT_VERSION(ToolVersion.VERSION.MAJOR_VERSION)); return true; WscompileMessages.WSIMPORT_FULLVERSION(ToolVersion.VERSION.toString())); return true; listener.message(WscompileMessages.WSCOMPILE_COMPILATION_FAILED()); return false;
target = Target.parse(token); if(target == null) throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_TARGET_VERSION(token)); return 2; } else if (args[i].equals("-classpath") || args[i].equals("-cp")) { destDir = new File(requireArgument("-d", args, ++i)); if (!destDir.exists()) throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(destDir.getPath())); return 2; } else if (args[i].equals("-s")) { keep = true; if (!sourceDir.exists()) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(sourceDir.getPath())); try { if (!Charset.isSupported(encoding)) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_UNSUPPORTED_ENCODING(encoding)); throw new BadCommandLineException(WscompileMessages.WSCOMPILE_UNSUPPORTED_ENCODING(encoding));
protected ClassLoader createClassLoader() throws ClassNotFoundException, IOException { ClassLoader cl = getClass().getClassLoader(); if (doEndorsedMagic) { return Invoker.createClassLoader(cl); } else { Options.Target targetVersion; if (targetVersionAttribute != null) { targetVersion = Options.Target.parse(targetVersionAttribute); } else { targetVersion = Options.Target.getDefault(); } Options.Target loadedVersion = Options.Target.getLoadedAPIVersion(); //Check if the target version is supported by the loaded API version if (loadedVersion.isLaterThan(targetVersion)) { return cl; } else { if (Service.class.getClassLoader() == null) throw new BuildException(WscompileMessages.WRAPPER_TASK_NEED_ENDORSED(loadedVersion.getVersion(), targetVersion.getVersion())); else { throw new BuildException(WscompileMessages.WRAPPER_TASK_LOADING_INCORRECT_API(loadedVersion.getVersion(), Which.which(Service.class), targetVersion.getVersion())); } } } } }
System.err.println(WscompileMessages.INVOKER_NEED_ENDORSED(loadedVersion.getVersion(), targetVersion.getVersion())); else { System.err.println(WscompileMessages.WRAPPER_TASK_LOADING_INCORRECT_API(loadedVersion.getVersion(), Which.which(Service.class), targetVersion.getVersion()));
/** * Parses arguments and fill fields of this object. * * @exception BadCommandLineException * thrown when there's a problem in the command-line arguments */ public void parseArguments( String[] args ) throws BadCommandLineException { for (int i = 0; i < args.length; i++) { if(args[i].length()==0) throw new BadCommandLineException(); if (args[i].charAt(0) == '-') { int j = parseArguments(args,i); if(j==0) throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i])); i += (j-1); } else { addFile(args[i]); } } if(destDir == null) destDir = new File("."); if(sourceDir == null) sourceDir = destDir; }
serviceName = QName.valueOf(requireArgument(SERVICENAME_OPTION, args, ++i)); if (serviceName.getNamespaceURI() == null || serviceName.getNamespaceURI().length() == 0) { throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_NAMESPACE(args[i])); throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_LOCALNAME(args[i])); portName = QName.valueOf(requireArgument(PORTNAME_OPTION, args, ++i)); if (portName.getNamespaceURI() == null || portName.getNamespaceURI().length() == 0) { throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_NAMESPACE(args[i])); throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_LOCALNAME(args[i])); nonclassDestDir = new File(requireArgument("-r", args, ++i)); if (!nonclassDestDir.exists()) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(nonclassDestDir.getPath()));
out.println(WscompileMessages.WSCOMPILE_CANT_GET_COMPILER(property("java.home"), property("java.version"), property("java.vendor"))); return false; out.println(WscompileMessages.WSCOMPILE_ERROR(WscompileMessages.WSCOMPILE_COMPILATION_FAILED())); return false; endpointClass = classLoader.loadClass(endpoint); } catch (ClassNotFoundException e) { throw new BadCommandLineException(WscompileMessages.WSGEN_CLASS_NOT_FOUND(endpoint));
throw new BadCommandLineException(WscompileMessages.WSIMPORT_FAILED_TO_PARSE(catalog, e.getMessage())); String value = args[i].substring(11); if (value.length() == 0) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i])); if(r==0) { throw new BadCommandLineException(WscompileMessages.WSIMPORT_NO_SUCH_JAXB_OPTION(subCmd[0])); implDestDir = new File(requireArgument("-implDestDir", args, ++i)); if (!implDestDir.exists()) throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(implDestDir.getPath())); return 2; } else if (args[i].equals("-implServiceName")) {
if (arg.equals("-version")) { listener.message( WscompileMessages.WSIMPORT_VERSION(ToolVersion.VERSION.MAJOR_VERSION)); return true; WscompileMessages.WSIMPORT_FULLVERSION(ToolVersion.VERSION.toString())); return true; listener.message(WscompileMessages.WSCOMPILE_COMPILATION_FAILED()); return false;
target = Target.parse(token); if(target == null) throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_TARGET_VERSION(token)); return 2; } else if (args[i].equals("-classpath") || args[i].equals("-cp")) { destDir = new File(requireArgument("-d", args, ++i)); if (!destDir.exists()) throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(destDir.getPath())); return 2; } else if (args[i].equals("-s")) { keep = true; if (!sourceDir.exists()) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(sourceDir.getPath())); try { if (!Charset.isSupported(encoding)) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_UNSUPPORTED_ENCODING(encoding)); throw new BadCommandLineException(WscompileMessages.WSCOMPILE_UNSUPPORTED_ENCODING(encoding));
protected ClassLoader createClassLoader() throws ClassNotFoundException, IOException { ClassLoader cl = getClass().getClassLoader(); if (doEndorsedMagic) { return Invoker.createClassLoader(cl); } else { Options.Target targetVersion; if (targetVersionAttribute != null) { targetVersion = Options.Target.parse(targetVersionAttribute); } else { targetVersion = Options.Target.getDefault(); } Options.Target loadedVersion = Options.Target.getLoadedAPIVersion(); //Check if the target version is supported by the loaded API version if (loadedVersion.isLaterThan(targetVersion)) { return cl; } else { if (Service.class.getClassLoader() == null) throw new BuildException(WscompileMessages.WRAPPER_TASK_NEED_ENDORSED(loadedVersion.getVersion(), targetVersion.getVersion())); else { throw new BuildException(WscompileMessages.WRAPPER_TASK_LOADING_INCORRECT_API(loadedVersion.getVersion(), Which.which(Service.class), targetVersion.getVersion())); } } } } }
System.err.println(WscompileMessages.INVOKER_NEED_ENDORSED(loadedVersion.getVersion(), targetVersion.getVersion())); else { System.err.println(WscompileMessages.WRAPPER_TASK_LOADING_INCORRECT_API(loadedVersion.getVersion(), Which.which(Service.class), targetVersion.getVersion()));
/** * Parses arguments and fill fields of this object. * * @exception BadCommandLineException * thrown when there's a problem in the command-line arguments */ public void parseArguments( String[] args ) throws BadCommandLineException { for (int i = 0; i < args.length; i++) { if(args[i].length()==0) throw new BadCommandLineException(); if (args[i].charAt(0) == '-') { int j = parseArguments(args,i); if(j==0) throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i])); i += (j-1); } else { addFile(args[i]); } } if(destDir == null) destDir = new File("."); if(sourceDir == null) sourceDir = destDir; }
serviceName = QName.valueOf(requireArgument(SERVICENAME_OPTION, args, ++i)); if (serviceName.getNamespaceURI() == null || serviceName.getNamespaceURI().length() == 0) { throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_NAMESPACE(args[i])); throw new BadCommandLineException(WscompileMessages.WSGEN_SERVICENAME_MISSING_LOCALNAME(args[i])); portName = QName.valueOf(requireArgument(PORTNAME_OPTION, args, ++i)); if (portName.getNamespaceURI() == null || portName.getNamespaceURI().length() == 0) { throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_NAMESPACE(args[i])); throw new BadCommandLineException(WscompileMessages.WSGEN_PORTNAME_MISSING_LOCALNAME(args[i])); nonclassDestDir = new File(requireArgument("-r", args, ++i)); if (!nonclassDestDir.exists()) { throw new BadCommandLineException(WscompileMessages.WSCOMPILE_NO_SUCH_DIRECTORY(nonclassDestDir.getPath()));