Package org.apache.sandesha2.storage

Examples of org.apache.sandesha2.storage.StorageManager


    // Open a connection to the endpoint
    HttpURLConnection connection =
      FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
          pingAction);

    StorageManager storageManager =
      SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
   
    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
   
    String seqID = SandeshaUtil.getUUID();
   
    // Mockup an RMDBean
    RMDBean rmdBean = new RMDBean();
    rmdBean.setSequenceID(seqID);
    rmdBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmdBean.setServerCompletedMessages(new RangeString());
    // Flag that the sequence is closed.
    rmdBean.setClosed(true);
   
    // Create a transaction and insert the RMSBean
    Transaction tran = storageManager.getTransaction();
   
    rmdBeanMgr.insert(rmdBean);
   
    tran.commit();
View Full Code Here


    MessageContext msgCtx = rmMsgCtx.getMessageContext();

    String sequenceId = closeSequence.getIdentifier().getIdentifier();
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());

    RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);

    // Check that the sender of this CloseSequence holds the correct token
    if(rmdBean != null && rmdBean.getSecurityTokenData() != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(msgCtx.getConfigurationContext());
      OMElement body = msgCtx.getEnvelope().getBody();
      SecurityToken token = secManager.recoverSecurityToken(rmdBean.getSecurityTokenData());
      secManager.checkProofOfPossession(token, body, msgCtx);
    }

    if (FaultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: CloseSequenceProcessor::processInMessage, Unknown sequence " + sequenceId);
      return false;
    }
   
    // throwing a fault if the sequence is terminated
    if (FaultManager.checkForSequenceTerminated(rmMsgCtx, sequenceId, rmdBean, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: CloseSequenceProcessor::processInMessage, Sequence terminated");
      return false;
    }

    rmdBean.setClosed(true);
    storageManager.getRMDBeanMgr().update(rmdBean);

    RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(rmMsgCtx, rmdBean, sequenceId, storageManager, true);
    // adding the ack part(s) to the envelope.
    Iterator sequenceAckIter = ackRMMsgCtx
        .getMessageParts(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
View Full Code Here

    String sequenceId = ackRequested.getIdentifier().getIdentifier();

    MessageContext msgContext = rmMsgCtx.getMessageContext();
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();

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

    //Getting the operation for ack messages.
    AxisOperation ackOperation = SpecSpecificConstants.getWSRMOperation(
        Sandesha2Constants.MessageTypes.ACK,
        rmdBean.getRMVersion(),
        msgContext.getAxisService());
   
    MessageContext ackMsgCtx = SandeshaUtil.createNewRelatedMessageContext(rmMsgCtx, ackOperation);
   
    //setting up the RMMsgContext
    RMMsgContext ackRMMsgCtx = MsgInitializer.initializeMessage(ackMsgCtx);
    ackRMMsgCtx.setRMNamespaceValue(rmMsgCtx.getRMNamespaceValue());
       
    ackMsgCtx.setTo(acksTo);
       
    ackRMMsgCtx.setRMNamespaceValue(rmMsgCtx.getRMNamespaceValue());
   
    if (ackMsgCtx.getMessageID()==null)
      ackMsgCtx.setMessageID(SandeshaUtil.getUUID());
   
    //adding the SOAP Envelope
    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(msgContext.getEnvelope()));
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    try {
      ackMsgCtx.setEnvelope(envelope);
    } catch (AxisFault e3) {
      throw new SandeshaException(e3.getMessage());
    }

    ackMsgCtx.setReplyTo(msgContext.getTo());
    RMMsgCreator.addAckMessage(ackRMMsgCtx, sequenceId, rmdBean);
   
    //this is not a client generated message. So set serverSide to true.
    ackMsgCtx.setServerSide(true);

    if (acksTo.hasAnonymousAddress()) {
      //If acksTo is anonymous we will be sending the ack here it self. Transport will use what ever mechanism to send the
      //message. (for e.g. HTTP will use the back channel)

      // setting "response written" since acksto is anonymous
     
      //adding an OperationContext if one is not available. (for e.g. If we are in the SandeshaGlobalInHandler)
      if (rmMsgCtx.getMessageContext().getOperationContext() == null) {
        // operation context will be null when doing in a GLOBAL
        // handler.
       
        ServiceContext serviceCtx = msgContext.getServiceContext();
        OperationContext opCtx =  OperationContextFactory.createOperationContext(ackOperation.getAxisSpecificMEPConstant(), ackOperation, serviceCtx);

        rmMsgCtx.getMessageContext().setOperationContext(opCtx);
      }
     
      try {
        AxisEngine.send(ackMsgCtx);
        TransportUtils.setResponseWritten(ackMsgCtx, true);
      } catch (AxisFault e1) {
        throw new SandeshaException(e1.getMessage());
      }

    } else {
      //If AcksTo is non-anonymous we will be adding a senderBean entry here. The sender is responsible
      //for sending it out.
     
      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

      String key = SandeshaUtil.getUUID();

      // dumping to the storage will be done be Sandesha2 Transport Sender
      // storageManager.storeMessageContext(key,ackMsgCtx);
View Full Code Here

      boolean pending = messagePending.isPending();
      if (pending) {
        SequenceEntry entry = (SequenceEntry) message.getProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY);
        if(entry != null) {
          ConfigurationContext context = message.getConfigurationContext();
          StorageManager storage = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
          PollingManager pollingManager = storage.getPollingManager();
          if(pollingManager != null) pollingManager.schedulePollingRequest(entry.getSequenceId(), entry.isRmSource());
        }
      }
    }
     
