Examples of SequencePropertyBean


Examples of org.apache.sandesha2.storage.beans.SequencePropertyBean

    //retrieving storage manager
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msg.getConfigurationContext());
    SequencePropertyBeanMgr sequencePropertyMgr = storageManager.getSequencePropretyBeanMgr();
    SenderBeanMgr retransmitterMgr = storageManager.getRetransmitterBeanMgr();

    SequencePropertyBean toBean = sequencePropertyMgr.retrieve(
        internalSequenceId,Sandesha2Constants.SequenceProperties.TO_EPR);
    SequencePropertyBean replyToBean = sequencePropertyMgr.retrieve(
        internalSequenceId,Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);

    // again - looks weird in the client side - but consistent
    SequencePropertyBean outSequenceBean = sequencePropertyMgr.retrieve(
        internalSequenceId,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);

    if (toBean == null) {
      String message = "To is null";
      log.debug(message);
      throw new SandeshaException(message);
    }

    EndpointReference toEPR = new EndpointReference(toBean.getValue());
   
    EndpointReference replyToEPR = null;
    if (replyToBean != null) {
      replyToEPR = new EndpointReference(replyToBean.getValue());
    }

    if (toEPR == null || toEPR.getAddress() == null || toEPR.getAddress() == "") {
      String message = "To Property has an invalid value";
      log.debug(message);
      throw new SandeshaException(message);
    }

    String newToStr = null;
    if (msg.isServerSide()) {
      try {
        MessageContext requestMsg = msg.getOperationContext().getMessageContext(
                OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
        if (requestMsg != null) {
          newToStr = requestMsg.getReplyTo().getAddress();
        }
      } catch (AxisFault e) {
        throw new SandeshaException(e.getMessage());
      }
    }

    if (newToStr != null)
      rmMsg.setTo(new EndpointReference(newToStr));
    else
      rmMsg.setTo(toEPR);

    if (replyToEPR != null)
      rmMsg.setReplyTo(replyToEPR);

    String rmVersion = SandeshaUtil.getRMVersion(internalSequenceId,configurationContext);
    if (rmVersion==null)
      throw new SandeshaException ("Cant find the rmVersion of the given message");
   
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
   
    Sequence sequence = new Sequence(factory,rmNamespaceValue);
    MessageNumber msgNumber = new MessageNumber(factory,rmNamespaceValue);
    msgNumber.setMessageNumber(messageNumber);
    sequence.setMessageNumber(msgNumber);

    boolean lastMessage = false;
    // setting last message
    if (msg.isServerSide()) {
      MessageContext requestMsg = null;

      try {
        requestMsg = msg.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
      } catch (AxisFault e) {
        throw new SandeshaException(e.getMessage());
      }

      RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsg);
      Sequence requestSequence = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (requestSequence == null) {
        String message = "Request Sequence is null";
        log.debug(message);
        throw new SandeshaException(message);
      }

      if (requestSequence.getLastMessage() != null) {
        lastMessage = true;
        sequence.setLastMessage(new LastMessage(factory,rmNamespaceValue));

      }

    } else {
      // client side

      OperationContext operationContext = msg.getOperationContext();
      if (operationContext != null) {
        Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
        if (obj != null && "true".equals(obj)) {
          lastMessage = true;
         
          SequencePropertyBean specVersionBean = sequencePropertyMgr.retrieve(internalSequenceId,Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
          if (specVersionBean==null)
            throw new SandeshaException ("Spec version bean is not set");
         
          String specVersion = specVersionBean.getValue();
          if (SpecSpecificConstants.isLastMessageIndicatorRequired(specVersion))
            sequence.setLastMessage(new LastMessage(factory,rmNamespaceValue));
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.