WsimportOptions wsimportOptions = new WsimportOptions(); wsimportOptions.getSchemaCompiler().getOptions().activePlugins.add(new SerializablePlugin());
public void addWSDL(File source) { addWSDL(fileToInputSource(source)); }
protected void parseArguments(String[] args, Listener listener, Receiver receiver) throws BadCommandLineException { options.parseArguments(args); options.validate(); if (options.debugMode) listener.enableDebugging(); options.parseBindings(receiver); }
private void addRecursive(File dir, String suffix, List<InputSource> result) { File[] files = dir.listFiles(); if (files == null) return; // work defensively for (File f : files) { if (f.isDirectory()) addRecursive(f, suffix, result); else if (f.getPath().endsWith(suffix)) result.add(absolutize(fileToInputSource(f))); } }
addBindings(requireArgument("-b", args, ++i)); return 2; } else if (args[i].equals("-wsdllocation")) { wsdlLocation = requireArgument("-wsdllocation", args, ++i); return 2; } else if (args[i].equals("-XadditionalHeaders")) { return 1; } else if (args[i].equals("-p")) { defaultPackage = requireArgument("-p", args, ++i); return 2; } else if (args[i].equals("-m")) { javaModule = requireArgument("-m", args, ++i); return 2; } else if (args[i].equals("-catalog")) { String catalog = requireArgument("-catalog", args, ++i); try { if (entityResolver == null) { parseProxy(value); if (proxyHost != null || proxyPort != null) { System.setProperty("proxySet", "true"); String authfile = requireArgument("-Xauthfile", args, ++i); authFile = new File(authfile); return 2; } else if (args[i].equals("-clientjar")) { clientjar = requireArgument("-clientjar", args, ++i); return 2;
schemaCompiler = options.getSchemaCompiler(); schemaCompiler.resetSchema(); if(options.entityResolver != null) { InputSource[] externalBindings = options.getSchemaBindings(); if(externalBindings != null){ for(InputSource jaxbBinding : externalBindings){
public void testParseSimpleSystemIdNull() throws Exception { final ErrorReceiverFilter errorReceiver = new ErrorReceiverFilter(); final InputSource source = getResourceSource("com/sun/tools/ws/wsdl/parser/simple.wsdl"); source.setSystemId(null); final WsimportOptions options = new WsimportOptions(); options.addWSDL(source); try { final WSDLParser instance = new WSDLParser(options, errorReceiver); final WSDLDocument wsdl = instance.parse(); fail("Expected IllegalArgumentException, instead got " + wsdl); } catch (IllegalArgumentException e) { // expected } }
protected boolean compileGeneratedClasses(ErrorReceiver receiver, WsimportListener listener){ List<String> sourceFiles = new ArrayList<String>(); for (File f : options.getGeneratedFiles()) { if (f.exists() && f.getName().endsWith(".java")) { sourceFiles.add(f.getAbsolutePath()); args.addAll(options.getJavacOptions(args, listener));
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])); addFile(args[i]);
public WSDLDocument parse() throws SAXException, IOException { // parse external binding files for (InputSource value : options.getWSDLBindings()) { errReceiver.pollAbort(); Document root = forest.parse(value, false); if(root==null) continue; // error must have been reported Element binding = root.getDocumentElement(); if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(JAXWSBindingsConstants.NS_JAXWS_BINDINGS) || !binding.getLocalName().equals("bindings")){ errReceiver.error(forest.locatorTable.getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE( binding.getNamespaceURI(), binding.getLocalName())); continue; } NodeList nl = binding.getElementsByTagNameNS( "http://java.sun.com/xml/ns/javaee", "handler-chains"); for(int i = 0; i < nl.getLength(); i++){ options.addHandlerChainConfiguration((Element) nl.item(i)); } } return buildWSDLDocument(); }
private void addClassesToGeneratedFiles() throws IOException { Iterable<File> generatedFiles = options.getGeneratedFiles(); final List<File> trackedClassFiles = new ArrayList<>(); for(File f: generatedFiles) { if(f.getName().endsWith(".java")) { String relativeDir = DirectoryUtil.getRelativePathfromCommonBase(f.getParentFile(),options.sourceDir); final String className = f.getName().substring(0,f.getName().indexOf(".java")); File classDir = new File(options.destDir,relativeDir); if(classDir.exists()) { classDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if(name.equals(className+".class") || (name.startsWith(className+"$") && name.endsWith(".class"))) { trackedClassFiles.add(new File(dir,name)); return true; } return false; } }); } } } for(File f: trackedClassFiles) { options.addGeneratedFile(f); } }
WsimportOptions options = new WsimportOptions(); SchemaCompiler sc = options.getSchemaCompiler(); options.parseArguments(new String[0]); assertNull("ws encoding set", options.encoding); assertNull("xjc encoding set", sc.getOptions().encoding); options = new WsimportOptions(); sc = options.getSchemaCompiler(); String[] args = {"-encoding", "UTF-8"}; options.parseArguments(args); assertNotNull("ws encoding not set", options.encoding); assertEquals("UTF-8", options.encoding); assertEquals("UTF-8", sc.getOptions().encoding); options = new WsimportOptions(); sc = options.getSchemaCompiler(); args = new String[] {"-encoding", "UTF-8", "-B-encoding", "UTF-16"}; options.parseArguments(args); assertNotNull("ws encoding not set", options.encoding); assertEquals("UTF-8", options.encoding); options = new WsimportOptions(); sc = options.getSchemaCompiler(); args = new String[] {"-B-encoding", "UTF-16"}; options.parseArguments(args); assertNull("ws encoding set", options.encoding); assertNotNull("xjc encoding not set", sc.getOptions().encoding);
/** * Test of parseArguments(String[]) method, of class WsimportOptions. */ public void testParseArgument_javacArgs() throws Exception { WsimportOptions options = new WsimportOptions(); String[] args = new String[] {"-g", "-J-g", "-J-source=1.6", "-J-target=1.6", "-J-XprintRounds"}; options.parseArguments(args); assertFalse("javac options not set", options.javacOptions.isEmpty()); assertEquals("invalid option recognized", 4, options.javacOptions.size()); L l = new L(); List<String> jopts = options.getJavacOptions(new ArrayList<String>(){{add("-g");}}, l); assertEquals("incorrect split of javac options", 5, jopts.size()); assertTrue(jopts.remove("-source")); assertTrue(jopts.remove("1.6")); assertTrue(jopts.remove("-target")); assertTrue(jopts.remove("1.6")); assertTrue(jopts.remove("-XprintRounds")); assertTrue(jopts.isEmpty()); assertEquals(1, l.i); }
public void addWSDL(InputSource is) { wsdls.add(absolutize(is)); }
@Override protected void addFile(String arg) throws BadCommandLineException { addFile(arg, wsdls, ".wsdl"); }
jfo = filer.createResource(StandardLocation.SOURCE_OUTPUT, Names.getPackageName(name), getHandlerConfigFileName(name)); options.addGeneratedFile(new File(jfo.toUri())); p = new IndentingWriter(new OutputStreamWriter(jfo.openOutputStream())); } else { // leave for backw. compatibility now File packageDir = DirectoryUtil.getOutputDirectoryFor(name, destDir); File hcFile = new File(packageDir, hcName); options.addGeneratedFile(hcFile); p = new IndentingWriter(new OutputStreamWriter(new FileOutputStream(hcFile)));
/** * Recursively scan directories and add all XSD files in it. */ public void addGrammarRecursive(File dir) { addRecursive(dir, ".wsdl", wsdls); addRecursive(dir, ".xsd", schemas); }
private void addRecursive(File dir, String suffix, List<InputSource> result) { File[] files = dir.listFiles(); if (files == null) return; // work defensively for (File f : files) { if (f.isDirectory()) addRecursive(f, suffix, result); else if (f.getPath().endsWith(suffix)) result.add(absolutize(fileToInputSource(f))); } }
addBindings(requireArgument("-b", args, ++i)); return 2; } else if (args[i].equals("-wsdllocation")) { wsdlLocation = requireArgument("-wsdllocation", args, ++i); return 2; } else if (args[i].equals("-XadditionalHeaders")) { return 1; } else if (args[i].equals("-p")) { defaultPackage = requireArgument("-p", args, ++i); return 2; } else if (args[i].equals("-m")) { javaModule = requireArgument("-m", args, ++i); return 2; } else if (args[i].equals("-catalog")) { String catalog = requireArgument("-catalog", args, ++i); try { if (entityResolver == null) { parseProxy(value); if (proxyHost != null || proxyPort != null) { System.setProperty("proxySet", "true"); String authfile = requireArgument("-Xauthfile", args, ++i); authFile = new File(authfile); return 2; } else if (args[i].equals("-clientjar")) { clientjar = requireArgument("-clientjar", args, ++i); return 2;
schemaCompiler = options.getSchemaCompiler(); schemaCompiler.resetSchema(); if(options.entityResolver != null) { InputSource[] externalBindings = options.getSchemaBindings(); if(externalBindings != null){ for(InputSource jaxbBinding : externalBindings){