You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2006/11/06 00:58:56 UTC

svn commit: r471576 - in /webservices/sandesha/branches/sandesha2/java/1_1: src/org/apache/sandesha2/client/ src/org/apache/sandesha2/handlers/ src/org/apache/sandesha2/msgprocessors/ src/org/apache/sandesha2/polling/ src/org/apache/sandesha2/util/ src...

Author: chamikara
Date: Sun Nov  5 15:58:55 2006
New Revision: 471576

URL: http://svn.apache.org/viewvc?view=rev&rev=471576
Log:
A correction in the SandeshaClient.createSequence method to create a generate a new sequenceKey every time it
is called.
Added code to process MessagePending headers. This will be processed in the MessagePendingProcessor. Which
Which will shedule an polling request for the sequence.
Also additional sedulings will be done in AckProcessor and TerminateSeqResponse Processor.
Class EndpointReferenceSerializer was added with copied code from EndpointReferenceHelper. In Axis2 1.1 
which is only present in the addressing.mar.

Updated test cases.

Added:
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/MessagePendingProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/EndpointReferenceSerializer.java
Modified:
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/client/SandeshaClient.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqResponseMsgProcessor.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/polling/PollingManager.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/AcksTo.java
    webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/Endpoint.java
    webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/SandeshaClientTest.java
    webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/security/SecurityTest.java

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/client/SandeshaClient.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/client/SandeshaClient.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/client/SandeshaClient.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/client/SandeshaClient.java Sun Nov  5 15:58:55 2006
@@ -347,11 +347,10 @@
 		}
 
 		// setting a new squenceKey if not already set.
-		String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
-		if (sequenceKey == null) {
-			sequenceKey = SandeshaUtil.getUUID();
-			options.setProperty(SandeshaClientConstants.SEQUENCE_KEY, sequenceKey);
-		}
+		String oldSequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
+
+		String	newSequenceKey = SandeshaUtil.getUUID();
+		options.setProperty(SandeshaClientConstants.SEQUENCE_KEY, newSequenceKey);
 
 		String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
 
@@ -378,10 +377,11 @@
 		options.setAction(oldAction);
 		
 		options.setProperty(SandeshaClientConstants.DUMMY_MESSAGE, Sandesha2Constants.VALUE_FALSE);
+		options.setProperty(SandeshaClientConstants.SEQUENCE_KEY, oldSequenceKey);
 		
 		//the generated sequenceKey will be returned. Client can use this to work with this newly generated sequence.
 		
-		return sequenceKey;
+		return newSequenceKey;
 	}
 
 	public static void createSequence(ServiceClient serviceClient, boolean offer, String sequenceKey)

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/handlers/SandeshaInHandler.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/handlers/SandeshaInHandler.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/handlers/SandeshaInHandler.java Sun Nov  5 15:58:55 2006
@@ -112,6 +112,9 @@
 				returnValue = InvocationResponse.SUSPEND;
 			}
 
+			
+			
+			
 			AxisService axisService = msgCtx.getAxisService();
 			if (axisService == null) {
 				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.axisServiceIsNull);

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java Sun Nov  5 15:58:55 2006
@@ -36,11 +36,14 @@
 import org.apache.sandesha2.SandeshaException;
 import org.apache.sandesha2.i18n.SandeshaMessageHelper;
 import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.polling.PollingManager;
 import org.apache.sandesha2.security.SecurityManager;
 import org.apache.sandesha2.security.SecurityToken;
 import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.NextMsgBean;
 import org.apache.sandesha2.storage.beans.SenderBean;
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;
 import org.apache.sandesha2.util.AcknowledgementManager;
@@ -197,7 +200,20 @@
 
 			// TODO - Process Nack
 		}
