Package net.sf.xbus.base.core.config

Examples of net.sf.xbus.base.core.config.Configuration


   * @param sectionName The name of the process.
   * @throws XException
   */
  private void readConfig(String sectionName) throws XException
  {
    Configuration config = Configuration.getInstance();
    Configuration xBusConfig = Configuration.getInstance("xbus");
    String tempVariable = null;

    // get Field Separator
    if ((fieldSeparator = config.getValueOptional(Constants.CHAPTER_SYSTEM,
        sectionName, Constants.KEY_CSV_FIELD_SEPARATOR)) == null)
    {
      fieldSeparator = xBusConfig.getValue("MessageDefaults",
          "CSVMessage", Constants.KEY_CSV_FIELD_SEPARATOR);
    }

    // get Quote Character
    if ((quoteChar = config.getValueOptional(Constants.CHAPTER_SYSTEM,
        sectionName, Constants.KEY_CSV_QUOTE_CHAR)) == null)
    {
      quoteChar = xBusConfig.getValue("MessageDefaults", "CSVMessage",
          Constants.KEY_CSV_QUOTE_CHAR);
    }

    if (quoteChar == null || fieldSeparator == null
        || quoteChar.equals(fieldSeparator))
      throw new XException(Constants.LOCATION_INTERN,
          Constants.LAYER_PROTOCOL, Constants.PACKAGE_PROTOCOL_CSV,
          "15");

    quotePair = quoteChar + quoteChar;

    // get configuration entry if containing header
    if ((tempVariable = config.getValueOptional(Constants.CHAPTER_SYSTEM,
        sectionName, Constants.KEY_CSV_HAS_HEADER)) == null)
    {
      hasHeader = xBusConfig.getValueAsBoolean("MessageDefaults",
          "CSVMessage", Constants.KEY_CSV_HAS_HEADER);
    }
    else if (tempVariable.equalsIgnoreCase(Constants.CONFIGURATION_TRUE))
    {
      hasHeader = true;
    }
    else
    {
      hasHeader = false;
    }

    // get configuration if all fields should be quoted
    if ((tempVariable = config.getValueOptional(Constants.CHAPTER_SYSTEM,
        sectionName, Constants.KEY_CSV_ALWAYS_QUOTE)) == null)
    {
      alwaysQuote = xBusConfig.getValueAsBoolean("MessageDefaults",
          "CSVMessage", Constants.KEY_CSV_ALWAYS_QUOTE);
    }
    else if (tempVariable.equalsIgnoreCase(Constants.CONFIGURATION_TRUE))
    {
      alwaysQuote = true;
View Full Code Here


   * @exception XException if the configuartion is not available or a
   *                mandatory key cannot be read
   */
  public void readConfiguration(String system) throws XException
  {
    Configuration config = Configuration.getInstance();

    // create an AS400 object for the server that holds the files
    // and connection to the iSeries
    AS400Connection connection = AS400Connection.getInstance(config
        .getValue(Constants.CHAPTER_SYSTEM, system, "AS400"));
    mAS400System = connection.getSystem();

    mResolution = getResolution(config, system);
    mOnError = getOnError(config, system);
    mConfigFilename = config.getValue(Constants.CHAPTER_SYSTEM, system,
        Constants.KEY_FILENAME);
    mEncoding = getEncoding(mAS400System, system);
    mAS400TerminatorProgram = config.getValueOptional(
        Constants.CHAPTER_SYSTEM, system, "AS400Program.Terminator");
    mRetryCount = Configuration.getInstance().getValueAsInt(
        Constants.CHAPTER_BASE, "Retry", "Count");
    if (mRetryCount > 0)
      mTimeout = config.getValueAsInt(Constants.CHAPTER_BASE,
          "ReceiverTimeout", "Seconds");

    mProgramTimeout = config.getValueAsIntOptional(
        Constants.CHAPTER_SYSTEM, system, "ProgramTimeout") * 1000;
    if (mProgramTimeout == 0)
    {
      mProgramTimeout = Integer.MAX_VALUE;
    }
View Full Code Here

    mErrorMessage = errorMessage;
    mErrorRequest = errorRequest;
    mAdditionalInfo = additionalInfo;
    mClassName = className;

    Configuration config = Configuration.getInstance();

    String sourceName = "<null>";
    if (getSource() != null)
    {
      sourceName = getSource().getCompleteName();
    }

    /**
     * Build up error message
     */
    StringBuffer errorText = new StringBuffer()
        .append("Unrecoverable error while receiving message!")
        .append(Constants.LINE_SEPERATOR)
        .append(Constants.LINE_SEPERATOR)
        .append("Class          : ")
        .append(mClassName)
        .append(Constants.LINE_SEPERATOR)
        .append(Constants.LINE_SEPERATOR)
        .append("Date            : ")
        .append(Constants.getDateFormat().format(getRequestTimestamp()))
        .append(Constants.LINE_SEPERATOR).append(
            Constants.LINE_SEPERATOR).append("Receiving system: ")
        .append(sourceName).append(Constants.LINE_SEPERATOR).append(
            Constants.LINE_SEPERATOR).append("Error message:    ")
        .append(mErrorMessage).append(Constants.LINE_SEPERATOR);

    if (mErrorRequest != null)
    {
      int length = config.getValueAsInt("Base", "NotifyError",
          "MessageLength");
      if (length > 0)
      {
        String errorRequestString = mErrorRequest.toString();
        if (errorRequestString.length() > length)
View Full Code Here

  private Context createContext() throws XException {
    try {
      Hashtable env = new Hashtable();

      Configuration config = Configuration.getInstance();
      String factory = config.getValue("Connection", "MQ",
          "ContextFactory");
      env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
      String url = config.getValueOptional("Connection", "MQ", "URL");
      if (url != null) {
        env.put(Context.PROVIDER_URL, url);
      }
      String user = config.getValueOptional("Connection", "MQ", "User");
      if (user != null) {
        env.put(Context.SECURITY_PRINCIPAL, user);
      }
      String password = config.getValueOptional("Connection", "MQ",
          "Password");
      if (password != null) {
        env.put(Context.SECURITY_CREDENTIALS, password);
      }
      String referral = config.getValueOptional("Connection", "MQ",
          "Referral");
      if (referral != null) {
        env.put(Context.REFERRAL, referral);
      }
      String authorative = config.getValueOptional("Connection", "MQ",
          "Authorative");
      if (authorative != null) {
        env.put(Context.AUTHORITATIVE, authorative);
      }
      String batchSize = config.getValueOptional("Connection", "MQ",
          "BatchSize");
      if (batchSize != null) {
        env.put(Context.BATCHSIZE, batchSize);
      }
      String language = config.getValueOptional("Connection", "MQ",
          "Language");
      if (language != null) {
        env.put(Context.LANGUAGE, language);
      }
      String dnsUrl = config.getValueOptional("Connection", "MQ",
          "DNS_URL");
      if (dnsUrl != null) {
        env.put(Context.DNS_URL, dnsUrl);
      }
      String objectFactories = config.getValueOptional("Connection",
          "MQ", "ObjectFactories");
      if (objectFactories != null) {
        env.put(Context.OBJECT_FACTORIES, objectFactories);
      }
      String securityProtocol = config.getValueOptional("Connection",
          "MQ", "SecurityProtocol");
      if (securityProtocol != null) {
        env.put(Context.SECURITY_PROTOCOL, securityProtocol);
      }
      String securityAuthentication = config.getValueOptional(
          "Connection", "MQ", "SecurityAuthentication");
      if (securityAuthentication != null) {
        env
            .put(Context.SECURITY_AUTHENTICATION,
                securityAuthentication);
      }
      String stateFactories = config.getValueOptional("Connection", "MQ",
          "StateFactories");
      if (stateFactories != null) {
        env.put(Context.STATE_FACTORIES, stateFactories);
      }
      String urlPkgPrefixes = config.getValueOptional("Connection", "MQ",
          "URLPkgPrefixes");
      if (urlPkgPrefixes != null) {
        env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
      }
      String port = config.getValueOptional("Connection", "MQ", "Port");
      if (port != null) {
        env.put("javax.naming.factory.port", port);
      }
      String host = config.getValueOptional("Connection", "MQ", "Host");
      if (host != null) {
        env.put("javax.naming.factory.host", host);
      }
      return new InitialContext(env);
    } catch (NamingException e) {
View Full Code Here

   * @return exist resolution (Preserve or Delete) as String
   * @exception XException if resolution is false or any errors occurs
   */
  private String getOnError(String system) throws XException
  {
    Configuration config = Configuration.getInstance();
    String onError = config.getValueOptional(Constants.CHAPTER_SYSTEM,
        system, "OnError");
    if (onError == null)
    {
      onError = Constants.READ_PRESERVE;
    }
View Full Code Here

    {
      mJournal = (JournalInterface) ReflectionSupport
          .createObject(mJournalClass);
    }

    Configuration config = Configuration.getInstance();

    /* Find out, if this event has to be logged. */
    boolean doIt;
    if (type == 'S')
    {
      doIt = config.getValueAsBooleanOptional(Constants.CHAPTER_SYSTEM,
          system.getName(), "Journal.Send");
    }
    else if (type == 'R')
    {
      doIt = config.getValueAsBooleanOptional(Constants.CHAPTER_SYSTEM,
          system.getName(), "Journal.Receive");
    }
    else
    {
      List params = new Vector();
View Full Code Here

  static public String formatText(Message message, XBUSSystem system,
      boolean request) throws XException
  {
    String retString = null;

    Configuration config = Configuration.getInstance();
    int length = config.getValueAsInt("Base", "Journal", "MessageLength");

    /*
     * When the length should be 0, we must not format anything.
     */
    if (length == 0)
View Full Code Here

    return retString;
  }

  static public void initialize() throws XException
  {
    Configuration config = Configuration.getInstance();

    String journalClassShort = config.getValue("Base", "Journal",
        "Implementation");
    mJournalClass = Configuration.getClass("Journal", journalClassShort);

    mInitialized = true;
  }
View Full Code Here

  static public synchronized void notifyError(Object className, XBUSSystem source,
      String message, Object request, Hashtable additionalInfo)
  {
    try
    {
      Configuration config = Configuration.getInstance();

      String notifySystemName = config.getValueOptional("Base",
          "NotifyError", Constants.CHAPTER_SYSTEM + "1");

      if (notifySystemName != null)
      {
        NotifyErrorMessage errorMessage = new NotifyErrorMessage(source);
        errorMessage.setData(className.getClass().getName(), message,
            request, additionalInfo);

        if (errorMessage.getRequestText(source).indexOf("file:") == -1
            || errorMessage.getRequestText(source).indexOf(
                "is empty") == -1)
        {
          /**
           * 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);
            }
View Full Code Here

   * @throws XException in case that the interface file name can not be
   *             retrieved
   */
  protected String getInterfaceDescription(String system) throws XException
  {
    Configuration config = Configuration.getInstance();
    String fileName = config.getValue("System", system, "DescriptionFile");
    return Constants.XBUS_ETC + "InterfaceDescriptions"
        + Constants.FILE_SEPERATOR + fileName;
  } // getInterfaceDescription(XBUSSystem source)
View Full Code Here

TOP

Related Classes of net.sf.xbus.base.core.config.Configuration

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.