axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r168274 - in /webservices/axis/trunk/java/modules/core: src/org/apache/axis/context/ src/org/apache/axis/description/ test/org/apache/axis/context/
Date Thu, 05 May 2005 05:35:06 GMT
Author: chinthaka
Date: Wed May  4 22:35:05 2005
New Revision: 168274

URL: http://svn.apache.org/viewcvs?rev=168274&view=rev
Log:
Making OperationContext a concrete class

Added:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
Removed:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/MEPContextFactory.java
Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/description/AxisOperation.java
    webservices/axis/trunk/java/modules/core/test/org/apache/axis/context/MEPContextTest.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java?rev=168274&r1=168273&r2=168274&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
Wed May  4 22:35:05 2005
@@ -1,7 +1,5 @@
 package org.apache.axis.context;
 
-import org.apache.axis.engine.AxisFault;
-
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -17,13 +15,139 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- * 
+ *
+ */
+
+import org.apache.axis.description.AxisOperation;
+import org.apache.axis.engine.AxisFault;
+import org.apache.wsdl.WSDLConstants;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author chathura@opensource.lk
+ *
  */
 
-public interface OperationContext {
-    public boolean isComplete();
-    public MessageContext getMessageContext(String messageLabel) throws AxisFault;
-    public void addMessageContext(String messageLabel, MessageContext msgContext) throws
AxisFault;
-    public MessageContext getLastInMessageContext();
-    public void cleanup() throws AxisFault;
-}
+/**
+ * This class will provide the functionality to support the two basic MEPs
+ * IN_OUT and IN_ONLY.
+ *
+ * @author chathura@opensource.lk
+ */
+
+public class OperationContext extends AbstractContext {
+
+    private ArrayList messageContextList;
+
+    private String MepId;
+
+    private AxisOperation axisOperation;
+
+    public OperationContext(AxisOperation axisOperation,ServiceContext serviceContext) {
+        super(serviceContext);
+        this.axisOperation = axisOperation;
+
+// Most frequently used MEPs are IN ONLY and IN-OUT MEP. So the number of messagecontext
for those MEPs are at most 2. Setting the initial capacity of the arrayList to 2.
+        messageContextList = new ArrayList(2);
+    }
+	/**
+	 *
+	 * When a new message is added to the <code>MEPContext</code> the logic
+	 * should be included remove the MEPContext from the table in the
+	 * <code>EngineContext</code>. Example: IN_IN_OUT At the second IN
+	 * message the MEPContext should be removed from the AxisOperation
+	 *
+	 * @param msgContext
+	 */
+	public void addMessageContext(MessageContext msgContext) throws AxisFault {
+		if (WSDLConstants.MEP_URI_IN_ONLY.equals(this.axisOperation.getMessageExchangePattern())){
+			messageContextList.add(msgContext);
+		} else if(WSDLConstants.MEP_URI_IN_OUT.equals(this.axisOperation.getMessageExchangePattern())){
+			messageContextList.add(msgContext);
+		}
+
+		if(this.isComplete())
+			msgContext.getEngineContext().removeMEP(this);
+
+
+    }
+
+    /**
+     * @param index
+     * @return
+     */
+    public MessageContext getMessageContext(int index) {
+        return (MessageContext) messageContextList.get(index);
+    }
+
+    public MessageContext removeMessageContext(MessageContext ctxt) {
+        messageContextList.remove(ctxt.getMessageID());
+        return ctxt;
+    }
+
+    public List getAllMessageContexts() {
+        return this.messageContextList;
+    }
+
+    public MessageContext getMessageContext(String messageID) throws AxisFault {
+        if (null != messageID) {
+            for (int i = 0; i < this.messageContextList.size(); i++) {
+                if (messageID.equals(((MessageContext) (this.messageContextList
+                        .get(i))).getMessageID())) {
+                    return ((MessageContext) (this.messageContextList.get(i)));
+                }
+            }
+        }
+
+        throw new AxisFault(" Message does not exist in the current MEP : Invalid MessageID
:" + messageID);
+    }
+
+    public void addMessageContext(String messageLabel, MessageContext msgContext) throws
AxisFault {
+        // TODO : Chathura
+        throw new UnsupportedOperationException();
+
+    }
+
+    /**
+     * @return Returns the mepId.
+     */
+    public String getMepId() {
+        return MepId;
+    }
+
+    /**
+     * @param mepId The mepId to set.
+     */
+    public void setMepId(String mepId) {
+        MepId = mepId;
+    }
+
+    /**
+     * Chathura, please implement this method to return the last in message of the MEP.
+     * I want this for addressing - Chinthaka
+     * @return
+     */
+    public MessageContext getLastInMessageContext(){
+        throw new UnsupportedOperationException();
+
+    }
+
+    public void cleanup() throws AxisFault {
+        //TODO Chathura
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isComplete(){
+		if (WSDLConstants.MEP_URI_IN_ONLY.equals(this.axisOperation.getMessageExchangePattern())){
+			if(1 == this.messageContextList.size())
+				return true;
+		}else if(WSDLConstants.MEP_URI_IN_OUT.equals(this.axisOperation.getMessageExchangePattern())){
+			if(2 == this.messageContextList.size())
+				return true;
+		}
+
+		return false;
+	}
+}
\ No newline at end of file

Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java?rev=168274&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
(added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
Wed May  4 22:35:05 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004,2005 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.
+ *
+ *  Runtime state of the engine
+ */
+package org.apache.axis.context;
+
+import org.apache.axis.description.AxisOperation;
+import org.apache.axis.engine.AxisFault;
+import org.apache.wsdl.WSDLConstants;
+
+public class OperationContextFactory implements WSDLConstants{
+    
+    public static OperationContext createMEP(String mepURI,boolean serverSide,AxisOperation
axisOp,ServiceContext serviceContext) throws AxisFault{
+        if(MEP_URI_IN_ONLY.equals(mepURI) || MEP_URI_IN_OUT.equals(mepURI)){
+            return new BasicOperationContext(axisOp,serviceContext);
+        
+        }else{
+        	throw new AxisFault("Cannot handle the MEP "
+        			+ mepURI+" for the current invocation of Operation ");
+        }
+    }
+    
+}

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/description/AxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/description/AxisOperation.java?rev=168274&r1=168273&r2=168274&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/description/AxisOperation.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/description/AxisOperation.java
Wed May  4 22:35:05 2005
@@ -7,7 +7,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis.context.OperationContext;
-import org.apache.axis.context.MEPContextFactory;
+import org.apache.axis.context.OperationContextFactory;
 import org.apache.axis.context.MessageContext;
 import org.apache.axis.engine.AxisFault;
 import org.apache.axis.engine.MessageReceiver;

Modified: webservices/axis/trunk/java/modules/core/test/org/apache/axis/context/MEPContextTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/context/MEPContextTest.java?rev=168274&r1=168273&r2=168274&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/context/MEPContextTest.java
(original)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/context/MEPContextTest.java
Wed May  4 22:35:05 2005
@@ -44,13 +44,13 @@
     	
     	messageContext1.setMessageID(new Long(System.currentTimeMillis()).toString());
     	AxisOperation axisOperation = new AxisOperation(new QName("test"));
-    	OperationContext mepContext1 = axisOperation.findMEPContext(messageContext1, true);
+    	OperationContext operationContext1 = axisOperation.findMEPContext(messageContext1, true);
     	
     	MessageContext messageContext2 = this.getBasicMessageContext();
     	messageContext2.setMessageID(new Long(System.currentTimeMillis()).toString());
     	messageContext2.getMessageInformationHeaders().setRelatesTo(new RelatesTo(messageContext1.getMessageID()));
-    	OperationContext mepContext2 = axisOperation.findMEPContext(messageContext2, true);
-    	assertEquals(mepContext1, mepContext2);
+    	OperationContext operationContext2 = axisOperation.findMEPContext(messageContext2, true);
+    	assertEquals(operationContext1, operationContext2);
     }
     
     public MessageContext getBasicMessageContext() throws AxisFault{



Mime
View raw message