Package org.apache.sandesha2.storage.beanmanagers

Examples of org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr


    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(applicationMsgContext.getEnvelope()));

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(context);
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();
    MessageContext createSeqmsgContext;
    try {
      //creating by copying common contents. (this will not set contexts
      // except for configCtx).
      AxisOperation createSequenceOperation = AxisOperationFactory
          .getAxisOperation(AxisOperation.MEP_CONSTANT_OUT_IN);
     
      createSeqmsgContext = SandeshaUtil.createNewRelatedMessageContext(
          applicationRMMsg, createSequenceOperation);
      OperationContext createSeqOpCtx = createSeqmsgContext
          .getOperationContext();
      String createSeqMsgId = SandeshaUtil.getUUID();
      createSeqmsgContext.setMessageID(createSeqMsgId);
      context.registerOperationContext(createSeqMsgId, createSeqOpCtx);

    } catch (AxisFault e) {
      throw new SandeshaException(e.getMessage());
    }

    setUpMessage(createSeqmsgContext);

    AxisOperation appMsgOperationDesc = applicationMsgContext
        .getAxisOperation();

    AxisOperation createSeqOperation = createSeqmsgContext
        .getAxisOperation();
    createSeqOperation.setName(new QName("CreateSequenceOperation"));
    if (appMsgOperationDesc != null) {
      createSeqOperation.setPhasesOutFlow(appMsgOperationDesc
          .getPhasesOutFlow());
      createSeqOperation.setPhasesOutFaultFlow(appMsgOperationDesc
          .getPhasesOutFaultFlow());
      createSeqOperation.setPhasesInFaultFlow(appMsgOperationDesc
          .getPhasesInFaultFlow());
      createSeqOperation.setRemainingPhasesInFlow(appMsgOperationDesc
          .getRemainingPhasesInFlow());
    }

    createSeqmsgContext.setAxisOperation(createSeqOperation);

    createSeqmsgContext.setTo(applicationRMMsg.getTo());
    createSeqmsgContext.setReplyTo(applicationRMMsg.getReplyTo());

    RMMsgContext createSeqRMMsg = new RMMsgContext(createSeqmsgContext);

    CreateSequence createSequencePart = new CreateSequence(factory);

    //Adding sequence offer - if present
    OperationContext operationcontext = applicationMsgContext
        .getOperationContext();
    if (operationcontext != null) {
      String offeredSequence = (String) applicationMsgContext
          .getProperty(Sandesha2ClientAPI.OFFERED_SEQUENCE_ID);
      if (offeredSequence != null && !"".equals(offeredSequence)) {
        SequenceOffer offerPart = new SequenceOffer(factory);
        Identifier identifier = new Identifier(factory);
        identifier.setIndentifer(offeredSequence);
        offerPart.setIdentifier(identifier);
        createSequencePart.setSequenceOffer(offerPart);
      }
    }

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

    if (toBean == null || toBean.getValue() == null)
      throw new SandeshaException("To EPR is not set.");
View Full Code Here


    ConfigurationContext ctx = applicationMsg.getMessageContext()
        .getConfigurationContext();
    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(ctx);
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    SequencePropertyBean seqBean = seqPropMgr.retrieve(sequenceId,
        Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES);
    String msgNoList = (String) seqBean.getValue();

    ArrayList ackRangeArrayList = SandeshaUtil.getAckRangeArrayList(msgNoList,factory);
    Iterator iterator = ackRangeArrayList.iterator();
