Examples of RMDBean


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

    if (log.isDebugEnabled())
      log.debug("Enter: TerminateSeqMsgProcessor::setUpHighestMsgNumbers, " + sequenceId);

    RMDBeanMgr mgr = storageManager.getRMDBeanMgr();
    RMDBean bean = mgr.retrieve(sequenceId);

    long highestInMsgNo = bean.getHighestInMessageNumber();

    // following will be valid only for the server side, since the obtained
    // int. seq ID is only valid there.
    String responseSideInternalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(sequenceId);
   
   
    long highestOutMsgNo = 0;
    try {
      boolean addResponseSideTerminate = false;
      if (highestInMsgNo == 0) {
        addResponseSideTerminate = false;
      } else {
        // Mark up the highest inbound message as if it had the last message flag on it.
        //
        String inMsgId = bean.getHighestInMessageId();
        bean.setLastInMessageId(inMsgId);
       
        // Update the RMDBean
        storageManager.getRMDBeanMgr().update(bean);
       
        // If an outbound message has already gone out with that relatesTo, then we can terminate
View Full Code Here

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

        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.accptButNoSequenceOffered);
        log.debug(message);
        throw new SandeshaException(message);
      }

      RMDBean rMDBean = new RMDBean();
     
      EndpointReference acksToEPR = accept.getAcksTo().getEPR();
      rMDBean.setAcksToEPR(acksToEPR.getAddress());
      rMDBean.setSequenceID(rmsBean.getOfferedSequence());
      rMDBean.setNextMsgNoToProcess(1);
      rMDBean.setOutboundInternalSequence(rmsBean.getInternalSequenceID());

      rMDBean.setServiceName(createSeqResponseRMMsgCtx.getMessageContext().getAxisService().getName());
     
      //Storing the referenceMessage of the sending side sequence as the reference message
      //of the receiving side as well.
      //This can be used when creating new outgoing messages.
     
      String referenceMsgStoreKey = rmsBean.getReferenceMessageStoreKey();
      MessageContext referenceMsg = storageManager.retrieveMessageContext(referenceMsgStoreKey, configCtx);
     
      String newMessageStoreKey = SandeshaUtil.getUUID();
      storageManager.storeMessageContext(newMessageStoreKey,referenceMsg);
     
      rMDBean.setReferenceMessageKey(newMessageStoreKey);

      // If this is an offered sequence that needs polling then we need to setup the
      // rmdBean for polling too, so that it still gets serviced after the outbound
      // sequence terminates.
      if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(createSeqResponseRMMsgCtx.getRMSpecVersion())) {
        if(rmsBean.isPollingMode()) {
          rMDBean.setPollingMode(true);
        }
      }
     
      String rmSpecVersion = createSeqResponseRMMsgCtx.getRMSpecVersion();
      rMDBean.setRMVersion(rmSpecVersion);
     
      EndpointReference toEPR = createSeqResponseRMMsgCtx.getTo();
      if (toEPR==null) {
        //Most probably this is a sync response message, using the replyTo of the request message
        OperationContext operationContext = createSeqResponseRMMsgCtx.getMessageContext().getOperationContext();
        if (operationContext!=null) {
          MessageContext createSequnceMessage = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
          if (createSequnceMessage!=null)
            toEPR = createSequnceMessage.getReplyTo();
        }
      }
     
      if (toEPR!=null)
        rMDBean.setToAddress(toEPR.getAddress());
     
      rMDBean.setServerCompletedMessages(new RangeString());
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();

      // Store the security token for the offered sequence
      rMDBean.setSecurityTokenData(rmsBean.getSecurityTokenData());
     
      rMDBean.setLastActivatedTime(System.currentTimeMillis());
     
      rmdBeanMgr.insert(rMDBean);
      SandeshaUtil.startWorkersForSequence(configCtx, rMDBean);
    }
   
