Package net.sf.xbus.base.xbussystem

Examples of net.sf.xbus.base.xbussystem.XBUSSystem


    {
      for (int i = 0; i < preProcessors.size(); i++)
      {
        Trace.info("Starting preprocessor "
            + (String) preProcessors.elementAt(i) + " ...");
        XBUSSystem preProcessorSystem = new XBUSSystem(
            (String) preProcessors.elementAt(i));
        Adapter.callSender(new EmptyMessage(preProcessorSystem),
            preProcessorSystem);
        Trace.info("PreProcessor "
            + (String) preProcessors.elementAt(i) + " finished");
View Full Code Here


          }
        }
        if (errorFree)
        {
          initializeErrorCounter();
          PostProcessor.start(new XBUSSystem(getSource().getName()),
              null, Constants.POSTPROCESSING_FINAL);
          // wait and try once again
          try
          {
            Thread.sleep(getTimeout());
View Full Code Here

   */
  public void receive(String systemName)
  {
    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)
View Full Code Here

            Trace.always("Error wile restarting ReceiverThread "
                + system);
            try
            {
              NotifyError.notifyError(null,
                  new XBUSSystem(system), e.getMessage(),
                  null, null);
            }
            catch (XException e1)
            {
              // do nothing
View Full Code Here

    Class[] conArgsClass = new Class[]
    {ReflectionSupport
        .classForName("net.sf.xbus.base.xbussystem.XBUSSystem")};
    Object[] conArgs = new Object[]
    {new XBUSSystem(system)};

    return (ReceiverThreadBase) ReflectionSupport.createObject(
        receiverClass, conArgsClass, conArgs);
  }
View Full Code Here

        .toString(), "/");
    while (tokenizer.hasMoreTokens())
    {
      servletName = tokenizer.nextToken();
    }
    mSource = new XBUSSystem(servletName);

    /*
     * Check, it this is a normal HTTPReceiver or a HTTPLineReaderReceiver
     */
    String receiverType = config.getValue(Constants.CHAPTER_SYSTEM, mSource
View Full Code Here

          Constants.LAYER_TECHNICAL,
          Constants.PACKAGE_TECHNICAL_JAVA, "2");
    }

    String errormessage = null;
    XBUSSystem source = new XBUSSystem(system);

    Trace.info("Receiving data from " + source.getCompleteName());

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

        // 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))
        } // for (Iterator it = systems.iterator(); it.hasNext();)
        // In next attempt only try the failed interfaces.
        systems = errorSystems;
        // One attempt more done.
        i++;
      } // while ((!systems.isEmpty()) && (i < mRetryCount + 1))

      if (!systems.isEmpty())
      { // Even after retrying some systems were not successfully
        // processed.
        Trace.error("Some systems couldn't be processed.");

        // Falied interfaces list for error message.
        Hashtable additionalInfo = new Hashtable();
        // Counting the failed interfaces.
        i = 1;
        XBUSSystem system;
        // loop over al failed interfaces
        for (Iterator it = systems.iterator(); it.hasNext();)
        { // iterating operation in first body instruction:
          system = (XBUSSystem) it.next();

          additionalInfo.put("System" + i, system.getCompleteName());

          // Perform cleaning operations according to configuration.
          try
          {
            if (mOnError.equals(Constants.READ_DELETE)
                || mOnError.equals(Constants.READ_DELETEFILE))
            {
              deleteFile(mAS400System, system
                  .replaceAllMarkers(mConfigFilename)[0]);
            } // delete
            else if (mOnError.equals(Constants.READ_DELETEMEMBER))
            {
              deleteMember(mAS400System, system
                  .replaceAllMarkers(mConfigFilename)[0]);
            } // delete member
            else if (mOnError.equals(Constants.READ_RENAME))
            {
              renameFile(
                  mAS400System,
                  system.replaceAllMarkers(mConfigFilename)[0],
                  system.replaceAllMarkers(mConfigFilename)[0]
                      + Constants.getDateAsString());
            } // rename
            // Nothing to do for "Preserve".
          } // try
          catch (XException e)
          {
            Trace.error(e);
          } // catch
          // Next system.
          i++;
        } // for (Iterator it = systems.iterator(); it.hasNext();)
        NotifyError.notifyError(this, new XBUSSystem(systemName),
            "Some interfaces couldn't be processed", null,
            additionalInfo);
      } // if (!systems.isEmpty())
      else
        PostProcessor.start(new XBUSSystem(systemName), null,
            Constants.POSTPROCESSING_FINAL);
    } // try
    catch (Throwable e)
    {
      try
      {
        NotifyError.notifyError(this, new XBUSSystem(systemName), e
            .getMessage(), null, null);
      }
      catch (XException e1)
      {
        // do nothing
View Full Code Here

        {
          /**
           * Send error message to various systems
           */
          Message sendMessage = null;
          XBUSSystem notifySystem = null;

          notifySystemName = config.getValueOptional("Base",
              "NotifyError", Constants.CHAPTER_SYSTEM + "1");
          if (notifySystemName != null)
          {
            notifySystem = new XBUSSystem(notifySystemName);
          }
          else
          {
            notifySystem = null;
          }
          int i = 1;
          while (notifySystem != null)
          {
            sendMessage = MessageFactory.createSenderMessage(
                notifySystem, errorMessage,
                MessageFactory.TRANSFORM_FROM_REQUEST);

            Adapter.callSender(sendMessage, notifySystem);

            Trace.error("Notified system: "
                + notifySystem.getCompleteName());

            i++;
            notifySystemName = config.getValueOptional("Base",
                "NotifyError", Constants.CHAPTER_SYSTEM + i);
            if (notifySystemName != null)
            {
              notifySystem = new XBUSSystem(notifySystemName);
            }
            else
            {
              notifySystem = null;
            }
View Full Code Here

     */
    try
    {
      Document messageDom = XMLHelper.parseXML(readFile(getDirectory()
          + Constants.FILE_SEPERATOR + filename), null, null);
      XBUSSystem source = new XBUSSystem(messageDom.getFirstChild()
          .getNodeName());
      NodeList addresses = messageDom.getElementsByTagName("Address");
      Node address = null;
      String attrName = null;
      String addressValue = null;
      for (int i = 0; i < addresses.getLength(); i++)
      {
        address = addresses.item(i);
        if ((attrName = XMLHelper.getAttribute(address, "name")) == null)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_BASE,
              Constants.PACKAGE_BASE_DELETEDMESSAGESTORE, "1");
        }
        if ((addressValue = XMLHelper.getNodeText(address)) == null)
        {
          throw new XException(Constants.LOCATION_INTERN,
              Constants.LAYER_BASE,
              Constants.PACKAGE_BASE_DELETEDMESSAGESTORE, "2");
        }
        source.setAddress(attrName, addressValue);
      }

      NodeList data = messageDom.getElementsByTagName("Data");
      String request = null;
      if (data.getLength() > 0)
      {
        Node messageNode = messageDom.getElementsByTagName("Data")
            .item(0);
        Node dataNode = null;
        if ((dataNode = messageNode.getFirstChild()) != null)
        {
          request = dataNode.getNodeValue();
        }
      }
      if (request == null)
      {
        throw new XException(Constants.LOCATION_INTERN,
            Constants.LAYER_BASE,
            Constants.PACKAGE_BASE_DELETEDMESSAGESTORE, "3");
      }

      /*
       * Resending the message
       */
      taManager = TAManager.getInstance();
      taManager.clearManager();
      taManager.begin();

      Adapter adapter = new Adapter();
      adapter.callApplication(source, request, Constants.TYPE_TEXT);
      Object responseObject = adapter.getResponse();
      if (Constants.RC_OK.equals(adapter.getReturncode()))
      {
        taManager.commit();
        PostProcessor.start(source, responseObject,
            Constants.POSTPROCESSING_PERSYSTEM);
        Trace.info("End resending " + source.getCompleteName());
        Trace.info("-----------------------------");
        retString.append("Message from ").append(
            source.getCompleteName()).append(
            " successfully resent!");

        File messageFile = new File(getDirectory()
            + Constants.FILE_SEPERATOR + filename);
        if (messageFile.delete())
        {
          retString.append("<br>");
          retString.append("File ").append(filename).append(
              " has been deleted.");
        }
        else
        {
          retString.append("<br />");
          retString.append("File ").append(filename).append(
              " cannot be deleted.");
        }
      }
      else
      {
        taManager.rollback();
        Trace.info("Error while resending " + source.getCompleteName());
        Trace.info("-----------------------------");
        retString.append("Error while resending ").append(
            source.getCompleteName()).append("<br>").append(
            "Reason: ").append(adapter.getErrormessage()).append(
            "<br>").append("File ").append(filename).append(
            " has not been deleted.");
      }
    }
View Full Code Here

TOP

Related Classes of net.sf.xbus.base.xbussystem.XBUSSystem

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.