Author: alessio.soldano(a)jboss.com
Date: 2013-01-31 12:08:55 -0500 (Thu, 31 Jan 2013)
New Revision: 478
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java
Log:
Support for INOUT / OUT parameters (jaxws Holder)
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java 2013-01-31
17:08:04 UTC (rev 477)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java 2013-01-31
17:08:55 UTC (rev 478)
@@ -195,15 +195,25 @@
private static TreeNodeImpl convertOperationResultToGui(InvocationResult result,
WSDynamicClient client) {
WiseTreeElementBuilder builder = new WiseTreeElementBuilder(client);
TreeNodeImpl rootElement = new TreeNodeImpl();
+ Map<String, Type> resTypes = new HashMap<String, Type>();
for (Entry<String, Object> res : result.getResult().entrySet()) {
+ String key = res.getKey();
+ if (key.startsWith(WSMethod.TYPE_PREFIX)) {
+ resTypes.put(key, (Type)res.getValue());
+ }
+ }
+ for (Entry<String, Object> res : result.getResult().entrySet()) {
Object resObj = res.getValue();
- WiseTreeElement wte;
- if (resObj != null) {
- wte = builder.buildTreeFromType(resObj.getClass(), res.getKey(), resObj, true);
- } else {
- wte = new EmptyWiseTreeElement("result");
+ final String key = res.getKey();
+ if (!key.startsWith(WSMethod.TYPE_PREFIX)) {
+ WiseTreeElement wte;
+ if (resObj != null) {
+ wte = builder.buildTreeFromType(resTypes.get(WSMethod.TYPE_PREFIX + key), key,
resObj, true);
+ } else {
+ wte = new EmptyWiseTreeElement("result"); // TODO!! remove this and treat
other elements now that return types are available
+ }
+ rootElement.addChild(wte.getId(), wte);
}
- rootElement.addChild(wte.getId(), wte);
}
return rootElement;
}
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java 2013-01-31
17:08:04 UTC (rev 477)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/ParameterizedWiseTreeElement.java 2013-01-31
17:08:55 UTC (rev 478)
@@ -21,7 +21,9 @@
import java.util.Iterator;
import java.util.List;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.ws.Holder;
import org.jboss.logging.Logger;
import org.jboss.wise.core.client.WSDynamicClient;
@@ -42,13 +44,15 @@
private Class<?> scope;
private String namespace;
+
+ private Class<?> parameterizedClass;
public ParameterizedWiseTreeElement() {
this.kind = PARAMETERIZED;
this.id = IDGenerator.nextVal();
}
- public ParameterizedWiseTreeElement(ParameterizedType classType, String name,
WSDynamicClient client, Class<?> scope, String namespace) {
+ public ParameterizedWiseTreeElement(ParameterizedType classType, Class<?>
parameterizedClass, String name, WSDynamicClient client, Class<?> scope, String
namespace) {
this.kind = PARAMETERIZED;
this.id = IDGenerator.nextVal();
this.classType = classType;
@@ -57,6 +61,7 @@
this.client = client;
this.scope = scope;
this.namespace = namespace;
+ this.parameterizedClass = parameterizedClass;
}
@Override
@@ -70,6 +75,7 @@
element.setClient(this.client);
element.setScope(this.scope);
element.setNamespace(this.namespace);
+ element.setParameterizedClass(this.parameterizedClass);
Iterator<Object> keyIt = this.getChildrenKeysIterator();
while (keyIt.hasNext()) { // actually 1 child only
WiseTreeElement child = (WiseTreeElement)this.getChild(keyIt.next());
@@ -80,9 +86,24 @@
@Override
public Object toObject() throws WiseRuntimeException {
- return isLeaf() ? null : instanceXmlElementDecl(this.name, this.scope, this.namespace,
((WiseTreeElement) this.getChild(this.getChildrenKeysIterator().next())).toObject());
+ if (isLeaf()) {
+ return null;
+ }
+ Object child = ((WiseTreeElement)
this.getChild(this.getChildrenKeysIterator().next())).toObject();
+ if (parameterizedClass.isAssignableFrom(JAXBElement.class)) {
+ return instanceXmlElementDecl(this.name, this.scope, this.namespace, child);
+ } else if (parameterizedClass.isAssignableFrom(Holder.class)) {
+ return instanceHolder(child);
+ } else {
+ throw new WiseRuntimeException("Unsupported parameterized class: " +
parameterizedClass);
+ }
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private Object instanceHolder(Object obj) {
+ return new Holder(obj);
+ }
+
private Object instanceXmlElementDecl(String name, Class<?> scope, String
namespace, Object value) {
try {
Class<?> objectFactoryClass = null;
@@ -133,4 +154,12 @@
public String getNamespace() {
return namespace;
}
+
+ public Class<?> getParameterizedClass() {
+ return parameterizedClass;
+ }
+
+ public void setParameterizedClass(Class<?> parameterizedClass) {
+ this.parameterizedClass = parameterizedClass;
+ }
}
\ No newline at end of file
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java 2013-01-31
17:08:04 UTC (rev 477)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java 2013-01-31
17:08:55 UTC (rev 478)
@@ -29,6 +29,7 @@
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.ws.Holder;
import org.jboss.logging.Logger;
import org.jboss.wise.core.client.WSDynamicClient;
@@ -99,11 +100,13 @@
}
return group;
} else {
- ParameterizedWiseTreeElement parameterized = new ParameterizedWiseTreeElement(pt,
name, client, scope, namespace);
if (obj != null && obj instanceof JAXBElement) {
obj = ((JAXBElement)obj).getValue();
+ } else if (obj != null && obj instanceof Holder) {
+ obj = ((Holder)obj).value;
}
WiseTreeElement element = this.buildTreeFromType(firstTypeArg, name, obj, true,
null, null, typeMap, stack);
+ ParameterizedWiseTreeElement parameterized = new ParameterizedWiseTreeElement(pt,
(Class<?>)pt.getRawType(), name, client, scope, namespace);
parameterized.addChild(element.getId(), element);
return parameterized;
}