+		
+		//adding a MakeConnection for the response sequence if needed.
+		String offeredSequenceId = SandeshaUtil.getSequenceProperty(sequencePropertyKey, 
+				Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE, storageManager);
+		if (offeredSequenceId!=null) {
 
+			NextMsgBeanMgr nextMsgBeanMgr = storageManager.getNextMsgBeanMgr();
+			NextMsgBean nextMsgBean = nextMsgBeanMgr.retrieve(outSequenceId);
+			
+			if (nextMsgBean!=null && nextMsgBean.isPollingMode())
+				SandeshaUtil.shedulePollingRequest(offeredSequenceId, configCtx);
+			
+		}
+		
 		// setting acked message date.
 		// TODO add details specific to each message.
 		long noOfMsgsAcked = getNoOfMessagesAcked(sequenceAck.getAcknowledgementRanges().iterator());
@@ -297,5 +313,5 @@
 
 		return noOfMsgs;
 	}
-
+	
 }

Added: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/MessagePendingProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/MessagePendingProcessor.java?view=auto&rev=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/MessagePendingProcessor.java (added)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/MessagePendingProcessor.java Sun Nov  5 15:58:55 2006
@@ -0,0 +1,52 @@
+package org.apache.sandesha2.msgprocessors;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.polling.PollingManager;
+import org.apache.sandesha2.util.MsgInitializer;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.MessagePending;
+import org.apache.sandesha2.wsrm.Sequence;
+
+public class MessagePendingProcessor {
+
+	private static final Log log = LogFactory.getLog(MessagePendingProcessor.class);
+	
+	public boolean processMessagePendingHeaders (MessageContext message) throws AxisFault {
+		
+		if (log.isDebugEnabled())
+			log.debug("Enter: MessagePendingProcessor::processMessagePendingHeaders");
+
+		boolean messagePaused = false;
+		
+		RMMsgContext rmMsgContext = MsgInitializer.initializeMessage(message);
+		Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+		MessagePending messagePending = (MessagePending) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.MESSAGE_PENDING);
+		
+		if (sequence!=null) {
+			String sequenceId = sequence.getIdentifier().getIdentifier();
+			
+			if (messagePending!=null) {
+				boolean pending = messagePending.isPending();
+				if (pending) {
+					PollingManager pollingManager = SandeshaUtil.getPollingManager(message.getConfigurationContext());
+					if (pollingManager!=null) {
+						pollingManager.shedulePollingRequest(sequenceId);
+					}
+				}
+			}
+		}
+			
+		
+		
+		if (log.isDebugEnabled())
+			log.debug("Exit: MessagePendingProcessor::processMessagePendingHeaders");
+
+		return messagePaused;
+	}
+
+}

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java Sun Nov  5 15:58:55 2006
@@ -43,6 +43,7 @@
 import org.apache.sandesha2.client.SandeshaClientConstants;
 import org.apache.sandesha2.i18n.SandeshaMessageHelper;
 import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
 import org.apache.sandesha2.security.SecurityManager;
 import org.apache.sandesha2.security.SecurityToken;
 import org.apache.sandesha2.storage.StorageManager;
@@ -380,7 +381,8 @@
 		// outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation.getRemainingPhasesInFlow());
 		outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation
 				.getRemainingPhasesInFlow());
-
+		outInAxisOp.setMessageReceiver(new RMMessageReceiver ());
+		
 		OperationContext opcontext = OperationContextFactory
 				.createOperationContext(
 						WSDL20_2004Constants.MEP_CONSTANT_OUT_IN, outInAxisOp);

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqResponseMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqResponseMsgProcessor.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqResponseMsgProcessor.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/msgprocessors/TerminateSeqResponseMsgProcessor.java Sun Nov  5 15:58:55 2006
@@ -29,7 +29,9 @@
 import org.apache.sandesha2.security.SecurityManager;
 import org.apache.sandesha2.security.SecurityToken;
 import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.NextMsgBean;
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;
 import org.apache.sandesha2.util.SandeshaUtil;
 import org.apache.sandesha2.util.TerminateManager;
@@ -72,6 +74,17 @@
 
 		ConfigurationContext configContext = msgContext.getConfigurationContext();
 
