Package org.apache.axis2.engine

Examples of org.apache.axis2.engine.AxisEngine


    FaultManager faultManager = new FaultManager();
    RMMsgContext faultMessageContext = faultManager.checkForCreateSequenceRefused(createSeqMsg);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = createSeqMsg.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }

    MessageContext outMessage = null;
    outMessage = Utils.createOutMessageContext(createSeqMsg)//createing a new response message.
   
    ConfigurationContext context = createSeqMsg.getConfigurationContext();
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
    Transaction createSequenceTransaction = storageManager.getTransaction();   //begining of a new transaction

    try {
      String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg)//newly created sequnceID.
     
      RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(
          createSeqRMMsg, outMessage,newSequenceId);    // 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 = "An accept part has not been generated for the create seq request with an offer part";
          log.debug(message);
          throw new SandeshaException(message);
        }

        String offeredSequenceID = offer.getIdentifer().getIdentifier(); //offered seq. id.
       
        boolean offerEcepted = offerAccepted (offeredSequenceID,context,createSeqRMMsg);
       
        if (offerEcepted)  {
          //Setting the CreateSequence table entry for the outgoing side.
          CreateSeqBean createSeqBean = new CreateSeqBean();
          createSeqBean.setSequenceID(offeredSequenceID);
          String outgoingSideInternalSequenceID = SandeshaUtil.getOutgoingSideInternalSequenceID(newSequenceId);
          createSeqBean.setInternalSequenceID(outgoingSideInternalSequenceID);
          createSeqBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); //this is a dummy value.
       
          CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
          createSeqMgr.insert(createSeqBean);
       
          //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.setSequenceID(outgoingSideInternalSequenceID);
          seqPropMgr.insert(outSequenceBean);

          //setting the internal_sequence_id
          SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
          internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
          internalSequenceBean.setSequenceID(offeredSequenceID);
          internalSequenceBean.setValue(outgoingSideInternalSequenceID);
          seqPropMgr.insert(internalSequenceBean);
        } else {
          //removing the accept part.
          createSeqResPart.setAccept(null);
          createSeqResponse.addSOAPEnvelope();
        }
      }

      EndpointReference acksTo = createSeqPart.getAcksTo().getAddress().getEpr();
      if (acksTo == null || acksTo.getAddress() == null
          || acksTo.getAddress() == "") {
        String message = "Acks to not present in the create sequence message";
        log.debug(message);
        throw new AxisFault(message);
      }

      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.
      createSequenceTransaction.commit();
     
      Transaction updateLastActivatedTransaction = storageManager.getTransaction();
      SequenceManager.updateLastActivatedTime(newSequenceId,createSeqRMMsg.getMessageContext().getConfigurationContext());
      updateLastActivatedTransaction.commit();
     
      AxisEngine engine = new AxisEngine(context);
      engine.send(outMessage);
     
      SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,Sandesha2Constants.SequenceProperties.TO_EPR);
      if (toBean==null) {
        String message = "Internal Error: wsa:To value is not set";
        log.debug(message);
View Full Code Here


    terminateRMMessage.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY,key);
    terminateRMMessage.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE,Sandesha2Constants.VALUE_TRUE);
    terminateRMMessage.getMessageContext().setTransportOut(new Sandesha2TransportOutDesc ());
    addTerminateSeqTransaction.commit();
   
      AxisEngine engine = new AxisEngine (configurationContext);
      try {
      engine.send(terminateRMMessage.getMessageContext());
    } catch (AxisFault e) {
      throw new SandeshaException (e.getMessage());
    }
     
  }
