use of com.sun.tools.ws.processor.modeler.ModelerException in project metro-jax-ws by eclipse-ee4j.
the class WebServiceApTest method testRemoteIfaceArg.
public void testRemoteIfaceArg() {
options.add("-proc:only");
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
WsgenOptions wsgenOptions = new WsgenOptions();
wsgenOptions.verbose = true;
JavaCompiler.CompilationTask task = getCompilationTask("com.sun.tools.ws.test.processor.modeler.annotation.RemoteArgTestWS", options, wsgenOptions, diagnostics);
try {
task.call();
} catch (RuntimeException re) {
if (!(re.getCause() instanceof ModelerException)) {
fail(ModelerException.class.getName() + " should have been thrown - spec requirement");
}
}
}
use of com.sun.tools.ws.processor.modeler.ModelerException in project metro-jax-ws by eclipse-ee4j.
the class WebServiceApTest method testRemoteIfaceReturn.
public void testRemoteIfaceReturn() {
options.add("-proc:only");
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
WsgenOptions wsgenOptions = new WsgenOptions();
wsgenOptions.verbose = true;
JavaCompiler.CompilationTask task = getCompilationTask("com.sun.tools.ws.test.processor.modeler.annotation.RemoteReturnTestWs", options, wsgenOptions, diagnostics);
try {
task.call();
} catch (RuntimeException re) {
if (!(re.getCause() instanceof ModelerException)) {
fail(ModelerException.class.getName() + " should have been thrown - spec requirement");
}
}
}
use of com.sun.tools.ws.processor.modeler.ModelerException in project metro-jax-ws by eclipse-ee4j.
the class ModelerExceptionTest method testLocalizability.
public void testLocalizability() {
String msg = "Try localizing me";
ModelerException pe = new ModelerException(msg);
Localizer localizer = new Localizer();
assertEquals(msg, localizer.localize(pe));
}
use of com.sun.tools.ws.processor.modeler.ModelerException in project metro-jax-ws by eclipse-ee4j.
the class WebServiceWrapperGenerator method generateWrappers.
private boolean generateWrappers(ExecutableElement method, WebMethod webMethod) {
boolean isOneway = method.getAnnotation(Oneway.class) != null;
String beanPackage = packageName + WebServiceConstants.PD_JAXWS_PACKAGE_PD.getValue();
if (packageName.length() == 0)
beanPackage = WebServiceConstants.JAXWS_PACKAGE_PD.getValue();
Name methodName = method.getSimpleName();
String operationName = builder.getOperationName(methodName);
operationName = webMethod != null && webMethod.operationName().length() > 0 ? webMethod.operationName() : operationName;
String reqName = operationName;
String resName = operationName + WebServiceConstants.RESPONSE.getValue();
String reqNamespace = typeNamespace;
String resNamespace = typeNamespace;
String requestClassName = beanPackage + StringUtils.capitalize(method.getSimpleName().toString());
RequestWrapper reqWrapper = method.getAnnotation(RequestWrapper.class);
if (reqWrapper != null) {
if (reqWrapper.className().length() > 0)
requestClassName = reqWrapper.className();
if (reqWrapper.localName().length() > 0)
reqName = reqWrapper.localName();
if (reqWrapper.targetNamespace().length() > 0)
reqNamespace = reqWrapper.targetNamespace();
}
builder.log("requestWrapper: " + requestClassName);
boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName);
if (!canOverwriteRequest) {
builder.log("Class " + requestClassName + " exists. Not overwriting.");
}
if (duplicateName(requestClassName) && canOverwriteRequest) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_REQUEST_WRAPPER_BEAN_NAME_NOT_UNIQUE(typeElement.getQualifiedName(), method.toString()));
}
String responseClassName = null;
boolean canOverwriteResponse = canOverwriteRequest;
if (!isOneway) {
responseClassName = beanPackage + StringUtils.capitalize(method.getSimpleName().toString()) + WebServiceConstants.RESPONSE.getValue();
ResponseWrapper resWrapper = method.getAnnotation(ResponseWrapper.class);
if (resWrapper != null) {
if (resWrapper.className().length() > 0)
responseClassName = resWrapper.className();
if (resWrapper.localName().length() > 0)
resName = resWrapper.localName();
if (resWrapper.targetNamespace().length() > 0)
resNamespace = resWrapper.targetNamespace();
}
canOverwriteResponse = builder.canOverWriteClass(responseClassName);
builder.log("responseWrapper: " + responseClassName);
if (!canOverwriteResponse) {
builder.log("Class " + responseClassName + " exists. Not overwriting.");
}
if (duplicateName(responseClassName) && canOverwriteResponse) {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE(typeElement.getQualifiedName(), method.toString()));
}
}
// ArrayList<MemberInfo> reqMembers = new ArrayList<MemberInfo>();
// ArrayList<MemberInfo> resMembers = new ArrayList<MemberInfo>();
WrapperInfo reqWrapperInfo = new WrapperInfo(requestClassName);
// reqWrapperInfo.setMembers(reqMembers);
WrapperInfo resWrapperInfo = null;
if (!isOneway) {
resWrapperInfo = new WrapperInfo(responseClassName);
// resWrapperInfo.setMembers(resMembers);
}
seiContext.setReqWrapperOperation(method, reqWrapperInfo);
if (!isOneway)
seiContext.setResWrapperOperation(method, resWrapperInfo);
try {
if (!canOverwriteRequest && !canOverwriteResponse) {
return false;
}
JDefinedClass reqCls = null;
if (canOverwriteRequest) {
reqCls = getCMClass(requestClassName, ClassType.CLASS);
}
JDefinedClass resCls = null;
if (!isOneway && canOverwriteResponse) {
resCls = getCMClass(responseClassName, ClassType.CLASS);
}
// XMLElement Declarations
writeXmlElementDeclaration(reqCls, reqName, reqNamespace);
writeXmlElementDeclaration(resCls, resName, resNamespace);
List<MemberInfo> reqMembers = ap_generator.collectRequestBeanMembers(method);
List<MemberInfo> resMembers = ap_generator.collectResponseBeanMembers(method);
// XmlType
writeXmlTypeDeclaration(reqCls, reqName, reqNamespace, reqMembers);
writeXmlTypeDeclaration(resCls, resName, resNamespace, resMembers);
// class members
writeMembers(reqCls, reqMembers);
writeMembers(resCls, resMembers);
} catch (Exception e) {
throw new ModelerException("modeler.nestedGeneratorError", e);
}
return true;
}
Aggregations