use of com.sun.xml.ws.spi.db.TypeInfo in project metro-jax-ws by eclipse-ee4j.
the class RuntimeModeler method processDocBareMethod.
/**
* models a document/literal bare method
* @param javaMethod the runtime model <code>JavaMethod</code> instance being created
* @param operationName the runtime model <code>JavaMethod</code> instance being created
* @param method the runtime model <code>JavaMethod</code> instance being created
*/
protected void processDocBareMethod(JavaMethodImpl javaMethod, String operationName, Method method) {
String resultName = operationName + RESPONSE;
String resultTNS = targetNamespace;
String resultPartName = null;
boolean isResultHeader = false;
WebResult webResult = getAnnotation(method, WebResult.class);
if (webResult != null) {
if (webResult.name().length() > 0)
resultName = webResult.name();
if (webResult.targetNamespace().length() > 0)
resultTNS = webResult.targetNamespace();
resultPartName = webResult.partName();
isResultHeader = webResult.header();
}
Class returnType = method.getReturnType();
Type gReturnType = method.getGenericReturnType();
if (javaMethod.isAsync()) {
returnType = getAsyncReturnType(method, returnType);
}
if ((returnType != null) && (!returnType.getName().equals("void"))) {
Annotation[] rann = getAnnotations(method);
if (resultName != null) {
QName responseQName = new QName(resultTNS, resultName);
TypeInfo rTypeReference = new TypeInfo(responseQName, returnType, rann);
rTypeReference.setGenericType(gReturnType);
metadataReader.getProperties(rTypeReference.properties(), method);
ParameterImpl returnParameter = new ParameterImpl(javaMethod, rTypeReference, Mode.OUT, -1);
if (resultPartName == null || (resultPartName.length() == 0)) {
resultPartName = resultName;
}
returnParameter.setPartName(resultPartName);
if (isResultHeader) {
returnParameter.setBinding(ParameterBinding.HEADER);
} else {
ParameterBinding rb = getBinding(operationName, resultPartName, false, Mode.OUT);
returnParameter.setBinding(rb);
}
javaMethod.addParameter(returnParameter);
}
}
// get WebParam
Class<?>[] parameterTypes = method.getParameterTypes();
Type[] genericParameterTypes = method.getGenericParameterTypes();
Annotation[][] pannotations = getParamAnnotations(method);
int pos = 0;
for (Class clazzType : parameterTypes) {
// method.getName();
String paramName = operationName;
String partName = null;
String requestNamespace = targetNamespace;
boolean isHeader = false;
// async
if (javaMethod.isAsync() && AsyncHandler.class.isAssignableFrom(clazzType)) {
continue;
}
boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
// set the actual type argument of Holder in the TypeReference
if (isHolder) {
if (clazzType == Holder.class)
clazzType = erasure(((ParameterizedType) genericParameterTypes[pos]).getActualTypeArguments()[0]);
}
Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
for (Annotation annotation : pannotations[pos]) {
if (annotation.annotationType() == jakarta.jws.WebParam.class) {
jakarta.jws.WebParam webParam = (jakarta.jws.WebParam) annotation;
paramMode = webParam.mode();
if (isHolder && paramMode == Mode.IN)
paramMode = Mode.INOUT;
isHeader = webParam.header();
if (isHeader)
paramName = "arg" + pos;
if (paramMode == Mode.OUT && !isHeader)
paramName = operationName + RESPONSE;
if (webParam.name().length() > 0)
paramName = webParam.name();
partName = webParam.partName();
if (!webParam.targetNamespace().equals("")) {
requestNamespace = webParam.targetNamespace();
}
break;
}
}
QName requestQName = new QName(requestNamespace, paramName);
if (!isHeader && paramMode != Mode.OUT)
javaMethod.setRequestPayloadName(requestQName);
// doclit/wrapped
// operationName with upper 1 char
TypeInfo typeRef = new TypeInfo(requestQName, clazzType, pannotations[pos]);
metadataReader.getProperties(typeRef.properties(), method, pos);
typeRef.setGenericType(genericParameterTypes[pos]);
ParameterImpl param = new ParameterImpl(javaMethod, typeRef, paramMode, pos++);
if (partName == null || (partName.length() == 0)) {
partName = paramName;
}
param.setPartName(partName);
if (paramMode == Mode.INOUT) {
ParameterBinding pb = getBinding(operationName, partName, isHeader, Mode.IN);
param.setInBinding(pb);
pb = getBinding(operationName, partName, isHeader, Mode.OUT);
param.setOutBinding(pb);
} else {
if (isHeader) {
param.setBinding(ParameterBinding.HEADER);
} else {
ParameterBinding pb = getBinding(operationName, partName, false, paramMode);
param.setBinding(pb);
}
}
javaMethod.addParameter(param);
}
validateDocBare(javaMethod);
processExceptions(javaMethod, method);
}
use of com.sun.xml.ws.spi.db.TypeInfo in project metro-jax-ws by eclipse-ee4j.
the class AbstractSEIModelImpl method createBondMap.
private void createBondMap(List<TypeInfo> types) {
for (TypeInfo type : types) {
XMLBridge binding = bindingContext.createBridge(type);
xmlBridgeMap.put(type, binding);
}
}
use of com.sun.xml.ws.spi.db.TypeInfo in project metro-jax-ws by eclipse-ee4j.
the class JAXBContextFactory method createTypeMappings.
static Map<TypeInfo, TypeMappingInfo> createTypeMappings(Collection<TypeInfo> col) {
Map<TypeInfo, TypeMappingInfo> refs = new HashMap<>();
if (col == null || col.isEmpty()) {
return refs;
}
for (TypeInfo e : col) {
if (e.type.equals(WrapperComposite.class)) {
continue;
}
Element xmlElem = findXmlElement(e.properties());
if (e.isRepeatedElement()) {
e = repeatedWrapee(e, xmlElem);
xmlElem = null;
}
// First do the obvious check: is the instance already in the map?
if (refs.get(e) != null) {
continue;
}
TypeMappingInfo tmi = null;
boolean forceLocal = false;
for (TypeInfo ti : refs.keySet()) {
// Workaround for runtime duplicates.
if (e.tagName.equals(ti.tagName)) {
if (e.isGlobalElement() && ti.isGlobalElement()) {
if (e.type.equals(ti.type)) {
// be resolved adequately.
if (e.type instanceof Class<?>) {
Class<?> clz = (Class<?>) e.type;
if (clz.isEnum()) {
forceLocal = true;
break;
} else {
tmi = refs.get(ti);
break;
}
} else {
tmi = refs.get(ti);
break;
}
} else {
// Conflicting types on globals! May not be
// a bullet-proof solution possible.
forceLocal = true;
break;
}
}
}
}
if (tmi == null) {
tmi = new TypeMappingInfo();
tmi.setXmlTagName(e.tagName);
tmi.setType((e.getGenericType() != null) ? e.getGenericType() : e.type);
tmi.setNillable(e.isNillable());
if (e.getGenericType() != null) {
String gts = e.getGenericType().toString();
if (gts.startsWith("jakarta.xml.ws.Holder")) {
tmi.setType(e.type);
} else if (gts.startsWith("jakarta.xml.ws.Response")) {
tmi.setType(e.type);
} else if (gts.startsWith("java.util.concurrent.Future")) {
tmi.setType(e.type);
}
if (Object.class.equals(e.type)) {
tmi.setType(e.type);
// System.out.println(e.getGenericType().getClass() + " "
// + e.type);
}
if (tmi.getType() instanceof GenericArrayType) {
tmi.setType(typeToClass(tmi.getType(), null));
}
}
// Filter out non-JAXB annotations.
Annotation[] aa = e.annotations;
if (aa != null && aa.length != 0) {
List<Annotation> la = new ArrayList<>();
for (Annotation a : aa) {
for (Class<?> clz : a.getClass().getInterfaces()) {
if (clz.getName().startsWith("jakarta.xml.bind.annotation.")) {
la.add(a);
break;
}
}
}
aa = la.toArray(new Annotation[0]);
// System.out.println("filtered: " + la);
}
tmi.setAnnotations(aa);
if (forceLocal) {
tmi.setElementScope(ElementScope.Local);
} else {
tmi.setElementScope(e.isGlobalElement() ? ElementScope.Global : ElementScope.Local);
}
tmi.setXmlElement(xmlElem);
}
refs.put(e, tmi);
}
return refs;
}
use of com.sun.xml.ws.spi.db.TypeInfo in project metro-jax-ws by eclipse-ee4j.
the class JAXBRIContextFactory method typeInfoMappings.
private Map<TypeInfo, TypeReference> typeInfoMappings(Collection<TypeInfo> typeInfos) {
Map<TypeInfo, TypeReference> map = new java.util.HashMap<>();
for (TypeInfo ti : typeInfos) {
Type type = WrapperComposite.class.equals(ti.type) ? CompositeStructure.class : ti.type;
TypeReference tr = new TypeReference(ti.tagName, type, ti.annotations);
map.put(ti, tr);
}
return map;
}
use of com.sun.xml.ws.spi.db.TypeInfo in project metro-jax-ws by eclipse-ee4j.
the class JAXBRIContextFactory method newContext.
@Override
public BindingContext newContext(BindingInfo bi) {
Class[] classes = bi.contentClasses().toArray(new Class[0]);
for (int i = 0; i < classes.length; i++) {
if (WrapperComposite.class.equals(classes[i])) {
classes[i] = CompositeStructure.class;
}
}
Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
Map<Class, Class> subclassReplacements = bi.subclassReplacements();
String defaultNamespaceRemap = bi.getDefaultNamespace();
Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("org.glassfish.jaxb.runtime.v2.model.annotation.RuntimeAnnotationReader");
JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
try {
JAXBRIContext context = (jaxbContextFactory != null) ? jaxbContextFactory.createJAXBContext(bi.getSEIModel(), toList(classes), toList(typeInfoMappings.values())) : ContextFactory.createContext(classes, typeInfoMappings.values(), subclassReplacements, defaultNamespaceRemap, (c14nSupport != null) ? c14nSupport : false, ar, false, false, false);
return new JAXBRIContextWrapper(context, typeInfoMappings);
} catch (Exception e) {
throw new DatabindingException(e);
}
}
Aggregations