Package net.sf.xbus.base.core

Examples of net.sf.xbus.base.core.TAManager


    // readConfiguration
    readConfiguration(system);

    // register resource by TAManager
    TAManager taManager = TAManager.getInstance();
    taManager.registerResource(this);

  }
View Full Code Here


    try
    {
      readConfiguration(systemName);

      // FileReceiver will be registered by TAManager
      TAManager taManager = TAManager.getInstance();
      taManager.clearManager();
      taManager.registerResource(this);

      // determine the list of XBUSSystem for the system
      List systems = XBUSSystem.getSystems(systemName, mConfiguration
          .getFileName());
View Full Code Here

   * @exception XException if an error occurs
   */
  public FileSender(XBUSSystem system) throws XException
  {
    readConfiguration(system);
    TAManager taManager = TAManager.getInstance();
    taManager.registerResource(this);
  }
View Full Code Here

        .always("Starting FileReceiverThread for "
            + getSource().getName());

    mReceiver = createReceiver();

    TAManager taManager = null;
    List systems = null;

    // initialize and register all resources
    try
    {
      taManager = TAManager.getInstance();
      mReceiver.readConfiguration(getSource().getName());
      // register resource
      taManager.registerResource(mReceiver);
    }
    catch (XException xe)
    {
      Trace.always("Couldn't start " + getSource().getName());
      NotifyError.notifyError(this, getSource(), "Couldn't start "
          + getSource().getName(), null, null);
      return;
    }

    // main loop
    while (checkProceed())
    {
      try
      {
        try
        {
          // determine the list of XBUSSystem for the system
          systems = XBUSSystem.getSystems(getSource().getName(),
              mReceiver.getConfigFilename());
        }
        catch (XException xex)
        {
          NotifyError.notifyError(this, getSource(),
              xex.getMessage(), null, null);
          return;
        }

        // for loop iterates over the all XBUSSystems
        // and proceed the receipt for each ones
        boolean errorFree = true;
        for (Iterator it = systems.iterator(); it.hasNext();)
        {
          if (!mReceiver.doReceive((XBUSSystem) it.next()))
          {
            errorFree = false;
          }
        }
        if (errorFree)
        {
          initializeErrorCounter();
          PostProcessor.start(new XBUSSystem(getSource().getName()),
              null, Constants.POSTPROCESSING_FINAL);
          // wait and try once again
          try
          {
            Thread.sleep(getTimeout());
          }
          catch (InterruptedException ie)
          {}
        }
        else
        {
          incrementErrorCounter();
          // wait and try once again
          try
          {
            Thread.sleep(getErrorTimeout());
          }
          catch (InterruptedException ie)
          {}
        }

      }
      catch (Throwable t)
      {
        /*
         * Last safety belt, if anything happens, at least the error
         * should be reported.
         */
        NotifyError.notifyError(this, getSource(), t.getMessage(),
            null, null);
        interruptThread();

      }
    }

    Trace.always("FileReceiverThread for " + getSource().getName()
        + " stopped");

    // close all resources and remove Resource from the TAManager
    taManager.close();
    taManager.removeResource(mReceiver);
  }
View Full Code Here

  {
    mDeleted = false;

    XBUSSystem xbusSystem = null;

    TAManager taManager = TAManager.getInstance();
    taManager.clearManager();
    taManager.registerResource(this);

    try
    {

      readConfiguration(systemName);

      xbusSystem = new XBUSSystem(systemName);

      Trace.info("Start processing " + xbusSystem.getCompleteName());

      // POP3XMLReceiver will be registered by TAManager
      doReceive(xbusSystem);
    }
    catch (Exception t)
    {
      NotifyError.notifyError(this, xbusSystem, t.getMessage(), null,
          null);
    }
    finally
    {
      // close resources and remove from the resources
      taManager.close();
      taManager.removeResource(this);
    }
  }
