You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2006/07/20 05:21:06 UTC
svn commit: r423736 [1/2] - in
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws: ./
client/ core/ core/controller/ impl/
Author: nagy
Date: Wed Jul 19 20:21:05 2006
New Revision: 423736
URL: http://svn.apache.org/viewvc?rev=423736&view=rev
Log:
AXIS2-909
Fixed the invokeOneWay and invokeAsync (callback) implementations in AxisInvocationController
Contributor: Nick Gallardo
Added:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncListener.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncListenerWrapper.java
Removed:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncResponse.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/impl/AsyncResponseProcessor.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisCallback.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisCallback.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisCallback.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisCallback.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisCallback.java Wed Jul 19 20:21:05 2006
@@ -1,46 +1,70 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.jaxws;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.client.async.AsyncResult;
-import org.apache.axis2.client.async.Callback;
-import org.apache.axis2.context.MessageContext;
-
-public class AxisCallback extends Callback {
-
- private SOAPEnvelope responseEnv;
- private MessageContext responseMsgCtx;
-
- public void onComplete(AsyncResult result) {
- responseEnv = result.getResponseEnvelope();
- responseMsgCtx = result.getResponseMessageContext();
- }
-
- public void onError(Exception e) {
- e.printStackTrace();
- }
-
- public SOAPEnvelope getSOAPEnvelope() {
- return responseEnv;
- }
-
- public MessageContext getResponseMessageContext() {
- return responseMsgCtx;
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.jaxws;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.jaxws.core.MessageContext;
+
+/**
+ * The AxisCallback is the touch point for asynchronous invocations
+ * between the Axis2 runtime and the JAX-WS implementation. This
+ * object will be handed to the ServiceClient/OperationClient APIs
+ * to use in processing the async response.
+ *
+ * The AxisCallback is responsible for taking the incoming message and
+ * MessageContext from Axis2 and turning that into a MessageContext
+ * that can be used by the JAX-WS implementation.
+ */
+public class AxisCallback extends Callback {
+
+ private MessageContext responseMsgCtx;
+
+ /**
+ * This method will be called when the Axis2 implementation is
+ * ready to send the async response back to the client.
+ */
+ public void onComplete(AsyncResult result) {
+ org.apache.axis2.context.MessageContext axisMsgCtx =
+ result.getResponseMessageContext();
+ responseMsgCtx = new MessageContext(axisMsgCtx);
+
+ try {
+ OMElement responseEnv = result.getResponseEnvelope();
+ responseMsgCtx.setMessageAsOM(responseEnv);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // FIXME: Figure out what needs to be done when this method is called
+ // and we've received an error from Axis2.
+ public void onError(Exception e) {
+ e.printStackTrace();
+ }
+
+ /**
+ * Returns the <@link org.apache.axis2.jaxws.core.MessageContext> that was
+ * created for the response message.
+ * @return - a MessageContext with the response contents
+ */
+ public MessageContext getResponseMessageContext() {
+ return responseMsgCtx;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java Wed Jul 19 20:21:05 2006
@@ -1,385 +1,385 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.axis2.jaxws;
-
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.Service.Mode;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.context.ServiceGroupContext;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.jaxws.handler.PortData;
-import org.apache.axis2.jaxws.impl.AsyncResponse;
-import org.apache.axis2.jaxws.impl.AsyncResponseProcessor;
-import org.apache.axis2.jaxws.param.JAXBParameter;
-import org.apache.axis2.jaxws.param.Parameter;
-import org.apache.axis2.jaxws.param.ParameterFactory;
-import org.apache.axis2.jaxws.param.ParameterUtils;
-import org.apache.axis2.jaxws.util.Constants;
-import org.apache.axis2.jaxws.util.WSDLWrapper;
-
-
-public class AxisController {
- private AxisService axisService = null;
-// TODO: This configContext will come from websphere deployment code later
- private ConfigurationContext configContext = null;
- private ServiceClient serviceClient = null;
- private ServiceContext serviceContext = null;
- private JAXWSClientContext clientContext = null;
- private ServiceGroupContext groupContext = null;
- private EndpointReference myEPR;
-
- public AxisService getAxisService() {
- return axisService;
- }
- public void setAxisService(AxisService axisService) {
- this.axisService = axisService;
- }
- public ConfigurationContext getConfigContext() {
- return configContext;
- }
- public void setConfigContext(ConfigurationContext configContext) {
- this.configContext = configContext;
- }
- public ServiceClient getServiceClient() {
- return serviceClient;
- }
- public void setServiceClient(ServiceClient serviceClient) {
- this.serviceClient = serviceClient;
- }
- public ServiceContext getServiceContext() {
- return serviceContext;
- }
- public void setServiceContext(ServiceContext serviceContext) {
- this.serviceContext = serviceContext;
- }
- public JAXWSClientContext getClientContext() {
- return clientContext;
- }
- public void setClientContext(JAXWSClientContext clientContext) {
- this.clientContext = clientContext;
- }
- public ServiceGroupContext getGroupContext() {
- return groupContext;
- }
- public void setGroupContext(ServiceGroupContext groupContext) {
- this.groupContext = groupContext;
- }
- public PortData getPortInfo(){
- return clientContext.getPort();
- }
- public QName getServiceName(){
- return getPortInfo().getServiceName();
- }
- public QName getPortName(){
- return getPortInfo().getPortName();
- }
- public String getEndpointAddress(){
- return getPortInfo().getEndpointAddress();
- }
- public String getBindingId(){
- return getPortInfo().getBindingID();
- }
- public WSDLWrapper getWSDLContext(){
- return clientContext.getWsdlContext();
- }
- public ExecutorService getExecutor() {
- return clientContext.getExecutor();
- }
- public Mode getServiceMode() {
- return (Mode) clientContext.getServiceMode();
- }
- public URL getWSDLLocation(){
- return clientContext.getWSDLLocation();
- }
-
- public Object invoke(Parameter param, Map requestContext) throws WebServiceException {
- setupProperties(requestContext);
-
- try{
- //TODO: This is not the correct way to setup the JAXBContext
- if (clientContext.getJAXBContext() != null) {
- JAXBParameter p = (JAXBParameter) param;
- p.setJAXBContext(clientContext.getJAXBContext());
- }
-
- serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(getEndpointURL(requestContext)));
- String soapAction = getSOAPAction(requestContext);
- if (soapAction != null) {
- serviceClient.getOptions().setAction(soapAction);
- }
- else {
- //TODO: This should be an addressing exception on the client side
- serviceClient.getOptions().setAction("none");
- }
-
- //Create the Parameter wrapper for the response based on what the input
- //type was. If it was a JAXBParameter, then set the JAXBContext on it as well
- Parameter response = ParameterFactory.createParameter(param.getValue().getClass());
- if (param instanceof JAXBParameter) {
- JAXBParameter p = (JAXBParameter) response;
- p.setJAXBContext(clientContext.getJAXBContext());
- }
- OMElement axisResponse = null;
-
- //TODO: Team needs to decide if we are going to use ServiceClient api or go to AxisEngine api directly. ServiceClient requires that we send a OMElement
- //and it creates a SOAPEnvelop by reading the headers that dispatch sets in ServiceClient. This is not a good way for message modeas we will be
- //manuplating client message first to read all the headers and then read the body. we add the headers in ServiceClient then create OMElement from body
- //and send then OMElement in SendReceive operation, which then is converted again to an envelope and header headers are added to it by ServiceClient
- //before sending it to axis enging.
- axisResponse = serviceClient.sendReceive(ServiceClient.ANON_OUT_IN_OP, toOM(param));
-
- //TODO: If ServiceClient can return the actual sopaEnvelope from MessageContext we can use the message mode and param this way.
- //response.fromEnvelope(mode, axisResponse);
- //return response.getValue();
- return buildResponse(axisResponse, response).getValue();
- }catch(AxisFault e){
- //TODO
- String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
- throw new WebServiceException(e.getMessage() + " " + todo);
-
- }
- }
-
- public void invokeOneWay(Parameter param, Map requestContext) throws WebServiceException{
- setupProperties(requestContext);
-
- try{
- //TODO: This is not the correct way to setup the JAXBContext
- if (clientContext.getJAXBContext() != null) {
- JAXBParameter p = (JAXBParameter) param;
- p.setJAXBContext(clientContext.getJAXBContext());
- }
-
- serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(getEndpointURL(requestContext)));
- String soapAction = getSOAPAction(requestContext);
- if (soapAction != null) {
- serviceClient.getOptions().setAction(soapAction);
- }
- else {
- serviceClient.getOptions().setAction("none");
- }
-
- serviceClient.fireAndForget(ServiceClient.ANON_OUT_ONLY_OP, toOM(param));
- } catch(AxisFault e) {
-
- String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
- throw new WebServiceException(e.getMessage() + " " + todo);
- }
- }
-
- public Future<?> invokeAsync(Parameter param, AsyncHandler asynchandler, Map requestContext) throws WebServiceException{
- setupProperties(requestContext);
-
- try{
- //TODO: This is not the correct way to setup the JAXBContext
- if (clientContext.getJAXBContext() != null) {
- JAXBParameter p = (JAXBParameter) param;
- p.setJAXBContext(clientContext.getJAXBContext());
- }
-
- serviceClient.getOptions().setTo(new EndpointReference(getEndpointURL(requestContext)));
- serviceClient.getOptions().setReplyTo(getMyEPR());
-
- //TODO: This is a hack. Need a better way to determine the default wsa:Action if
- //a SOAPAction header does not exist.
- String soapAction = getSOAPAction(requestContext);
- if (soapAction != null) {
- serviceClient.getOptions().setAction(soapAction);
- }
- else {
- serviceClient.getOptions().setAction("none");
- }
-
- AxisCallback callback = new AxisCallback();
- Boolean useAsyncMep = (Boolean) requestContext.get(Constants.USE_ASYNC_MEP);
-
- if((useAsyncMep != null && useAsyncMep.booleanValue())
- || serviceClient.getOptions().isUseSeparateListener()) {
- serviceClient.getOptions().setUseSeparateListener(true);
- serviceClient.getOptions().setTransportInProtocol("http");
- }
-
- serviceClient.sendReceiveNonBlocking(ServiceClient.ANON_OUT_IN_OP,
- toOM(param), callback);
-
- //Create the Parameter wrapper for the response based on what the input
- //type was. If it was a JAXBParameter, then set the JAXBContext on it as well
- Parameter responseParam = ParameterFactory.createParameter(param.getValue().getClass());
- if (param instanceof JAXBParameter) {
- JAXBParameter p = (JAXBParameter) responseParam;
- p.setJAXBContext(clientContext.getJAXBContext());
- }
-
- AsyncResponseProcessor asyncProcessor = new AsyncResponseProcessor(callback);
- asyncProcessor.setMode((Mode) clientContext.getServiceMode());
- asyncProcessor.setParameter(responseParam);
-
- AsyncResponse<?> response = new AsyncResponse<Object>(asyncProcessor);
- if(asynchandler !=null){
- response.setAsyncHandler(asynchandler);
- }
-
- try {
- getExecutor().submit(response).get();
- } catch (InterruptedException e) {
- e.printStackTrace();
- throw new WebServiceException(e.getMessage());
- } catch (ExecutionException e) {
- e.printStackTrace();
- throw new WebServiceException(e.getMessage());
- }
-
- //TODO: Need to figure out who/when the Listener should be shutdown
- //Do we do it after this request? Or, can we ask the listener to check
- //itself to see if any other responses are outstanding.
- return response;
- }catch(AxisFault e){
-
- String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
- throw new WebServiceException(e.getMessage() + " " + todo);
- }
- }
-
- public Response invokeAsync(Parameter param, Map requestContext)throws WebServiceException{
- AsyncResponse<Object> response= (AsyncResponse<Object>)invokeAsync(param, null, requestContext);
- return response;
- }
-
- private String getEndpointURL(Map requestContext){
- return (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
- }
-
- private String getSOAPAction(Map requestContext){
- Boolean useSoapAction = (Boolean)requestContext.get(BindingProvider.SOAPACTION_USE_PROPERTY);
- if(useSoapAction!=null && useSoapAction.booleanValue()){
- return (String)requestContext.get(BindingProvider.SOAPACTION_URI_PROPERTY);
- }
- return null;
- }
-
- private OMElement toOM(Parameter param){
- /*TODO: This is a a hack.... I am getting the Header of the message and setting serviceClent header, then
- * extract body of message as OM and ServiceCleint will create the envelope.
- * I am doing this because ServiceClient wants to form the envelope and send it to AxisEngine.
- * I would like to return param.toEnvelope() but ServiceClient will try to build envelope on top of envelope.
- * Let just go directly to AxisEngine forget about ServiceClient... can I?
- */
- SOAPEnvelope env = ParameterUtils.toEnvelope((Mode) clientContext.getServiceMode(),
- serviceClient.getOptions().getSoapVersionURI(),
- param);
- SOAPBody body= env.getBody();
- SOAPHeader soapHeader = env.getHeader();
- addHeadersToServiceClient(soapHeader);
- return body.getFirstElement();
- }
-
- private void addHeadersToServiceClient(SOAPHeader soapHeader){
- if(soapHeader!=null){
- for(Iterator headers = soapHeader.getChildElements(); headers.hasNext();){
- OMElement header = (OMElement)headers.next();
- serviceClient.addHeader(header);
- }
- }
- }
-
- private Parameter buildResponse(OMElement element, Parameter xmlResponse){
- //Create empty SoapResponse first
- Parameter soapResponse = xmlResponse;
-
- /* get xmlResponse param from ServiceClient OM response, By the way ServiceClient always retuns an
- * OMElement xml string not Soap Env or Body.
- * It does something like msgCtx.getEnvelope().getBody.getChild() --> i.e OMElement under the body.
- * So we now have to go thru the pain of recreating the envelope. This is a performance issue...
- */
- xmlResponse.fromOM(element);
- /*I will convert param toEnvelope since ServiceClient always send xml string.
- * toEnvelope() in Parameter is coded just to handle this.
- */
- SOAPEnvelope env =xmlResponse.toEnvelope(null,serviceClient.getOptions().getSoapVersionURI());
-
- //TODO:(NLG) Need to figure out why we have to cast to (Mode) here.
- soapResponse.fromEnvelope((Mode) clientContext.getServiceMode(), env);
-
- return soapResponse;
- }
-
- /*
- * Returns the EPR that should be used for in-bound async responses
- */
- private EndpointReference getMyEPR() {
- if (myEPR != null) {
- return myEPR;
- }
- else {
- try {
- //TODO:(NLG) This should not be hard coded to HTTP and should allow
- //for other transports to be used.
- myEPR = serviceClient.getMyEPR("http");
- } catch (AxisFault e) {
- e.printStackTrace();
- }
- return myEPR;
- }
- }
-
-
- /*
- * TODO: This is a first pass at filtering the properties that are set on the
- * RequestContext. Right now it's called during the invoke, but needs to be
- * moved over to when the property is set. This should not be in the path
- * of performance.
- */
- private void setupProperties(Map<String, Object> requestCtx) {
- for (Iterator<String> it = requestCtx.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- Object value = requestCtx.get(key);
-
- if (key.equals(Constants.QOS_WSRM_ENABLE)) {
- key = "Sandesha2AppProcessingDone";
- value = !(Boolean) value;
- value = value.toString();
- }
- else if (key.equals(Constants.QOS_WSADDRESSING_ENABLE)) {
- key = org.apache.axis2.Constants.Configuration.DISABLE_ADDRESSING_FOR_OUT_MESSAGES;
- value = !(Boolean) value;
- }
-
- serviceClient.getOptions().setProperty(key, value);
- }
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.axis2.jaxws;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.Service.Mode;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.handler.PortData;
+import org.apache.axis2.jaxws.impl.AsyncListenerWrapper;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.param.JAXBParameter;
+import org.apache.axis2.jaxws.param.Parameter;
+import org.apache.axis2.jaxws.param.ParameterFactory;
+import org.apache.axis2.jaxws.param.ParameterUtils;
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.axis2.jaxws.util.WSDLWrapper;
+
+
+public class AxisController {
+ private AxisService axisService = null;
+// TODO: This configContext will come from websphere deployment code later
+ private ConfigurationContext configContext = null;
+ private ServiceClient serviceClient = null;
+ private ServiceContext serviceContext = null;
+ private JAXWSClientContext clientContext = null;
+ private ServiceGroupContext groupContext = null;
+ private EndpointReference myEPR;
+
+ public AxisService getAxisService() {
+ return axisService;
+ }
+ public void setAxisService(AxisService axisService) {
+ this.axisService = axisService;
+ }
+ public ConfigurationContext getConfigContext() {
+ return configContext;
+ }
+ public void setConfigContext(ConfigurationContext configContext) {
+ this.configContext = configContext;
+ }
+ public ServiceClient getServiceClient() {
+ return serviceClient;
+ }
+ public void setServiceClient(ServiceClient serviceClient) {
+ this.serviceClient = serviceClient;
+ }
+ public ServiceContext getServiceContext() {
+ return serviceContext;
+ }
+ public void setServiceContext(ServiceContext serviceContext) {
+ this.serviceContext = serviceContext;
+ }
+ public JAXWSClientContext getClientContext() {
+ return clientContext;
+ }
+ public void setClientContext(JAXWSClientContext clientContext) {
+ this.clientContext = clientContext;
+ }
+ public ServiceGroupContext getGroupContext() {
+ return groupContext;
+ }
+ public void setGroupContext(ServiceGroupContext groupContext) {
+ this.groupContext = groupContext;
+ }
+ public PortData getPortInfo(){
+ return clientContext.getPort();
+ }
+ public QName getServiceName(){
+ return getPortInfo().getServiceName();
+ }
+ public QName getPortName(){
+ return getPortInfo().getPortName();
+ }
+ public String getEndpointAddress(){
+ return getPortInfo().getEndpointAddress();
+ }
+ public String getBindingId(){
+ return getPortInfo().getBindingID();
+ }
+ public WSDLWrapper getWSDLContext(){
+ return clientContext.getWsdlContext();
+ }
+ public ExecutorService getExecutor() {
+ return clientContext.getExecutor();
+ }
+ public Mode getServiceMode() {
+ return (Mode) clientContext.getServiceMode();
+ }
+ public URL getWSDLLocation(){
+ return clientContext.getWSDLLocation();
+ }
+
+ public Object invoke(Parameter param, Map requestContext) throws WebServiceException {
+ setupProperties(requestContext);
+
+ try{
+ //TODO: This is not the correct way to setup the JAXBContext
+ if (clientContext.getJAXBContext() != null) {
+ JAXBParameter p = (JAXBParameter) param;
+ p.setJAXBContext(clientContext.getJAXBContext());
+ }
+
+ serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(getEndpointURL(requestContext)));
+ String soapAction = getSOAPAction(requestContext);
+ if (soapAction != null) {
+ serviceClient.getOptions().setAction(soapAction);
+ }
+ else {
+ //TODO: This should be an addressing exception on the client side
+ serviceClient.getOptions().setAction("none");
+ }
+
+ //Create the Parameter wrapper for the response based on what the input
+ //type was. If it was a JAXBParameter, then set the JAXBContext on it as well
+ Parameter response = ParameterFactory.createParameter(param.getValue().getClass());
+ if (param instanceof JAXBParameter) {
+ JAXBParameter p = (JAXBParameter) response;
+ p.setJAXBContext(clientContext.getJAXBContext());
+ }
+ OMElement axisResponse = null;
+
+ //TODO: Team needs to decide if we are going to use ServiceClient api or go to AxisEngine api directly. ServiceClient requires that we send a OMElement
+ //and it creates a SOAPEnvelop by reading the headers that dispatch sets in ServiceClient. This is not a good way for message modeas we will be
+ //manuplating client message first to read all the headers and then read the body. we add the headers in ServiceClient then create OMElement from body
+ //and send then OMElement in SendReceive operation, which then is converted again to an envelope and header headers are added to it by ServiceClient
+ //before sending it to axis enging.
+ axisResponse = serviceClient.sendReceive(ServiceClient.ANON_OUT_IN_OP, toOM(param));
+
+ //TODO: If ServiceClient can return the actual sopaEnvelope from MessageContext we can use the message mode and param this way.
+ //response.fromEnvelope(mode, axisResponse);
+ //return response.getValue();
+ return buildResponse(axisResponse, response).getValue();
+ }catch(AxisFault e){
+ //TODO
+ String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
+ throw new WebServiceException(e.getMessage() + " " + todo);
+
+ }
+ }
+
+ public void invokeOneWay(Parameter param, Map requestContext) throws WebServiceException{
+ setupProperties(requestContext);
+
+ try{
+ //TODO: This is not the correct way to setup the JAXBContext
+ if (clientContext.getJAXBContext() != null) {
+ JAXBParameter p = (JAXBParameter) param;
+ p.setJAXBContext(clientContext.getJAXBContext());
+ }
+
+ serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(getEndpointURL(requestContext)));
+ String soapAction = getSOAPAction(requestContext);
+ if (soapAction != null) {
+ serviceClient.getOptions().setAction(soapAction);
+ }
+ else {
+ serviceClient.getOptions().setAction("none");
+ }
+
+ serviceClient.fireAndForget(ServiceClient.ANON_OUT_ONLY_OP, toOM(param));
+ } catch(AxisFault e) {
+
+ String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
+ throw new WebServiceException(e.getMessage() + " " + todo);
+ }
+ }
+
+ public Future<?> invokeAsync(Parameter param, AsyncHandler asynchandler, Map requestContext) throws WebServiceException{
+ setupProperties(requestContext);
+
+ try{
+ //TODO: This is not the correct way to setup the JAXBContext
+ if (clientContext.getJAXBContext() != null) {
+ JAXBParameter p = (JAXBParameter) param;
+ p.setJAXBContext(clientContext.getJAXBContext());
+ }
+
+ serviceClient.getOptions().setTo(new EndpointReference(getEndpointURL(requestContext)));
+ serviceClient.getOptions().setReplyTo(getMyEPR());
+
+ //TODO: This is a hack. Need a better way to determine the default wsa:Action if
+ //a SOAPAction header does not exist.
+ String soapAction = getSOAPAction(requestContext);
+ if (soapAction != null) {
+ serviceClient.getOptions().setAction(soapAction);
+ }
+ else {
+ serviceClient.getOptions().setAction("none");
+ }
+
+ AxisCallback callback = new AxisCallback();
+ Boolean useAsyncMep = (Boolean) requestContext.get(Constants.USE_ASYNC_MEP);
+
+ if((useAsyncMep != null && useAsyncMep.booleanValue())
+ || serviceClient.getOptions().isUseSeparateListener()) {
+ serviceClient.getOptions().setUseSeparateListener(true);
+ serviceClient.getOptions().setTransportInProtocol("http");
+ }
+
+ serviceClient.sendReceiveNonBlocking(ServiceClient.ANON_OUT_IN_OP,
+ toOM(param), callback);
+
+ //Create the Parameter wrapper for the response based on what the input
+ //type was. If it was a JAXBParameter, then set the JAXBContext on it as well
+ Parameter responseParam = ParameterFactory.createParameter(param.getValue().getClass());
+ if (param instanceof JAXBParameter) {
+ JAXBParameter p = (JAXBParameter) responseParam;
+ p.setJAXBContext(clientContext.getJAXBContext());
+ }
+
+ AsyncListener asyncProcessor = new AsyncListener(callback);
+ asyncProcessor.setMode((Mode) clientContext.getServiceMode());
+ //asyncProcessor.setParameter(responseParam);
+
+ AsyncListenerWrapper<?> response = new AsyncListenerWrapper<Object>(asyncProcessor);
+ if(asynchandler !=null){
+ response.setAsyncHandler(asynchandler);
+ }
+
+ try {
+ getExecutor().submit(response).get();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new WebServiceException(e.getMessage());
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ throw new WebServiceException(e.getMessage());
+ }
+
+ //TODO: Need to figure out who/when the Listener should be shutdown
+ //Do we do it after this request? Or, can we ask the listener to check
+ //itself to see if any other responses are outstanding.
+ return response;
+ }catch(AxisFault e){
+
+ String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
+ throw new WebServiceException(e.getMessage() + " " + todo);
+ }
+ }
+
+ public Response invokeAsync(Parameter param, Map requestContext)throws WebServiceException{
+ AsyncListenerWrapper<Object> response= (AsyncListenerWrapper<Object>)invokeAsync(param, null, requestContext);
+ return response;
+ }
+
+ private String getEndpointURL(Map requestContext){
+ return (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+ }
+
+ private String getSOAPAction(Map requestContext){
+ Boolean useSoapAction = (Boolean)requestContext.get(BindingProvider.SOAPACTION_USE_PROPERTY);
+ if(useSoapAction!=null && useSoapAction.booleanValue()){
+ return (String)requestContext.get(BindingProvider.SOAPACTION_URI_PROPERTY);
+ }
+ return null;
+ }
+
+ private OMElement toOM(Parameter param){
+ /*TODO: This is a a hack.... I am getting the Header of the message and setting serviceClent header, then
+ * extract body of message as OM and ServiceCleint will create the envelope.
+ * I am doing this because ServiceClient wants to form the envelope and send it to AxisEngine.
+ * I would like to return param.toEnvelope() but ServiceClient will try to build envelope on top of envelope.
+ * Let just go directly to AxisEngine forget about ServiceClient... can I?
+ */
+ SOAPEnvelope env = ParameterUtils.toEnvelope((Mode) clientContext.getServiceMode(),
+ serviceClient.getOptions().getSoapVersionURI(),
+ param);
+ SOAPBody body= env.getBody();
+ SOAPHeader soapHeader = env.getHeader();
+ addHeadersToServiceClient(soapHeader);
+ return body.getFirstElement();
+ }
+
+ private void addHeadersToServiceClient(SOAPHeader soapHeader){
+ if(soapHeader!=null){
+ for(Iterator headers = soapHeader.getChildElements(); headers.hasNext();){
+ OMElement header = (OMElement)headers.next();
+ serviceClient.addHeader(header);
+ }
+ }
+ }
+
+ private Parameter buildResponse(OMElement element, Parameter xmlResponse){
+ //Create empty SoapResponse first
+ Parameter soapResponse = xmlResponse;
+
+ /* get xmlResponse param from ServiceClient OM response, By the way ServiceClient always retuns an
+ * OMElement xml string not Soap Env or Body.
+ * It does something like msgCtx.getEnvelope().getBody.getChild() --> i.e OMElement under the body.
+ * So we now have to go thru the pain of recreating the envelope. This is a performance issue...
+ */
+ xmlResponse.fromOM(element);
+ /*I will convert param toEnvelope since ServiceClient always send xml string.
+ * toEnvelope() in Parameter is coded just to handle this.
+ */
+ SOAPEnvelope env =xmlResponse.toEnvelope(null,serviceClient.getOptions().getSoapVersionURI());
+
+ //TODO:(NLG) Need to figure out why we have to cast to (Mode) here.
+ soapResponse.fromEnvelope((Mode) clientContext.getServiceMode(), env);
+
+ return soapResponse;
+ }
+
+ /*
+ * Returns the EPR that should be used for in-bound async responses
+ */
+ private EndpointReference getMyEPR() {
+ if (myEPR != null) {
+ return myEPR;
+ }
+ else {
+ try {
+ //TODO:(NLG) This should not be hard coded to HTTP and should allow
+ //for other transports to be used.
+ myEPR = serviceClient.getMyEPR("http");
+ } catch (AxisFault e) {
+ e.printStackTrace();
+ }
+ return myEPR;
+ }
+ }
+
+
+ /*
+ * TODO: This is a first pass at filtering the properties that are set on the
+ * RequestContext. Right now it's called during the invoke, but needs to be
+ * moved over to when the property is set. This should not be in the path
+ * of performance.
+ */
+ private void setupProperties(Map<String, Object> requestCtx) {
+ for (Iterator<String> it = requestCtx.keySet().iterator(); it.hasNext(); ) {
+ String key = it.next();
+ Object value = requestCtx.get(key);
+
+ if (key.equals(Constants.QOS_WSRM_ENABLE)) {
+ key = "Sandesha2AppProcessingDone";
+ value = !(Boolean) value;
+ value = value.toString();
+ }
+ else if (key.equals(Constants.QOS_WSADDRESSING_ENABLE)) {
+ key = org.apache.axis2.Constants.Configuration.DISABLE_ADDRESSING_FOR_OUT_MESSAGES;
+ value = !(Boolean) value;
+ }
+
+ serviceClient.getOptions().setProperty(key, value);
+ }
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java Wed Jul 19 20:21:05 2006
@@ -1,199 +1,284 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.client;
-
-import java.util.concurrent.Future;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.Service.Mode;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.jaxws.AxisController;
-import org.apache.axis2.jaxws.BindingProvider;
-import org.apache.axis2.jaxws.core.InvocationContext;
-import org.apache.axis2.jaxws.core.InvocationContextFactory;
-import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.core.controller.AxisInvocationController;
-import org.apache.axis2.jaxws.core.controller.InvocationController;
-import org.apache.axis2.jaxws.param.Parameter;
-import org.apache.axis2.jaxws.param.ParameterFactory;
-import org.apache.axis2.jaxws.param.ParameterUtils;
-import org.apache.axis2.jaxws.spi.ServiceDelegate;
-import org.apache.axis2.jaxws.util.Constants;
-import org.apache.axis2.jaxws.util.WSDLWrapper;
-
-public abstract class BaseDispatch<T> extends BindingProvider
- implements javax.xml.ws.Dispatch {
-
- //FIXME: Remove the AxisController completely and replace with InvocationController
- protected AxisController axisController = null;
-
- protected InvocationController ic;
- protected ServiceDelegate serviceDelegate;
- protected Mode mode;
-
- protected BaseDispatch() {
- //do nothing
- }
-
- protected BaseDispatch(AxisController ac) {
- super();
-
- //FIXME: Remove this when we remove the AxisController
- axisController = ac;
-
- ic = new AxisInvocationController();
- setRequestContext();
- }
-
- protected abstract OMElement createMessageFromValue(Object value);
-
- protected abstract Object getValueFromMessage(OMElement message);
-
- public Object invoke(Object obj) throws WebServiceException {
- // Create the InvocationContext instance for this request/response flow.
- InvocationContext invocationContext = InvocationContextFactory.createInvocationContext(null);
- invocationContext.setServiceClient(axisController.getServiceClient());
-
- // Create the MessageContext to hold the actual request message and its
- // associated properties
- MessageContext requestMsgCtx = new MessageContext();
- invocationContext.setRequestMessageContext(requestMsgCtx);
-
- OMElement reqEnvelope = createMessageFromValue(obj);
- requestMsgCtx.setMessageAsOM(reqEnvelope);
-
- // Copy the properties from the request context into the MessageContext
- requestMsgCtx.getProperties().putAll(requestContext);
-
- // Send the request using the InvocationController
- ic.invoke(invocationContext);
-
- MessageContext responseMsgCtx = invocationContext.getResponseMessageContext();
-
- //FIXME: This is temporary until more of the Message model is available
- OMElement rspEnvelope = responseMsgCtx.getMessageAsOM();
- Object returnObj = getValueFromMessage(rspEnvelope);
-
- return returnObj;
- }
-
- public void invokeOneWay(Object obj) throws WebServiceException{
- if(obj == null){
- throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
- }
- try{
- Parameter param = ParameterFactory.createParameter(obj);
- axisController.invokeOneWay(param, requestContext);
- }catch(Exception e){
- throw new WebServiceException(e);
- }
- }
-
- public Future<?> invokeAsync(Object obj, AsyncHandler asynchandler) throws WebServiceException {
- if(obj == null){
- throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
- }
- try{
- Parameter param = ParameterFactory.createParameter(obj);
- return axisController.invokeAsync(param, asynchandler, requestContext);
- } catch(Exception e) {
- throw new WebServiceException(e);
- }
- }
-
- public Response invokeAsync(Object obj)throws WebServiceException{
- if(obj == null){
- throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
- }
- try{
- Parameter param = ParameterFactory.createParameter(obj);
- return axisController.invokeAsync(param, requestContext);
- }catch(Exception e){
- throw new WebServiceException(e);
- }
- }
-
- protected void setRequestContext(){
- String endPointAddress = axisController.getEndpointAddress();
- WSDLWrapper wsdl = axisController.getWSDLContext();
- QName serviceName = axisController.getServiceName();
- QName portName = axisController.getPortName();
- if(endPointAddress != null && !"".equals(endPointAddress)){
- getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPointAddress);
- }else if(wsdl != null){
- String soapAddress = wsdl.getSOAPAddress(serviceName, portName);
- getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, soapAddress);
- }
-
- if(wsdl != null){
- String soapAction = wsdl.getSOAPAction(serviceName, portName);
- getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, soapAction);
- }
-
- getRequestContext().put(Constants.QOS_WSADDRESSING_ENABLE, Boolean.FALSE);
- getRequestContext().put(Constants.QOS_WSRM_ENABLE, Boolean.FALSE);
- }
-
- public ServiceDelegate getServiceDelegate() {
- return serviceDelegate;
- }
-
- public void setServiceDelegate(ServiceDelegate sd) {
- serviceDelegate = sd;
- }
-
- public Mode getMode() {
- return mode;
- }
-
- public void setMode(Mode m) {
- mode = m;
- }
-
- /*
- * FIXME: This is temporary until more of the Message Model is available.
- */
- protected OMElement toOM(Parameter param, String soapVersion){
- SOAPEnvelope env = ParameterUtils.toEnvelope(mode, soapVersion, param);
- System.out.println(">> Generated envelope [" + env.toString() + "]");
-
- SOAPBody body = env.getBody();
- //SOAPHeader soapHeader = env.getHeader();
- //addHeadersToServiceClient(soapHeader);
- return body.getFirstElement();
- }
-
- /*
- * FIXME: This is temporary until more of the Message Model is available.
- */
- protected Parameter fromOM(OMElement element, Parameter response, String soapVersion){
- response.fromOM(element);
-
- // Convert param toEnvelope since ServiceClient always send xml string.
- // toEnvelope() in Parameter is coded just to handle this.
- SOAPEnvelope env = response.toEnvelope(null, soapVersion);
-
- response.fromEnvelope(mode, env);
- return response;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.client;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.Service.Mode;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.jaxws.AxisController;
+import org.apache.axis2.jaxws.BindingProvider;
+import org.apache.axis2.jaxws.core.InvocationContext;
+import org.apache.axis2.jaxws.core.InvocationContextFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.core.controller.AxisInvocationController;
+import org.apache.axis2.jaxws.core.controller.InvocationController;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.param.Parameter;
+import org.apache.axis2.jaxws.param.ParameterFactory;
+import org.apache.axis2.jaxws.param.ParameterUtils;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.axis2.jaxws.util.WSDLWrapper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class BaseDispatch<T> extends BindingProvider
+ implements javax.xml.ws.Dispatch {
+
+ private Log log = LogFactory.getLog(BaseDispatch.class);
+
+ //FIXME: Remove the AxisController completely and replace with InvocationController
+ protected AxisController axisController = null;
+
+ protected InvocationController ic;
+ protected ServiceDelegate serviceDelegate;
+ protected Mode mode;
+
+ protected BaseDispatch() {
+ super();
+ }
+
+ protected BaseDispatch(AxisController ac) {
+ super();
+
+ //FIXME: Remove this when we remove the AxisController
+ axisController = ac;
+
+ ic = new AxisInvocationController();
+ setRequestContext();
+ }
+
+ /**
+ * Take the input object and turn it into an OMElement so that it can
+ * be sent.
+ *
+ * @param value
+ * @return
+ */
+ protected abstract OMElement createMessageFromValue(Object value);
+
+ /**
+ * Given a message, return the business object based on the requestor's
+ * required format (PAYLOAD vs. MESSAGE) and datatype.
+ *
+ * @param message
+ * @return
+ */
+ protected abstract Object getValueFromMessage(OMElement message);
+
+ /**
+ * Creates an instance of the AsyncListener that is to be used for waiting
+ * for async responses.
+ *
+ * @return a configured AsyncListener instance
+ */
+ protected abstract AsyncListener createAsyncListener();
+
+ public Object invoke(Object obj) throws WebServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Entered synchronous invocation: BaseDispatch.invoke()");
+ }
+
+ // Create the InvocationContext instance for this request/response flow.
+ InvocationContext invocationContext = InvocationContextFactory.createInvocationContext(null);
+ invocationContext.setServiceClient(axisController.getServiceClient());
+
+ // Create the MessageContext to hold the actual request message and its
+ // associated properties
+ MessageContext requestMsgCtx = new MessageContext();
+ invocationContext.setRequestMessageContext(requestMsgCtx);
+
+ OMElement reqEnvelope = createMessageFromValue(obj);
+ requestMsgCtx.setMessageAsOM(reqEnvelope);
+
+ // Copy the properties from the request context into the MessageContext
+ requestMsgCtx.getProperties().putAll(requestContext);
+
+ // Send the request using the InvocationController
+ ic.invoke(invocationContext);
+
+ MessageContext responseMsgCtx = invocationContext.getResponseMessageContext();
+
+ //FIXME: This is temporary until more of the Message model is available
+ OMElement rspEnvelope = responseMsgCtx.getMessageAsOM();
+ Object returnObj = getValueFromMessage(rspEnvelope);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Synchronous invocation completed: BaseDispatch.invoke()");
+ }
+
+ return returnObj;
+ }
+
+ public void invokeOneWay(Object obj) throws WebServiceException{
+ if (log.isDebugEnabled()) {
+ log.debug("Entered one-way invocation: BaseDispatch.invokeOneWay()");
+ }
+
+ // Create the InvocationContext instance for this request/response flow.
+ InvocationContext invocationContext = InvocationContextFactory.createInvocationContext(null);
+ invocationContext.setServiceClient(axisController.getServiceClient());
+
+ // Create the MessageContext to hold the actual request message and its
+ // associated properties
+ MessageContext requestMsgCtx = new MessageContext();
+ invocationContext.setRequestMessageContext(requestMsgCtx);
+
+ OMElement reqEnvelope = createMessageFromValue(obj);
+ requestMsgCtx.setMessageAsOM(reqEnvelope);
+
+ // Copy the properties from the request context into the MessageContext
+ requestMsgCtx.getProperties().putAll(requestContext);
+
+ // Send the request using the InvocationController
+ ic.invokeOneWay(invocationContext);
+
+ if (log.isDebugEnabled()) {
+ log.debug("One-way invocation completed: BaseDispatch.invokeOneWay()");
+ }
+
+ return;
+ }
+
+ public Future<?> invokeAsync(Object obj, AsyncHandler asynchandler) throws WebServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Entered asynchronous (callback) invocation: BaseDispatch.invokeAsync()");
+ }
+
+ // Create the InvocationContext instance for this request/response flow.
+ InvocationContext invocationContext = InvocationContextFactory.createInvocationContext(null);
+ invocationContext.setServiceClient(axisController.getServiceClient());
+
+ // Create the MessageContext to hold the actual request message and its
+ // associated properties
+ MessageContext requestMsgCtx = new MessageContext();
+ invocationContext.setRequestMessageContext(requestMsgCtx);
+
+ OMElement reqEnvelope = createMessageFromValue(obj);
+ requestMsgCtx.setMessageAsOM(reqEnvelope);
+
+ // Copy the properties from the request context into the MessageContext
+ requestMsgCtx.getProperties().putAll(requestContext);
+
+ // Setup the Executor that will be used to drive async responses back to
+ // the client.
+ // FIXME: We shouldn't be getting this from the ServiceDelegate, rather each
+ // Dispatch object should have it's own.
+ Executor e = serviceDelegate.getExecutor();
+ invocationContext.setExecutor(e);
+
+ // Create the AsyncListener that is to be used by the InvocationController.
+ AsyncListener listener = createAsyncListener();
+ invocationContext.setAsyncListener(listener);
+
+ // Send the request using the InvocationController
+ Future<?> asyncResponse = ic.invokeAsync(invocationContext, asynchandler);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Asynchronous (callback) invocation sent: BaseDispatch.invokeOneWay()");
+ }
+
+ return asyncResponse;
+ }
+
+ public Response invokeAsync(Object obj)throws WebServiceException{
+ if(obj == null){
+ throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
+ }
+ try{
+ Parameter param = ParameterFactory.createParameter(obj);
+ return axisController.invokeAsync(param, requestContext);
+ }catch(Exception e){
+ throw new WebServiceException(e);
+ }
+ }
+
+ //FIXME: This needs to be moved up to the BindingProvider and should actually
+ //be called "initRequestContext()" or something like that.
+ protected void setRequestContext(){
+ String endPointAddress = axisController.getEndpointAddress();
+ WSDLWrapper wsdl = axisController.getWSDLContext();
+ QName serviceName = axisController.getServiceName();
+ QName portName = axisController.getPortName();
+ if(endPointAddress != null && !"".equals(endPointAddress)){
+ getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPointAddress);
+ }else if(wsdl != null){
+ String soapAddress = wsdl.getSOAPAddress(serviceName, portName);
+ getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, soapAddress);
+ }
+
+ if(wsdl != null){
+ String soapAction = wsdl.getSOAPAction(serviceName, portName);
+ getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, soapAction);
+ }
+
+ getRequestContext().put(Constants.QOS_WSADDRESSING_ENABLE, Boolean.FALSE);
+ getRequestContext().put(Constants.QOS_WSRM_ENABLE, Boolean.FALSE);
+ }
+
+ public ServiceDelegate getServiceDelegate() {
+ return serviceDelegate;
+ }
+
+ public void setServiceDelegate(ServiceDelegate sd) {
+ serviceDelegate = sd;
+ }
+
+ public Mode getMode() {
+ return mode;
+ }
+
+ public void setMode(Mode m) {
+ mode = m;
+ }
+
+ /*
+ * FIXME: This is temporary until more of the Message Model is available.
+ */
+ protected OMElement toOM(Parameter param, String soapVersion){
+ SOAPEnvelope env = ParameterUtils.toEnvelope(mode, soapVersion, param);
+ System.out.println(">> Generated envelope [" + env.toString() + "]");
+
+ SOAPBody body = env.getBody();
+ //SOAPHeader soapHeader = env.getHeader();
+ //addHeadersToServiceClient(soapHeader);
+ return body.getFirstElement();
+ }
+
+ /*
+ * FIXME: This is temporary until more of the Message Model is available.
+ */
+ protected Parameter fromOM(OMElement element, Parameter response, String soapVersion){
+ response.fromOM(element);
+
+ // Convert param toEnvelope since ServiceClient always send xml string.
+ // toEnvelope() in Parameter is coded just to handle this.
+ SOAPEnvelope env = response.toEnvelope(null, soapVersion);
+
+ response.fromEnvelope(mode, env);
+ return response;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java Wed Jul 19 20:21:05 2006
@@ -1,67 +1,75 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.client;
-
-import javax.xml.bind.JAXBContext;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.jaxws.AxisController;
-import org.apache.axis2.jaxws.param.JAXBParameter;
-import org.apache.axis2.jaxws.param.Parameter;
-
-public class JAXBDispatch<T> extends BaseDispatch<T> {
-
- private JAXBContext jaxbContext;
-
- public JAXBDispatch() {
- //do nothing
- }
-
- public JAXBDispatch(AxisController ac) {
- super(ac);
- }
-
- public OMElement createMessageFromValue(Object value) {
- // FIXME: This is where the Message Model will be integrated instead of
- // the ParameterFactory/Parameter APIs.
- JAXBParameter param = new JAXBParameter();
- param.setValue(value);
- param.setJAXBContext(jaxbContext);
-
- OMElement envelope = toOM(param,
- axisController.getServiceClient().getOptions().getSoapVersionURI());
- return envelope;
- }
-
- public Object getValueFromMessage(OMElement message) {
- // FIXME: This is where the Message Model will be integrated instead of
- // the ParameterFactory/Parameter APIs.
- JAXBParameter param = new JAXBParameter();
- param.setJAXBContext(jaxbContext);
- Parameter p = fromOM(message, param,
- axisController.getServiceClient().getOptions().getSoapVersionURI());
- return p.getValue();
- }
-
- public JAXBContext getJAXBContext() {
- return jaxbContext;
- }
-
- public void setJAXBContext(JAXBContext jbc) {
- jaxbContext = jbc;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.client;
+
+import javax.xml.bind.JAXBContext;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.AxisController;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.param.JAXBParameter;
+import org.apache.axis2.jaxws.param.Parameter;
+
+public class JAXBDispatch<T> extends BaseDispatch<T> {
+
+ private JAXBContext jaxbContext;
+
+ public JAXBDispatch() {
+ //do nothing
+ }
+
+ public JAXBDispatch(AxisController ac) {
+ super(ac);
+ }
+
+ public JAXBContext getJAXBContext() {
+ return jaxbContext;
+ }
+
+ public void setJAXBContext(JAXBContext jbc) {
+ jaxbContext = jbc;
+ }
+
+ public AsyncListener createAsyncListener() {
+ JAXBDispatchAsyncListener listener = new JAXBDispatchAsyncListener();
+ listener.setJAXBContext(jaxbContext);
+ listener.setMode(mode);
+ return listener;
+ }
+
+ public OMElement createMessageFromValue(Object value) {
+ // FIXME: This is where the Message Model will be integrated instead of
+ // the ParameterFactory/Parameter APIs.
+ JAXBParameter param = new JAXBParameter();
+ param.setValue(value);
+ param.setJAXBContext(jaxbContext);
+
+ OMElement envelope = toOM(param,
+ axisController.getServiceClient().getOptions().getSoapVersionURI());
+ return envelope;
+ }
+
+ public Object getValueFromMessage(OMElement message) {
+ // FIXME: This is where the Message Model will be integrated instead of
+ // the ParameterFactory/Parameter APIs.
+ JAXBParameter param = new JAXBParameter();
+ param.setJAXBContext(jaxbContext);
+ Parameter p = fromOM(message, param,
+ axisController.getServiceClient().getOptions().getSoapVersionURI());
+ return p.getValue();
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java?rev=423736&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java Wed Jul 19 20:21:05 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.client;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.ws.Service.Mode;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.param.JAXBParameter;
+import org.apache.axis2.jaxws.param.ParameterUtils;
+
+/**
+ * The JAXBDispatchAsyncListener is an extension of the
+ * {@link org.apache.axis2.jaxws.impl.AsyncListener} class to provide JAX-B
+ * specific function when processing an async response.
+ */
+public class JAXBDispatchAsyncListener extends AsyncListener {
+
+ private Mode mode;
+ private JAXBContext jaxbContext;
+
+ public JAXBDispatchAsyncListener() {
+ super();
+ }
+
+ public void setMode(Mode m) {
+ mode = m;
+ }
+
+ public void setJAXBContext(JAXBContext jbc) {
+ jaxbContext = jbc;
+ }
+
+ public Object getResponseValueObject(MessageContext mc) {
+ // FIXME: This is where the Message Model will be integrated instead of
+ // the ParameterFactory/Parameter APIs.
+ SOAPEnvelope msg = (SOAPEnvelope) mc.getMessageAsOM();
+
+ JAXBParameter param = new JAXBParameter();
+ param.setJAXBContext(jaxbContext);
+ ParameterUtils.fromEnvelope(mode, msg, param);
+
+ return param.getValue();
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java Wed Jul 19 20:21:05 2006
@@ -1,64 +1,72 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.client;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axis2.jaxws.AxisController;
-import org.apache.axis2.jaxws.param.Parameter;
-import org.apache.axis2.jaxws.param.ParameterFactory;
-
-public class XMLDispatch<T> extends BaseDispatch<T> {
-
- public Class type;
-
- public XMLDispatch() {
- super();
- }
-
- public XMLDispatch(AxisController ac) {
- super(ac);
- }
-
- public OMElement createMessageFromValue(Object value) {
- type = value.getClass();
-
- // FIXME: This is where the Message Model will be integrated instead of
- // the ParameterFactory/Parameter APIs.
- Parameter param = ParameterFactory.createParameter(type);
- param.setValue(value);
- OMElement envelope = toOM(param,
- axisController.getServiceClient().getOptions().getSoapVersionURI());
- return envelope;
- }
-
- public Object getValueFromMessage(OMElement message) {
- // FIXME: This is where the Message Model will be integrated instead of
- // the ParameterFactory/Parameter APIs.
- Parameter param = ParameterFactory.createParameter(type);
- param = fromOM(message, param,
- axisController.getServiceClient().getOptions().getSoapVersionURI());
- return param.getValue();
- }
-
- public Class getType() {
- return type;
- }
-
- public void setType(Class c) {
- type = c;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.client;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.AxisController;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.param.Parameter;
+import org.apache.axis2.jaxws.param.ParameterFactory;
+
+public class XMLDispatch<T> extends BaseDispatch<T> {
+
+ public Class type;
+
+ public XMLDispatch() {
+ super();
+ }
+
+ public XMLDispatch(AxisController ac) {
+ super(ac);
+ }
+
+ public AsyncListener createAsyncListener() {
+ XMLDispatchAsyncListener al = new XMLDispatchAsyncListener();
+ al.setMode(mode);
+ al.setType(type);
+ return al;
+ }
+
+ public OMElement createMessageFromValue(Object value) {
+ type = value.getClass();
+
+ // FIXME: This is where the Message Model will be integrated instead of
+ // the ParameterFactory/Parameter APIs.
+ Parameter param = ParameterFactory.createParameter(type);
+ param.setValue(value);
+ OMElement envelope = toOM(param,
+ axisController.getServiceClient().getOptions().getSoapVersionURI());
+ return envelope;
+ }
+
+ public Object getValueFromMessage(OMElement message) {
+ // FIXME: This is where the Message Model will be integrated instead of
+ // the ParameterFactory/Parameter APIs.
+ Parameter param = ParameterFactory.createParameter(type);
+ param = fromOM(message, param,
+ axisController.getServiceClient().getOptions().getSoapVersionURI());
+ return param.getValue();
+ }
+
+ public Class getType() {
+ return type;
+ }
+
+ public void setType(Class c) {
+ type = c;
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java?rev=423736&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java Wed Jul 19 20:21:05 2006
@@ -0,0 +1,43 @@
+package org.apache.axis2.jaxws.client;
+
+import javax.xml.ws.Service.Mode;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.param.Parameter;
+import org.apache.axis2.jaxws.param.ParameterFactory;
+import org.apache.axis2.jaxws.param.ParameterUtils;
+
+/**
+ * The XMLDispatchAsyncListener is an extension of the
+ * {@link org.apache.axis2.jaxws.impl.AsyncListener} class to provide
+ * proper deserialization into the target format (XML String or Source).
+ */
+public class XMLDispatchAsyncListener extends AsyncListener {
+
+ private Mode mode;
+ private Class type;
+
+ public XMLDispatchAsyncListener() {
+ super();
+ }
+
+ public void setMode(Mode m) {
+ mode = m;
+ }
+
+ public void setType(Class t) {
+ type = t;
+ }
+
+ protected Object getResponseValueObject(MessageContext mc) {
+ // FIXME: This is where the Message Model will be integrated instead of
+ // the ParameterFactory/Parameter APIs.
+ SOAPEnvelope msg = (SOAPEnvelope) mc.getMessageAsOM();
+
+ Parameter param = ParameterFactory.createParameter(type);
+ ParameterUtils.fromEnvelope(mode, msg, param);
+ return param.getValue();
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java Wed Jul 19 20:21:05 2006
@@ -1,49 +1,59 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.core;
-
-import java.util.List;
-
-import javax.xml.ws.handler.Handler;
-
-import org.apache.axis2.client.ServiceClient;
-
-/**
- * The <code>InvocationContext</code> encapsulates all of the information
- * relevant to a particular invocation. This ties the context of the
- * request back to the context of the response message (if applicable)
- * through the use of the MessageContext API. There is a separate
- * MessageContext for both the request and the response. *
- */
-public interface InvocationContext {
-
- public MessageContext getRequestMessageContext();
-
- public MessageContext getResponseMessageContext();
-
- public List<Handler> getHandlers();
-
- public void setRequestMessageContext(MessageContext ctx);
-
- public void setResponseMessageContext(MessageContext ctx);
-
- //FIXME: This is temporary.
- public void setServiceClient(ServiceClient client);
-
- //FIXME: This is temporary.
- public ServiceClient getServiceClient();
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.core;
+
+import java.util.List;
+import java.util.concurrent.Executor;
+
+import javax.xml.ws.handler.Handler;
+
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+
+/**
+ * The <code>InvocationContext</code> encapsulates all of the information
+ * relevant to a particular invocation. This ties the context of the
+ * request back to the context of the response message (if applicable)
+ * through the use of the MessageContext API. There is a separate
+ * MessageContext for both the request and the response. *
+ */
+public interface InvocationContext {
+
+ public List<Handler> getHandlers();
+
+ public MessageContext getRequestMessageContext();
+
+ public void setRequestMessageContext(MessageContext ctx);
+
+ public MessageContext getResponseMessageContext();
+
+ public void setResponseMessageContext(MessageContext ctx);
+
+ public Executor getExecutor();
+
+ public void setExecutor(Executor e);
+
+ public AsyncListener getAsyncListener();
+
+ public void setAsyncListener(AsyncListener al);
+
+ //FIXME: This is temporary.
+ public void setServiceClient(ServiceClient client);
+
+ //FIXME: This is temporary.
+ public ServiceClient getServiceClient();
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java?rev=423736&r1=423735&r2=423736&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java Wed Jul 19 20:21:05 2006
@@ -1,95 +1,115 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.core;
-
-import java.util.List;
-
-import javax.xml.ws.handler.Handler;
-
-import org.apache.axis2.client.ServiceClient;
-
-/**
- * An implementation of the InvocationContext interface.
- *
- * @see org.apache.axis2.jaxws.core.InvocationContext
- */
-public class InvocationContextImpl implements InvocationContext {
-
- private List<Handler> handlers;
- private MessageContext requestMsgCtx;
- private MessageContext responseMsgCtx;
-
- private ServiceClient serviceClient; //FIXME: This is temporary
-
- public InvocationContextImpl() {
- //do nothing
- }
-
- /**
- * @see org.apache.axis2.jaxws.core.InvocationContext#getHandlers()
- */
- public List<Handler> getHandlers() {
- return handlers;
- }
-
- /**
- * Sets the list of hanlders for this InvocationContext
- *
- * @param list
- */
- public void setHandlers(List<Handler> list) {
- handlers = list;
- }
-
- /**
- * @see org.apache.axis2.jaxws.core.InvocationContext#setRequestMessageContext(MessageContext)
- */
- public void setRequestMessageContext(MessageContext ctx) {
- requestMsgCtx = ctx;
- }
-
- /**
- * @see org.apache.axis2.jaxws.core.InvocationContext#setResponseMessageContext(MessageContext)
- */
- public void setResponseMessageContext(MessageContext ctx) {
- responseMsgCtx = ctx;
- }
-
- /**
- * @see org.apache.axis2.jaxws.core.InvocationContext#getResponseMessageContext()
- */
- public MessageContext getResponseMessageContext() {
- return responseMsgCtx;
- }
-
- /**
- * @see org.apache.axis2.jaxws.core.InvocationContext#getRequestMessageContext()
- */
- public MessageContext getRequestMessageContext() {
- return requestMsgCtx;
- }
-
- // FIXME: This is temporary
- public ServiceClient getServiceClient() {
- return serviceClient;
- }
-
- // FIXME: This is temporary
- public void setServiceClient(ServiceClient client) {
- serviceClient = client;
- }
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.core;
+
+import java.util.List;
+import java.util.concurrent.Executor;
+
+import javax.xml.ws.handler.Handler;
+
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.jaxws.impl.AsyncListener;
+
+/**
+ * An implementation of the InvocationContext interface.
+ *
+ * @see org.apache.axis2.jaxws.core.InvocationContext
+ */
+public class InvocationContextImpl implements InvocationContext {
+
+ private List<Handler> handlers;
+ private MessageContext requestMsgCtx;
+ private MessageContext responseMsgCtx;
+ private Executor executor;
+ private AsyncListener asyncListener;
+
+ private ServiceClient serviceClient; //FIXME: This is temporary
+
+ public InvocationContextImpl() {
+ //do nothing
+ }
+
+ /**
+ * @see org.apache.axis2.jaxws.core.InvocationContext#getHandlers()
+ */
+ public List<Handler> getHandlers() {
+ return handlers;
+ }
+
+ /**
+ * Sets the list of hanlders for this InvocationContext
+ *
+ * @param list
+ */
+ public void setHandlers(List<Handler> list) {
+ handlers = list;
+ }
+
+ /**
+ * @see org.apache.axis2.jaxws.core.InvocationContext#setRequestMessageContext(MessageContext)
+ */
+ public void setRequestMessageContext(MessageContext ctx) {
+ requestMsgCtx = ctx;
+ }
+
+ /**
+ * @see org.apache.axis2.jaxws.core.InvocationContext#setResponseMessageContext(MessageContext)
+ */
+ public void setResponseMessageContext(MessageContext ctx) {
+ responseMsgCtx = ctx;
+ }
+
+ /**
+ * @see org.apache.axis2.jaxws.core.InvocationContext#getResponseMessageContext()
+ */
+ public MessageContext getResponseMessageContext() {
+ return responseMsgCtx;
+ }
+
+ /**
+ * @see org.apache.axis2.jaxws.core.InvocationContext#getRequestMessageContext()
+ */
+ public MessageContext getRequestMessageContext() {
+ return requestMsgCtx;
+ }
+
+ public Executor getExecutor() {
+ return executor;
+ }
+
+ public void setExecutor(Executor e) {
+ executor = e;
+ }
+
+ public AsyncListener getAsyncListener() {
+ return asyncListener;
+ }
+
+ public void setAsyncListener(AsyncListener al) {
+ asyncListener = al;
+ }
+
+ // FIXME: This is temporary
+ public ServiceClient getServiceClient() {
+ return serviceClient;
+ }
+
+ // FIXME: This is temporary
+ public void setServiceClient(ServiceClient client) {
+ serviceClient = client;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org