+		//shedulling a polling request for the response side.
+		String offeredSequenceId = SandeshaUtil.getSequenceProperty(sequencePropertyKey, 
+				Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE, storageManager);
+		
+		if (offeredSequenceId!=null) {
+			NextMsgBeanMgr nextMsgBeanMgr = storageManager.getNextMsgBeanMgr();
+			NextMsgBean nextMsgBean = nextMsgBeanMgr.retrieve(sequenceId);
+			
+			if (nextMsgBean!=null && nextMsgBean.isPollingMode())
+				SandeshaUtil.shedulePollingRequest(offeredSequenceId, configContext);
+		}
 
 		TerminateManager.terminateSendingSide (configContext, sequencePropertyKey,internalSequenceID, msgContext.isServerSide(),
 				storageManager);
@@ -80,7 +93,7 @@
 		terminateResRMMsg.pause();
 
 		if(log.isDebugEnabled()) log.debug("Exit: TerminateSeqResponseMsgProcessor::processInMessage " + Boolean.TRUE);
-		return true;
+			return true;
   }
 
 	public boolean processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/polling/PollingManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/polling/PollingManager.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/polling/PollingManager.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/polling/PollingManager.java Sun Nov  5 15:58:55 2006
@@ -18,6 +18,7 @@
 package org.apache.sandesha2.polling;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Random;
 
@@ -25,20 +26,15 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisEngine;
 import org.apache.sandesha2.RMMsgContext;
 import org.apache.sandesha2.Sandesha2Constants;
 import org.apache.sandesha2.SandeshaException;
 import org.apache.sandesha2.storage.SandeshaStorageException;
 import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
-import org.apache.sandesha2.storage.beans.CreateSeqBean;
 import org.apache.sandesha2.storage.beans.NextMsgBean;
 import org.apache.sandesha2.storage.beans.SenderBean;
-import org.apache.sandesha2.transport.Sandesha2TransportOutDesc;
 import org.apache.sandesha2.util.MsgInitializer;
 import org.apache.sandesha2.util.RMMsgCreator;
 import org.apache.sandesha2.util.SandeshaUtil;
@@ -55,37 +51,29 @@
 	/**
 	 * By adding an entry to this, the PollingManager will be asked to do a polling request on this sequence.
 	 */
-	private ArrayList sheduledPollingRequests = null;
+	private HashMap sheduledPollingRequests = null;
 	