View Full Code Here

  }

  protected boolean doReceive(XBUSSystem xbusSystem)
  {
    boolean mailReceived = false;
    TAManager taManager = TAManager.getInstance();

    try
    {
      taManager.begin();

      // Subclasses may define their own request content
      Object requestContent = getRequestContent(xbusSystem
          .getCompleteName());

      if (requestContent != null)
      {
        Trace.info("Receiving data from " + getAddress());

        // call application layer
        Adapter adapter = new Adapter();
        adapter.callApplication(xbusSystem, requestContent, getType());
        mReturncode = adapter.getReturncode();

        // check the Adapter return code
        // in case of "not success" throw new XException
        if (Constants.RC_OK.equals(adapter.getReturncode()))
        {
          mailReceived = true;
          taManager.commit();
          PostProcessor.start(xbusSystem, adapter.getResponse(),
              Constants.POSTPROCESSING_PERSYSTEM);
          Trace
              .info("End processing "
                  + xbusSystem.getCompleteName());
          Trace.info("----------------------------------------");
        }
        else
        {
          taManager.rollback();
          handleError(null, xbusSystem, requestContent);
          Trace.info("Error while processing "
              + xbusSystem.getCompleteName());
          Trace.info("----------------------------------------");
        }
      }
      else
      {
        /*
         * Folder must be closed, otherwise the messageCount of the
         * folder will not be updated in further calls.
         */
        closeFolder();
      }
    }
    catch (Exception e)
    {
      taManager.rollback();
      NotifyError.notifyError(this, xbusSystem, e.getMessage(), null,
          null);
    }

    return mailReceived;
View Full Code Here

    }

    /*
     * Initialize transaction manager
     */
    TAManager taManager = TAManager.getInstance();
    try
    {
      taManager.clearManager();
      taManager.begin();
    }
    catch (XException e)
    {
      handleError(res, e, null, e.getMessage());
      Trace.info("Error while processing " + mSource.getCompleteName());
      Trace.info("----------------------------");
      return;
    }

    /*
     * Process the message, either an InputStream or a textual message
     */
    try
    {
      if (HTTP_RECEIVER.equals(mReceiverType))
      {
        processTextMessage(req, res);
      }
      else if (HTTP_STREAM_RECEIVER.equals(mReceiverType))
      {
        processStreamMessage(req, res);
      }
      else if (HTTP_PARAMETER_RECEIVER.equals(mReceiverType))
      {
        processParameterMessage(req, res);
      }
      Trace.info("End processing " + mSource.getCompleteName());
      Trace.info("----------------------------");
    }
    catch (Exception e)
    {
      handleError(res, e, null, e.getMessage());
      Trace.info("Error while processing " + mSource.getCompleteName());
      Trace.info("----------------------------");
    }
    catch (Error e)
    {
      handleError(res, e, null, e.getMessage());
      Trace.info("Error while processing " + mSource.getCompleteName());
      Trace.info("----------------------------");

      /*
       * Errors must be passed through, the servlet engine has to process
       * them too.
       */
      throw e;
    }

    taManager.close();
  }
View Full Code Here

            + mSource.getCompleteName());

    /*
     * Initialize the ReceiverThread, e.g. opening a connection
     */
    TAManager taManager = TAManager.getInstance();
    boolean initializeSuccessful = false;
    while (!initializeSuccessful && checkProceed())
    {
      try
      {
        initializeThread();
        initializeSuccessful = true;
        initializeErrorCounter();
      }
      catch (XException e)
      {
        incrementErrorCounter();
        Trace.error("Problem while starting "
            + mSource.getCompleteName());
        Trace.error("Retry after " + getErrorTimeout() / 1000
            + " seconds");
        Trace.error("------------------------------");
        try
        {
          Thread.sleep(getErrorTimeout());
        }
        catch (InterruptedException ie)
        {
          // do nothing
        }
      }
    }

    /*
     * Process messages
     */
    Object message = null;
    while (checkProceed())
    {
      try
      {
        taManager.clearManager();
        registerResources(taManager);
        taManager.begin();
      }
      catch (XException e)
      {
        taManager.close();
        incrementErrorCounter();
        Trace.error("Problem while starting "
            + mSource.getCompleteName());
        Trace.error("Retry after " + getErrorTimeout() / 1000
            + " seconds");
        Trace.error("------------------------------");
        try
        {
          Thread.sleep(getErrorTimeout());
        }
        catch (InterruptedException e1)
        {
          // do nothing
        }
      }

      try
      {
        message = receive();

        if (message != null)
        {
          Trace.info("Receiving data from " + getAddress());

          Adapter adapter = new Adapter();
          adapter.callApplication(getSource(), message, getType());

          if (Constants.RC_OK.equals(adapter.getReturncode()))
          {
            initializeErrorCounter();
            taManager.commit();
            PostProcessor.start(getSource(), adapter.getResponse(),
                Constants.POSTPROCESSING_PERSYSTEM);
            Trace.info("End processing "
                + getSource().getCompleteName());
            Trace.info("------------------------------");
          }
          else
          {
            handleError(taManager, message, adapter
                .getErrormessage());
          }
        }
        else
        {
          /*
           * All receiver threads except the MQReceiver shall wait
           * some seconds if there is currently no message available.
           */

          if (!"MQReceiverThread".equals(getReceiverClassName()))
          {
            try
            {
              Thread.sleep(getTimeout());
            }
            catch (InterruptedException e1)
            {
              // do nothing
            }
          }
        }
      }
      catch (XException e)
      {
        handleError(taManager, message, e.getMessage());
      }
    }

    taManager.close();

    Trace
        .always("ReceiverThread for " + getSource().getName()
            + " stopped");
  }
