Package org.apache.axis2.context

Examples of org.apache.axis2.context.ConfigurationContext


  public boolean processOutMessage(RMMsgContext rmMsgCtx) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: ApplicationMsgProcessor::processOutMessage");

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

    //validating the outgoing message
    MessageValidator.validateOutgoingMessage(rmMsgCtx);
   
    // setting the Fault callback
    SandeshaListener faultCallback = (SandeshaListener) msgContext.getOptions().getProperty(
        SandeshaClientConstants.SANDESHA_LISTENER);
    if (faultCallback != null) {
      OperationContext operationContext = msgContext.getOperationContext();
      if (operationContext != null) {
        operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, faultCallback);
      }
    }

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, configContext
        .getAxisConfiguration());

    boolean serverSide = msgContext.isServerSide();

    // setting message Id if null
    if (msgContext.getMessageID() == null)
      msgContext.setMessageID(SandeshaUtil.getUUID());

    // find internal sequence id
    String internalSequenceId = null;

    String storageKey = SandeshaUtil.getUUID(); // the key which will be
                          // used to store this
                          // message.

    /*
     * Internal sequence id is the one used to refer to the sequence (since
     * actual sequence id is not available when first msg arrives) server
     * side - a derivation of the sequenceId of the incoming sequence client
     * side - a derivation of wsaTo & SeequenceKey
     */

    boolean lastMessage = false;
    if (serverSide) {
      if (inboundSequence == null || "".equals(inboundSequence)) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.incomingSequenceNotValidID, inboundSequence);
        log.debug(message);
        throw new SandeshaException(message);
      }

      internalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(inboundSequence);
    } else {
      // set the internal sequence id for the client side.
      EndpointReference toEPR = msgContext.getTo();
      if (toEPR == null || toEPR.getAddress() == null || "".equals(toEPR.getAddress())) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
        log.debug(message);
        throw new SandeshaException(message);
      }

      String to = toEPR.getAddress();
      String sequenceKey = (String) msgContext.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
      internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);

      String lastAppMessage = (String) msgContext.getProperty(SandeshaClientConstants.LAST_MESSAGE);
      if (lastAppMessage != null && "true".equals(lastAppMessage))
        lastMessage = true;
    }
   
    if (internalSequenceId!=null)
      rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID,internalSequenceId);

    /*
     * checking weather the user has given the messageNumber (most of the
     * cases this will not be the case where the system will generate the
     * message numbers
     */

    // User should set it as a long object.
    Long messageNumberLng = (Long) msgContext.getProperty(SandeshaClientConstants.MESSAGE_NUMBER);

    long givenMessageNumber = -1;
    if (messageNumberLng != null) {
      givenMessageNumber = messageNumberLng.longValue();
      if (givenMessageNumber <= 0) {
        throw new SandeshaException(SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.msgNumberMustBeLargerThanZero, Long.toString(givenMessageNumber)));
      }
    }

    // A dummy message is a one which will not be processed as a actual
    // application message.
    // The RM handlers will simply let these go.
    String dummyMessageString = (String) msgContext.getOptions().getProperty(SandeshaClientConstants.DUMMY_MESSAGE);
    boolean dummyMessage = false;
    if (dummyMessageString != null && Sandesha2Constants.VALUE_TRUE.equals(dummyMessageString))
      dummyMessage = true;

    RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);

    //see if the sequence is closed
    if(rmsBean != null && rmsBean.isSequenceClosedClient()){
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceClosed, internalSequenceId));
    }

    //see if the sequence is terminated
    if(rmsBean != null && rmsBean.isTerminateAdded()) {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTerminated, internalSequenceId));
    }

    //see if the sequence is timed out
    if(rmsBean != null && rmsBean.isTimedOut()){
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTimedout, internalSequenceId));
    }
   
    // If the call application is a 2-way MEP, and uses a anonymous replyTo, and the
    // RM 1.1 spec level, then we must have MakeConnection enabled. We check that here,
    // before we start creating a new Sequence.
    if(!serverSide) {
      AxisOperation op = msgContext.getAxisOperation();
      int mep = WSDLConstants.MEP_CONSTANT_INVALID;
      if(op != null) {
        mep = op.getAxisSpecifMEPConstant();
      }
      if(mep == WSDLConstants.MEP_CONSTANT_OUT_IN) {
        String specVersion = null;
        if(rmsBean == null) {
          specVersion = SequenceManager.getSpecVersion(msgContext, storageManager);
        } else {
          specVersion = rmsBean.getRMVersion();
        }
        if(specVersion == Sandesha2Constants.SPEC_VERSIONS.v1_1) {
          SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(configContext.getAxisConfiguration());
          if(!policy.isEnableMakeConnection()) {
            String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.makeConnectionDisabled);
            throw new SandeshaException(message);
          }
        }
View Full Code Here


    if (log.isDebugEnabled())
      log.debug("Enter: ApplicationMsgProcessor::addCreateSequenceMessage, " + rmsBean);

    MessageContext applicationMsg = applicationRMMsg.getMessageContext();
    ConfigurationContext configCtx = applicationMsg.getConfigurationContext();

    // generating a new create sequeuce message.
    RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);

    createSeqRMMessage.setFlow(MessageContext.OUT_FLOW);
