src/share/jaxws_classes/com/sun/tools/internal/ws/processor/generator/GeneratorBase.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 58,72 ****
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
- /**
- *
- * @author WS Development Team
- */
public abstract class GeneratorBase implements ModelVisitor {
private File destDir;
private String targetVersion;
protected boolean donotOverride;
protected JCodeModel cm;
--- 58,72 ----
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+ import javax.annotation.processing.Filer;
+ import javax.tools.FileObject;
+
+ import javax.tools.StandardLocation;
public abstract class GeneratorBase implements ModelVisitor {
private File destDir;
private String targetVersion;
protected boolean donotOverride;
protected JCodeModel cm;
*** 94,150 ****
} catch (Exception e) {
receiver.error(e);
}
}
public void visit(Model model) throws Exception {
for (Service service : model.getServices()) {
service.accept(this);
}
}
public void visit(Service service) throws Exception {
for (Port port : service.getPorts()) {
port.accept(this);
}
}
public void visit(Port port) throws Exception {
for (Operation operation : port.getOperations()) {
operation.accept(this);
}
}
public void visit(Operation operation) throws Exception {
operation.getRequest().accept(this);
! if (operation.getResponse() != null)
operation.getResponse().accept(this);
Iterator faults = operation.getFaultsSet().iterator();
if (faults != null) {
Fault fault;
while (faults.hasNext()) {
fault = (Fault) faults.next();
fault.accept(this);
}
}
}
! public void visit(Parameter param) throws Exception {
! }
!
! public void visit(Block block) throws Exception {
! }
! public void visit(Response response) throws Exception {
! }
! public void visit(Request request) throws Exception {
! }
! public void visit(Fault fault) throws Exception {
! }
public List<String> getJAXWSClassComment(){
return getJAXWSClassComment(targetVersion);
}
--- 94,154 ----
} catch (Exception e) {
receiver.error(e);
}
}
+ @Override
public void visit(Model model) throws Exception {
for (Service service : model.getServices()) {
service.accept(this);
}
}
+ @Override
public void visit(Service service) throws Exception {
for (Port port : service.getPorts()) {
port.accept(this);
}
}
+ @Override
public void visit(Port port) throws Exception {
for (Operation operation : port.getOperations()) {
operation.accept(this);
}
}
+ @Override
public void visit(Operation operation) throws Exception {
operation.getRequest().accept(this);
! if (operation.getResponse() != null) {
operation.getResponse().accept(this);
+ }
Iterator faults = operation.getFaultsSet().iterator();
if (faults != null) {
Fault fault;
while (faults.hasNext()) {
fault = (Fault) faults.next();
fault.accept(this);
}
}
}
! @Override
! public void visit(Parameter param) throws Exception {}
! @Override
! public void visit(Block block) throws Exception {}
+ @Override
+ public void visit(Response response) throws Exception {}
! @Override
! public void visit(Request request) throws Exception {}
! @Override
! public void visit(Fault fault) throws Exception {}
public List<String> getJAXWSClassComment(){
return getJAXWSClassComment(targetVersion);
}
*** 160,172 ****
JDefinedClass cls;
try {
cls = cm._class(className, type);
} catch (JClassAlreadyExistsException e){
cls = cm._getClass(className);
! if(cls == null)
throw e;
}
return cls;
}
protected void log(String msg) {
if (options.verbose) {
--- 164,177 ----
JDefinedClass cls;
try {
cls = cm._class(className, type);
} catch (JClassAlreadyExistsException e){
cls = cm._getClass(className);
! if (cls == null) {
throw e;
}
+ }
return cls;
}
protected void log(String msg) {
if (options.verbose) {
*** 179,190 ****
}
}
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
Element e = options.getHandlerChainConfiguration();
! if(e == null)
return;
JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
NodeList nl = e.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chain");
if(nl.getLength() > 0){
String fName = getHandlerConfigFileName(className);
--- 184,196 ----
}
}
protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
Element e = options.getHandlerChainConfiguration();
! if (e == null) {
return;
+ }
JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
NodeList nl = e.getElementsByTagNameNS(
"http://java.sun.com/xml/ns/javaee", "handler-chain");
if(nl.getLength() > 0){
String fName = getHandlerConfigFileName(className);
*** 197,217 ****
String name = Names.stripQualifier(fullName);
return name+"_handler.xml";
}
private void generateHandlerChainFile(Element hChains, String name) {
- String hcName = getHandlerConfigFileName(name);
File packageDir = DirectoryUtil.getOutputDirectoryFor(name, destDir);
File hcFile = new File(packageDir, hcName);
-
options.addGeneratedFile(hcFile);
- try {
- IndentingWriter p =
- new IndentingWriter(
- new OutputStreamWriter(new FileOutputStream(hcFile)));
Transformer it = XmlUtil.newTransformer();
it.setOutputProperty(OutputKeys.METHOD, "xml");
it.setOutputProperty(OutputKeys.INDENT, "yes");
it.setOutputProperty(
--- 203,231 ----
String name = Names.stripQualifier(fullName);
return name+"_handler.xml";
}
private void generateHandlerChainFile(Element hChains, String name) {
+ Filer filer = options.filer;
+
+ try {
+ IndentingWriter p;
+ FileObject jfo;
+ if (filer != null) {
+ 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
+ String hcName = getHandlerConfigFileName(name);
File packageDir = DirectoryUtil.getOutputDirectoryFor(name, destDir);
File hcFile = new File(packageDir, hcName);
options.addGeneratedFile(hcFile);
+ p = new IndentingWriter(new OutputStreamWriter(new FileOutputStream(hcFile)));
+ }
Transformer it = XmlUtil.newTransformer();
it.setOutputProperty(OutputKeys.METHOD, "xml");
it.setOutputProperty(OutputKeys.INDENT, "yes");
it.setOutputProperty(