Package org.apache.sandesha2.storage.beans

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


    //retrieving the storage managers
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
        internalSequenceId,Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
   
    long nextMsgNo = -1;
    if (nextMsgNoBean != null) {
      Long nextMsgNoLng = new Long(nextMsgNoBean.getValue());
      nextMsgNo = nextMsgNoLng.longValue();
    }
   
    return nextMsgNo;
  }
View Full Code Here

    }
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
        internalSequenceId,Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);

    boolean update = true;
    if (nextMsgNoBean == null) {
      update = false;
      nextMsgNoBean = new SequencePropertyBean();
      nextMsgNoBean.setSequenceID(internalSequenceId);
      nextMsgNoBean.setName(Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
    }

    nextMsgNoBean.setValue(new Long(msgNo).toString());
    if (update)
      seqPropMgr.update(nextMsgNoBean);
    else
      seqPropMgr.insert(nextMsgNoBean);
View Full Code Here

  public static SandeshaReport getSandeshaReport (ConfigurationContext configurationContext) throws SandeshaException {
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
    SandeshaReport sandeshaReport = new SandeshaReport ();
    SequencePropertyBean internalSequenceFindBean = new SequencePropertyBean ();
    internalSequenceFindBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
    Collection collection = seqPropMgr.find(internalSequenceFindBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      SequencePropertyBean bean = (SequencePropertyBean) iterator.next();
      String sequenceID = bean.getSequenceID();
      sandeshaReport.addToOutgoingSequenceList (sequenceID);
      sandeshaReport.addToOutgoingInternalSequenceMap(sequenceID,bean.getValue());
     
      SequenceReport report = getOutgoingSequenceReport(bean.getValue(),configurationContext);
     
      sandeshaReport.addToNoOfCompletedMessagesMap(sequenceID ,report.getCompletedMessages().size());
      sandeshaReport.addToSequenceStatusMap(sequenceID ,report.getSequenceStatus());
    }
   
   
    //incoming sequences
    SequencePropertyBean serverCompletedMsgsFindBean = new SequencePropertyBean ();
    serverCompletedMsgsFindBean.setName(Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
   
    Collection serverCompletedMsgsBeans = seqPropMgr.find(serverCompletedMsgsFindBean);
    Iterator iter = serverCompletedMsgsBeans.iterator();
    while (iter.hasNext()) {
      SequencePropertyBean serverCompletedMsgsBean = (SequencePropertyBean) iter.next();
      String sequenceID = serverCompletedMsgsBean.getSequenceID();
      sandeshaReport.addToIncomingSequenceList(sequenceID);
     
      SequenceReport sequenceReport = getIncomingSequenceReport(sequenceID,configurationContext);
     
      sandeshaReport.addToNoOfCompletedMessagesMap(sequenceID,sequenceReport.getCompletedMessages().size());
View Full Code Here

    }
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    SequencePropertyBean sequenceIDBean = seqPropMgr.retrieve(internalSequenceID,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
    if (sequenceIDBean==null)
      throw new SandeshaException ("SequenceIdBean is not set");
   
    String sequenceID = sequenceIDBean.getValue();
    return sequenceID;
  }
View Full Code Here

    if (sequenceReport.getSequenceStatus()!=SequenceReport.SEQUENCE_STATUS_ESTABLISHED)
      throw new SandeshaException ("Canot close the sequence since it is not active");
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
    SequencePropertyBean sequenceIDBean = seqPropMgr.retrieve(internalSequenceID,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
    if (sequenceIDBean==null)
      throw new SandeshaException ("SequenceIdBean is not set");
   
    String sequenceID = sequenceIDBean.getValue();

    if (sequenceID==null)
      throw new SandeshaException ("Cannot find the sequenceID");
   
    String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
View Full Code Here

   
    return dummyEnvelope;
  }
 
  private static boolean isSequenceTerminated (String internalSequenceID, SequencePropertyBeanMgr seqPropMgr) throws SandeshaException {
    SequencePropertyBean internalSequenceFindBean = new SequencePropertyBean ();
    internalSequenceFindBean.setValue(internalSequenceID);
    internalSequenceFindBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
   
    SequencePropertyBean internalSequenceBean = seqPropMgr.findUnique(internalSequenceFindBean);
    if (internalSequenceBean==null) {
      String message = "Internal sequence Bean is not available for the given sequence";
      log.debug (message);
     
      return false;
    }
   
    String outSequenceID = internalSequenceBean.getSequenceID();
 
    SequencePropertyBean sequenceTerminatedBean = seqPropMgr.retrieve(outSequenceID,Sandesha2Constants.SequenceProperties.SEQUENCE_TERMINATED);
    if (sequenceTerminatedBean!=null && Sandesha2Constants.VALUE_TRUE.equals(sequenceTerminatedBean.getValue())) {
      return true;
    }
   
    return false;
  }
View Full Code Here

   
    return false;
  }
 
  private static boolean isSequenceTimedout (String internalSequenceID, SequencePropertyBeanMgr seqPropMgr) throws SandeshaException {
    SequencePropertyBean internalSequenceFindBean = new SequencePropertyBean ();
    internalSequenceFindBean.setValue(internalSequenceID);
    internalSequenceFindBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
   
    SequencePropertyBean internalSequenceBean = seqPropMgr.findUnique(internalSequenceFindBean);
    if (internalSequenceBean==null) {
      String message = "Internal sequence Bean is not available for the given sequence";
      log.debug (message);
     
      return false;
    }
   
    String outSequenceID = internalSequenceBean.getSequenceID();
    SequencePropertyBean sequenceTerminatedBean = seqPropMgr.retrieve(outSequenceID,Sandesha2Constants.SequenceProperties.SEQUENCE_TIMED_OUT);
    if (sequenceTerminatedBean!=null && Sandesha2Constants.VALUE_TRUE.equals(sequenceTerminatedBean.getValue())) {
      return true;
    }
   
    return false;
  }
View Full Code Here

   
    return false;
  }
 
  private static void fillTerminatedOutgoingSequenceInfo (SequenceReport report,String internalSequenceID,SequencePropertyBeanMgr seqPropMgr) throws SandeshaException  {
    SequencePropertyBean internalSequenceFindBean = new SequencePropertyBean ();
    internalSequenceFindBean.setValue(internalSequenceID);
    internalSequenceFindBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
   
    SequencePropertyBean internalSequenceBean = seqPropMgr.findUnique(internalSequenceFindBean);
    if (internalSequenceBean==null) {
      String message = "Not a valid terminated sequence. Internal sequence Bean is not available for the given sequence";
      log.debug (message);
     
      throw new SandeshaException (message);
    }
   
    report.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_TERMINATED);
   
    String outSequenceID = internalSequenceBean.getSequenceID();
    fillOutgoingSequenceInfo(report,outSequenceID,seqPropMgr);
  }
View Full Code Here

    String outSequenceID = internalSequenceBean.getSequenceID();
    fillOutgoingSequenceInfo(report,outSequenceID,seqPropMgr);
  }
 
  private static void fillTimedoutOutgoingSequenceInfo (SequenceReport report,String internalSequenceID, SequencePropertyBeanMgr seqPropMgr) throws SandeshaException  {
    SequencePropertyBean internalSequenceFindBean = new SequencePropertyBean ();
    internalSequenceFindBean.setValue(internalSequenceID);
    internalSequenceFindBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
   
    SequencePropertyBean internalSequenceBean = seqPropMgr.findUnique(internalSequenceFindBean);
    if (internalSequenceBean==null) {
      String message = "Not a valid timedOut sequence. Internal sequence Bean is not available for the given sequence";
      log.debug (message);
     
      throw new SandeshaException (message);
    }
   
    report.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_TIMED_OUT);
    String outSequenceID = internalSequenceBean.getSequenceID();
    fillOutgoingSequenceInfo(report,outSequenceID,seqPropMgr);
  }
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beans.SequencePropertyBean

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.