View Full Code Here

      System.out.println("ERROR: Please change <SANDESHA2_HOME> to your Sandesha2 installation directory.");
      return;
    }
   
    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
   
    Options clientOptions = new Options ()
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
    clientOptions.setTo(new EndpointReference (toEPR));
   
    String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
     
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
//    clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
//    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
   
    clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
    ServiceClient serviceClient = new ServiceClient (configContext,null);
    serviceClient.engageModule(new QName ("sandesha2"));
   
    clientOptions.setAction("urn:wsrm:Ping");
    serviceClient.setOptions(clientOptions);
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");

    serviceClient.fireAndForget(getPingOMBlock());
    SandeshaClient.waitUntilSequenceCompleted(serviceClient);
   
    configContext.terminate();
    serviceClient.cleanup();
  }
View Full Code Here

    if (log.isDebugEnabled())
      log.debug("Enter: SandeshaInHandler::invoke, " + msgCtx.getEnvelope().getHeader());

    InvocationResponse returnValue = InvocationResponse.CONTINUE;
   
    ConfigurationContext context = msgCtx.getConfigurationContext();
    if (context == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
      log.debug(message);
      throw new AxisFault(message);
    }

    String DONE = (String) msgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE);
    if (null != DONE && Sandesha2Constants.VALUE_TRUE.equals(DONE)) {
      if (log.isDebugEnabled())
        log.debug("Exit: SandeshaInHandler::invoke, Application processing done " + returnValue);
      return returnValue;
    }
   
    // look at the service to see if RM is totally disabled. This allows the user to disable RM using
    // a property on the service, even when Sandesha is engaged.
    if (msgCtx.getAxisService() != null) {
      Parameter unreliableParam = msgCtx.getAxisService().getParameter(SandeshaClientConstants.UNRELIABLE_MESSAGE);
      if (null != unreliableParam && "true".equals(unreliableParam.getValue())) {
        log.debug("Exit: SandeshaInHandler::invoke, Service has disabled RM " + returnValue);
        return returnValue;
      }
    }
    if (log.isDebugEnabled()) log.debug("SandeshaInHandler::invoke Continuing beyond basic checks");

    Transaction transaction = null;

    try {
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
      transaction = storageManager.getTransaction();

      AxisService axisService = msgCtx.getAxisService();
      if (axisService == null) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.axisServiceIsNull);
View Full Code Here

        return false;

      }
 
      MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
      ConfigurationContext context = createSeqMsg.getConfigurationContext();
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
     
      // If the inbound CreateSequence includes a SecurityTokenReference then
      // ask the security manager to resolve that to a token for us. We also
      // check that the Create was secured using the token.
      SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
