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 2005/09/23 05:54:41 UTC
svn commit: r291067 [1/3] - in
/webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/
msgprocessors/ msgreceivers/ storage/ storage/beanmanagers/ storage/beans/
storage/inmemory/ util/ wsrm/
Author: chamikara
Date: Thu Sep 22 20:52:54 2005
New Revision: 291067
URL: http://svn.apache.org/viewcvs?rev=291067&view=rev
Log:
added some more functionality for implementing the echo case. A serder thread was adder which is responsible for sending and retransmitting response messages.
Also cleaned some unwanted code.
Added:
webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java
Removed:
webservices/sandesha/trunk/src/org/apache/sandesha2/RMException.java
webservices/sandesha/trunk/src/org/apache/sandesha2/RMHeaders.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/MsgProcessorException.java
Modified:
webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
webservices/sandesha/trunk/src/org/apache/sandesha2/InOrderInvoker.java
webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java
webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java
webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java
webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java
webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/MsgProcessor.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/AbstractBeanMgrFactory.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/NextMsgBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/RetransmitterBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/SequencePropertyBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/StorageMapBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beans/CreateSeqBean.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beans/NextMsgBean.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beans/RMBean.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beans/RetransmitterBean.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beans/SequencePropertyBean.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beans/StorageMapBean.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemBeanMgrFactory.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemCreateSeqBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemNextMsgBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemRetransmitterBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemSequencePropretyBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemStorageMapBeanMgr.java
webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequenceResponse.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Expires.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/FaultCode.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Identifier.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/LastMessage.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/RMElements.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Sequence.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceAcknowledgement.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceFault.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/SequenceOffer.java
webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/TerminateSequence.java
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java Thu Sep 22 20:52:54 2005
@@ -147,15 +147,20 @@
String IN_HANDLER_NAME = "SandeshaInHandler";
+ String OUT_HANDLER_NAME = "SandeshaOutHandler";
+
//Sequence properties
String SEQ_PROPERTY_RECEIVED_MESSAGES = "SeqMsgListProperty";
- String SEQ_PROPERTY_ACKS_TO = "acksToProperty";
+ String SEQ_PROPERTY_TO_EPR = "ToEPR";
+
+ String SEQ_PROPERTY_ACKS_TO_EPR = "acksToEPR";
String SEQ_PROPERTY_OUT_SEQUENCE_ID = "OutSequenceId";
+ String SEQ_PROPERTY_REPLY_TO_EPR = "ReplyToEPR";
//SOAP versions
int SOAP_1_1 = 1;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/InOrderInvoker.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/InOrderInvoker.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/InOrderInvoker.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/InOrderInvoker.java Thu Sep 22 20:52:54 2005
@@ -22,12 +22,10 @@
import javax.xml.namespace.QName;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.AxisEngine;
-import org.apache.sandesha2.msgprocessors.MsgProcessorException;
import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
@@ -39,103 +37,109 @@
/**
* @author Chamikara
* @author Sanka
- * @author Jaliya
+ * @author Jaliya
*/
public class InOrderInvoker extends Thread {
boolean stopInvoker = false;
+
ConfigurationContext context = null;
-
+
public synchronized void stopWork() {
stopInvoker = true;
}
-
- public synchronized boolean isStopped () {
+
+ public synchronized boolean isStopped() {
return stopInvoker;
}
-
- public void setConfugurationContext (ConfigurationContext context) {
+
+ public void setConfugurationContext(ConfigurationContext context) {
this.context = context;
}
-
- public void run (){
-
+
+ public void run() {
+
while (!isStopped()) {
-
- System.out.print ("|");
- NextMsgBeanMgr nextMsgMgr = AbstractBeanMgrFactory.getInstance(context).getNextMsgBeanMgr();
-
- StorageMapBeanMgr storageMapMgr = AbstractBeanMgrFactory.getInstance(context).getStorageMapBeanMgr();
-
- Collection coll = nextMsgMgr.retrieveAll ();
-
+
+ System.out.print("|");
+ NextMsgBeanMgr nextMsgMgr = AbstractBeanMgrFactory.getInstance(
+ context).getNextMsgBeanMgr();
+
+ StorageMapBeanMgr storageMapMgr = AbstractBeanMgrFactory
+ .getInstance(context).getStorageMapBeanMgr();
+
+ Collection coll = nextMsgMgr.retrieveAll();
+
Iterator it = coll.iterator();
-
+
while (it.hasNext()) {
Object obj = it.next();
NextMsgBean nextMsgBean = (NextMsgBean) obj;
long msgNo = nextMsgBean.getNextMsgNoToProcess();
boolean tryNext = true;
-
+
while (tryNext) {
String seqId = nextMsgBean.getSequenceId();
- Collection coll1 = storageMapMgr.find(new StorageMapBean (null,msgNo,seqId));
- if (coll1==null || coll1.isEmpty())
- {
- tryNext=false;
+ Collection coll1 = storageMapMgr.find(new StorageMapBean(
+ null, msgNo, seqId));
+ if (coll1 == null || coll1.isEmpty()) {
+ tryNext = false;
continue;
}
-
- StorageMapBean stMapBean = (StorageMapBean) coll1.iterator().next();
- if (stMapBean==null) {
- tryNext=false;
+ StorageMapBean stMapBean = (StorageMapBean) coll1
+ .iterator().next();
+ if (stMapBean == null) {
+
+ tryNext = false;
continue;
}
-
+
String key = stMapBean.getKey();
-
+
try {
- boolean done = resumeMessageContext (key);
- System.out.println ("Resumed");
+ boolean done = resumeMessageContext(key);
+ System.out.println("Resumed");
if (!done) {
- tryNext=false;
+ tryNext = false;
continue;
}
- }catch (MsgProcessorException ex) {
+ } catch (SandeshaException ex) {
ex.printStackTrace();
- tryNext=false;
+ tryNext = false;
continue;
}
-
+
msgNo++;
}
-
+
nextMsgBean.setNextMsgNoToProcess(msgNo);
nextMsgMgr.update(nextMsgBean);
}
-
+
try {
Thread.sleep(20000);
- }catch (InterruptedException ex) {
+ } catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
-
- private boolean resumeMessageContext (String key) throws MsgProcessorException {
+
+ private boolean resumeMessageContext(String key) throws SandeshaException {
MessageContext ctx = SandeshaUtil.getStoredMessageContext(key);
- if (ctx==null)
+ if (ctx == null)
return false;
-
- ctx.setPausedTrue(new QName (Constants.IN_HANDLER_NAME)); //in case the pause is not set
-
+
+ ctx.setPausedTrue(new QName(Constants.IN_HANDLER_NAME)); //in case the
+ // pause is not
+ // set
+
//resuming.
try {
- new AxisEngine(ctx.getSystemContext()).receive(ctx);
- }catch (AxisFault ex) {
- throw new MsgProcessorException (ex.getMessage());
+ new AxisEngine(ctx.getSystemContext()).receive(ctx);
+ } catch (AxisFault ex) {
+ throw new SandeshaException(ex.getMessage());
}
return true;
}
-}
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/MsgInitializer.java Thu Sep 22 20:52:54 2005
@@ -25,68 +25,80 @@
import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
import org.apache.sandesha2.wsrm.RMElements;
-
/**
* @author Chamikara
* @author Sanka
- * @author Jaliya
+ * @author Jaliya
*/
-
public class MsgInitializer {
- public static RMMsgContext initializeMessage (MessageContext ctx) throws RMException {
- RMMsgContext rmMsgCtx = new RMMsgContext (ctx);
- populateRMMsgContext(ctx,rmMsgCtx);
+ public static RMMsgContext initializeMessage(MessageContext ctx)
+ throws SandeshaException {
+ RMMsgContext rmMsgCtx = new RMMsgContext(ctx);
+ populateRMMsgContext(ctx, rmMsgCtx);
validateMessage(rmMsgCtx);
return rmMsgCtx;
}
-
- private static void populateRMMsgContext (MessageContext msgCtx, RMMsgContext rmMsgContext) {
+
+ private static void populateRMMsgContext(MessageContext msgCtx,
+ RMMsgContext rmMsgContext) {
//TODO set message parts
-
- RMElements elements = new RMElements ();
+
+ RMElements elements = new RMElements();
elements.fromSOAPEnvelope(msgCtx.getEnvelope());
-
- if (elements.getCreateSequence()!=null)
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ,elements.getCreateSequence());
-
- if(elements.getCreateSequenceResponse()!=null)
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE,elements.getCreateSequenceResponse());
-
- if (elements.getSequence()!=null)
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQUENCE ,elements.getSequence());
-
- if (elements.getSequenceAcknowledgement()!=null)
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQ_ACKNOWLEDGEMENT,elements.getSequenceAcknowledgement());
-
- if (elements.getTerminateSequence()!=null)
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_TERMINATE_SEQ,elements.getTerminateSequence());
-
- if (elements.getAckRequested()!=null)
- rmMsgContext.setMessagePart(Constants.MESSAGE_PART_ACK_REQUEST,elements.getAckRequested());
-
+
+ if (elements.getCreateSequence() != null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ,
+ elements.getCreateSequence());
+
+ if (elements.getCreateSequenceResponse() != null)
+ rmMsgContext.setMessagePart(
+ Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE, elements
+ .getCreateSequenceResponse());
+
+ if (elements.getSequence() != null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_SEQUENCE,
+ elements.getSequence());
+
+ if (elements.getSequenceAcknowledgement() != null)
+ rmMsgContext.setMessagePart(
+ Constants.MESSAGE_PART_SEQ_ACKNOWLEDGEMENT, elements
+ .getSequenceAcknowledgement());
+
+ if (elements.getTerminateSequence() != null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_TERMINATE_SEQ,
+ elements.getTerminateSequence());
+
+ if (elements.getAckRequested() != null)
+ rmMsgContext.setMessagePart(Constants.MESSAGE_PART_ACK_REQUEST,
+ elements.getAckRequested());
+
}
-
- private static boolean validateMessage (RMMsgContext rmMsgCtx) throws RMException {
-
+
+ private static boolean validateMessage(RMMsgContext rmMsgCtx)
+ throws SandeshaException {
+
//TODO: performa validation
-
+
//Setting message type.
- if(rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ)!=null)
+ if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ) != null)
rmMsgCtx.setMessageType(Constants.MESSAGE_TYPE_CREATE_SEQ);
- else if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE)!=null)
+ else if (rmMsgCtx
+ .getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE) != null)
rmMsgCtx.setMessageType(Constants.MESSAGE_TYPE_CREATE_SEQ_RESPONSE);
- else if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_TERMINATE_SEQ)!=null)
+ else if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_TERMINATE_SEQ) != null)
rmMsgCtx.setMessageType(Constants.MESSAGE_TYPE_TERMINATE_SEQ);
- else if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_SEQUENCE)!=null)
+ else if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_SEQUENCE) != null)
rmMsgCtx.setMessageType(Constants.MESSAGE_TYPE_APPLICATION);
+ else if (rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_SEQ_ACKNOWLEDGEMENT)!=null)
+ rmMsgCtx.setMessageType(Constants.MESSAGE_TYPE_ACK);
else
rmMsgCtx.setMessageType(Constants.MESSAGE_TYPE_UNKNOWN);
-
+
return true;
}
-
-}
+
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgContext.java Thu Sep 22 20:52:54 2005
@@ -41,152 +41,160 @@
/**
* @author Chamikara
* @author Sanka
- * @author Jaliya
+ * @author Jaliya
*/
public class RMMsgContext {
-
+
private MessageContext msgContext;
+
private HashMap rmMessageParts;
+
private int messageType;
-
- public RMMsgContext (){
- rmMessageParts = new HashMap ();
+
+ public RMMsgContext() {
+ rmMessageParts = new HashMap();
messageType = Constants.MESSAGE_TYPE_UNKNOWN;
}
-
- public RMMsgContext (MessageContext ctx) {
- this ();
+
+ public RMMsgContext(MessageContext ctx) {
+ this();
this.msgContext = ctx;
//MsgInitializer.populateRMMsgContext(ctx,this);
}
-
- public void addSOAPEnvelope () throws AxisFault {
- if (msgContext.getEnvelope()==null) {
- msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope());
- }
-
+
+ public void addSOAPEnvelope() throws AxisFault {
+ if (msgContext.getEnvelope() == null) {
+ msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(
+ Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope());
+ }
+
SOAPEnvelope envelope = msgContext.getEnvelope();
Iterator keys = rmMessageParts.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
IOMRMPart rmPart = (IOMRMPart) rmMessageParts.get(key);
rmPart.toSOAPEnvelope(envelope);
- }
+ }
}
-
- public int getMessageType (){
+
+ public int getMessageType() {
return messageType;
}
-
- public void setMessageType (int msgType){
- if(msgType>=0 && msgType<=Constants.MAX_MSG_TYPE)
+
+ public void setMessageType(int msgType) {
+ if (msgType >= 0 && msgType <= Constants.MAX_MSG_TYPE)
this.messageType = msgType;
}
-
- public void setMessagePart (int partId, IOMRMPart part){
- if (partId>=0 && partId<=Constants.MAX_MSG_PART_ID)
- rmMessageParts.put(new Integer (partId),part);
- }
-
- public IOMRMElement getMessagePart (int partId) {
- return (IOMRMElement) rmMessageParts.get(new Integer (partId));
+
+ public void setMessagePart(int partId, IOMRMPart part) {
+ if (partId >= 0 && partId <= Constants.MAX_MSG_PART_ID)
+ rmMessageParts.put(new Integer(partId), part);
+ }
+
+ public IOMRMElement getMessagePart(int partId) {
+ return (IOMRMElement) rmMessageParts.get(new Integer(partId));
}
-
- public EndpointReference getFrom () {
+
+ public EndpointReference getFrom() {
return msgContext.getFrom();
}
-
- public EndpointReference getTo (){
+
+ public EndpointReference getTo() {
return msgContext.getTo();
}
-
- public EndpointReference getReplyTo (){
+
+ public EndpointReference getReplyTo() {
return msgContext.getReplyTo();
}
-
- public RelatesTo getRelatesTo () {
+
+ public RelatesTo getRelatesTo() {
return msgContext.getRelatesTo();
}
-
- public String getMessageId (){
+
+ public String getMessageId() {
return msgContext.getMessageID();
}
-
- public SOAPEnvelope getSOAPEnvelope () {
+
+ public SOAPEnvelope getSOAPEnvelope() {
return msgContext.getEnvelope();
}
-
- public void setSOAPEnvelop (SOAPEnvelope envelope) throws AxisFault {
- msgContext.setEnvelope(envelope);
- }
-
- public void test (){
- String opearaitonName = msgContext.getOperationContext().getAxisOperation().getName().getLocalPart();
- System.out.println ("Operation is:" + opearaitonName);
+
+ public void setSOAPEnvelop(SOAPEnvelope envelope) throws SandeshaException {
+
+ try {
+ msgContext.setEnvelope(envelope);
+ } catch (AxisFault e) {
+ throw new SandeshaException (e.getMessage());
+ }
+ }
+
+ public void test() {
+ String opearaitonName = msgContext.getOperationContext()
+ .getAxisOperation().getName().getLocalPart();
+ System.out.println("Operation is:" + opearaitonName);
}
-
- public void serializeSOAPEnvelop () {
+
+ public void serializeSOAPEnvelop() {
try {
SOAPEnvelope envelop = msgContext.getEnvelope();
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
+ XMLStreamWriter writer = XMLOutputFactory.newInstance()
+ .createXMLStreamWriter(System.out);
envelop.serialize(writer);
- }catch (Exception ex){
+ } catch (Exception ex) {
ex.printStackTrace();
}
}
-
- public void setFrom (EndpointReference epr) {
+
+ public void setFrom(EndpointReference epr) {
msgContext.setFrom(epr);
}
-
- public void setTo (EndpointReference epr){
+
+ public void setTo(EndpointReference epr) {
msgContext.setTo(epr);
}
-
- public void setReplyTo (EndpointReference epr) {
+
+ public void setReplyTo(EndpointReference epr) {
msgContext.setReplyTo(epr);
}
-
- public void setMessageId (String messageId){
+
+ public void setMessageId(String messageId) {
msgContext.setMessageID(messageId);
}
-
- public void setAction (String action){
+
+ public void setAction(String action) {
msgContext.setWSAAction(action);
}
-
- public void setRelatesTo (RelatesTo relatesTo){
+
+ public void setRelatesTo(RelatesTo relatesTo) {
msgContext.setRelatesTo(relatesTo);
}
-
- public MessageContext getMessageContext () {
+
+ public MessageContext getMessageContext() {
return msgContext;
}
-
- public Object getProperty (String key) {
- if (msgContext==null)
+
+ public Object getProperty(String key) {
+ if (msgContext == null)
return null;
-
+
return msgContext.getProperty(key);
}
-
- public boolean setProperty (String key, Object val){
- if (msgContext==null)
+
+ public boolean setProperty(String key, Object val) {
+ if (msgContext == null)
return false;
-
- msgContext.setProperty(key,val);
+
+ msgContext.setProperty(key, val);
return true;
}
-
- public AbstractContext getContext () {
- if (msgContext==null)
- return null;
-
- return msgContext.getSystemContext();
- }
-
-
-
-}
+
+ public AbstractContext getContext() {
+ if (msgContext == null)
+ return null;
+
+ return msgContext.getSystemContext();
+ }
+
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java Thu Sep 22 20:52:54 2005
@@ -54,138 +54,195 @@
/**
* @author Chamikara
* @author Sanka
- * @author Jaliya
+ * @author Jaliya
*/
public class RMMsgCreator {
-
- public static RMMsgContext createCreateSeqMsg (RMMsgContext applicationMsg) throws AxisFault {
- ConfigurationContext context = applicationMsg.getMessageContext().getSystemContext();
- if (context==null)
- throw new AxisFault ("Configuration Context is null");
-
- MessageContext msgContext = new MessageContext (context);
- RMMsgContext createSeqMsg = new RMMsgContext (msgContext);
-
- IOMRMPart createSeqiuencePart = new CreateSequence ();
- createSeqMsg.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ,createSeqiuencePart);
- createSeqMsg.addSOAPEnvelope();
+
+ public static RMMsgContext createCreateSeqMsg(RMMsgContext applicationMsg)
+ throws SandeshaException {
+ ConfigurationContext context = applicationMsg.getMessageContext()
+ .getSystemContext();
+ if (context == null)
+ throw new SandeshaException("Configuration Context is null");
+
+ MessageContext msgContext;
+ try {
+ msgContext = new MessageContext(context,applicationMsg.getMessageContext().getTransportIn(),
+ applicationMsg.getMessageContext().getTransportOut());
+ } catch (AxisFault e) {
+ throw new SandeshaException (e.getMessage());
+ }
+ msgContext.setTo(applicationMsg.getTo());
+ msgContext.setReplyTo(applicationMsg.getReplyTo());
+ RMMsgContext createSeqMsg = new RMMsgContext(msgContext);
+
+ CreateSequence createSequencePart = new CreateSequence();
+
+ //TODO correct below. Set a correct acksTo value
+ EndpointReference acksToEPR = applicationMsg.getReplyTo();
+
+ createSequencePart.setAcksTo (new AcksTo (new Address (acksToEPR)));
+ createSeqMsg.setMessagePart(Constants.MESSAGE_PART_CREATE_SEQ,
+ createSequencePart);
+
+ try {
+ createSeqMsg.addSOAPEnvelope();
+ } catch (AxisFault e1) {
+ throw new SandeshaException (e1.getMessage());
+ }
+
createSeqMsg.setAction(Constants.WSRM.ACTION_CREATE_SEQ);
EndpointReference to = applicationMsg.getTo();
- if (to==null || to.getAddress()==null || to.getAddress()==null || to.getAddress()=="")
- throw new AxisFault ("To value of the Application Message is not set correctly");
-
+ if (to == null || to.getAddress() == null || to.getAddress() == null
+ || to.getAddress() == "")
+ throw new SandeshaException(
+ "To value of the Application Message is not set correctly");
+
createSeqMsg.setTo(to);
-
+
EndpointReference replyTo = applicationMsg.getReplyTo();
- if (replyTo==null || replyTo.getAddress()==null || replyTo.getAddress()==null || to.getAddress()=="")
- throw new AxisFault ("ReplyTo value of the Application Message is not set correctly");
-
+ if (replyTo == null || replyTo.getAddress() == null
+ || replyTo.getAddress() == null || to.getAddress() == "")
+ throw new SandeshaException(
+ "ReplyTo value of the Application Message is not set correctly");
+
createSeqMsg.setTo(replyTo);
createSeqMsg.setReplyTo(replyTo);
-
+
return createSeqMsg;
}
-
- public static RMMsgContext createCreateSeqResponseMsg (RMMsgContext createSeqMessage, MessageContext outMessage) throws AxisFault {
-
- IOMRMElement messagePart =
- createSeqMessage.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
+ public static RMMsgContext createCreateSeqResponseMsg(
+ RMMsgContext createSeqMessage, MessageContext outMessage)
+ throws AxisFault {
+
+ IOMRMElement messagePart = createSeqMessage
+ .getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
CreateSequence cs = (CreateSequence) messagePart;
-
+
CreateSequenceResponse response = new CreateSequenceResponse();
-
+
Identifier identifier = new Identifier();
String newSequenceID = SandeshaUtil.getUUID();
identifier.setIndentifer(newSequenceID);
-
+
response.setIdentifier(identifier);
-
+
Accept accept = new Accept();
- EndpointReference acksToEPR = createSeqMessage.getTo();
+ EndpointReference acksToEPR = createSeqMessage.getTo();
AcksTo acksTo = new AcksTo();
- Address address = new Address ();
- address.setEpr(acksToEPR);
+ Address address = new Address();
+ address.setEpr(acksToEPR);
acksTo.setAddress(address);
accept.setAcksTo(acksTo);
response.setAccept(accept);
-
- SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
+
+ SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
+ Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
response.toOMElement(envelope.getBody());
- outMessage.setWSAAction(Constants.WSRM.NS_URI_CREATE_SEQ_RESPONSE);
-
- String newMessageId = SandeshaUtil.getUUID();
- outMessage.setMessageID(newMessageId);
-
- outMessage.setEnvelope(envelope);
-
- RMMsgContext createSeqResponse = null;
- try {
- createSeqResponse = MsgInitializer.initializeMessage(outMessage);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
- return createSeqResponse;
+ outMessage.setWSAAction(Constants.WSRM.NS_URI_CREATE_SEQ_RESPONSE);
+
+ String newMessageId = SandeshaUtil.getUUID();
+ outMessage.setMessageID(newMessageId);
+
+ outMessage.setEnvelope(envelope);
+
+ RMMsgContext createSeqResponse = null;
+ try {
+ createSeqResponse = MsgInitializer.initializeMessage(outMessage);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
+ return createSeqResponse;
}
-
-
+
//Adds a ack message to the following message.
- public static void addAckMessage (RMMsgContext applicationMsg) throws AxisFault {
+ public static void addAckMessage(RMMsgContext applicationMsg)
+ throws SandeshaException {
SOAPEnvelope envelope = applicationMsg.getSOAPEnvelope();
- if(envelope==null) {
- SOAPEnvelope newEnvelope = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
- applicationMsg.setSOAPEnvelop(envelope);
+ if (envelope == null) {
+ SOAPEnvelope newEnvelope = SOAPAbstractFactory.getSOAPFactory(
+ Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
+ applicationMsg.setSOAPEnvelop(newEnvelope);
}
envelope = applicationMsg.getSOAPEnvelope();
+
+ MessageContext requestMessage = null;
- MessageContext requestMessage = applicationMsg.getMessageContext().getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN);
+ try {
+ requestMessage = applicationMsg.getMessageContext()
+ .getOperationContext().getMessageContext(
+ WSDLConstants.MESSAGE_LABEL_IN);
+ } catch (AxisFault e) {
+ throw new SandeshaException (e.getMessage());
+ }
- RMMsgContext reqRMMsgCtx = null;
+ if (requestMessage==null)
+ throw new SandeshaException ("Request message is null");
- try {
- reqRMMsgCtx = MsgInitializer.initializeMessage(requestMessage);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
-
- Sequence reqSequence = (Sequence) reqRMMsgCtx.getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
- if (reqSequence==null)
- throw new AxisFault ("Sequence part of application message is null");
-
+ RMMsgContext reqRMMsgCtx = null;
+
+
+ reqRMMsgCtx = MsgInitializer.initializeMessage(requestMessage);
+
+
+ Sequence reqSequence = (Sequence) reqRMMsgCtx
+ .getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
+ if (reqSequence == null)
+ throw new SandeshaException("Sequence part of application message is null");
+
String sequenceId = reqSequence.getIdentifier().getIdentifier();
-
- SequenceAcknowledgement sequenceAck = new SequenceAcknowledgement ();
- Identifier id = new Identifier ();
+
+ SequenceAcknowledgement sequenceAck = new SequenceAcknowledgement();
+ Identifier id = new Identifier();
id.setIndentifer(sequenceId);
sequenceAck.setIdentifier(id);
-// SequencePropertyBean seqPropBean = new SequencePropertyBean (newSequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES,acksTo);
-// SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr (Constants.DEFAULT_STORAGE_TYPE);
-// SequencePropertyBean msgNosBean = (SequencePropertyBean) beanMgr.retrieve(sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES);
-// String msgNoList = (String) msgNosBean.getValue();
-
- ConfigurationContext ctx = applicationMsg.getMessageContext().getSystemContext();
- SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(ctx).
- getSequencePropretyBeanMgr();
-
- SequencePropertyBean seqBean = seqPropMgr.retrieve(sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES);
+ // SequencePropertyBean seqPropBean = new SequencePropertyBean
+ // (newSequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES,acksTo);
+ // SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr
+ // (Constants.DEFAULT_STORAGE_TYPE);
+ // SequencePropertyBean msgNosBean = (SequencePropertyBean)
+ // beanMgr.retrieve(sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES);
+ // String msgNoList = (String) msgNosBean.getValue();
+
+ ConfigurationContext ctx = applicationMsg.getMessageContext()
+ .getSystemContext();
+ SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+ .getInstance(ctx).getSequencePropretyBeanMgr();
+
+ SequencePropertyBean seqBean = seqPropMgr.retrieve(sequenceId,
+ Constants.SEQ_PROPERTY_RECEIVED_MESSAGES);
String msgNoList = (String) seqBean.getValue();
- System.out.println ("Message No List:" + msgNoList);
-
- AcknowledgementRange[] ackRangeArr = SandeshaUtil.getAckRangeArray(msgNoList);
-
+ System.out.println("Message No List:" + msgNoList);
+
+ AcknowledgementRange[] ackRangeArr = SandeshaUtil
+ .getAckRangeArray(msgNoList);
+
int length = ackRangeArr.length;
-
- for (int i=0;i<length;i++)
+
+ for (int i = 0; i < length; i++)
sequenceAck.addAcknowledgementRanges(ackRangeArr[i]);
-
+
sequenceAck.toOMElement(envelope.getHeader());
applicationMsg.setAction(Constants.WSRM.ACTION_SEQ_ACK);
- applicationMsg.setMessageId(SandeshaUtil.getUUID());
-
+ applicationMsg.setMessageId(SandeshaUtil.getUUID());
+
+ }
+
+ public static RMMsgContext createAckMessage (RMMsgContext applicationMsg) throws SandeshaException {
+ try {
+ MessageContext applicationMsgCtx = applicationMsg.getMessageContext();
+ MessageContext ackMsgCtx = new MessageContext (applicationMsgCtx.getSystemContext(),
+ applicationMsgCtx.getTransportIn(),applicationMsgCtx.getTransportOut());
+ RMMsgContext ackRMMsgCtx = new RMMsgContext (ackMsgCtx);
+ addAckMessage(ackRMMsgCtx);
+ return ackRMMsgCtx;
+ } catch (AxisFault e) {
+ throw new SandeshaException (e.getMessage());
+ }
}
-}
+}
\ No newline at end of file
Added: webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java?rev=291067&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java Thu Sep 22 20:52:54 2005
@@ -0,0 +1,20 @@
+/*
+ * Created on Sep 5, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.sandesha2;
+
+/**
+ * @author chamikara
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SandeshaException extends Exception {
+
+ public SandeshaException (String message) {
+ super (message);
+ }
+}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java Thu Sep 22 20:52:54 2005
@@ -10,6 +10,8 @@
import javax.naming.Context;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.AbstractContext;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
@@ -17,29 +19,71 @@
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.wsrm.AcksTo;
+import org.apache.sandesha2.wsrm.CreateSequence;
/**
* @author Chamikara
* @author Sanka
- * @author Jaliya
+ * @author Jaliya
*/
public class SequenceMenager {
- public static void setUpNewSequence (String sequenceId,ConfigurationContext context) {
-// SequencePropertyBean seqPropBean = new SequencePropertyBean (sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES,"");
-// SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr (Constants.DEFAULT_STORAGE_TYPE);
-// beanMgr.create(seqPropBean);
-
- SequencePropertyBean seqPropBean = new SequencePropertyBean (sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES,"");
- SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(context).getSequencePropretyBeanMgr();
- seqPropMgr.insert(seqPropBean);
+ public static void setUpNewSequence(String sequenceId,
+ RMMsgContext createSequenceMsg) throws AxisFault {
+ // SequencePropertyBean seqPropBean = new SequencePropertyBean
+ // (sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES,"");
+ // SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr
+ // (Constants.DEFAULT_STORAGE_TYPE);
+ // beanMgr.create(seqPropBean);
+
+ AbstractContext context = createSequenceMsg.getContext();
+
+ EndpointReference to = createSequenceMsg.getTo();
+ if (to==null)
+ throw new AxisFault ("To is null");
+
- NextMsgBeanMgr nextMsgMgr = AbstractBeanMgrFactory.getInstance(context).getNextMsgBeanMgr();
- nextMsgMgr.insert(new NextMsgBean (sequenceId,1)); // 1 will be the next message to invoke
- //this will apply for only in-order invocations.
+ EndpointReference replyTo = createSequenceMsg.getReplyTo();
+ if (replyTo == null)
+ throw new AxisFault("ReplyTo is null");
+
+ CreateSequence createSequence = (CreateSequence) createSequenceMsg
+ .getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
+ if (createSequence == null)
+ throw new AxisFault("Create Sequence Part is null");
+
+ EndpointReference acksTo = createSequence.getAcksTo().getAddress()
+ .getEpr();
+
+ if (acksTo == null)
+ throw new AxisFault("AcksTo is null");
+
+ SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+ .getInstance(context).getSequencePropretyBeanMgr();
+
+ SequencePropertyBean receivedMsgBean = new SequencePropertyBean(
+ sequenceId, Constants.SEQ_PROPERTY_RECEIVED_MESSAGES, "");
+ SequencePropertyBean toBean = new SequencePropertyBean (sequenceId,
+ Constants.SEQ_PROPERTY_TO_EPR,to);
+ SequencePropertyBean replyToBean = new SequencePropertyBean(sequenceId,
+ Constants.SEQ_PROPERTY_REPLY_TO_EPR, replyTo);
+ SequencePropertyBean acksToBean = new SequencePropertyBean(sequenceId,
+ Constants.SEQ_PROPERTY_ACKS_TO_EPR, acksTo);
+
+ seqPropMgr.insert(receivedMsgBean);
+ seqPropMgr.insert(toBean);
+ seqPropMgr.insert(replyToBean);
+ seqPropMgr.insert(acksToBean);
+
+ NextMsgBeanMgr nextMsgMgr = AbstractBeanMgrFactory.getInstance(context)
+ .getNextMsgBeanMgr();
+ nextMsgMgr.insert(new NextMsgBean(sequenceId, 1)); // 1 will be the next
+ // message to invoke
+ //this will apply for only in-order invocations.
}
-
- public void removeSequence (String sequence) {
-
+
+ public void removeSequence(String sequence) {
+
}
-}
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java Thu Sep 22 20:52:54 2005
@@ -28,52 +28,43 @@
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.MsgInitializer;
import org.apache.sandesha2.MsgValidator;
-import org.apache.sandesha2.RMException;
+import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.msgprocessors.MsgProcessor;
-import org.apache.sandesha2.msgprocessors.MsgProcessorException;
import org.apache.sandesha2.msgprocessors.MsgProcessorFactory;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
/**
* @author Chamikara
* @author Sanka
- * @author Jaliya
+ * @author Jaliya
*/
public class ServerInHandler extends AbstractHandler {
-// public ServerInHandler (){
-// System.out.println ("NEW SERVER IN HANDLER");
-// }
-
- public QName getName (){
- return new QName (Constants.IN_HANDLER_NAME);
+ public QName getName() {
+ return new QName(Constants.IN_HANDLER_NAME);
}
-
+
public void invoke(MessageContext msgCtx) throws AxisFault {
- System.out.println ("In server Handler 1");
-
-// String opearaitonName = msgCtx.getOperationContext().getAxisOperation().getName().getLocalPart();
-// System.out.println ("Operation is:" + opearaitonName);
-//
-
+ System.out.println("In server InHandler");
+
RMMsgContext rmMsgCtx = null;
+ try {
+ rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
+ MsgProcessor msgProcessor = MsgProcessorFactory
+ .getMessageProcessor(rmMsgCtx.getMessageType());
- try {
- rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
- MsgProcessor msgProcessor = MsgProcessorFactory.getMessageProcessor(rmMsgCtx.getMessageType());
-
try {
msgProcessor.processMessage(rmMsgCtx);
- }catch (MsgProcessorException mpe) {
- mpe.printStackTrace();
- throw new AxisFault ("Error in processing the message");
+ } catch (SandeshaException se) {
+ se.printStackTrace();
+ throw new AxisFault("Error in processing the message");
}
-
+
}
-
-}
+
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java Thu Sep 22 20:52:54 2005
@@ -17,27 +17,35 @@
package org.apache.sandesha2.handlers;
+import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.AbstractContext;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.soap.SOAPBody;
import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.log4j.lf5.viewer.configure.MRUFileManager;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.MsgInitializer;
import org.apache.sandesha2.MsgValidator;
-import org.apache.sandesha2.RMException;
+import org.apache.sandesha2.SOAPAbstractFactory;
+import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.RMMsgCreator;
-import org.apache.sandesha2.msgprocessors.MsgProcessorException;
import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
+import org.apache.sandesha2.storage.beans.RetransmitterBean;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.storage.beans.StorageMapBean;
+import org.apache.sandesha2.util.SandeshaUtil;
import org.apache.sandesha2.wsrm.Sequence;
import org.apache.wsdl.MessageReference;
import org.apache.wsdl.WSDLConstants;
@@ -45,88 +53,234 @@
/**
* @author Sanka
* @author Chamikara
- * @author Jaliya
+ * @author Jaliya
*/
public class ServerOutHandler extends AbstractHandler {
public void invoke(MessageContext msgCtx) throws AxisFault {
- System.out.println ("Server out handler called");
-
+ System.out.println("In server OutHandler");
+
RMMsgContext rmMsgCtx;
- try {
- rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
-
+ try {
+ rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
//getting the request message.
- MessageContext reqMsgCtx = msgCtx.getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN);
+ MessageContext reqMsgCtx = msgCtx.getOperationContext()
+ .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN);
RMMsgContext requestRMMsgCtx;
- try {
- requestRMMsgCtx = MsgInitializer.initializeMessage(reqMsgCtx);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
-
- if (requestRMMsgCtx.getMessageType()!=Constants.MESSAGE_TYPE_CREATE_SEQ)
- RMMsgCreator.addAckMessage(rmMsgCtx);
-
- if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_UNKNOWN) {
- //This is a possible response message.
- System.out.println ("GOT Possible Response Message");
-
- processResponseMessage(rmMsgCtx,requestRMMsgCtx);
+ try {
+ requestRMMsgCtx = MsgInitializer.initializeMessage(reqMsgCtx);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
}
-
- SOAPEnvelope env = msgCtx.getEnvelope();
-
+
+ // try {
+ // if (requestRMMsgCtx.getMessageType() !=
+ // Constants.MESSAGE_TYPE_CREATE_SEQ)
+ // RMMsgCreator.addAckMessage(rmMsgCtx);
+ // } catch (SandeshaException e) {
+ // throw new AxisFault (e.getMessage());
+ // }
+
try {
- XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
- //env.serialize(writer);
- }catch (Exception ex) {
- ex.printStackTrace();
+ if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_UNKNOWN) {
+ //This is a possible response message.
+ System.out.println("GOT Possible Response Message");
+ //RMMsgCreator.addAckMessage(rmMsgCtx);
+
+ AbstractContext context = rmMsgCtx.getContext();
+ if (context == null)
+ throw new SandeshaException("Context is null");
+ Sequence sequence = (Sequence) requestRMMsgCtx
+ .getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
+ //check weather the seq is is available.
+
+ if (sequence == null)
+ throw new SandeshaException("Sequence part is null");
+
+ String incomingSeqId = sequence.getIdentifier().getIdentifier();
+ if (incomingSeqId == null || incomingSeqId == "")
+ throw new SandeshaException("Invalid seqence Id");
+
+ SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+ .getInstance(context).getSequencePropretyBeanMgr();
+ SequencePropertyBean acksToBean = seqPropMgr.retrieve(
+ incomingSeqId, Constants.SEQ_PROPERTY_ACKS_TO_EPR);
+
+ if (acksToBean == null
+ || acksToBean.getValue() == null
+ || !(acksToBean.getValue() instanceof EndpointReference))
+ throw new SandeshaException("Acksto is not set correctly");
+
+ EndpointReference acksToEPR = (EndpointReference) acksToBean
+ .getValue();
+ if (acksToEPR.getAddress() == null
+ || acksToEPR.getAddress() == "")
+ throw new SandeshaException("AcksTo not set correctly");
+
+ SOAPEnvelope env = rmMsgCtx.getSOAPEnvelope();
+ if (env == null){
+ SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(Constants.DEFAULT_SOAP_VERSION).getDefaultEnvelope();
+ rmMsgCtx.setSOAPEnvelop(envelope);
+ }
+
+ SOAPBody soapBody = rmMsgCtx.getSOAPEnvelope().getBody();
+ if (soapBody == null)
+ throw new SandeshaException(
+ "Invalid SOAP message. Body is not present");
+
+ boolean validResponse = false;
+ if (soapBody.getChildElements().hasNext())
+ validResponse = true;
+
+ if (!validResponse){
+ if (Constants.WSA.NS_URI_ANONYMOUS.equals(acksToEPR.getAddress())){
+ RMMsgCreator.addAckMessage(rmMsgCtx);
+ }
+ }
+
+// if (acksToEPR.getAddress().equals(
+// Constants.WSA.NS_URI_ANONYMOUS)) {
+// RMMsgCreator.addAckMessage(rmMsgCtx);
+// } else {
+// RMMsgContext ackRMMessage = RMMsgCreator
+// .createAckMessage(rmMsgCtx);
+// //TODO add async ack to the retransmitter.
+// }
+// //processResponseMessage(rmMsgCtx, requestRMMsgCtx);
+
+
+
+ }
+ } catch (SandeshaException e) {
+ throw new AxisFault(e.getMessage());
}
+ // SOAPEnvelope env = msgCtx.getEnvelope();
+ //
+ // try {
+ // XMLStreamWriter writer = XMLOutputFactory.newInstance()
+ // .createXMLStreamWriter(System.out);
+ // //env.serialize(writer);
+ // } catch (Exception ex) {
+ // ex.printStackTrace();
+ // }
+
}
-
- private void processResponseMessage (RMMsgContext msg,RMMsgContext reqMsg) throws AxisFault {
- if (msg==null || reqMsg==null)
- throw new AxisFault ("Message or reques message is null");
-
- Sequence sequence = (Sequence) reqMsg.getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
+
+ private void processResponseMessage(RMMsgContext msg, RMMsgContext reqMsg)
+ throws SandeshaException {
+ if (msg == null || reqMsg == null)
+ throw new SandeshaException("Message or reques message is null");
+
+ Sequence sequence = (Sequence) reqMsg
+ .getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
//check weather the seq is is available.
-
- if (sequence==null)
- throw new AxisFault ("Sequence part is null");
-
+
+ if (sequence == null)
+ throw new SandeshaException("Sequence part is null");
+
String incomingSeqId = sequence.getIdentifier().getIdentifier();
- if (incomingSeqId==null || incomingSeqId=="")
- throw new AxisFault ("Invalid seqence Id");
-
- AbstractContext context = msg.getContext ();
- if (context==null)
- throw new AxisFault ("Context is null");
-
- System.out.println ("INCOMING SEQUENCE ID:" + incomingSeqId);
- SequencePropertyBeanMgr mgr = AbstractBeanMgrFactory.getInstance(context).getSequencePropretyBeanMgr();
-
- SequencePropertyBean bean = mgr.retrieve(incomingSeqId,Constants.SEQ_PROPERTY_OUT_SEQUENCE_ID);
-
- if(bean.getValue()==null) {
+ if (incomingSeqId == null || incomingSeqId == "")
+ throw new SandeshaException("Invalid seqence Id");
+
+ AbstractContext context = msg.getContext();
+ if (context == null)
+ throw new SandeshaException("Context is null");
+
+ System.out.println("INCOMING SEQUENCE ID:" + incomingSeqId);
+ SequencePropertyBeanMgr mgr = AbstractBeanMgrFactory.getInstance(
+ context).getSequencePropretyBeanMgr();
+
+ SequencePropertyBean toBean = mgr.retrieve(incomingSeqId,
+ Constants.SEQ_PROPERTY_TO_EPR);
+ SequencePropertyBean replyToBean = mgr.retrieve(incomingSeqId,
+ Constants.SEQ_PROPERTY_ACKS_TO_EPR);
+ SequencePropertyBean outSequenceBean = mgr.retrieve(incomingSeqId,
+ Constants.SEQ_PROPERTY_OUT_SEQUENCE_ID);
+
+ if (toBean == null)
+ throw new SandeshaException("To is null");
+ if (replyToBean == null)
+ throw new SandeshaException("Replyto is null");
+
+ EndpointReference incomingTo = (EndpointReference) toBean.getValue();
+ EndpointReference incomingReplyTo = (EndpointReference) replyToBean
+ .getValue();
+
+ if (incomingTo == null || incomingTo.getAddress() == null
+ || incomingTo.getAddress() == "")
+ throw new SandeshaException("To Property has an invalid value");
+ if (incomingReplyTo == null || incomingReplyTo.getAddress() == null
+ || incomingReplyTo.getAddress() == "")
+ throw new SandeshaException("ReplyTo is not set correctly");
+
+ msg.setTo(incomingReplyTo);
+ msg.setReplyTo(incomingTo);
+
+ // //TODO get following URL correctly.
+ // String serverURL =
+ // "http://localhost:8070/axis2/services/InteropService";
+ // EndpointReference replyTo = new EndpointReference (serverURL);
+ // msg.setReplyTo(replyTo);
+
+ if (outSequenceBean == null || outSequenceBean.getValue() == null) {
//sequence id is not present
- //add a create sequence
-
- RMMsgContext createSeqMessage = RMMsgCreator.createCreateSeqMsg (reqMsg);
-
-
+
//add msg to retransmitter with send=false;
- }else {
+ RetransmitterBeanMgr retransmitterMgr = AbstractBeanMgrFactory
+ .getInstance(context).getRetransmitterBeanMgr();
+
+ msg.getMessageContext().setPausedTrue(getName());
+
+ RetransmitterBean appMsgEntry = new RetransmitterBean();
+ String key = SandeshaUtil.storeMessageContext(msg
+ .getMessageContext());
+ appMsgEntry.setKey(key);
+ appMsgEntry.setLastSentTime(0);
+ appMsgEntry.setTempSequenceId(incomingSeqId);
+ appMsgEntry.setSend(false);
+ appMsgEntry.setMessageId(msg.getMessageId());
+
+ retransmitterMgr.insert(appMsgEntry);
+
+ addCreateSequenceMessage(msg);
+
+ } else {
//Sequence id is present
//set sequence part
//add message to retransmitter table with send=true;
+
}
-
+
+ }
+
+ public void addCreateSequenceMessage(RMMsgContext applicationMsg)
+ throws SandeshaException {
+ RMMsgContext createSeqMessage = RMMsgCreator
+ .createCreateSeqMsg(applicationMsg);
+ AbstractContext context = applicationMsg.getContext();
+ if (context == null)
+ throw new SandeshaException("Context is null");
+
+ StorageMapBeanMgr storageMapMgr = AbstractBeanMgrFactory.getInstance(
+ context).getStorageMapBeanMgr();
+ RetransmitterBeanMgr retransmitterMgr = AbstractBeanMgrFactory
+ .getInstance(context).getRetransmitterBeanMgr();
+ String key = SandeshaUtil.storeMessageContext(createSeqMessage
+ .getMessageContext());
+ RetransmitterBean createSeqEntry = new RetransmitterBean();
+ createSeqEntry.setKey(key);
+ createSeqEntry.setLastSentTime(0);
+ createSeqEntry.setMessageId(createSeqMessage.getMessageId());
+ createSeqEntry.setSend(true);
+ retransmitterMgr.insert(createSeqEntry);
+ }
+
+ public QName getName() {
+ return new QName(Constants.OUT_HANDLER_NAME);
}
-}
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Thu Sep 22 20:52:54 2005
@@ -20,16 +20,23 @@
import java.util.Collection;
import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.MsgInitializer;
import org.apache.sandesha2.MsgValidator;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.RMMsgCreator;
+import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
@@ -40,150 +47,189 @@
import org.apache.sandesha2.util.SandeshaUtil;
import org.apache.sandesha2.wsrm.AcknowledgementRange;
import org.apache.sandesha2.wsrm.Sequence;
+import org.apache.wsdl.WSDLConstants;
import org.ietf.jgss.MessageProp;
/**
- * @author
- *
+ * @author
*/
public class ApplicationMsgProcessor implements MsgProcessor {
- public void processMessage(RMMsgContext rmMsgCtx)
- throws MsgProcessorException {
+ public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
- System.out.println ("Application msg processor called");
-
- if (rmMsgCtx.getProperty(Constants.APPLICATION_PROCESSING_DONE)!=null && rmMsgCtx.getProperty(Constants.APPLICATION_PROCESSING_DONE).equals("true") ) {
+ System.out.println("Application msg processor called");
+
+ if (rmMsgCtx.getProperty(Constants.APPLICATION_PROCESSING_DONE) != null
+ && rmMsgCtx.getProperty(Constants.APPLICATION_PROCESSING_DONE)
+ .equals("true")) {
return;
}
-
+
//setting acked msg no range
- Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
+ Sequence sequence = (Sequence) rmMsgCtx
+ .getMessagePart(Constants.MESSAGE_PART_SEQUENCE);
String sequenceId = sequence.getIdentifier().getIdentifier();
- ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getSystemContext();
- SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(configCtx).getSequencePropretyBeanMgr();
- SequencePropertyBean msgsBean = seqPropMgr.retrieve( sequenceId,Constants.SEQ_PROPERTY_RECEIVED_MESSAGES);
+ ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
+ .getSystemContext();
+ if (configCtx==null)
+ throw new SandeshaException ("Configuration Context is null");
+
+ SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+ .getInstance(configCtx).getSequencePropretyBeanMgr();
+ SequencePropertyBean msgsBean = seqPropMgr.retrieve(sequenceId,
+ Constants.SEQ_PROPERTY_RECEIVED_MESSAGES);
long msgNo = sequence.getMessageNumber().getMessageNumber();
- if (msgNo==0)
- throw new MsgProcessorException ("Wrong message number");
-
- String messagesStr = (String) msgsBean.getValue();
-
- if (msgNoPresentInList (messagesStr,msgNo) && (Constants.DEFAULT_INVOCATION_TYPE==Constants.EXACTLY_ONCE)) {
- //this is a duplicate message and the invocation type is EXACTLY_ONCE.
- throw new MsgProcessorException ("Duplicate message - Invocation type is EXACTLY_ONCE");
+ if (msgNo == 0)
+ throw new SandeshaException("Wrong message number");
+
+ String messagesStr = (String) msgsBean.getValue();
+
+ if (msgNoPresentInList(messagesStr, msgNo)
+ && (Constants.DEFAULT_INVOCATION_TYPE == Constants.EXACTLY_ONCE)) {
+ //this is a duplicate message and the invocation type is
+ // EXACTLY_ONCE.
+ throw new SandeshaException(
+ "Duplicate message - Invocation type is EXACTLY_ONCE");
}
-
- if (messagesStr!="" && messagesStr!=null)
+
+ if (messagesStr != "" && messagesStr != null)
messagesStr = messagesStr + "," + Long.toString(msgNo);
- else
+ else
messagesStr = Long.toString(msgNo);
-
+
msgsBean.setValue(messagesStr);
seqPropMgr.update(msgsBean);
-
+
//Setting the ack depending on AcksTo.
//TODO: Stop sending askc for every message.
- SequencePropertyBean acksToBean = seqPropMgr.retrieve( sequenceId,Constants.SEQ_PROPERTY_ACKS_TO);
+ SequencePropertyBean acksToBean = seqPropMgr.retrieve(sequenceId,
+ Constants.SEQ_PROPERTY_ACKS_TO_EPR);
String acksToStr = null;
try {
- acksToStr = (String) acksToBean.getValue();
- }catch (Exception e) {
+ EndpointReference acksTo = (EndpointReference) acksToBean.getValue();
+ acksToStr = acksTo.getAddress();
+ } catch (Exception e) {
e.printStackTrace();
}
-
+
//TODO: remove folowing 2.
- System.out.println ("Messages received:" + messagesStr);
- System.out.println ("Acks To:" + acksToStr);
-
- if (acksToStr==null || messagesStr==null)
- throw new MsgProcessorException ("Seqeunce properties are not set correctly");
-
+ System.out.println("Messages received:" + messagesStr);
+ System.out.println("Acks To:" + acksToStr);
+
+ if (acksToStr == null || messagesStr == null)
+ throw new SandeshaException(
+ "Seqeunce properties are not set correctly");
+
if (acksToStr.equals(Constants.WSA.NS_URI_ANONYMOUS)) {
-
+
//Adding sync ack
//set acknowledgement
- //TODO stop adding acks to every message. Add acks only when needed.
-
+ //TODO stop adding acks to every message. Add acks only when
+ // needed.
+
+
+// try {
+// MessageContext responseMsgCtx = rmMsgCtx.getMessageContext().getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT);
+// if (responseMsgCtx==null){
+// responseMsgCtx = new MessageContext (configCtx,rmMsgCtx.getMessageContext().getTransportIn(),rmMsgCtx.getMessageContext().getTransportOut());
+// rmMsgCtx.getMessageContext().getOperationContext().addMessageContext(responseMsgCtx);
+//
+// //TODO following line is due to a bug in Axis2. Remove this when it is fixed.
+// responseMsgCtx.setOperationContext(rmMsgCtx.getMessageContext().getOperationContext());
+// }
+//
+// RMMsgContext responseRMMsg = new RMMsgContext (responseMsgCtx);
+// RMMsgCreator.addAckMessage(responseRMMsg);
+//
+// } catch (AxisFault af) {
+// throw new SandeshaException (af.getMessage());
+// }
- }else {
+ } else {
//TODO Add async Ack
}
-
-
-
-// Pause the messages bean if not the right message to invoke.
- NextMsgBeanMgr mgr = AbstractBeanMgrFactory.getInstance(configCtx).getNextMsgBeanMgr();
+
+ // Pause the messages bean if not the right message to invoke.
+ NextMsgBeanMgr mgr = AbstractBeanMgrFactory.getInstance(configCtx)
+ .getNextMsgBeanMgr();
NextMsgBean bean = mgr.retrieve(sequenceId);
-
- if (bean==null)
- throw new MsgProcessorException ("Error- The sequence does not exist");
-
- StorageMapBeanMgr storageMapMgr = AbstractBeanMgrFactory.getInstance(configCtx).getStorageMapBeanMgr();
-
- long nextMsgno = bean.getNextMsgNoToProcess();
-
-
- if (nextMsgno<msgNo) {
-
- //pause and store the message (since it is not the next message of the order)
- //rmMsgCtx.getMessageContext().setPausedTrue(new QName (Constants.IN_HANDLER_NAME));
-
-
-
-
+
+ if (bean == null)
+ throw new SandeshaException("Error- The sequence does not exist");
+
+ StorageMapBeanMgr storageMapMgr = AbstractBeanMgrFactory.getInstance(
+ configCtx).getStorageMapBeanMgr();
+
+ long nextMsgno = bean.getNextMsgNoToProcess();
+
+ if (nextMsgno < msgNo) {
+
+ //pause and store the message (since it is not the next message of
+ // the order)
+ //rmMsgCtx.getMessageContext().setPausedTrue(new QName
+ // (Constants.IN_HANDLER_NAME));
+
try {
- String key = SandeshaUtil.storeMessageContext(rmMsgCtx.getMessageContext());
- storageMapMgr.insert(new StorageMapBean (key,msgNo,sequenceId));
-
- //This will avoid performing application processing more than once.
- rmMsgCtx.setProperty(Constants.APPLICATION_PROCESSING_DONE,"true");
-
- }catch (Exception ex) {
- throw new MsgProcessorException (ex.getMessage());
- }
- }else {
- //OK this is a correct message.
- //(nextMsgNo>msgNo can not happen if EXCTLY_ONCE is enabled. This should have been
+ String key = SandeshaUtil.storeMessageContext(rmMsgCtx
+ .getMessageContext());
+ storageMapMgr
+ .insert(new StorageMapBean(key, msgNo, sequenceId));
+
+ //This will avoid performing application processing more than
+ // once.
+ rmMsgCtx.setProperty(Constants.APPLICATION_PROCESSING_DONE,
+ "true");
+
+ } catch (Exception ex) {
+ throw new SandeshaException(ex.getMessage());
+ }
+ } else {
+ //OK this is a correct message.
+ //(nextMsgNo>msgNo can not happen if EXCTLY_ONCE is enabled. This
+ // should have been
// detected previously)
- if (Constants.DEFAULT_DELIVERY_ASSURANCE==Constants.IN_ORDER) {
+ if (Constants.DEFAULT_DELIVERY_ASSURANCE == Constants.IN_ORDER) {
//store and let invoker handle for IN_ORDER invocation
- //rmMsgCtx.getMessageContext().setPausedTrue(new QName (Constants.IN_HANDLER_NAME));
-
-
+ //rmMsgCtx.getMessageContext().setPausedTrue(new QName
+ // (Constants.IN_HANDLER_NAME));
+
try {
- String key = SandeshaUtil.storeMessageContext(rmMsgCtx.getMessageContext());
- storageMapMgr.insert(new StorageMapBean (key,msgNo,sequenceId));
-
-// This will avoid performing application processing more than once.
- rmMsgCtx.setProperty(Constants.APPLICATION_PROCESSING_DONE,"true");
-
- System.out.println ("paused");
- }catch (Exception ex) {
- throw new MsgProcessorException (ex.getMessage());
- }
- }else {
- //if IN_ORDER is not required. Simply let this invoke (by doing nothing here :D )
+ String key = SandeshaUtil.storeMessageContext(rmMsgCtx
+ .getMessageContext());
+ storageMapMgr.insert(new StorageMapBean(key, msgNo,
+ sequenceId));
+
+ // This will avoid performing application processing more
+ // than once.
+ rmMsgCtx.setProperty(Constants.APPLICATION_PROCESSING_DONE,
+ "true");
+
+ System.out.println("paused");
+ } catch (Exception ex) {
+ throw new SandeshaException(ex.getMessage());
+ }
+ } else {
+ //if IN_ORDER is not required. Simply let this invoke (by doing
+ // nothing here :D )
}
}
-
+
int i = 1;
}
-
-
+
//TODO convert following from INT to LONG
- private boolean msgNoPresentInList (String list, long no) {
+ private boolean msgNoPresentInList(String list, long no) {
String[] msgStrs = list.split(",");
int l = msgStrs.length;
-
- for (int i=0;i<l;i++) {
+
+ for (int i = 0; i < l; i++) {
if (msgStrs[i].equals(Long.toString(no)))
return true;
}
-
+
return false;
}
-}
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java Thu Sep 22 20:52:54 2005
@@ -19,6 +19,7 @@
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.wsrm.CreateSequence;
/**
@@ -27,7 +28,7 @@
public class CreateSeqMsgProcessor implements MsgProcessor {
- public void processMessage(RMMsgContext rmMsgCtx) throws MsgProcessorException {
+ public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
//TODO: Add create sequence message processing logic
CreateSequence createSeq = (CreateSequence) rmMsgCtx.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/MsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/MsgProcessor.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/MsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/MsgProcessor.java Thu Sep 22 20:52:54 2005
@@ -18,6 +18,7 @@
package org.apache.sandesha2.msgprocessors;
import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.SandeshaException;
/**
@@ -25,5 +26,5 @@
*/
public interface MsgProcessor {
- public void processMessage(RMMsgContext rmMsgCtx) throws MsgProcessorException;
+ public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/TerminateSeqMsgProcessor.java Thu Sep 22 20:52:54 2005
@@ -18,6 +18,7 @@
package org.apache.sandesha2.msgprocessors;
import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.SandeshaException;
/**
* @author
@@ -26,7 +27,7 @@
public class TerminateSeqMsgProcessor implements MsgProcessor {
public void processMessage(RMMsgContext rmMsgCtx)
- throws MsgProcessorException {
+ throws SandeshaException {
//TODO Add terminate sequence message logic.
}
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java Thu Sep 22 20:52:54 2005
@@ -47,7 +47,7 @@
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.MsgInitializer;
import org.apache.sandesha2.MsgValidator;
-import org.apache.sandesha2.RMException;
+import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.RMMsgCreator;
import org.apache.sandesha2.SequenceMenager;
@@ -65,49 +65,55 @@
public class RMMessageReceiver extends AbstractMessageReceiver {
-
-
//TODO move this code to create seq msg processor.
public void setCreateSequence(MessageContext inMessage,
MessageContext outMessage) throws AxisFault {
System.out.println("set create seq was called in RM Msg receiver");
-
+
RMMsgContext createSeqMsg = null;
- try {
- createSeqMsg = MsgInitializer.initializeMessage(inMessage);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
- if (createSeqMsg.getMessageType()!=Constants.MESSAGE_TYPE_CREATE_SEQ)
- throw new AxisFault ("Wrong message type");
-
- RMMsgContext createSeqResponse = RMMsgCreator
- .createCreateSeqResponseMsg(createSeqMsg, outMessage);
- CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse.
- getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE);
-
+ try {
+ createSeqMsg = MsgInitializer.initializeMessage(inMessage);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
+ if (createSeqMsg.getMessageType() != Constants.MESSAGE_TYPE_CREATE_SEQ)
+ throw new AxisFault("Wrong message type");
+
+ RMMsgContext createSeqResponse = RMMsgCreator
+ .createCreateSeqResponseMsg(createSeqMsg, outMessage);
+ CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse
+ .getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ_RESPONSE);
+
String newSequenceId = createSeqResPart.getIdentifier().getIdentifier();
- if (newSequenceId==null)
- throw new AxisFault ("Internal error - Generated sequence id is null");
+ if (newSequenceId == null)
+ throw new AxisFault(
+ "Internal error - Generated sequence id is null");
ConfigurationContext configCtx = inMessage.getSystemContext();
- SequenceMenager.setUpNewSequence(newSequenceId,configCtx);
+ SequenceMenager.setUpNewSequence(newSequenceId, createSeqMsg);
+
+ CreateSequence createSeq = (CreateSequence) createSeqMsg
+ .getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
+ if (createSeq == null)
+ throw new AxisFault(
+ "Create sequence part not present in the create sequence message");
- CreateSequence createSeq = (CreateSequence) createSeqMsg.getMessagePart(Constants.MESSAGE_PART_CREATE_SEQ);
- if (createSeq==null)
- throw new AxisFault ("Create sequence part not present in the create sequence message");
-
- String acksTo = createSeq.getAcksTo().getAddress().getEpr().getAddress();
- if (acksTo==null || acksTo=="")
- throw new AxisFault ("Acks to not present in the create sequence message");
-
- SequencePropertyBean seqPropBean = new SequencePropertyBean (newSequenceId,Constants.SEQ_PROPERTY_ACKS_TO,acksTo);
-// SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr (Constants.DEFAULT_STORAGE_TYPE);
-// beanMgr.create(seqPropBean);
-
- SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(configCtx).getSequencePropretyBeanMgr();
+ EndpointReference acksTo = createSeq.getAcksTo().getAddress().getEpr();
+ if (acksTo == null || acksTo.getAddress() == null
+ || acksTo.getAddress() == "")
+ throw new AxisFault(
+ "Acks to not present in the create sequence message");
+
+ SequencePropertyBean seqPropBean = new SequencePropertyBean(
+ newSequenceId, Constants.SEQ_PROPERTY_ACKS_TO_EPR, acksTo);
+ // SequencePropertyBeanMgr beanMgr = new SequencePropertyBeanMgr
+ // (Constants.DEFAULT_STORAGE_TYPE);
+ // beanMgr.create(seqPropBean);
+
+ SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+ .getInstance(configCtx).getSequencePropretyBeanMgr();
seqPropMgr.insert(seqPropBean);
outMessage.setResponseWritten(true);
@@ -115,28 +121,29 @@
public final void receive(MessageContext messgeCtx) throws AxisFault {
- System.out.println ("within RM Msg receiver");
-
+ System.out.println("within RM Msg receiver");
+
//intitializing the message.
RMMsgContext rmMsgCtx = null;
- try {
- rmMsgCtx = MsgInitializer.initializeMessage(messgeCtx);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
+ try {
+ rmMsgCtx = MsgInitializer.initializeMessage(messgeCtx);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
AbstractMessageReceiver msgReceiver = null;
-
+
String replyTo = messgeCtx.getFrom().getAddress();
- if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_TERMINATE_SEQ)
- msgReceiver = new RMInMsgReceiver ();
- else if(rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_CREATE_SEQ && ((replyTo==null) || replyTo.equals(Constants.WSA.NS_URI_ANONYMOUS)))
- msgReceiver = new RMInOutSyncMsgReceiver ();
- else if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_CREATE_SEQ)
- msgReceiver = new RMInOutAsyncMsgReceiver ();
-
-
- if(msgReceiver!=null) {
+ if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_TERMINATE_SEQ)
+ msgReceiver = new RMInMsgReceiver();
+ else if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_CREATE_SEQ
+ && ((replyTo == null) || replyTo
+ .equals(Constants.WSA.NS_URI_ANONYMOUS)))
+ msgReceiver = new RMInOutSyncMsgReceiver();
+ else if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_CREATE_SEQ)
+ msgReceiver = new RMInOutAsyncMsgReceiver();
+
+ if (msgReceiver != null) {
msgReceiver.receive(messgeCtx);
}
}
@@ -154,60 +161,64 @@
}
return fac;
}
-
+
private class RMInMsgReceiver extends AbstractInMessageReceiver {
-
- public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {
+
+ public void invokeBusinessLogic(MessageContext inMessage)
+ throws AxisFault {
RMMsgContext rmMsgCtx = null;
- try {
- rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
+ try {
+ rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
//TODO check for terminate sequence.
//TODO handle terminate sequence.
-
-
+
}
}
-
- private class RMInOutSyncMsgReceiver extends AbstractInOutSyncMessageReceiver {
-
- public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
-
+
+ private class RMInOutSyncMsgReceiver extends
+ AbstractInOutSyncMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessage,
+ MessageContext outMessage) throws AxisFault {
+
RMMsgContext rmMsgCtx = null;
- try {
- rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
- if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_CREATE_SEQ) {
+ try {
+ rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
+ if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_CREATE_SEQ) {
//TODO handle sync create seq.
- setCreateSequence(inMessage,outMessage);
+ setCreateSequence(inMessage, outMessage);
}
-
+
}
-}
-
- private class RMInOutAsyncMsgReceiver extends AbstractInOutAsyncMessageReceiver {
-
+ }
+
+ private class RMInOutAsyncMsgReceiver extends
+ AbstractInOutAsyncMessageReceiver {
+
public void invokeBusinessLogic(MessageContext inMessage,
- MessageContext outMessage, ServerCallback callback) throws AxisFault {
-
+ MessageContext outMessage, ServerCallback callback)
+ throws AxisFault {
+
RMMsgContext rmMsgCtx = null;
- try {
- rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
- }catch (RMException ex) {
- throw new AxisFault ("Cant initialize the message");
- }
-
- if (rmMsgCtx.getMessageType()==Constants.MESSAGE_TYPE_CREATE_SEQ) {
+ try {
+ rmMsgCtx = MsgInitializer.initializeMessage(inMessage);
+ } catch (SandeshaException ex) {
+ throw new AxisFault("Cant initialize the message");
+ }
+
+ if (rmMsgCtx.getMessageType() == Constants.MESSAGE_TYPE_CREATE_SEQ) {
//TODO handle async create seq.
- setCreateSequence(inMessage,outMessage);
+ setCreateSequence(inMessage, outMessage);
ConfigurationContext configCtx = outMessage.getSystemContext();
- AxisEngine engine = new AxisEngine (configCtx);
+ AxisEngine engine = new AxisEngine(configCtx);
engine.send(outMessage);
}
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/AbstractBeanMgrFactory.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/AbstractBeanMgrFactory.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/AbstractBeanMgrFactory.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/AbstractBeanMgrFactory.java Thu Sep 22 20:52:54 2005
@@ -35,53 +35,53 @@
public class AbstractBeanMgrFactory {
AbstractContext context = null;
-
+
private static AbstractBeanMgrFactory instance = null;
-
+
public CreateSeqBeanMgr getCreateSeqBeanMgr() {
- return new CreateSeqBeanMgr (context);
+ return new CreateSeqBeanMgr(context);
}
-
+
public NextMsgBeanMgr getNextMsgBeanMgr() {
- return new NextMsgBeanMgr (context);
+ return new NextMsgBeanMgr(context);
}
-
+
public RetransmitterBeanMgr getRetransmitterBeanMgr() {
- return new RetransmitterBeanMgr (context);
+ return new RetransmitterBeanMgr(context);
}
-
+
public SequencePropertyBeanMgr getSequencePropretyBeanMgr() {
- return new SequencePropertyBeanMgr (context);
+ return new SequencePropertyBeanMgr(context);
}
-
+
public StorageMapBeanMgr getStorageMapBeanMgr() {
- return new StorageMapBeanMgr (context);
+ return new StorageMapBeanMgr(context);
}
-
-// public static AbstractBeanMgrFactory getBeanMgrFactory (int storageType) {
-// switch (storageType) {
-// case Constants.STORAGE_TYPE_PERSISTANCE:
-// return new PersistentBeanMgrFactory();
-// case Constants.STORAGE_TYPE_IN_MEMORY:
-// return new InMemBeanMgrFactory();
-// default:
-// return null;
-// }
-// }
-
-
- private AbstractBeanMgrFactory (AbstractContext context) {
+
+ // public static AbstractBeanMgrFactory getBeanMgrFactory (int storageType)
+ // {
+ // switch (storageType) {
+ // case Constants.STORAGE_TYPE_PERSISTANCE:
+ // return new PersistentBeanMgrFactory();
+ // case Constants.STORAGE_TYPE_IN_MEMORY:
+ // return new InMemBeanMgrFactory();
+ // default:
+ // return null;
+ // }
+ // }
+
+ private AbstractBeanMgrFactory(AbstractContext context) {
this.context = context;
}
-
- public void init (ConfigurationContext context) {
+
+ public void init(ConfigurationContext context) {
this.context = context;
}
-
- public static AbstractBeanMgrFactory getInstance (AbstractContext context) {
- if (instance==null)
- instance = new AbstractBeanMgrFactory (context);
-
+
+ public static AbstractBeanMgrFactory getInstance(AbstractContext context) {
+ if (instance == null)
+ instance = new AbstractBeanMgrFactory(context);
+
return instance;
}
-}
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java?rev=291067&r1=291066&r2=291067&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java Thu Sep 22 20:52:54 2005
@@ -25,7 +25,7 @@
import org.apache.axis2.context.AbstractContext;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.sandesha2.Constants;
-import org.apache.sandesha2.RMException;
+import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.storage.beans.CreateSeqBean;
/**
@@ -34,28 +34,28 @@
*/
public class CreateSeqBeanMgr {
-
+
private Hashtable table = null;
/**
- *
+ *
*/
public CreateSeqBeanMgr(AbstractContext context) {
Object obj = context.getProperty(Constants.CREATE_SEQUECE_BEAN_MAP);
- if (obj!=null) {
+ if (obj != null) {
table = (Hashtable) obj;
- }else {
- table = new Hashtable ();
- context.setProperty(Constants.CREATE_SEQUECE_BEAN_MAP,table);
+ } else {
+ table = new Hashtable();
+ context.setProperty(Constants.CREATE_SEQUECE_BEAN_MAP, table);
}
}
- public boolean insert(CreateSeqBean bean) {
+ public boolean insert(CreateSeqBean bean) {
table.put(bean.getCreateSeqMsgId(), bean);
return true;
}
- public boolean delete(String msgId) {
+ public boolean delete(String msgId) {
return table.remove(msgId) != null;
}
@@ -63,23 +63,23 @@
return (CreateSeqBean) table.get(msgId);
}
- public boolean update(CreateSeqBean bean){
+ public boolean update(CreateSeqBean bean) {
return table.put(bean.getCreateSeqMsgId(), bean) != null;
}
public Collection find(CreateSeqBean bean) {
- ArrayList beans = new ArrayList();
+ ArrayList beans = new ArrayList();
Iterator iterator = table.values().iterator();
-
- CreateSeqBean temp;
+
+ CreateSeqBean temp;
while (iterator.hasNext()) {
temp = (CreateSeqBean) iterator.next();
- if ( (bean.getCreateSeqMsgId() != null
- && bean.getCreateSeqMsgId().equals(temp.getCreateSeqMsgId()))
- && (bean.getSequenceId() != null
- && bean.getSequenceId().equals(bean.getSequenceId()))) {
+ if ((bean.getCreateSeqMsgId() != null && bean.getCreateSeqMsgId()
+ .equals(temp.getCreateSeqMsgId()))
+ && (bean.getSequenceId() != null && bean.getSequenceId()
+ .equals(bean.getSequenceId()))) {
beans.add(temp);
-
+
}
}
return beans;
@@ -89,4 +89,4 @@
throw new UnsupportedOperationException("selectRS() is not supported");
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org