View Full Code Here

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

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,
        configurationContext.getAxisConfiguration());
   
    // Check that the sender of this AckRequest holds the correct token
    RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);

    if(rmdBean != null && rmdBean.getSecurityTokenData() != null) {;
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configurationContext);
      SecurityToken token = secManager.recoverSecurityToken(rmdBean.getSecurityTokenData());
     
      secManager.checkProofOfPossession(token, soapHeader, msgContext);
    }

    // Check that the sequence requested exists
    if (FaultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager, piggybackedAckRequest)) {
      if (log.isDebugEnabled())
        log.debug("Exit: AckRequestedProcessor::processAckRequestedHeader, Unknown sequence ");
      return false;
    }

    // throwing a fault if the sequence is terminated
    if (FaultManager.checkForSequenceTerminated(rmMsgCtx, sequenceId, rmdBean, piggybackedAckRequest)) {
      if (log.isDebugEnabled())
        log.debug("Exit: AckRequestedProcessor::processAckRequestedHeader, Sequence terminated");
      return false;
    }

    // Setting the ack depending on AcksTo.
    EndpointReference acksTo = new EndpointReference(rmdBean.getAcksToEPR());
    String acksToStr = acksTo.getAddress();

    if (acksToStr == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.acksToStrNotSet));

    AxisOperation ackOperation = SpecSpecificConstants.getWSRMOperation(
        Sandesha2Constants.MessageTypes.ACK,
        rmdBean.getRMVersion(),
        msgContext.getAxisService());
    MessageContext ackMsgCtx = SandeshaUtil.createNewRelatedMessageContext(rmMsgCtx, ackOperation);

    ackMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