View Full Code Here

   
    FaultManager faultManager = new FaultManager();
    RMMsgContext faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx,sequenceID);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
   
    Transaction closeSequenceTransaction = storageManager.getTransaction();
   
    SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropretyBeanMgr();
    SequencePropertyBean sequenceClosedBean = new SequencePropertyBean ();
    sequenceClosedBean.setSequenceID(sequenceID);
    sequenceClosedBean.setName(Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED);
    sequenceClosedBean.setValue(Sandesha2Constants.VALUE_TRUE);
   
    sequencePropMgr.insert(sequenceClosedBean);
   
    RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(rmMsgCtx,sequenceID);
   
    MessageContext ackMsgCtx = ackRMMsgCtx.getMessageContext();
   
    String rmNamespaceValue = rmMsgCtx.getRMNamespaceValue();
    ackRMMsgCtx.setRMNamespaceValue(rmNamespaceValue);
   

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(rmMsgCtx.getSOAPEnvelope()));
   
    //Setting new envelope
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    try {
      ackMsgCtx.setEnvelope(envelope);
    } catch (AxisFault e3) {
      throw new SandeshaException(e3.getMessage());
    }
   
    //adding the ack part to the envelope.
    SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) ackRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
 
    MessageContext closeSequenceMsg = rmMsgCtx.getMessageContext();
   
    MessageContext closeSequenceResponseMsg = null;
    closeSequenceResponseMsg = Utils.createOutMessageContext(closeSequenceMsg);
   
    RMMsgContext closeSeqResponseRMMsg = RMMsgCreator
        .createCloseSeqResponseMsg(rmMsgCtx, closeSequenceResponseMsg);
   
    closeSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,sequenceAcknowledgement);
   
    closeSeqResponseRMMsg.setFlow(MessageContext.OUT_FLOW);
    closeSeqResponseRMMsg.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true");

    closeSequenceResponseMsg.setResponseWritten(true);
   
    closeSeqResponseRMMsg.addSOAPEnvelope();
   
    AxisEngine engine = new AxisEngine (closeSequenceMsg.getConfigurationContext());
   
    try {
      engine.send(closeSequenceResponseMsg);
    } catch (AxisFault e) {
      String message = "Could not send the terminate sequence response";
      throw new SandeshaException (message,e);
    }
   
View Full Code Here

    FaultManager faultManager = new FaultManager();
    RMMsgContext faultMessageContext = faultManager.checkForLastMsgNumberExceeded(rmMsgCtx);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }
   
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    //setting acked msg no range
    Sequence sequence = (Sequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
        .getConfigurationContext();
    if (configCtx == null) {
      String message = "Configuration Context is null";
      log.debug(message);
      throw new SandeshaException(message);
    }

    faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx,sequenceId);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.send(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }
   
    //setting mustUnderstand to false.
    sequence.setMustUnderstand(false);
    rmMsgCtx.addSOAPEnvelope();
   
    //throwing a fault if the sequence is closed.
    faultMessageContext = faultManager. checkForSequenceClosed(rmMsgCtx,sequenceId);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
View Full Code Here

      rmMsgCtx.addSOAPEnvelope();
    }
   
     RMMsgContext ackRMMessage = AcknowledgementManager.generateAckMessage(rmMsgCtx,sequenceId);
   
     AxisEngine engine = new AxisEngine (configCtx);
    
     try {
      engine.send(ackRMMessage.getMessageContext());
    } catch (AxisFault e) {
      String message = "Exception thrown while trying to send the ack message";
      throw new SandeshaException (message,e);
    }
  }
View Full Code Here

   
    Sandesha2TransportOutDesc sandesha2TransportOutDesc = new Sandesha2TransportOutDesc ();
    createSeqMsg.setTransportOut(sandesha2TransportOutDesc);

    // sending the message once through Sandesha2TransportSender.
    AxisEngine engine = new AxisEngine(createSeqMsg.getConfigurationContext());
     try {
       engine.send(createSeqMsg);
     } catch (AxisFault e) {
       throw new SandeshaException (e.getMessage());
     }
  }
View Full Code Here

    //increasing the current handler index, so that the message will not be going throught the SandeshaOutHandler again.
    msg.setCurrentHandlerIndex(msg.getCurrentHandlerIndex()+1);
   
    //sending the message through, other handlers and the Sandesha2TransportSender so that it get dumped to the storage.
    AxisEngine engine = new AxisEngine (msg.getConfigurationContext());
    try {
      engine.resumeSend(msg);
    } catch (AxisFault e) {
      throw new SandeshaException (e);
    }
  } 