View Full Code Here

    MakeConnection makeConnection = (MakeConnection) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.MAKE_CONNECTION);
    Address address = makeConnection.getAddress();
    Identifier identifier = makeConnection.getIdentifier();
   
    ConfigurationContext configurationContext = rmMsgCtx.getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
   
    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
   
    //selecting the set of SenderBeans that suit the given criteria.
    SenderBean findSenderBean = new SenderBean ();
    findSenderBean.setSend(true);
    findSenderBean.setTransportAvailable(false);
View Full Code Here

    // Open a connection to the endpoint
    HttpURLConnection connection =
      FaultTestUtils.getHttpURLConnection("http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService",
          pingAction);

    StorageManager storageManager =
      SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
   
    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
   
    String seqID = SandeshaUtil.getUUID();
   
    // Mockup an RMSBean
    RMDBean rmdBean = new RMDBean();
    rmdBean.setSequenceID(seqID);
    rmdBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmdBean.setServerCompletedMessages(new RangeString());
    rmdBean.getServerCompletedMessages().addRange(new Range(1, Long.MAX_VALUE -1));
    rmdBean.getServerCompletedMessages().addRange(new Range(Long.MAX_VALUE, Long.MAX_VALUE));
   
    // Create a transaction and insert the RMSBean
    Transaction tran = storageManager.getTransaction();
   
    rmdBeanMgr.insert(rmdBean);
   
    tran.commit();
View Full Code Here

    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      try {
        // Get the storage manager from the ConfigurationContext
        StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
       
        // Get the sequence id for this sequence.
        String sequenceId = SandeshaClient.getSequenceID(serviceClient);
       
        // Get the SenderBeanManager
        SenderBeanMgr senderManager = storageManager.getSenderBeanMgr();
           
        Transaction transaction = storageManager.getTransaction();
       
        // Check that there are no sender beans inside the SenderBeanMgr.
        SenderBean senderBean = new SenderBean();
        senderBean.setSequenceID(sequenceId);
        senderBean.setSend(true);
View Full Code Here

    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      // Check that the sequence has been deleted.
      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMSBean finderBean = new RMSBean();
      List rmsBeans = storageManager.getRMSBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
     
View Full Code Here

    Error lastError = null;
    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      // Check that the sequence has been deleted.
      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMDBean finderBean = new RMDBean();
      List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
     
      if (rmdBeans.isEmpty())
        lastError = new Error("rmdBeans empty " + rmdBeans);
      else {
        RMDBean bean = (RMDBean)rmdBeans.get(0);
        if (bean.isTerminated())
          break;
       
        lastError = new Error("RMDBean not deleted " + bean);
      }
    }

    if(lastError != null) throw lastError;

    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      // Check that the sequence has been deleted.
      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMDBean finderBean = new RMDBean();
      List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
     
View Full Code Here

      //now deliver the next out of order
      clientOptions.setProperty(SandeshaClientConstants.MESSAGE_NUMBER,new Long(3));
      serviceClient.fireAndForget(getPingOMBlock("ping3"));
 
      Thread.sleep(5000);
      StorageManager mgr = SandeshaUtil.getInMemoryStorageManager(configContext);
      Transaction t = mgr.getTransaction();
      String inboundSequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(SandeshaUtil.getInternalSequenceID(to, sequenceKey),
          mgr);
      t.commit();
     
      SandeshaClient.forceDispatchOfInboundMessages(serverConfigCtx,
          inboundSequenceID,
          true); //allow later msgs to be delivered
     
      //check that the server is now expecting msg 4
      StorageManager serverStore = SandeshaUtil.getInMemoryStorageManager(serverConfigCtx);
      t = serverStore.getTransaction();
      RMDBean rMDBean =
        serverStore.getRMDBeanMgr().retrieve(inboundSequenceID);
      assertNotNull(rMDBean);
      assertEquals(rMDBean.getNextMsgNoToProcess(), 4);
     
      //also check that the sequence has an out of order gap that contains msg 2     
      assertNotNull(rMDBean.getOutOfOrderRanges());
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.StorageManager

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.