1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/GeneratorBase.java Thu Apr 04 19:05:24 2013 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/GeneratorBase.java Tue Apr 09 14:51:13 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -60,11 +60,11 @@ 1.11 import java.util.ArrayList; 1.12 import java.util.Iterator; 1.13 import java.util.List; 1.14 +import javax.annotation.processing.Filer; 1.15 +import javax.tools.FileObject; 1.16 1.17 -/** 1.18 - * 1.19 - * @author WS Development Team 1.20 - */ 1.21 +import javax.tools.StandardLocation; 1.22 + 1.23 public abstract class GeneratorBase implements ModelVisitor { 1.24 private File destDir; 1.25 private String targetVersion; 1.26 @@ -96,28 +96,33 @@ 1.27 } 1.28 } 1.29 1.30 + @Override 1.31 public void visit(Model model) throws Exception { 1.32 for (Service service : model.getServices()) { 1.33 service.accept(this); 1.34 } 1.35 } 1.36 1.37 + @Override 1.38 public void visit(Service service) throws Exception { 1.39 for (Port port : service.getPorts()) { 1.40 port.accept(this); 1.41 } 1.42 } 1.43 1.44 + @Override 1.45 public void visit(Port port) throws Exception { 1.46 for (Operation operation : port.getOperations()) { 1.47 operation.accept(this); 1.48 } 1.49 } 1.50 1.51 + @Override 1.52 public void visit(Operation operation) throws Exception { 1.53 operation.getRequest().accept(this); 1.54 - if (operation.getResponse() != null) 1.55 + if (operation.getResponse() != null) { 1.56 operation.getResponse().accept(this); 1.57 + } 1.58 Iterator faults = operation.getFaultsSet().iterator(); 1.59 if (faults != null) { 1.60 Fault fault; 1.61 @@ -128,21 +133,20 @@ 1.62 } 1.63 } 1.64 1.65 - public void visit(Parameter param) throws Exception { 1.66 - } 1.67 + @Override 1.68 + public void visit(Parameter param) throws Exception {} 1.69 1.70 - public void visit(Block block) throws Exception { 1.71 - } 1.72 + @Override 1.73 + public void visit(Block block) throws Exception {} 1.74 1.75 - public void visit(Response response) throws Exception { 1.76 - } 1.77 + @Override 1.78 + public void visit(Response response) throws Exception {} 1.79 1.80 + @Override 1.81 + public void visit(Request request) throws Exception {} 1.82 1.83 - public void visit(Request request) throws Exception { 1.84 - } 1.85 - 1.86 - public void visit(Fault fault) throws Exception { 1.87 - } 1.88 + @Override 1.89 + public void visit(Fault fault) throws Exception {} 1.90 1.91 public List<String> getJAXWSClassComment(){ 1.92 return getJAXWSClassComment(targetVersion); 1.93 @@ -162,8 +166,9 @@ 1.94 cls = cm._class(className, type); 1.95 } catch (JClassAlreadyExistsException e){ 1.96 cls = cm._getClass(className); 1.97 - if(cls == null) 1.98 + if (cls == null) { 1.99 throw e; 1.100 + } 1.101 } 1.102 return cls; 1.103 } 1.104 @@ -181,8 +186,9 @@ 1.105 1.106 protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) { 1.107 Element e = options.getHandlerChainConfiguration(); 1.108 - if(e == null) 1.109 + if (e == null) { 1.110 return; 1.111 + } 1.112 JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class)); 1.113 NodeList nl = e.getElementsByTagNameNS( 1.114 "http://java.sun.com/xml/ns/javaee", "handler-chain"); 1.115 @@ -199,17 +205,25 @@ 1.116 } 1.117 1.118 private void generateHandlerChainFile(Element hChains, String name) { 1.119 - String hcName = getHandlerConfigFileName(name); 1.120 1.121 - File packageDir = DirectoryUtil.getOutputDirectoryFor(name, destDir); 1.122 - File hcFile = new File(packageDir, hcName); 1.123 - 1.124 - options.addGeneratedFile(hcFile); 1.125 + Filer filer = options.filer; 1.126 1.127 try { 1.128 - IndentingWriter p = 1.129 - new IndentingWriter( 1.130 - new OutputStreamWriter(new FileOutputStream(hcFile))); 1.131 + IndentingWriter p; 1.132 + FileObject jfo; 1.133 + if (filer != null) { 1.134 + jfo = filer.createResource(StandardLocation.SOURCE_OUTPUT, 1.135 + Names.getPackageName(name), getHandlerConfigFileName(name)); 1.136 + options.addGeneratedFile(new File(jfo.toUri())); 1.137 + p = new IndentingWriter(new OutputStreamWriter(jfo.openOutputStream())); 1.138 + } else { // leave for backw. compatibility now 1.139 + String hcName = getHandlerConfigFileName(name); 1.140 + File packageDir = DirectoryUtil.getOutputDirectoryFor(name, destDir); 1.141 + File hcFile = new File(packageDir, hcName); 1.142 + options.addGeneratedFile(hcFile); 1.143 + p = new IndentingWriter(new OutputStreamWriter(new FileOutputStream(hcFile))); 1.144 + } 1.145 + 1.146 Transformer it = XmlUtil.newTransformer(); 1.147 1.148 it.setOutputProperty(OutputKeys.METHOD, "xml");