View Full Code Here

      return;
   
    Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
   
    ConfigurationContext configurationContext = rmMsgCtx.getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(
              configurationContext, configurationContext.getAxisConfiguration());
   
    RMDBeanMgr rmdMgr = storageManager.getRMDBeanMgr();
    RMDBean rmdBean = rmdMgr.retrieve(sequenceId);
    String outBoundInternalSequence = rmdBean.getOutboundInternalSequence();
   
View Full Code Here

  public boolean processInMessage(RMMsgContext rmMsgCtx, Transaction transaction) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: CloseSequenceProcessor::processInMessage");

    ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();
    CloseSequence closeSequence = (CloseSequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);

    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
View Full Code Here

  public AxisService findService(MessageContext msgContext) throws AxisFault {
    // TODO Auto-generated method stub
   
   
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    RMMsgContext rmmsgContext = MsgInitializer.initializeMessage(msgContext);
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext, configurationContext.getAxisConfiguration());
   
    Transaction transaction = storageManager.getTransaction();
   
    AxisService service;
    try {
      String sequenceID = (String) rmmsgContext
          .getProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID);
      service = null;
      if (sequenceID != null) {

        //If this is the RMD of the sequence
        RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
        RMDBean rmdFindBean = new RMDBean();
        rmdFindBean.setSequenceID(sequenceID);

        RMDBean rmdBean = rmdBeanMgr.findUnique(rmdFindBean);
        if (rmdBean != null) {

          String serviceName = rmdBean.getServiceName();
          if (serviceName != null) {
            service = configurationContext.getAxisConfiguration()
                .getService(serviceName);
          }
        }

        if (service == null && rmdBean == null) {
          //If this is the RMD of the sequence
          RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
          RMSBean rmsfindBean = new RMSBean();
          rmsfindBean.setSequenceID(sequenceID);

          RMSBean rmsBean = rmsBeanMgr.findUnique(rmsfindBean);

          if (rmsBean != null) {
            String serviceName = rmsBean.getServiceName();
            if (serviceName != null) {
              service = configurationContext
                  .getAxisConfiguration().getService(
                      serviceName);
            }
          }
        }
View Full Code Here

      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.invalidSequenceID, null);
      log.debug(message);
      throw new SandeshaException(message);
    }
   
    ConfigurationContext context = terminateSeqMsg.getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
   
    // Check that the sender of this TerminateSequence holds the correct token
    RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);
    if(rmdBean != null && rmdBean.getSecurityTokenData() != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
      OMElement body = terminateSeqRMMsg.getSOAPEnvelope().getBody();
      SecurityToken token = secManager.recoverSecurityToken(rmdBean.getSecurityTokenData());
      secManager.checkProofOfPossession(token, body, terminateSeqRMMsg.getMessageContext());
    }

    if (FaultManager.checkForUnknownSequence(terminateSeqRMMsg, sequenceId, storageManager, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: TerminateSeqMsgProcessor::processInMessage, unknown sequence");
      return false;
    }

    // add the terminate sequence response if required.
    RMMsgContext terminateSequenceResponse = null;
    if (SpecSpecificConstants.isTerminateSequenceResponseRequired(terminateSeqRMMsg.getRMSpecVersion()))
      terminateSequenceResponse = getTerminateSequenceResponse(terminateSeqRMMsg, rmdBean, sequenceId, storageManager);

    setUpHighestMsgNumbers(context, storageManager, sequenceId, terminateSeqRMMsg);
   
   
   
    boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(context.getAxisConfiguration()).isInOrder();
   
   
    //if the invocation is inOrder and if this is RM 1.1 there is a posibility of all the messages having eleady being invoked.
    //In this case we should do the full termination.
   
View Full Code Here

   */
  private static void processCreateSequenceRefusedFault(RMMsgContext rmMsgCtx, AxisFault fault) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: FaultManager::processCreateSequenceRefusedFault");

    ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());

    RelatesTo relatesTo = rmMsgCtx.getMessageContext().getRelatesTo();
    String createSeqMsgId = null;
    if (relatesTo != null) {
View Full Code Here

TOP

Related Classes of org.apache.axis2.context.ConfigurationContext

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.