View Full Code Here

    String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(sequenceID,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,configurationContext);
    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
   
    if (anonymousURI.equals(acksTo.getAddress())) {

      AxisEngine engine = new AxisEngine(ackRMMsgCtx.getMessageContext()
          .getConfigurationContext());

      //setting CONTEXT_WRITTEN since acksto is anonymous
      if (rmMsgCtx.getMessageContext().getOperationContext() == null) {
        //operation context will be null when doing in a GLOBAL
        // handler.
        try {
          AxisOperation op = AxisOperationFactory
              .getAxisOperation(AxisOperationFactory.MEP_CONSTANT_IN_OUT);
          OperationContext opCtx = new OperationContext(op);
          rmMsgCtx.getMessageContext().setAxisOperation(op);
          rmMsgCtx.getMessageContext().setOperationContext(opCtx);
        } catch (AxisFault e2) {
          throw new SandeshaException(e2.getMessage());
        }
      }

      rmMsgCtx.getMessageContext().getOperationContext().setProperty(
          org.apache.axis2.Constants.RESPONSE_WRITTEN,
          Constants.VALUE_TRUE);

      rmMsgCtx.getMessageContext().setProperty(
          Sandesha2Constants.ACK_WRITTEN, "true");
      try {
        engine.send(ackRMMsgCtx.getMessageContext());
      } catch (AxisFault e1) {
        throw new SandeshaException(e1.getMessage());
      }
    } else {

      Transaction asyncAckTransaction = storageManager.getTransaction();

      SenderBeanMgr retransmitterBeanMgr = storageManager
          .getRetransmitterBeanMgr();

      String key = SandeshaUtil.getUUID();
     
      //dumping to the storage will be done be Sandesha2 Transport Sender
      //storageManager.storeMessageContext(key,ackMsgCtx);
     
      SenderBean ackBean = new SenderBean();
      ackBean.setMessageContextRefKey(key);
      ackBean.setMessageID(ackMsgCtx.getMessageID());
      ackBean.setReSend(false);
      ackBean.setSequenceID(sequenceID);
     
      //this will be set to true in the sender.
      ackBean.setSend(true);
     
      ackMsgCtx.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,
          Sandesha2Constants.VALUE_FALSE);
     
      ackBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
     
      //the internalSequenceId value of the retransmitter Table for the
      // messages related to an incoming
      //sequence is the actual sequence ID

      //operation is the lowest level, Sandesha2 can be engaged.
      SandeshaPropertyBean propertyBean = SandeshaUtil.getPropertyBean(msgContext.getAxisOperation());
     
     
      long ackInterval = propertyBean.getAcknowledgementInaterval();
     
      //Ack will be sent as stand alone, only after the retransmitter
      // interval.
      long timeToSend = System.currentTimeMillis() + ackInterval;

      //removing old acks.
      SenderBean findBean = new SenderBean();
      findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
     
      //this will be set to true in the sandesha2TransportSender.
      findBean.setSend(true);
      findBean.setReSend(false);
      Collection coll = retransmitterBeanMgr.find(findBean);
      Iterator it = coll.iterator();

      if (it.hasNext()) {
        SenderBean oldAckBean = (SenderBean) it.next();
        timeToSend = oldAckBean.getTimeToSend();    //If there is an old ack. This ack will be sent in the old timeToSend.
        retransmitterBeanMgr.delete(oldAckBean.getMessageID());
      }
     
      ackBean.setTimeToSend(timeToSend);

      storageManager.storeMessageContext(key,ackMsgCtx);
     
      //inserting the new ack.
      retransmitterBeanMgr.insert(ackBean);

      asyncAckTransaction.commit();

      //passing the message through sandesha2sender

      ackMsgCtx.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC,ackMsgCtx.getTransportOut());
      ackMsgCtx.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE,Sandesha2Constants.VALUE_TRUE);
     
      ackMsgCtx.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY,key);
     
      ackMsgCtx.setTransportOut(new Sandesha2TransportOutDesc ());
     
      AxisEngine engine = new AxisEngine (configurationContext);
      try {
        engine.send(ackMsgCtx);
      } catch (AxisFault e) {
        throw new SandeshaException (e.getMessage());
      }
     
      SandeshaUtil.startSenderForTheSequence(configurationContext,sequenceID);
View Full Code Here

    FaultManager faultManager = new FaultManager();
    RMMsgContext faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx,outSequenceId);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }
   
    faultMessageContext = faultManager.checkForInvalidAcknowledgement(rmMsgCtx);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
View Full Code Here

                }
            }

            oc.addMessageContext(mc);
            // ship it out
            AxisEngine engine = new AxisEngine(cc);
            engine.send(mc);
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.axis2.engine.AxisEngine

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.