-	private final int POLLING_MANAGER_WAIT_TIME = 5000;
+	private final int POLLING_MANAGER_WAIT_TIME = 3000;
 	
 	public void run() {
 		
+		
 		while (isPoll()) {
 			
 			try {
 				
-				try {
-					Thread.sleep(POLLING_MANAGER_WAIT_TIME);
-				} catch (InterruptedException e) {
-					e.printStackTrace();
-				}
-				
 				NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
 				
 				//geting the sequences to be polled.
 				//if shedule contains any requests, do the earliest one.
 				//else pick one randomly.
 				
-				String sequenceId = null;
-				if (sheduledPollingRequests.size()>0) {
-					sequenceId = (String )sheduledPollingRequests.get(0);
-					sheduledPollingRequests.remove(0);
-				}
+				String sequenceId = getNextSheduleEntry ();
 
 				NextMsgBean nextMsgBean = null;
 				
 				if (sequenceId==null) {
+					
 					NextMsgBean findBean = new NextMsgBean ();
 					findBean.setPollingMode(true);
 					
@@ -97,6 +85,8 @@
 						nextMsgBean = (NextMsgBean) results.get(item);
 					}
 					
+					
+					
 				} else {
 					NextMsgBean findBean = new NextMsgBean ();
 					findBean.setPollingMode(true);
@@ -173,6 +163,22 @@
 		}
 	}
 	
+	private synchronized String getNextSheduleEntry () {
+		String sequenceId = null;
+		
+		if (sheduledPollingRequests.size()>0) {
+			sequenceId = (String) sheduledPollingRequests.keySet().iterator().next();
+			Integer sequencEntryCount = (Integer) sheduledPollingRequests.get(sequenceId);
+			
+			Integer leftCount = new Integer (sequencEntryCount.intValue() -1 );
+			if (leftCount.intValue()==0) 
+				sheduledPollingRequests.remove(sequenceId);
+			
+		}
+		
+		return sequenceId;
+	}
+	
 	/**
 	 * Starts the PollingManager.
 	 * 
@@ -181,7 +187,7 @@
 	 */
 	public synchronized void start (ConfigurationContext configurationContext) throws SandeshaException {
 		this.configurationContext = configurationContext;
-		this.sheduledPollingRequests = new ArrayList ();
+		this.sheduledPollingRequests = new HashMap ();
 		this.storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
 		setPoll(true);
 		super.start();
@@ -213,9 +219,19 @@
 	 * 
 	 * @param sequenceId
 	 */
-	public synchronized void shedulePollingRequest (String internalSequenceId) {
-		if (!sheduledPollingRequests.contains(internalSequenceId))
-			sheduledPollingRequests.add(internalSequenceId);
+	public synchronized void shedulePollingRequest (String sequenceId) {
+		
+		System.out.println("Polling request sheduled for sequence:" + sequenceId);
+		
+		if (sheduledPollingRequests.containsKey (sequenceId)) {
+			Integer sequenceEntryCount = (Integer) sheduledPollingRequests.get(sequenceId);
+			Integer newCount = new Integer (sequenceEntryCount.intValue()+1);
+			sheduledPollingRequests.put(sequenceId,newCount);
+		} else {
+			Integer sequenceEntryCount = new Integer (1);
+			sheduledPollingRequests.put(sequenceId, sequenceEntryCount);
+		}
+		
 	}
 
 	

Added: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/EndpointReferenceSerializer.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/EndpointReferenceSerializer.java?view=auto&rev=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/EndpointReferenceSerializer.java (added)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/EndpointReferenceSerializer.java Sun Nov  5 15:58:55 2006
@@ -0,0 +1,270 @@
+package org.apache.sandesha2.util;
+
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class EndpointReferenceSerializer {
+
+    private static final Log log = LogFactory.getLog(EndpointReferenceSerializer.class);
+
+    private final static Map finalQNames      = new IdentityHashMap();
+    private final static Map submissionQNames = new IdentityHashMap();
+     
+    /**
+     * Populates an endpoint reference based on the <code>OMElement</code> and
+     * WS-Addressing namespace that is passed in. If the string passed in is not
+     * recognized as a valid WS-Addressing namespace then this method behaves as
+     * if http://www.w3.org/2005/08/addressing has been passed in.
+     * 
+     * @param epr an endpoint reference instance to hold the info.
+     * @param eprOMElement an element of endpoint reference type 
+     * @param addressingNamespace the namespace of the WS-Addressing spec to comply with.
+     * @throws AxisFault if unable to locate an address element
+     * @see #fromOM(OMElement)
+     */
+    public static void fromOM(EndpointReference epr, OMElement eprOMElement, String addressingNamespace) throws AxisFault {
+        boolean isFinalAddressingNamespace = false;
+        Map map = null;
+
+        //First pass, identify the addressing namespace.
+        if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
+            OMElement address = eprOMElement.getFirstChildWithName((QName) submissionQNames.get(AddressingConstants.EPR_ADDRESS));
+            
+            if (address != null) {
+                map = submissionQNames;
+                isFinalAddressingNamespace = false;
+                
+                if (log.isDebugEnabled())
+                    log.debug("fromOM: Found address element for namespace, " + AddressingConstants.Submission.WSA_NAMESPACE);                
+            }
+            else {
+                throw new AxisFault("Unable to locate an address element for the endpoint reference type.");
+            }
+        }
+        else {
+            OMElement address = eprOMElement.getFirstChildWithName((QName) finalQNames.get(AddressingConstants.EPR_ADDRESS));
+            
+            if (address != null) {
+                map = finalQNames;
+                isFinalAddressingNamespace = true;
+                
+                if (log.isDebugEnabled())
+                    log.debug("fromOM: Found address element for namespace, " + AddressingConstants.Final.WSA_NAMESPACE);                
+            }
+            else {
+                throw new AxisFault("Unable to locate an address element for the endpoint reference type.");
+            }
+        }
+        
+        //Second pass, identify the properties.
+        fromOM(epr, eprOMElement, map, isFinalAddressingNamespace);
+    }
+    
+    /**
+     * Populates an endpoint reference based on the <code>OMElement</code> that is
+     * passed in. If the http://schemas.xmlsoap.org/ws/2004/08/addressing namespace
+     * is in effect then any reference properties will be saved as reference parameters.
+     * Regardless of the addressing namespace in effect, any elements present in the
+     * <code>OMElement</code> that are not recognised are saved as extensibility elements.
+     * 
+     * @param eprOMElement an element of endpoint reference type 
+     * @throws AxisFault if unable to locate an address element
+     */
+    public static EndpointReference fromOM(OMElement eprOMElement) throws AxisFault {
+        EndpointReference epr = new EndpointReference("");
+        boolean isFinalAddressingNamespace = false;
+        Map map = null;
+        
+        //First pass, identify the addressing namespace.
+        OMElement address = eprOMElement.getFirstChildWithName((QName) finalQNames.get(AddressingConstants.EPR_ADDRESS));
+        
+        if (address != null) {
+            map = finalQNames;
+            isFinalAddressingNamespace = true;
+            
+            if (log.isDebugEnabled())
+                log.debug("fromOM: Found address element for namespace, " + AddressingConstants.Final.WSA_NAMESPACE);                
+        }
+        else {
+            address = eprOMElement.getFirstChildWithName((QName) submissionQNames.get(AddressingConstants.EPR_ADDRESS));
+            
+            if (address != null) {
+                map = submissionQNames;
+                isFinalAddressingNamespace = false;
+                
+                if (log.isDebugEnabled())
+                    log.debug("fromOM: Found address element for namespace, " + AddressingConstants.Submission.WSA_NAMESPACE);                
+            }
+            else {
+                throw new AxisFault("Unable to locate an address element for the endpoint reference type.");
+            }
+        }
+        
+        //Second pass, identify the properties.
+        fromOM(epr, eprOMElement, map, isFinalAddressingNamespace);
+        
+        return epr;
+    }
+    
+    /**
+     * Creates an <code>OMElement</code> based on the properties of the endpoint
+     * reference. The output may differ based on the addressing namespace that is
+     * in effect when this method is called. If the http://www.w3.org/2005/08/addressing
+     * namespace is in effect, and a metadata property has been defined for the
+     * endpoint reference, then there will be a metadata element to contain the
+     * property in the output. If the http://schemas.xmlsoap.org/ws/2004/08/addressing
+     * namespace is in effect, however, then no metadata element will be included
+     * in the output, even if a metadata property element has been defined.
+     * 
+     * @param factory
+     * @param epr
+     * @param qname
+     * @param addressingNamespace
+     * @return
+     * @throws AxisFault
+     */
+    public static OMElement toOM(OMFactory factory, EndpointReference epr, QName qname, String addressingNamespace) throws AxisFault {
+        OMElement eprElement = null;
+        
+        if (log.isDebugEnabled()) {
+            log.debug("toOM: Factory, " + factory);
+            log.debug("toOM: Endpoint reference, " + epr);
+            log.debug("toOM: Element qname, " + qname);
+            log.debug("toOM: Addressing namespace, " + addressingNamespace);
+        }
+        
+        if (qname.getPrefix() != null) {
+            OMNamespace wrapNs = factory.createOMNamespace(qname.getNamespaceURI(), qname.getPrefix());
+//Temp workaround to aviod hitting -  https://issues.apache.org/jira/browse/WSCOMMONS-103 
+//since Axis2 next release (1.1) will be based on Axiom 1.1 
+//We can get rid of this fix with the Axiom SNAPSHOT
+//            if (factory instanceof SOAPFactory)
+//                eprElement = ((SOAPFactory) factory).createSOAPHeaderBlock(qname.getLocalPart(), wrapNs);
+//            else
+                eprElement = factory.createOMElement(qname.getLocalPart(), wrapNs);
+            
+            OMNamespace wsaNS = factory.createOMNamespace(addressingNamespace, AddressingConstants.WSA_DEFAULT_PREFIX);
+            OMElement addressE = factory.createOMElement(AddressingConstants.EPR_ADDRESS, wsaNS, eprElement);
+            String address = epr.getAddress();
+            addressE.setText(address);
+            
+            List metaData = epr.getMetaData();
+            if (metaData != null && AddressingConstants.Final.WSA_NAMESPACE.equals(addressingNamespace)) {
+                OMElement metadataE = factory.createOMElement(AddressingConstants.Final.WSA_METADATA, wsaNS, eprElement);
+                for (int i = 0, size = metaData.size(); i < size; i++) {
+                    OMNode omNode = (OMNode) metaData.get(i);
+                    metadataE.addChild(omNode);
+                }
+            }
+
+            Map referenceParameters = epr.getAllReferenceParameters();
+            if (referenceParameters != null) {
+                OMElement refParameterElement = factory.createOMElement(AddressingConstants.EPR_REFERENCE_PARAMETERS, wsaNS, eprElement);
+                Iterator iterator = referenceParameters.values().iterator();
+                while (iterator.hasNext()) {
+                    OMNode omNode = (OMNode) iterator.next();
+                    refParameterElement.addChild(omNode);
+                }
+            }
+            
+            List attributes = epr.getAttributes();
+            if (attributes != null) {
+                for (int i = 0, size = attributes.size(); i < size; i++) {
+                    OMAttribute omAttribute = (OMAttribute) attributes.get(i);
+                    eprElement.addAttribute(omAttribute);
+                }
+            }
+            
+            // add xs:any
+            List extensibleElements = epr.getExtensibleElements();
+            if (extensibleElements != null) {
+                for (int i = 0, size = extensibleElements.size(); i < size; i++) {
+                    OMNode omNode = (OMNode) extensibleElements.get(i);
+                    eprElement.addChild(omNode);
+                }
+            }
+        } else {
+            throw new AxisFault("prefix must be specified");
+        }
+        
+        return eprElement;
+    }
+    
+    private static void fromOM(EndpointReference epr, OMElement eprOMElement, Map map, boolean isFinalAddressingNamespace) {
+        Iterator childElements = eprOMElement.getChildElements();
+        
+        while (childElements.hasNext()) {
+            OMElement eprChildElement = (OMElement) childElements.next();
+            QName qname = eprChildElement.getQName();
+            
+            if (map.get(AddressingConstants.EPR_ADDRESS).equals(qname)) {
+                //We need to identify the address element again in order to ensure
+                //that it is not included with the extensibility elements.
+                epr.setAddress(eprChildElement.getText());
+            }
+            else if (map.get(AddressingConstants.EPR_REFERENCE_PARAMETERS).equals(qname)) {
+                Iterator iterator = eprChildElement.getChildElements();
+                while (iterator.hasNext()) {
+                    OMElement element = (OMElement) iterator.next();
+                    epr.addReferenceParameter(element);
+                }
+            }
+            else if (isFinalAddressingNamespace &&
+                    map.get(AddressingConstants.Final.WSA_METADATA).equals(qname)) {
+                Iterator iterator = eprChildElement.getChildElements();
+                while (iterator.hasNext()) {
+                    OMNode node = (OMNode) iterator.next();
+                    epr.addMetaData(node);
+                }
+            }
+            else if (!isFinalAddressingNamespace &&
+                    map.get(AddressingConstants.Submission.EPR_REFERENCE_PROPERTIES).equals(qname)) {
+                // since we have the model for WS-Final, we don't have a place to keep this reference properties.
+                // The only compatible place is reference properties
+                Iterator iterator = eprChildElement.getChildElements();
+                while (iterator.hasNext()) {
+                    OMElement element = (OMElement) iterator.next();
+                    epr.addReferenceParameter(element);
+                }
+            }
+            else {
+                epr.addExtensibleElement(eprChildElement);
+            }
+        }
+
+        Iterator attributes = eprOMElement.getAllAttributes();
+        while (attributes.hasNext()) {
+            OMAttribute attribute = (OMAttribute) attributes.next();
+            epr.addAttribute(attribute);
+        }
+        
+        if (log.isDebugEnabled()) {
+            log.debug("fromOM: Endpoint reference, " + epr);
+        }
+    }
+
+    static {
+        finalQNames.put(AddressingConstants.EPR_ADDRESS, new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS));
+        finalQNames.put(AddressingConstants.EPR_REFERENCE_PARAMETERS, new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS));
+        finalQNames.put(AddressingConstants.Final.WSA_METADATA, new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.Final.WSA_METADATA));
+        
+        submissionQNames.put(AddressingConstants.EPR_ADDRESS, new QName(AddressingConstants.Submission.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS));
+        submissionQNames.put(AddressingConstants.EPR_REFERENCE_PARAMETERS, new QName(AddressingConstants.Submission.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS));
+        submissionQNames.put(AddressingConstants.Submission.EPR_REFERENCE_PROPERTIES, new QName(AddressingConstants.Submission.WSA_NAMESPACE, AddressingConstants.Submission.EPR_REFERENCE_PROPERTIES));
+    }
+}

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/SandeshaUtil.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/util/SandeshaUtil.java Sun Nov  5 15:58:55 2006
@@ -272,6 +272,13 @@
 		if (pollingManager!=null) 
 			pollingManager.stopPolling ();
 	}