View Full Code Here

        NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();

        InvokerBeanMgr storageMapMgr = storageManager
            .getStorageMapBeanMgr();

        SequencePropertyBeanMgr sequencePropMgr = storageManager
            .getSequencePropretyBeanMgr();

        //Getting the incomingSequenceIdList
        SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) sequencePropMgr
            .retrieve(
                Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
                Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
        if (sequencePropertyBean == null)
          continue;
View Full Code Here

      if (sequenceId != null && msgNo > 0) {
        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(rmMsgContext
                .getMessageContext().getConfigurationContext());
        SequencePropertyBeanMgr seqPropMgr = storageManager
            .getSequencePropretyBeanMgr();
        SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(
            sequenceId,
            Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES);
        if (receivedMsgsBean != null) {
          String receivedMsgStr = (String) receivedMsgsBean
              .getValue();
          ArrayList msgNoArrList = SandeshaUtil
              .getSplittedMsgNoArraylist(receivedMsgStr);

          Iterator iterator = msgNoArrList.iterator();
          while (iterator.hasNext()) {
            String temp = (String) iterator.next();
            String msgNoStr = new Long(msgNo).toString();
            if (msgNoStr.equals(temp)) {
              drop = true;
            }
          }
         
        }

        if (drop == false) {
          //Checking for RM specific EMPTY_BODY LASTMESSAGE.
          SOAPBody body = rmMsgContext.getSOAPEnvelope().getBody();
          boolean emptyBody = false;
          if (body.getChildElements().hasNext() == false) {
            emptyBody = true;
          }

          if (emptyBody) {
            boolean lastMessage = false;
            if (sequence.getLastMessage() != null) {
              System.out
                  .println("Empty Body Last Message Received");
              drop = true;

              if (receivedMsgsBean == null) {
                receivedMsgsBean = new SequencePropertyBean(
                    sequenceId,
                    Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES,
                    "");
                seqPropMgr.insert(receivedMsgsBean);
              }

              String receivedMsgStr = (String) receivedMsgsBean
                  .getValue();
              if (receivedMsgStr != "" && receivedMsgStr != null)
                receivedMsgStr = receivedMsgStr + ","
                    + Long.toString(msgNo);
              else
                receivedMsgStr = Long.toString(msgNo);

              receivedMsgsBean.setValue(receivedMsgStr);
              seqPropMgr.update(receivedMsgsBean);

              ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
              ackProcessor.sendAckIfNeeded(rmMsgContext,
                  receivedMsgStr);
View Full Code Here

      }

      StorageManager storageManager = SandeshaUtil
          .getSandeshaStorageManager(rmMsgContext.getMessageContext()
              .getConfigurationContext());
      SequencePropertyBeanMgr seqPropMgr = storageManager
          .getSequencePropretyBeanMgr();
      SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(
          sequenceId, Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES);
      String receivedMsgStr = (String) receivedMsgsBean.getValue();

      ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
      //Even though the duplicate message is dropped, hv to send the ack
View Full Code Here

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(context);

    CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    boolean serverSide = msgCtx.isServerSide();

    //setting message Id if null
    if (msgCtx.getMessageID() == null) {
      msgCtx.setMessageID(SandeshaUtil.getUUID());
    }
    //initial work
    //find internal sequence id
    String internalSequenceId = null;

    //Temp sequence id is the one used to refer to the sequence (since
    //actual sequence id is not available when first msg arrives)
    //server side - sequenceId if the incoming sequence
    //client side - wsaTo + SeequenceKey

    if (serverSide) {
      //getting the request message and rmMessage.
      MessageContext reqMsgCtx = msgCtx.getOperationContext()
          .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

      RMMsgContext requestRMMsgCtx = MsgInitializer
          .initializeMessage(reqMsgCtx);

      Sequence reqSequence = (Sequence) requestRMMsgCtx
          .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (reqSequence == null)
        throw new SandeshaException("Sequence part is null");

      String incomingSeqId = reqSequence.getIdentifier().getIdentifier();
      if (incomingSeqId == null || incomingSeqId == "")
        throw new SandeshaException("Invalid seqence Id");

      internalSequenceId = incomingSeqId;

    } else {
      //set the internal sequence id for the client side.
      EndpointReference toEPR = msgCtx.getTo();
      if (toEPR == null || toEPR.getAddress() == null
          || "".equals(toEPR.getAddress()))
        throw new AxisFault(
            "TO End Point Reference is not set correctly. This is a must for the sandesha client side.");

      internalSequenceId = toEPR.getAddress();
      OperationContext opContext = msgCtx.getOperationContext();
      String sequenceKey = (String) msgCtx
          .getProperty(Sandesha2ClientAPI.SEQUENCE_KEY);
      if (sequenceKey != null)
        internalSequenceId = internalSequenceId + sequenceKey;

    }

    //check if the first message

    long messageNumber = getNextMsgNo(context, internalSequenceId);

    boolean sendCreateSequence = false;

    SequencePropertyBean outSeqBean = seqPropMgr.retrieve(
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);

    if (messageNumber == 1) {
      if (outSeqBean == null) {
        sendCreateSequence = true;
      }
    }

    //if fist message - setup the sequence for the client side
    if (!serverSide && sendCreateSequence) {
      SequenceManager.setupNewClientSequence(msgCtx, internalSequenceId);
    }

    //if first message - add create sequence
    if (sendCreateSequence) {

      SequencePropertyBean responseCreateSeqAdded = seqPropMgr.retrieve(
          internalSequenceId,
          Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT);

      if (responseCreateSeqAdded == null) {
        responseCreateSeqAdded = new SequencePropertyBean(
            internalSequenceId,
            Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT,
            "true");
        seqPropMgr.insert(responseCreateSeqAdded);

        String acksTo = null;
        if (serviceContext != null) {
          acksTo = (String) msgCtx
              .getProperty(Sandesha2ClientAPI.AcksTo);
        }

        if (acksTo == null)
          acksTo = Sandesha2Constants.WSA.NS_URI_ANONYMOUS;

        //If acksTo is not anonymous. Start the listner TODO: verify
        if (!Sandesha2Constants.WSA.NS_URI_ANONYMOUS.equals(acksTo)
            && !serverSide) {
          String transportIn = (String) context
              .getProperty(MessageContext.TRANSPORT_IN);
          if (transportIn == null)
            transportIn = org.apache.axis2.Constants.TRANSPORT_HTTP;
          ListenerManager.makeSureStarted(transportIn, context);
        } else if (acksTo == null && serverSide) {
          String incomingSequencId = SandeshaUtil
              .getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
          SequencePropertyBean bean = seqPropMgr.retrieve(
              incomingSequencId,
              Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
          if (bean != null) {
            EndpointReference acksToEPR = (EndpointReference) bean
                .getValue();
View Full Code Here

      StorageManager storageManager = SandeshaUtil
          .getSandeshaStorageManager(applicationMsg
              .getConfigurationContext());

      SequencePropertyBeanMgr seqPropMgr = storageManager
          .getSequencePropretyBeanMgr();

      seqPropMgr.insert(msgsBean);
      seqPropMgr.insert(offeredSequenceBean);
    }

    MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
    createSeqMsg.setRelatesTo(null); //create seq msg does not relateTo
    // anything
View Full Code Here

    if (context == null)
      throw new SandeshaException("Context is null");

    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)
      throw new SandeshaException("To is null");

    EndpointReference toEPR = (EndpointReference) toBean.getValue();
    EndpointReference replyToEPR = null;

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

    if (toEPR == null || toEPR.getAddress() == null
        || toEPR.getAddress() == "")
      throw new SandeshaException("To Property has an invalid value");

    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);

    Sequence sequence = new Sequence(factory);

    MessageNumber msgNumber = new MessageNumber(factory);
    msgNumber.setMessageNumber(messageNumber);
    sequence.setMessageNumber(msgNumber);

    boolean lastMessage = false;
    //setting last message
    if (msg.isServerSide()) {
      //server side
      String incomingSeqId = internalSequenceId;
      MessageContext requestMsg = null;

      try {
        requestMsg = msg.getOperationContext().getMessageContext(
            WSDLConstants.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)
        throw new SandeshaException("Request Sequence is null");

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

        //saving the last message no.
        SequencePropertyBean lastOutMsgBean = new SequencePropertyBean(
            internalSequenceId,
            Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE,
            new Long(messageNumber));
        sequencePropertyMgr.insert(lastOutMsgBean);
      }

    } else {
      //client side

      OperationContext operationContext = msg.getOperationContext();
      if (operationContext != null) {
        Object obj = msg.getProperty(Sandesha2ClientAPI.LAST_MESSAGE);
        if (obj != null && "true".equals(obj)) {
          lastMessage = true;
          sequence.setLastMessage(new LastMessage(factory));
          //saving the last message no.
          SequencePropertyBean lastOutMsgBean = new SequencePropertyBean(
              internalSequenceId,
              Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE,
              new Long(messageNumber));
          sequencePropertyMgr.insert(lastOutMsgBean);
        }
      }
    }

    AckRequested ackRequested = null;
View Full Code Here

      String internalSequenceId) throws SandeshaException {

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(context);

    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();
    SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
    long nextMsgNo = 1;
    boolean update = false;
    if (nextMsgNoBean != null) {
      update = true;
      Long nextMsgNoLng = (Long) nextMsgNoBean.getValue();
      nextMsgNo = nextMsgNoLng.longValue();
    } else {
      nextMsgNoBean = new SequencePropertyBean();
      nextMsgNoBean.setSequenceId(internalSequenceId);
      nextMsgNoBean
          .setName(Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
    }

    nextMsgNoBean.setValue(new Long(nextMsgNo + 1));
    if (update)
      seqPropMgr.update(nextMsgNoBean);
    else
      seqPropMgr.insert(nextMsgNoBean);

    return nextMsgNo;
  }
View Full Code Here

                                    // response
                                    // message.
    } catch (AxisFault e1) {
      throw new SandeshaException(e1);
    }
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    try {
      String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg, storageManager); // newly
                                                    // created
                                                    // sequnceID.

     
     
     
      RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg, outMessage,
          newSequenceId, storageManager); // converting the blank out
                          // message in to a create
      // sequence response.
      createSeqResponse.setFlow(MessageContext.OUT_FLOW);

      createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true"); // for
                                                  // making
                                                  // sure
                                                  // that
                                                  // this
                                                  // wont
                                                  // be
                                                  // processed
                                                  // again.
      CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse
          .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);

      // OFFER PROCESSING
      SequenceOffer offer = createSeqPart.getSequenceOffer();
      if (offer != null) {
        Accept accept = createSeqResPart.getAccept();
        if (accept == null) {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart);
          log.debug(message);
          throw new SandeshaException(message);
        }

        String offeredSequenceID = offer.getIdentifer().getIdentifier(); // offered
                                          // seq.
                                          // id.

        boolean offerEcepted = offerAccepted(offeredSequenceID, context, createSeqRMMsg, storageManager);

        if (offerEcepted) {
          // Setting the CreateSequence table entry for the outgoing
          // side.
          RMSBean rmsBean = new RMSBean();
          rmsBean.setSequenceID(offeredSequenceID);
          String outgoingSideInternalSequenceId = SandeshaUtil
              .getOutgoingSideInternalSequenceID(newSequenceId);
          rmsBean.setInternalSequenceID(outgoingSideInternalSequenceId);
          rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); // this
                                        // is a
                                        // dummy
                                        // value.
         
         
          String outgoingSideSequencePropertyKey = outgoingSideInternalSequenceId;

          RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
          rmsBeanMgr.insert(rmsBean);

          // Setting sequence properties for the outgoing sequence.
          // Only will be used by the server side response path. Will
          // be wasted properties for the client side.

          // setting the out_sequence_id
          SequencePropertyBean outSequenceBean = new SequencePropertyBean();
          outSequenceBean.setName(Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
          outSequenceBean.setValue(offeredSequenceID);
          outSequenceBean.setSequencePropertyKey(outgoingSideSequencePropertyKey);
          seqPropMgr.insert(outSequenceBean);

          // setting the internal_sequence_id
          SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
          internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
          internalSequenceBean.setSequencePropertyKey(offeredSequenceID);
          internalSequenceBean.setValue(outgoingSideInternalSequenceId);
          seqPropMgr.insert(internalSequenceBean);
         
          Endpoint endpoint = offer.getEndpoint();
          if (endpoint!=null) {
            // setting the OfferedEndpoint
            SequencePropertyBean offeredEndpointBean = new SequencePropertyBean();
            offeredEndpointBean.setName(Sandesha2Constants.SequenceProperties.OFFERED_ENDPOINT);
         
            //currently we can only serialize the Address part of the Endpoint.
            //TODO correct this to serialize the whole EPR.
            offeredEndpointBean.setValue(endpoint.getEPR().getAddress())
            offeredEndpointBean.setSequencePropertyKey(outgoingSideSequencePropertyKey);
            seqPropMgr.insert(offeredEndpointBean);
          }
        } else {
          // removing the accept part.
          createSeqResPart.setAccept(null);
          createSeqResponse.addSOAPEnvelope();
        }
      }

      EndpointReference acksTo = createSeqPart.getAcksTo().getEPR();
      if (acksTo == null || acksTo.getAddress() == null || "".equals(acksTo.getAddress())) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence);
        log.debug(message);
        throw new AxisFault(message);
      }
     
      //TODO add createSequenceResponse message as the referenceMessage to the NextMsgBean.
     

      SequencePropertyBean acksToBean = new SequencePropertyBean(newSequenceId,
          Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, acksTo.getAddress());

      seqPropMgr.insert(acksToBean);

      outMessage.setResponseWritten(true);

      // commiting tr. before sending the response msg.

      SequenceManager.updateLastActivatedTime(newSequenceId, storageManager);

      AxisEngine engine = new AxisEngine(context);
      engine.send(outMessage);

      SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,
          Sandesha2Constants.SequenceProperties.TO_EPR);
      if (toBean == null) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
        log.debug(message);
        throw new SandeshaException(message);
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr

Copyright © 2018 www.massapicom. 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.