View Full Code Here

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

    EndpointReference target = rmMessageContext.getTo();
    if(target == null || target.hasAnonymousAddress()) {
      if(target != null && SandeshaUtil.isWSRMAnonymous(target.getAddress())) {
        // Search for any sequences that have an acksTo that matches this target, and add an ack
        // for each of them.
        RMDBean findBean = new RMDBean();
        findBean.setAcksToEPR(target.getAddress());
        findBean.setTerminated(false);
        Collection rmdBeans = storageManager.getRMDBeanMgr().find(findBean);
        Iterator sequences = rmdBeans.iterator();
        while(sequences.hasNext()) {
          RMDBean sequence = (RMDBean) sequences.next();
          if (sequence.getHighestInMessageNumber() > 0) {
            if(log.isDebugEnabled()) log.debug("Piggybacking ack for sequence: " + sequence.getSequenceID());
            RMMsgCreator.addAckMessage(rmMessageContext, sequence.getSequenceID(), sequence);
          }
        }
       
      } else {
        // We have no good indicator of the identity of the destination, so the only sequence
        // we can ack is the inbound one that caused us to create this response.
        String inboundSequence = (String) rmMessageContext.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
        if(inboundSequence != null) {
          RMDBean inboundBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
          if(inboundBean != null && !inboundBean.isTerminated()) {
            String acksTo = inboundBean.getAcksToEPR();
            EndpointReference acksToEPR = new EndpointReference(acksTo);
           
            if(acksTo == null || acksToEPR.hasAnonymousAddress()) {
              if(log.isDebugEnabled()) log.debug("Piggybacking ack for inbound sequence: " + inboundSequence);
              RMMsgCreator.addAckMessage(rmMessageContext, inboundSequence, inboundBean);
            }
          }
        }
      }
      if(log.isDebugEnabled()) log.debug("Exit: AcknowledgementManager::piggybackAcksIfPresent, anon");
      return;
    }
   
    // From here on, we must be dealing with a real address. Piggyback all sequences that have an
    // acksTo that matches the To address, and that have an ackMessage queued up for sending.
    Set acked = new HashSet();
    SenderBean findBean = new SenderBean();
    findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
    findBean.setSend(true);
    findBean.setToAddress(target.getAddress());

    Collection collection = retransmitterBeanMgr.find(findBean);
    Iterator it = collection.iterator();
    while (it.hasNext()) {
      SenderBean ackBean = (SenderBean) it.next();

      // Piggybacking will happen only if the end of ack interval (timeToSend) is not reached.
      long timeNow = System.currentTimeMillis();
      if (ackBean.getTimeToSend() > timeNow) {
        // Delete the beans that would have sent the ack
        retransmitterBeanMgr.delete(ackBean.getMessageID());
        storageManager.removeMessageContext(ackBean.getMessageContextRefKey());

        String sequenceId = ackBean.getSequenceID();
        if (log.isDebugEnabled()) log.debug("Piggybacking ack for sequence: " + sequenceId);

        RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);
        if(rmdBean != null && !rmdBean.isTerminated()) {
          RMMsgCreator.addAckMessage(rmMessageContext, sequenceId, rmdBean);
        }
        acked.add(sequenceId);
      }
    }
   
    // As a special case, if this is a terminate sequence message then add in ack messages for
    // any sequences that have an acksTo that matches the target address. This helps to ensure
    // that request-response sequence pairs end cleanly.
    if(rmMessageContext.getMessageType() == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
      if(log.isDebugEnabled()) log.debug("Adding extra acks, as this is a terminate");
     
      RMDBean findRMDBean = new RMDBean();
      findRMDBean.setAcksToEPR(target.getAddress());
      findRMDBean.setTerminated(false);
      Collection rmdBeans = storageManager.getRMDBeanMgr().find(findRMDBean);
      Iterator sequences = rmdBeans.iterator();
      while(sequences.hasNext()) {
        RMDBean sequence = (RMDBean) sequences.next();
        String sequenceId = sequence.getSequenceID();
       
        if(!acked.contains(sequenceId) && sequence.getHighestInMessageNumber() > 0) {
          if(log.isDebugEnabled()) log.debug("Piggybacking ack for sequence: " + sequenceId);
          RMMsgCreator.addAckMessage(rmMessageContext, sequenceId, sequence);
          acked.add(sequenceId);
        }
      }
View Full Code Here

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

      log.debug("Enter: SequenceManager::setupNewSequence");
   
    String sequenceId = SandeshaUtil.getUUID();

    // Generate the new RMD Bean
    RMDBean rmdBean = new RMDBean();

    EndpointReference to = createSequenceMsg.getTo();
    if (to == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
      log.debug(message);
      throw new AxisFault(message);
    }

    EndpointReference replyTo = createSequenceMsg.getReplyTo();

    CreateSequence createSequence = (CreateSequence) createSequenceMsg
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    if (createSequence == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound);
      log.debug(message);
      throw new AxisFault(message);
    }

    EndpointReference acksTo = createSequence.getAcksTo().getEPR();

    if (acksTo == null) {
      FaultManager.makeCreateSequenceRefusedFault(createSequenceMsg, SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence), new Exception());
    } else if (acksTo.getAddress().equals(AddressingConstants.Final.WSA_NONE_URI)){
      FaultManager.makeCreateSequenceRefusedFault(createSequenceMsg, "AcksTo can not be " + AddressingConstants.Final.WSA_NONE_URI, new Exception());
    }

    MessageContext createSeqContext = createSequenceMsg.getMessageContext();
   
    // If this create is the result of a MakeConnection, then we must have a related
    // outbound sequence.
    SequenceEntry entry = (SequenceEntry) createSeqContext.getProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY);
    if(log.isDebugEnabled()) log.debug("This message is associated with sequence entry: " + entry);
    if(entry != null && entry.isRmSource()) {
      rmdBean.setOutboundInternalSequence(entry.getSequenceId());
    }

    rmdBean.setServerCompletedMessages(new RangeString());
   
    rmdBean.setReplyToEPR(to.getAddress());
    rmdBean.setAcksToEPR(acksTo.getAddress());

    // If no replyTo value. Send responses as sync.
    if (replyTo != null)
      rmdBean.setToEPR(replyTo.getAddress());

    // Store the security token alongside the sequence
    if(token != null) {
      String tokenData = securityManager.getTokenRecoveryData(token);
      rmdBean.setSecurityTokenData(tokenData);
    }   
   
    rmdBean.setSequenceID(sequenceId);
    rmdBean.setNextMsgNoToProcess(1);
   
    rmdBean.setToAddress(to.getAddress());
   
    // If this sequence has a 'To' address that is anonymous then we must have got the
    // message as a response to a poll. We need to make sure that we keep polling until
    // the sequence is closed.
    if(to.hasAnonymousAddress()) {
      String newKey = SandeshaUtil.getUUID();
      rmdBean.setPollingMode(true);
      rmdBean.setReferenceMessageKey(newKey);
      storageManager.storeMessageContext(newKey, createSeqContext);
    }

    String messageRMNamespace = createSequence.getNamespaceValue();

    String specVersion = null;
    if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
    } else if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
    } else {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));
    }

    rmdBean.setRMVersion(specVersion);
    rmdBean.setLastActivatedTime(System.currentTimeMillis());

    storageManager.getRMDBeanMgr().insert(rmdBean);

    // TODO get the SOAP version from the create seq message.
