You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2005/09/21 07:23:47 UTC
svn commit: r290622 - in /webservices/axis2/trunk/java/modules:
addressing/src/org/apache/axis2/handlers/addressing/
core/src/org/apache/axis2/context/ core/src/org/apache/axis2/receivers/
core/src/org/apache/axis2/transport/http/ integration/test/org/...
Author: chinthaka
Date: Tue Sep 20 22:23:26 2005
New Revision: 290622
URL: http://svn.apache.org/viewcvs?rev=290622&view=rev
Log:
- Fixing ServiceGroupContext test.
Good News !!! Now SGC mechanism works well with information extracted from addressing information too. (see ServiceGroupContextTest for more information)
Modified:
webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=290622&r1=290621&r2=290622&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java Tue Sep 20 22:23:26 2005
@@ -24,6 +24,7 @@
import org.apache.axis2.addressing.MessageInformationHeaders;
import org.apache.axis2.addressing.miheaders.RelatesTo;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceGroupContext;
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.om.OMAttribute;
import org.apache.axis2.om.OMElement;
@@ -90,11 +91,17 @@
}
- private void extractServiceGroupContextId(SOAPHeader header, MessageContext msgContext) {
+ private void extractServiceGroupContextId(SOAPHeader header, MessageContext msgContext) throws AxisFault {
OMElement serviceGroupId = header.getFirstChildWithName(new QName(Constants.AXIS2_NAMESPACE_URI,
Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX));
if (serviceGroupId != null) {
- msgContext.setProperty( PARAM_SERVICE_GROUP_CONTEXT_ID, serviceGroupId.getText());
+ String groupId = serviceGroupId.getText();
+ ServiceGroupContext serviceGroupContext = msgContext.getSystemContext().getServiceGroupContext(groupId);
+ if (serviceGroupContext == null) {
+ throw new AxisFault("Invalid Service Group Id." + groupId);
+ }
+ msgContext.setServiceGroupContextId(serviceGroupId.getText());
+// msgContext.setProperty( PARAM_SERVICE_GROUP_CONTEXT_ID, serviceGroupId.getText());
}
}
Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=290622&r1=290621&r2=290622&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Tue Sep 20 22:23:26 2005
@@ -118,7 +118,10 @@
}
// add the service group id as a reference parameter
String serviceGroupContextId = msgContext.getServiceGroupContextId();
- if (serviceGroupContextId != null && "".equals(serviceGroupContextId)) {
+ if (serviceGroupContextId != null && !"".equals(serviceGroupContextId)) {
+ if(epr.getReferenceParameters() == null){
+ epr.setReferenceParameters(new AnyContentType());
+ }
epr.getReferenceParameters().addReferenceValue(new QName(Constants.AXIS2_NAMESPACE_URI,
Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX), serviceGroupContextId);
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java?rev=290622&r1=290621&r2=290622&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java Tue Sep 20 22:23:26 2005
@@ -17,11 +17,9 @@
package org.apache.axis2.context;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.description.ServiceGroupDescription;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.storage.AxisStorage;
-import org.apache.axis2.transport.http.AxisServlet;
import org.apache.axis2.util.UUIDGenerator;
import org.apache.axis2.util.threadpool.ThreadPool;
@@ -225,17 +223,10 @@
* @param messageContext
*/
public ServiceGroupContext fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault {
- String serviceGroupContextId = messageContext.getServiceGroupContextId();
- if (isNull(serviceGroupContextId)) {
- // try to get the id from addressing
- serviceGroupContextId = (String) messageContext.getProperty(AddressingConstants.PARAM_SERVICE_GROUP_CONTEXT_ID);
- if (serviceContextMap.get(serviceGroupContextId) == null) {
- // try session id
- serviceGroupContextId = (String) messageContext.getProperty(AxisServlet.SESSION_ID);
- }
- }
+ String serviceGroupContextId = messageContext.getServiceGroupContextId();
+ // by this time service group context id must have a value. Either from transport or from addressing
ServiceGroupContext serviceGroupContext;
ServiceContext serviceContext;
if (!isNull(serviceGroupContextId) && serviceGroupContextMap.get(serviceGroupContextId) != null) {
@@ -290,6 +281,13 @@
serviceGroupContextMap.put(id, serviceGroupContext);
serviceGroupContext.setParent(this);
}
+ }
+
+ public ServiceGroupContext getServiceGroupContext(String serviceGroupContextId){
+ if(serviceGroupContextMap != null){
+ return (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
+ }
+ return null;
}
private boolean isNull(String string) {
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java?rev=290622&r1=290621&r2=290622&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractInOutSyncMessageReceiver.java Tue Sep 20 22:23:26 2005
@@ -57,6 +57,7 @@
outMsgContext.setMessageInformationHeaders(messageInformationHeaders);
outMsgContext.setOperationContext(msgContext.getOperationContext());
outMsgContext.setServiceContext(msgContext.getServiceContext());
+ outMsgContext.setServiceGroupContextId(msgContext.getServiceGroupContextId());
outMsgContext.setProperty(MessageContext.TRANSPORT_OUT,
msgContext.getProperty(MessageContext.TRANSPORT_OUT));
outMsgContext.setProperty(HTTPConstants.HTTPOutTransportInfo,
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=290622&r1=290621&r2=290622&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java Tue Sep 20 22:23:26 2005
@@ -29,6 +29,7 @@
import org.apache.axis2.transport.http.server.SimpleHttpServerConnection;
import org.apache.axis2.transport.http.server.SimpleRequest;
import org.apache.axis2.transport.http.server.SimpleResponse;
+import org.apache.axis2.util.UUIDGenerator;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.logging.Log;
@@ -97,6 +98,7 @@
//set the transport Headers
msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, getHeaders(request));
+ msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
//This is way to provide Accsess to the transport information to the transport Sender
msgContext.setProperty(
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java?rev=290622&r1=290621&r2=290622&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java Tue Sep 20 22:23:26 2005
@@ -6,10 +6,8 @@
import org.apache.axis2.description.ServiceDescription;
import org.apache.axis2.engine.util.RequestCounter;
import org.apache.axis2.engine.util.RequestCounterMessageReceiver;
-import org.apache.axis2.integration.TestingUtils;
import org.apache.axis2.integration.UtilServer;
import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMNamespace;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.axis2.soap.SOAPFactory;
@@ -20,25 +18,39 @@
import javax.xml.namespace.QName;
-
/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- *
- * @author : Eran Chinthaka (chinthaka@apache.org)
- */
+* Copyright 2001-2004 The Apache Software Foundation.
+*
+* 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.
+*
+* @author : Eran Chinthaka (chinthaka@apache.org)
+*/
public class ServiceGroupContextTest extends TestCase {
+
+ /**
+ * This test will first sends a request to a dummy service deployed. That service will get
+ * message contexts as inputs and will put a property in the service group context to count the
+ * number of requests.
+ * Then the client, upon receiving the response, extracts the sgc id from the received message
+ * (this will come as a reference parameter in the ReplyTo EPR) and sets that as a top level
+ * soap header in the next request to the same service group.
+ * Server will correctly identify the service group from the information sent by the client and
+ * retrieve the sgc earlier used and will use that for the current request as well.
+ * The service will retrieve the request count from the sgc and increase that by one.
+ *
+ * Test will asserts whether the client gets the number of requests as 2, when he invokes two times.
+ */
+
protected EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:" +
(UtilServer.TESTING_PORT) +
"/axis/services/RequestCounter");
@@ -64,7 +76,7 @@
public void testEchoXMLSync() throws Exception {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
- OMElement payload = TestingUtils.createDummyOMElement();
+ SOAPEnvelope payload = fac.getDefaultEnvelope();
org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call("target/test-resources/intregrationRepo");
@@ -72,28 +84,25 @@
call.setTransportInfo(Constants.TRANSPORT_HTTP, Constants.TRANSPORT_HTTP, false);
call.setWsaAction(operationName.getLocalPart());
- OMElement result = call.invokeBlocking(operationName.getLocalPart(), payload);
+ SOAPEnvelope result = call.invokeBlocking(operationName.getLocalPart(), payload);
-// print(result);
OMNamespace axis2Namespace = fac.createOMNamespace(Constants.AXIS2_NAMESPACE_URI,
Constants.AXIS2_NAMESPACE_PREFIX);
SOAPEnvelope defaultEnvelope = fac.getDefaultEnvelope();
SOAPHeaderBlock soapHeaderBlock = defaultEnvelope.getHeader().addHeaderBlock(Constants.SERVICE_GROUP_ID,
axis2Namespace);
- soapHeaderBlock.setText(result.getText());
+
+ String serviceGroupId = result.getHeader().getFirstChildWithName(new QName("ReplyTo"))
+ .getFirstChildWithName(new QName("ReferenceParameters")).
+ getFirstChildWithName(new QName("ServiceGroupId")).getText();
+
+ soapHeaderBlock.setText(serviceGroupId);
SOAPEnvelope soapEnvelope = call.invokeBlocking(operationName.getLocalPart(),
defaultEnvelope);
-// print(soapEnvelope.getBody().getFirstElement());
+ String text = soapEnvelope.getBody().getFirstElement().getText();
+ assertEquals("Number of requests should be 2", 2, Integer.parseInt(text));
}
-// private void print(OMElement result) throws XMLStreamException {
-// System.out.println("*******************************************");
-// OMOutputImpl out = new OMOutputImpl(System.out, false);
-// result.serializeWithCache(out);
-// out.flush();
-// System.out.println("*******************************************");
-//
-// }
}