View Full Code Here

    Object responseObject = null;

    /*
     * Initialize transaction manager
     */
    TAManager taManager = TAManager.getInstance();

    try
    {
      taManager.clearManager();
      taManager.begin();

      Adapter adapter = new Adapter();
      adapter.callApplication(source, request, getType());
      responseObject = adapter.getResponse();
      if (Constants.RC_OK.equals(adapter.getReturncode()))
      {
        taManager.commit();
        PostProcessor.start(source, responseObject,
            Constants.POSTPROCESSING_PERSYSTEM);
        Trace.info("End processing " + source.getCompleteName());
        Trace.info("-----------------------------");
      }
      else
      {
        errormessage = adapter.getErrormessage();
        taManager.rollback();
        NotifyError.notifyError(this, source, errormessage, request,
            null);
        Trace
            .info("Error while processing "
                + source.getCompleteName());
        Trace.info("-----------------------------");
      }
    }
    catch (Exception t)
    {
      errormessage = t.getMessage();
      NotifyError.notifyError(this, source, errormessage, request, null);
      Trace.info("Error while processing " + source.getCompleteName());
      Trace.info("-----------------------------");
      if (t instanceof XException)
      {
        throw (XException) t;
      }
    }

    taManager.close();

    if (errormessage != null)
    {
      List messages = new Vector(1);
      messages.add(errormessage);
View Full Code Here

      readConfiguration(systemName);

      mAS400System.connectService(AS400.FILE);

      // AS400Receiver will be registered by TAManager
      TAManager taManager = TAManager.getInstance();
      taManager.clearManager();
      taManager.registerResource(this);
      taManager.begin();

      // determine the list of XBUSSystems for the system name
      List systems = XBUSSystem.getSystems(systemName, mConfigFilename);
      // for failed transmissions
      List errorSystems = null;

      // for counting the attempts
      int i = 0;
      // while loop for the attemps to process the interfaces
      while ((!systems.isEmpty()) && (i < mRetryCount + 1))
      { // still some systems to process and number of retires nor yet
        // reached
        // time out before retries
        if (i > 0)
          Thread.sleep(mTimeout * 1000);

        // empty list for failed interfaces
        errorSystems = new Vector();

        // for loop iterates over the all XBUSSystems and tries to
        // receive the interface data
        for (Iterator it = systems.iterator(); it.hasNext();)
        { // iterating operation in first body instruction:
          XBUSSystem xbusSystem = (XBUSSystem) it.next();
          if (i == 0)
          { // first attempt
            Trace.info("Start processing "
                + xbusSystem.getCompleteName());
          } // then (i == 0)
          else
          { // a retry
            Trace.info("Retry number " + i + ": "
                + xbusSystem.getCompleteName());
          } // else (i == 0)
          if (doReceive(xbusSystem))
          { // successfully received
            taManager.commit();

            PostProcessor.start(xbusSystem, null,
                Constants.POSTPROCESSING_PERSYSTEM);

            Trace.info("End processing "
                + xbusSystem.getCompleteName());
            Trace.info("----------------------------------------");
          } // then (receive(xbusSystem))
          else
          { // An error occured during data transmission
            // but the resulting exception was already catched.
            taManager.rollback();
            Trace.info("Error while processing "
                + xbusSystem.getCompleteName());
            Trace.info("----------------------------------------");
            errorSystems.add(xbusSystem);
          } // else (receive(xbusSystem))
View Full Code Here

TOP

Related Classes of net.sf.xbus.base.core.TAManager

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.