Author: heiko.braun(a)jboss.com
Date: 2006-11-15 13:13:04 -0500 (Wed, 15 Nov 2006)
New Revision: 1439
Modified:
trunk/src/main/java/org/jboss/ws/Constants.java
trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java
trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
trunk/src/main/java/org/jboss/ws/jaxrpc/MetaDataSynchronization.java
trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java
trunk/src/main/java/org/jboss/ws/jaxws/client/ResponseImpl.java
trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java
trunk/src/main/java/org/jboss/ws/soap/MessageContextAssociation.java
trunk/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java
trunk/src/test/ant/build-jars-jaxws.xml
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/AsynchronousProxyTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/TestEndpointBean.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderMgmtBean.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderStatus.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/RetailSampleTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerification.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerificationBean.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationRequest.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationResponse.java
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ProfileMgmtBean.java
Log:
Add support for async invocations
Modified: trunk/src/main/java/org/jboss/ws/Constants.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/Constants.java 2006-11-15 18:01:07 UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/Constants.java 2006-11-15 18:13:04 UTC (rev 1439)
@@ -267,4 +267,6 @@
static final String WSDL20_PATTERN_ROBUST_OUT_ONLY =
"http://www.w3.org/2004/08/wsdl/robust-out-only";
static final String WSDL20_PATTERN_OUT_IN =
"http://www.w3.org/2004/08/wsdl/out-in";
static final String WSDL20_PATTERN_OUT_OPT_IN =
"http://www.w3.org/2004/08/wsdl/out-opt-in";
+
+ static final String ASYNC_METHOD_SUFFIX = "Async";
}
Modified: trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java 2006-11-15 18:01:07 UTC
(rev 1438)
+++ trunk/src/main/java/org/jboss/ws/common/CommonSOAPBinding.java 2006-11-15 18:13:04 UTC
(rev 1439)
@@ -96,6 +96,7 @@
/** A constant representing the identity of the SOAP 1.1 over HTTP binding. */
public static final String SOAP11HTTP_BINDING =
"http://schemas.xmlsoap.org/wsdl/soap/http";
+ private static final Name SOAP_ARRAY_NAME = new NameImpl("Array",
Constants.PREFIX_SOAP11_ENC, Constants.URI_SOAP11_ENC);
public CommonSOAPBinding()
{
@@ -785,7 +786,6 @@
private Object getParameterFromMessage(ParameterMetaData paramMetaData, SOAPElement
soapElement, boolean optional) throws BindingException
{
Name xmlName = new NameImpl(paramMetaData.getXmlName());
- Name soapArrayName = new NameImpl("Array", Constants.PREFIX_SOAP11_ENC,
Constants.URI_SOAP11_ENC);
SOAPContentElement soapContentElement = null;
Iterator childElements = soapElement.getChildElements();
@@ -808,7 +808,7 @@
break;
}
- if (soapArrayName.equals(elName))
+ if (SOAP_ARRAY_NAME.equals(elName))
{
CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
msgContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM,
Boolean.TRUE);
Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java 2006-11-15
18:01:07 UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR181MetaDataBuilder.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -134,15 +134,36 @@
{
Class seiClass = null;
String seiName = null;
+
if (anWebService.endpointInterface().length() > 0)
{
seiName = anWebService.endpointInterface();
seiClass = udi.classLoader.loadClass(seiName);
anWebService = (WebService)seiClass.getAnnotation(WebService.class);
+
if (anWebService == null)
throw new WSException("Interface does not have a @WebService
annotation: " + seiName);
}
+ else
+ {
+ WebService seiAnnotation = null;
+
+ for(Class potentialSEI : sepClass.getInterfaces())
+ {
+ if(potentialSEI.isAnnotationPresent(WebService.class))
+ {
+ seiClass = potentialSEI;
+ seiName = seiClass.getName();
+ seiAnnotation = sepClass.getAnnotation(WebService.class);
+ break;
+ }
+ }
+
+ if(seiAnnotation!=null)
+ anWebService = seiAnnotation;
+ }
+
// Clear the java types, etc.
resetMetaDataBuilder(udi.classLoader);
@@ -371,11 +392,12 @@
if (webMethodCount == 0)
{
Class superClass = wsClass.getSuperclass();
- boolean isJDKClass =
superClass.getPackage().getName().startsWith("java");
- if(!isJDKClass)
+ while (superClass != null)
{
- while (superClass != null)
+ boolean isJDKClass =
superClass.getPackage().getName().startsWith("java");
+
+ if(!isJDKClass)
{
for (Method method : superClass.getMethods())
{
@@ -384,6 +406,7 @@
}
superClass = superClass.getSuperclass();
+
}
}
}
@@ -394,6 +417,12 @@
private void processWebMethod(EndpointMetaData epMetaData, Method method)
{
+ String javaName = method.getName();
+
+ // skip asnyc methods, they dont need meta data representation
+ if(method.getName().endsWith(Constants.ASYNC_METHOD_SUFFIX))
+ return;
+
ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData();
TypesMetaData typesMetaData = serviceMetaData.getTypesMetaData();
String targetNS = epMetaData.getQName().getNamespaceURI();
@@ -408,10 +437,11 @@
WebMethod anWebMethod = method.getAnnotation(WebMethod.class);
soapAction = anWebMethod.action();
if (anWebMethod.operationName().length() > 0)
+ {
operationName = anWebMethod.operationName();
+ }
}
- String javaName = method.getName();
OperationMetaData opMetaData = new OperationMetaData(epMetaData, new
QName(targetNS, operationName), javaName);
opMetaData.setOneWayOperation(method.isAnnotationPresent(Oneway.class));
opMetaData.setSOAPAction(soapAction);
Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/MetaDataSynchronization.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/MetaDataSynchronization.java 2006-11-15
18:01:07 UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/MetaDataSynchronization.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -29,6 +29,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.metadata.EndpointMetaData;
import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.Constants;
/** A helper that synchronizes the SEI with the endpoint meta data
*
@@ -52,6 +53,10 @@
for (int i = 0; i < methods.length; i++)
{
Method method = methods[i];
+
+ if(method.getName().endsWith(Constants.ASYNC_METHOD_SUFFIX))
+ continue;
+
log.debug("synchronize method: " + method);
OperationMetaData opMetaData = epMetaData.getOperation(method);
Modified: trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java 2006-11-15 18:01:07 UTC
(rev 1438)
+++ trunk/src/main/java/org/jboss/ws/jaxws/client/ClientProxy.java 2006-11-15 18:13:04 UTC
(rev 1439)
@@ -26,11 +26,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.rmi.RemoteException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@@ -42,6 +38,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
+import org.jboss.ws.Constants;
import org.jboss.ws.metadata.EndpointMetaData;
import org.jboss.ws.metadata.OperationMetaData;
import org.jboss.ws.utils.JavaUtils;
@@ -122,7 +119,7 @@
{
Object retObj;
Class retType = method.getReturnType();
- boolean isAsync = methodName.endsWith("Async");
+ boolean isAsync = methodName.endsWith(Constants.ASYNC_METHOD_SUFFIX);
// Invoke asynchronously
if (isAsync && JavaUtils.isAssignableFrom(Response.class, retType))
@@ -169,6 +166,9 @@
{
ResponseImpl response = new ResponseImpl();
Runnable task = new AsyncRunnable(response, null, opName, args, retType);
+
+ log.debug("Schedule task " +
((AsyncRunnable)task).getTaskID().toString());
+
Future future = executor.submit(task);
response.setFuture(future);
return response;
@@ -196,6 +196,7 @@
private QName opName;
private Object[] args;
private Class retType;
+ private UUID uuid;
public AsyncRunnable(ResponseImpl response, AsyncHandler handler, QName opName,
Object[] args, Class retType)
{
@@ -204,6 +205,7 @@
this.opName = opName;
this.args = args;
this.retType = retType;
+ this.uuid = UUID.randomUUID();
}
public void run()
@@ -212,6 +214,9 @@
{
Map<String, Object> resContext = response.getContext();
Object result = invoke(opName, args, retType, resContext);
+
+ log.debug("Finished task " + getTaskID().toString()+": "
+ result);
+
response.set(result);
// Call the handler if available
@@ -244,5 +249,9 @@
}
response.setException(wsex);
}
+
+ public UUID getTaskID() {
+ return uuid;
+ }
}
}
Modified: trunk/src/main/java/org/jboss/ws/jaxws/client/ResponseImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/client/ResponseImpl.java 2006-11-15 18:01:07
UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/jaxws/client/ResponseImpl.java 2006-11-15 18:13:04
UTC (rev 1439)
@@ -23,6 +23,8 @@
// $Id$
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@@ -30,9 +32,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import javax.xml.ws.Response;
-import javax.xml.ws.WebServiceException;
-
/**
* The Response interface provides methods used to obtain the payload and context of a
* message sent in response to an operation invocation.
@@ -47,7 +46,7 @@
private WebServiceException exception;
private Map<String, Object> context = new HashMap<String, Object>();
-
+
public void setException(WebServiceException ex)
{
this.exception = ex;
@@ -57,7 +56,7 @@
{
if (delegate == null)
throw new IllegalStateException("Future not available");
-
+
return delegate;
}
@@ -70,12 +69,12 @@
{
return context;
}
-
+
void set(Object result)
{
this.result = result;
}
-
+
public boolean cancel(boolean mayInterruptIfRunning)
{
return getFuture().cancel(mayInterruptIfRunning);
@@ -87,10 +86,10 @@
{
getFuture().get();
}
-
+
if (exception != null)
throw new ExecutionException(exception);
-
+
return result;
}
@@ -100,10 +99,10 @@
{
getFuture().get(timeout, unit);
}
-
+
if (exception != null)
throw new ExecutionException(exception);
-
+
return result;
}
Modified: trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java 2006-11-15 18:01:07
UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/metadata/EndpointMetaData.java 2006-11-15 18:13:04
UTC (rev 1439)
@@ -38,6 +38,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
+import org.jboss.ws.Constants;
import org.jboss.ws.common.CommonSOAPBinding;
import org.jboss.ws.jaxrpc.Style;
import org.jboss.ws.jaxrpc.TypeMappingImpl;
@@ -338,7 +339,7 @@
{
QName opQName = aux.getQName();
String javaName = aux.getJavaName();
- if (opQName.equals(xmlName) && !javaName.endsWith("Async"))
+ if (opQName.equals(xmlName) &&
!javaName.endsWith(Constants.ASYNC_METHOD_SUFFIX))
{
if (opMetaData == null)
{
@@ -389,12 +390,23 @@
{
for (OperationMetaData aux : operations)
{
- if (aux.getJavaMethod().equals(method))
+ boolean doesMatch = aux.getJavaMethod().equals(method);
+
+ // fallback for async methods
+ if(!doesMatch &&
method.getName().endsWith(Constants.ASYNC_METHOD_SUFFIX))
{
+ String name = method.getName();
+ name = name.substring(0, name.length()-5);
+ doesMatch = aux.getJavaName().equals(name);
+ }
+
+ if (doesMatch)
+ {
methodCache.put(method, aux);
opMetaData = aux;
break;
}
+
}
}
return opMetaData;
Modified: trunk/src/main/java/org/jboss/ws/soap/MessageContextAssociation.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/soap/MessageContextAssociation.java 2006-11-15
18:01:07 UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/soap/MessageContextAssociation.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -43,7 +43,7 @@
public static void pushMessageContext(CommonMessageContext msgContext)
{
- log.debug("pushMessageContext: " + msgContext);
+ log.debug("pushMessageContext: " + msgContext + " (Thread "
+Thread.currentThread().getName()+ ")");
Stack<CommonMessageContext> stack =
ThreadLocalAssociation.localMsgContextAssoc().get();
if (stack == null)
{
@@ -72,7 +72,7 @@
{
msgContext = stack.pop();
}
- log.debug("popMessageContext: " + msgContext);
+ log.debug("popMessageContext: " + msgContext +" (Thread "
+Thread.currentThread().getName()+ ")");
return msgContext;
}
}
Modified: trunk/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java 2006-11-15 18:01:07
UTC (rev 1438)
+++ trunk/src/main/java/org/jboss/ws/utils/ThreadLocalAssociation.java 2006-11-15 18:13:04
UTC (rev 1439)
@@ -46,12 +46,12 @@
* SOAP message context
* @see org.jboss.ws.soap.MessageContextAssociation
*/
- private static ThreadLocal<Stack<CommonMessageContext>> msgContextAssoc =
new InheritableThreadLocal<Stack<CommonMessageContext>>();
+ private static ThreadLocal<Stack<CommonMessageContext>> msgContextAssoc =
new ThreadLocal<Stack<CommonMessageContext>>();
/**
* @see org.jboss.ws.wsse.STRTransform
*/
- private static InheritableThreadLocal<SecurityStore> strTransformAssoc = new
InheritableThreadLocal<SecurityStore>();
+ private static ThreadLocal<SecurityStore> strTransformAssoc = new
ThreadLocal<SecurityStore>();
public static ThreadLocal localInvokerMDBAssoc() {
return invokerMDBAssoc;
Modified: trunk/src/test/ant/build-jars-jaxws.xml
===================================================================
--- trunk/src/test/ant/build-jars-jaxws.xml 2006-11-15 18:01:07 UTC (rev 1438)
+++ trunk/src/test/ant/build-jars-jaxws.xml 2006-11-15 18:13:04 UTC (rev 1439)
@@ -21,6 +21,7 @@
<!-- jaxws-asynchronous -->
<war warfile="${build.test.dir}/libs/jaxws-asynchronous.war"
webxml="${build.test.dir}/resources/jaxws/asynchronous/WEB-INF/web.xml">
<classes dir="${build.test.dir}/classes">
+ <include
name="org/jboss/test/ws/jaxws/asynchronous/TestEndpoint.class"/>
<include
name="org/jboss/test/ws/jaxws/asynchronous/TestEndpointBean.class"/>
</classes>
</war>
@@ -406,7 +407,8 @@
<include
name="org/jboss/test/ws/jaxws/samples/retail/**/*.class"/>
</fileset>
<metainf
dir="${build.test.dir}/resources/jaxws/samples/retail/META-INF">
- <include name="wsdl/*"/>
+ <include name="wsdl/*"/>
+ <include name="jaxws-handler.xml"/>
</metainf>
</jar>
<jar
jarfile="${build.test.dir}/libs/jaxws-samples-retail-client.jar">
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/AsynchronousProxyTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/AsynchronousProxyTestCase.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/AsynchronousProxyTestCase.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -37,6 +37,7 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
+import org.jboss.ws.jaxws.client.ResponseImpl;
/**
* Test JAXWS asynchrous proxy
@@ -57,9 +58,6 @@
public void testInvokeSync() throws Exception
{
- System.out.println("FIXME: [JBWS-1294] Add support for mapping async
methods");
- if (true) return;
-
TestEndpoint port = createProxy();
String retStr = port.echo("Hello");
assertEquals("Hello", retStr);
@@ -67,20 +65,37 @@
public void testInvokeAsync() throws Exception
{
- System.out.println("FIXME: [JBWS-1294] Add support for mapping async
methods");
- if (true) return;
-
TestEndpoint port = createProxy();
- Response response = port.echoAsync("Hello");
- String retStr = (String) response.get(1000, TimeUnit.MILLISECONDS);
- assertEquals("Hello", retStr);
+ Response response = port.echoAsync("Async");
+
+ // access future
+ String retStr = (String) response.get();
+ assertEquals("Async", retStr);
}
+ public void testInvokeAsyncReentrant() throws Exception
+ {
+
+ if(true)
+ {
+ System.out.println("FIXME:JBWS-1294");
+ return;
+ }
+
+ TestEndpoint port = createProxy();
+ Response response = port.echoAsync("Async");
+
+ // do something in between
+ String retStr = port.echo("Sync");
+ assertEquals("Sync", retStr);
+
+ // access future
+ retStr = (String) response.get();
+ assertEquals("Async", retStr);
+ }
+
public void testInvokeAsyncHandler() throws Exception
{
- System.out.println("FIXME: [JBWS-1294] Add support for mapping async
methods");
- if (true) return;
-
AsyncHandler<String> handler = new AsyncHandler<String>()
{
public void handleResponse(Response response)
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/TestEndpointBean.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/TestEndpointBean.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/asynchronous/TestEndpointBean.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -30,7 +30,10 @@
import org.jboss.logging.Logger;
-@WebService(name = "TestEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/asynchronous")
+@WebService(
+ name = "TestEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/asynchronous",
+ endpointInterface = "org.jboss.test.ws.jaxws.asynchronous.TestEndpoint"
+)
@SOAPBinding(style = Style.RPC)
public class TestEndpointBean
{
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderMgmtBean.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderMgmtBean.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderMgmtBean.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -21,18 +21,22 @@
*/
package org.jboss.test.ws.jaxws.samples.retail;
+import org.jboss.logging.Logger;
+import org.jboss.test.ws.jaxws.samples.retail.cc.CCVerification;
import org.jboss.test.ws.jaxws.samples.retail.cc.CCVerificationService;
-import org.jboss.test.ws.jaxws.samples.retail.cc.CCVerification;
-import org.jboss.test.ws.jaxws.samples.retail.profile.ProfileMgmtService;
-import org.jboss.test.ws.jaxws.samples.retail.profile.ProfileMgmt;
+import org.jboss.test.ws.jaxws.samples.retail.cc.VerificationRequest;
+import org.jboss.test.ws.jaxws.samples.retail.cc.VerificationResponse;
import org.jboss.test.ws.jaxws.samples.retail.profile.DiscountRequest;
import org.jboss.test.ws.jaxws.samples.retail.profile.DiscountResponse;
-import org.jboss.logging.Logger;
+import org.jboss.test.ws.jaxws.samples.retail.profile.ProfileMgmt;
+import org.jboss.test.ws.jaxws.samples.retail.profile.ProfileMgmtService;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
+import javax.jws.HandlerChain;
import javax.jws.WebService;
import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.Response;
/**
* An example order management component
@@ -40,6 +44,7 @@
*/
@Stateless
@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.samples.retail.OrderMgmt")
+@HandlerChain(file = "META-INF/jaxws-handler.xml")
public class OrderMgmtBean implements OrderMgmt {
private static final Logger log = Logger.getLogger(OrderMgmtBean.class);
@@ -64,14 +69,14 @@
* @param order
* @return OrderStaus
*/
- public OrderStatus prepareOrder(Order order) {
+ public OrderStatus prepareOrder(Order order)
+ {
log.info("Preparing order " + order);
// verify billing details
String creditCard = order.getCustomer().getCreditCardDetails();
- boolean isValidCard = verificationPort.verify(creditCard);
- log.info(creditCard + " valid? " + isValidCard);
+ Response<Boolean> response = verificationPort.verifyAsync( creditCard );
// high value customer discount
DiscountRequest discountRequest = new DiscountRequest(order.getCustomer());
@@ -79,11 +84,21 @@
boolean hasDiscount = discount.getDiscount() > 0.00;
log.info("High value customer ? " + hasDiscount);
+ try
+ {
+ log.info(creditCard + " valid? " + response.get());
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to access async results", e);
+ }
+
// transition to prepared state
order.setState(Order.OrderState.PREPARED);
// done
- return new OrderStatus("Prepared", order.getOrderNum());
+ //return new OrderStatus("Prepared", order.getOrderNum(),
discount.getDiscount());
+ return new OrderStatus("Prepared", order.getOrderNum(), 0);
}
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderStatus.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderStatus.java 2006-11-15
18:01:07 UTC (rev 1438)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/OrderStatus.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -31,13 +31,15 @@
public class OrderStatus implements Serializable {
private String status;
private long orderNum;
+ private double discount;
public OrderStatus() {
}
- public OrderStatus(String status, long orderNum) {
+ public OrderStatus(String status, long orderNum, double discount) {
this.status = status;
this.orderNum = orderNum;
+ this.discount = discount;
}
public String getStatus() {
@@ -55,4 +57,12 @@
public void setOrderNum(long orderNum) {
this.orderNum = orderNum;
}
+
+ public double getDiscount() {
+ return discount;
+ }
+
+ public void setDiscount(double discount) {
+ this.discount = discount;
+ }
}
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/RetailSampleTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/RetailSampleTestCase.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/RetailSampleTestCase.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -27,7 +27,6 @@
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
import org.jboss.ws.metadata.wsdl.WSDLDefinitionsFactory;
-import javax.naming.InitialContext;
import javax.xml.namespace.QName;
import java.net.MalformedURLException;
import java.net.URL;
@@ -74,16 +73,6 @@
}
- public void testRemoteAccess() throws Exception
- {
- InitialContext iniCtx = getInitialContext();
- OrderMgmt orderMgmtEJB =
(OrderMgmt)iniCtx.lookup("/OrderMgmtBean/remote");
- assertNotNull(orderMgmtEJB);
-
- OrderStatus result = orderMgmtEJB.prepareOrder(ORDER);
- assertEquals("Prepared", result.getStatus());
- }
-
public void testWebService() throws Exception
{
assertWSDLAccess();
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerification.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerification.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerification.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -7,6 +7,7 @@
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.Response;
/**
@@ -29,8 +30,10 @@
@WebResult(name = "verified", targetNamespace = "")
@RequestWrapper(localName = "verify", targetNamespace =
"http://org.jboss.ws/samples/retail/cc", className =
"org.jboss.test.ws.jaxws.samples.retail.cc.VerificationRequest")
@ResponseWrapper(localName = "verifyResponse", targetNamespace =
"http://org.jboss.ws/samples/retail/cc", className =
"org.jboss.test.ws.jaxws.samples.retail.cc.VerificationResponse")
- public boolean verify(
+ public Boolean verify(
@WebParam(name = "creditCardNumber", targetNamespace = "")
String creditCardNumber);
+ Response<Boolean> verifyAsync(String creditCardNumber);
+
}
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerificationBean.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerificationBean.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/CCVerificationBean.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -25,18 +25,26 @@
import javax.ejb.Stateless;
import javax.jws.WebService;
+import javax.jws.HandlerChain;
+import javax.xml.ws.Response;
@Stateless
@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.samples.retail.cc.CCVerification")
+@HandlerChain(file = "META-INF/jaxws-handler.xml")
public class CCVerificationBean implements CCVerification {
private static final Logger log = Logger.getLogger(CCVerificationBean.class);
- public boolean verify(String creditcard) {
+ public Boolean verify(String creditcard) {
log.info("Verifying credit card: " + creditcard);
-
+
+ CreditcardProcessor.process(creditcard);
+
return true;
}
+ public Response<Boolean> verifyAsync(String creditCardNumber) {
+ return null;
+ }
}
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationRequest.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationRequest.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationRequest.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -8,9 +8,9 @@
/**
* <p>Java class for verificationRequest complex type.
- *
+ *
* <p>The following schema fragment specifies the expected content contained within
this class.
- *
+ *
* <pre>
* <complexType name="verificationRequest">
* <complexContent>
@@ -22,39 +22,46 @@
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "verificationRequest", propOrder = {
"creditCardNumber"
-})
+ })
public class VerificationRequest {
- protected String creditCardNumber;
+ protected String creditCardNumber;
- /**
- * Gets the value of the creditCardNumber property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getCreditCardNumber() {
- return creditCardNumber;
- }
+ public VerificationRequest(String creditCardNumber) {
+ this.creditCardNumber = creditCardNumber;
+ }
- /**
- * Sets the value of the creditCardNumber property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setCreditCardNumber(String value) {
- this.creditCardNumber = value;
- }
+ public VerificationRequest() {
+ }
+ /**
+ * Gets the value of the creditCardNumber property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCreditCardNumber() {
+ return creditCardNumber;
+ }
+
+ /**
+ * Sets the value of the creditCardNumber property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCreditCardNumber(String value) {
+ this.creditCardNumber = value;
+ }
+
}
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationResponse.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationResponse.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/cc/VerificationResponse.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -8,9 +8,9 @@
/**
* <p>Java class for verificationResponse complex type.
- *
+ *
* <p>The following schema fragment specifies the expected content contained within
this class.
- *
+ *
* <pre>
* <complexType name="verificationResponse">
* <complexContent>
@@ -22,8 +22,8 @@
* </complexContent>
* </complexType>
* </pre>
- *
- *
+ *
+ *
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "verificationResponse", propOrder = {
@@ -31,21 +31,21 @@
})
public class VerificationResponse {
- protected boolean verified;
+ protected Boolean verified;
/**
* Gets the value of the verified property.
- *
+ *
*/
- public boolean isVerified() {
+ public Boolean isVerified() {
return verified;
}
/**
* Sets the value of the verified property.
- *
+ *
*/
- public void setVerified(boolean value) {
+ public void setVerified(Boolean value) {
this.verified = value;
}
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ProfileMgmtBean.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ProfileMgmtBean.java 2006-11-15
18:01:07 UTC (rev 1438)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/samples/retail/profile/ProfileMgmtBean.java 2006-11-15
18:13:04 UTC (rev 1439)
@@ -23,9 +23,11 @@
import javax.ejb.Stateless;
import javax.jws.WebService;
+import javax.jws.HandlerChain;
@Stateless
@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.samples.retail.profile.ProfileMgmt")
+@HandlerChain(file = "META-INF/jaxws-handler.xml")
public class ProfileMgmtBean implements ProfileMgmt {
public DiscountResponse getCustomerDiscount(DiscountRequest request) {