View Full Code Here

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

    rmsBean.setInternalSequenceID(internalSequenceId);

    // If we are server-side, we use the details from the inbound sequence to help set
    // up the reply sequence.
    String inboundSequence = null;
    RMDBean inboundBean = null;
    if(firstAplicationMsgCtx.isServerSide()) {
      inboundSequence = (String) firstAplicationMsgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
      if(inboundSequence != null) {
        inboundBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
      }
    }
   
    // Finding the spec version
    String specVersion = getSpecVersion(firstAplicationMsgCtx, storageManager);
    rmsBean.setRMVersion(specVersion);

    // Set up the To EPR
    EndpointReference toEPR = firstAplicationMsgCtx.getTo();

    if (toEPR == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
      log.debug(message);
      throw new SandeshaException(message);
    }

    rmsBean.setToEPR(toEPR.getAddress());

    // Discover the correct acksTo and replyTo EPR for this RMSBean
    EndpointReference acksToEPR = null;
    EndpointReference replyToEPR = null;

    if (firstAplicationMsgCtx.isServerSide()) {
      // Server side, we want the replyTo and AcksTo EPRs to point into this server.
      // We can work that out by looking at the RMD bean that pulled the message in,
      // and copying its 'ReplyTo' address.
      if(inboundBean != null && inboundBean.getReplyToEPR() != null) {
        acksToEPR = new EndpointReference(inboundBean.getReplyToEPR());
        replyToEPR = new EndpointReference(inboundBean.getReplyToEPR());
      } else {
        String beanInfo = (inboundBean == null) ? "null" : inboundBean.toString();
        String message = SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.cannotChooseAcksTo, inboundSequence, beanInfo);
        SandeshaException e = new SandeshaException(message);
        if(log.isDebugEnabled()) log.debug("Throwing", e);
        throw e;
View Full Code Here

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

  throws SandeshaException
  {
    String specVersion = null;
    if (applicationMessage.isServerSide()) {
      String inboundSequence = null;
      RMDBean inboundBean = null;
      if(applicationMessage.isServerSide()) {
        inboundSequence = (String) applicationMessage.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
        if(inboundSequence != null) {
          inboundBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
        }
      }

      // in the server side, get the RM version from the request sequence.
      if(inboundBean == null || inboundBean.getRMVersion() == null) {
        String beanInfo = (inboundBean == null) ? "null" : inboundBean.toString();
        String message = SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.cannotChooseSpecLevel, inboundSequence, beanInfo );
        SandeshaException e = new SandeshaException(message);
        if(log.isDebugEnabled()) log.debug("Throwing", e);
        throw e;
      }

      specVersion = inboundBean.getRMVersion();
    } else {
      // in the client side, user will set the RM version.
      specVersion = (String) applicationMessage.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
     
      // If the spec version is null, look in the axis operation to see value has been set
View Full Code Here

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

    //adding a MakeConnection for the response sequence if needed.
    if (rmsBean.getOfferedSequence() != null) {

      RMDBeanMgr rMDBeanMgr = storageManager.getRMDBeanMgr();
      RMDBean rMDBean = rMDBeanMgr.retrieve(outSequenceId);
     
      if (rMDBean!=null && rMDBean.isPollingMode()) {
        PollingManager manager = storageManager.getPollingManager();
        if(manager != null) manager.schedulePollingRequest(rMDBean.getSequenceID(), false);
      }
    }

    // We overwrite the previous client completed message ranges with the
    // latest view, but only if it is an update i.e. contained a new
View Full Code Here

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

    public void tearDown() throws Exception {
      transaction.commit();
    }

    public void testDelete() throws SandeshaStorageException{
        mgr.insert(new RMDBean("SeqId1", 1001));
        mgr.delete("SeqId1");
        assertNull(mgr.retrieve("SeqId1"));
    }
View Full Code Here

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

        mgr.delete("SeqId1");
        assertNull(mgr.retrieve("SeqId1"));
    }

    public void testFind() throws SandeshaStorageException {
        mgr.insert(new RMDBean("SeqId2", 1002));
        mgr.insert(new RMDBean("SeqId3", 1002));

        RMDBean target = new RMDBean();
        target.setNextMsgNoToProcess(1002);

        Iterator iterator = mgr.find(target).iterator();
        RMDBean tmp = (RMDBean) iterator.next();

        if (tmp.getSequenceID().equals("SeqId2")) {
            tmp = (RMDBean) iterator.next();
            tmp.getSequenceID().equals("SeqId3");
        } else {
            tmp = (RMDBean) iterator.next();
            tmp.getSequenceID().equals("SeqId2");
        }

    }
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.