+	
+	public static PollingManager getPollingManager (ConfigurationContext configurationContext) {
+		PollingManager pollingManager = (PollingManager) configurationContext.getProperty(
+				Sandesha2Constants.POLLING_MANAGER);
+		
+		return pollingManager;
+	}
 
 	private static void stopInvokerForTheSequence(String sequenceID, ConfigurationContext context) {
 		Invoker invoker = (Invoker) context.getProperty(Sandesha2Constants.INVOKER);
@@ -1177,6 +1184,11 @@
 		
 		return newMsg;
 		
+	}
+	
+	public static void shedulePollingRequest (String sequenceId, ConfigurationContext configurationContext) throws SandeshaException { 
+		PollingManager pollingManager = getPollingManager(configurationContext);
+		pollingManager.shedulePollingRequest(sequenceId);
 	}
 	
 }

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/AcksTo.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/AcksTo.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/AcksTo.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/AcksTo.java Sun Nov  5 15:58:55 2006
@@ -24,11 +24,11 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.EndpointReferenceHelper;
 import org.apache.sandesha2.Sandesha2Constants;
 import org.apache.sandesha2.SandeshaException;
 import org.apache.sandesha2.i18n.SandeshaMessageHelper;
 import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.util.EndpointReferenceSerializer;
 
 /**
  * Represents an AcksTo element which comes within
@@ -71,7 +71,7 @@
 					SandeshaMessageKeys.noAcksToPart,
 					element.toString()));
 
-		epr = EndpointReferenceHelper.fromOM (acksToPart);
+		epr = EndpointReferenceSerializer.fromOM (acksToPart);
 
 		return this;
 	}
@@ -85,7 +85,7 @@
 		OMFactory factory = element.getOMFactory();
 		
 		QName acksTo = new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.ACKS_TO, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
-	    OMElement endpointElement =	EndpointReferenceHelper.toOM (factory,epr, acksTo ,addressingNamespaceValue);
+	    OMElement endpointElement =	EndpointReferenceSerializer.toOM (factory,epr, acksTo ,addressingNamespaceValue);
 		
 		element.addChild(endpointElement);
 		return element;

Modified: webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/Endpoint.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/Endpoint.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/Endpoint.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/src/org/apache/sandesha2/wsrm/Endpoint.java Sun Nov  5 15:58:55 2006
@@ -6,13 +6,12 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.EndpointReferenceHelper;
 import org.apache.sandesha2.Sandesha2Constants;
 import org.apache.sandesha2.SandeshaException;
 import org.apache.sandesha2.i18n.SandeshaMessageHelper;
 import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.util.EndpointReferenceSerializer;
 
 public class Endpoint implements IOMRMElement {
 
@@ -43,7 +42,7 @@
 
 	public Object fromOMElement(OMElement endpointElement) throws OMException,AxisFault {
 
-		epr = EndpointReferenceHelper.fromOM (endpointElement);
+		epr = EndpointReferenceSerializer.fromOM (endpointElement);
 		if (epr==null) {
 			String message = SandeshaMessageHelper.getMessage(
 					SandeshaMessageKeys.invalidElementFoundWithinElement,
@@ -65,7 +64,7 @@
 		OMFactory factory = element.getOMFactory();
 		
 		QName endpoint = new QName (rmNamespaceValue,Sandesha2Constants.WSRM_COMMON.ENDPOINT, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
-	    OMElement endpointElement =	EndpointReferenceHelper.toOM (factory,epr, endpoint,addressingNamespaceValue);
+	    OMElement endpointElement =	EndpointReferenceSerializer.toOM (factory,epr, endpoint,addressingNamespaceValue);
 		
 		element.addChild(endpointElement);
 		return element;

Modified: webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/SandeshaClientTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/SandeshaClientTest.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/SandeshaClientTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/SandeshaClientTest.java Sun Nov  5 15:58:55 2006
@@ -97,8 +97,8 @@
 		clientOptions.setTo(new EndpointReference (to));
 		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportTo);
 		
-		String sequenceKey = SandeshaUtil.getUUID();
-		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+//		String sequenceKey = SandeshaUtil.getUUID();
+//		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
 		
 		ServiceClient serviceClient = new ServiceClient (configContext,null);
 		
@@ -117,7 +117,8 @@
 		
 		serviceClient.setOptions(clientOptions);
 		
-		SandeshaClient.createSequence(serviceClient,true);
+		String sequenceKey = SandeshaClient.createSequence(serviceClient,true);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY, sequenceKey);
 		
 		Thread.sleep(10000);
 		

Modified: webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/security/SecurityTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/security/SecurityTest.java?view=diff&rev=471576&r1=471575&r2=471576
==============================================================================
--- webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/security/SecurityTest.java (original)
+++ webservices/sandesha/branches/sandesha2/java/1_1/test/src/org/apache/sandesha2/security/SecurityTest.java Sun Nov  5 15:58:55 2006
@@ -92,17 +92,21 @@
 		
 		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
 		ServiceClient serviceClient = new ServiceClient (configContext,null);
-		String sequenceKey = SandeshaUtil.getUUID();
+		
+//		String sequenceKey = SandeshaUtil.getUUID();
 
 		Options clientOptions = new Options ();
 
 		clientOptions.setTo(new EndpointReference (to));
 		clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,to);
-		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+
+//		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
+		
 		clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, spec);
 		serviceClient.setOptions(clientOptions);
 		
-		SandeshaClient.createSequence(serviceClient,false);
+		String sequenceKey = SandeshaClient.createSequence(serviceClient,false);
+		clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY, sequenceKey);
 		
 		SequenceReport sequenceReport = null;
 		for(int i = 0; i < 15; i++) {



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org