Beispiel #1
0
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   super.setConfiguration(cfg);
   this.protectedEntrys = cfg.getAll("protect-entry");
   this.wipedEntrys = cfg.getAll("wipe-entry");
   this.protectISO = cfg.getAll("protect-ISOMsg");
   this.protectFSD = cfg.getAll("protect-FSDMsg");
 }
 /**
  * Configuration method invoked by framework while initializing Class. Following are the
  * parameters used :
  *
  * <p>
  *
  * <blockquote>
  *
  * <pre>
  * resource-file - oneinc-resource.properties
  * validation-file - validation-rules.xml
  * </pre>
  *
  * </blockquote>
  *
  * <p>This method initialize the ValidatorResources by reading the validation-file passed and then
  * initialize different forms defined in this file. It also initialize the validation resource
  * bundle i.e. oneinc-resource.properties from where user friendly message would be picked in case
  * of validation failure.
  *
  * <p>Member-variable needs to be initialized/assigned once while initializing the class, and is
  * being passed from the XML is initialized in this method.
  *
  * <p>In XML, use the following tag to define the property:
  *
  * <p>&lt;property name="resource-file" value="oneinc-resource" /&gt;
  *
  * <p>corresponding code to get the property is as follow:
  *
  * <p>String resourceName = cfg.get("resource-file");
  *
  * @param cfg - Configuration object holds the property defined in the XML.
  * @throws ConfigurationException
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   try {
     String resourceName = cfg.get("resource-file");
     apps = ResourceBundle.getBundle(resourceName);
     validationFileName = cfg.get("validation-file");
     InputStream in = null;
     in = BaseValidation.class.getClassLoader().getResourceAsStream(validationFileName);
     try {
       resources = new ValidatorResources(in);
       form = resources.getForm(Locale.getDefault(), "ValidateBean");
       provForm = resources.getForm(Locale.getDefault(), "ValidateProvBean");
     } finally {
       if (in != null) {
         in.close();
       }
     }
     prepareTxnMap();
   } catch (FileNotFoundException e) {
     throw new ConfigurationException(e.getLocalizedMessage(), e);
   } catch (IOException e) {
     throw new ConfigurationException(e.getLocalizedMessage(), e);
   } catch (Exception e) {
     throw new ConfigurationException(e.getLocalizedMessage(), e);
   }
 }
Beispiel #3
0
 /**
  * Packager Configuration.
  *
  * <ul>
  *   <li>packager-config
  *   <li>packager-logger
  *   <li>packager-realm
  * </ul>
  *
  * @param cfg Configuration
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   try {
     String loggerName = cfg.get("packager-logger");
     if (loggerName != null) setLogger(Logger.getLogger(loggerName), cfg.get("packager-realm"));
     readFile(this.filename = cfg.get("packager-config"));
   } catch (ISOException e) {
     throw new ConfigurationException(e);
   }
 }
Beispiel #4
0
  public void setConfiguration(Configuration cfg) {
    if (this.cfg != null) sp.removeListener(from, this);

    this.cfg = cfg;
    from = cfg.get("from");
    to = cfg.get("to");

    sp.addListener(from, this);
  }
Beispiel #5
0
 /**
  * configure filter.
  *
  * <ul>
  *   <li>xsltfile - source XSL-T file
  *   <li>reread - something != "no" will re-read source file
  * </ul>
  *
  * @param cfg new ConfigurationFile
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   try {
     transformer = tfactory.newTransformer(new StreamSource(cfg.get("xsltfile")));
     String s = cfg.get("reread");
     reread = (s == null || s.equals("no"));
   } catch (Exception e) {
     throw new ConfigurationException(e);
   }
 }
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   timeout = cfg.getInt("timeout");
   if (pool == null) pool = new ThreadPool(1, cfg.getInt("poolsize", 10));
   muxName = cfg.get("destination-mux", null);
   channelName = cfg.get("destination-channel", null);
   delay = cfg.get("delay", "0");
   if (muxName == null && channelName == null) {
     throw new ConfigurationException("Neither destination mux nor channel were specified.");
   }
 }
Beispiel #7
0
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   this.cfg = cfg;
   try {
     socket = new DatagramSocket();
     port = cfg.getInt("port", SYSLOG_PORT);
     host = InetAddress.getByName(cfg.get("host", "localhost"));
     defaultFacility = cfg.getInt("facility", LOG_USER);
     defaultSeverity = cfg.getInt("severity", PRI_INFO);
     tags = cfg.get("tags", "audit, syslog");
     prefix = cfg.get("prefix", null);
   } catch (Exception e) {
     throw new ConfigurationException(e);
   }
 }
Beispiel #8
0
  /**
   * Configure this RotateLogListener<br>
   * Properties:<br>
   *
   * <ul>
   *   <li>file base log filename
   *   <li>[window] in seconds (default 0 - never rotate)
   *   <li>[count] number of copies (default 0 == single copy)
   *   <li>[maxsize] max log size in bytes (aprox)
   * </ul>
   *
   * @param cfg Configuration
   * @throws ConfigurationException
   */
  public void setConfiguration(Configuration cfg) throws ConfigurationException {
    maxCopies = cfg.getInt("copies");
    sleepTime = cfg.getInt("window") * 1000;
    logName = cfg.get("file");
    maxSize = cfg.getLong("maxsize");
    maxSize = maxSize <= 0 ? DEFAULT_MAXSIZE : maxSize;

    try {
      openLogFile();
    } catch (IOException e) {
      throw new ConfigurationException(e);
    }
    Timer timer = DefaultTimer.getTimer();
    if (sleepTime != 0) timer.schedule(rotate = new Rotate(), sleepTime, sleepTime);
  }
Beispiel #9
0
 /**
  * @param cfg
  *     <ul>
  *       <li>sequencer - a sequencer used to store counters
  *       <li>unset - space delimited list of fields to be unset
  *       <li>valid - space delimited list of valid fields
  *       <li>comma delimited list of fields to be unset when applying filter
  *       <li>xzy - property named "xyz"
  *     </ul>
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   this.cfg = cfg;
   try {
     String seqName = cfg.get("sequencer", null);
     unsetFields = ISOUtil.toIntArray(cfg.get("unset", ""));
     validFields = ISOUtil.toIntArray(cfg.get("valid", ""));
     if (seqName != null) {
       seq = (Sequencer) NameRegistrar.get("sequencer." + cfg.get("sequencer"));
     } else if (seq == null) {
       seq = new VolatileSequencer();
     }
   } catch (NameRegistrar.NotFoundException e) {
     throw new ConfigurationException(e);
   }
 }
 public synchronized Connection getConnection() {
   for (; ; ) {
     try {
       String url = cfg.get("jdbc.url");
       String user = cfg.get("jdbc.user");
       String pass = cfg.get("jdbc.password");
       return DriverManager.getConnection(url, user, pass);
     } catch (SQLException e) {
       Logger.log(new LogEvent(this, "sql-connection", e));
       try {
         Thread.sleep(2000);
       } catch (InterruptedException ex) {
       }
     }
   }
 }
 private void initJDBC() throws ConfigurationException {
   try {
     Class.forName(cfg.get("jdbc.driver")).newInstance();
   } catch (Exception e) {
     throw new ConfigurationException(e);
   }
 }
Beispiel #12
0
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   this.cfg = cfg;
   try {
     InitialContext ctx = new InitialContext();
     ctx.rebind(cfg.get("name"), stub);
   } catch (NamingException e) {
     throw new ConfigurationException(e);
   }
 }
Beispiel #13
0
 private void applyProps(ISOMsg m) throws ISOException {
   int maxField = m.getMaxField();
   for (int i = 0; i <= maxField; i++) {
     Object o = null;
     if (m.hasField(i)) o = m.getValue(i);
     if (o instanceof String) {
       String value = (String) o;
       if (value.length() == 0) continue;
       if (value.equalsIgnoreCase("$date"))
         m.set(new ISOField(i, ISODate.getDateTime(new Date())));
       else if ((value.toLowerCase().startsWith("$date")) && value.contains("GMT")) {
         String zoneID = value.substring(value.indexOf("GMT"));
         m.set(new ISOField(i, ISODate.getDateTime(new Date(), TimeZone.getTimeZone(zoneID))));
       } else if (value.charAt(0) == '#')
         m.set(new ISOField(i, ISOUtil.zeropad(Integer.toString(seq.get(value.substring(1))), 6)));
       else if (value.charAt(0) == '$') {
         String p = cfg.get(value.substring(1), null);
         if (p != null) m.set(new ISOField(i, p));
       }
     }
   }
 }
Beispiel #14
0
  public synchronized LogEvent log(LogEvent ev) {
    if (socket != null && ev.getTag() != null && tags.contains(ev.getTag())) {
      int facility = cfg.getInt(ev.getTag() + ".facility", defaultFacility);
      int severity = cfg.getInt(ev.getTag() + ".severity", defaultSeverity);
      int priority = (facility << 3) | severity;

      StringBuilder sb = new StringBuilder();
      sb.append('<');
      sb.append(Integer.toString(priority));
      sb.append('>');
      if (prefix != null) {
        sb.append(prefix);
        sb.append(' ');
      }
      sb.append(ev.getRealm());
      sb.append(' ');
      sb.append(ev.getTag());
      sb.append(" - ");
      synchronized (ev.getPayLoad()) {
        Iterator iter = ev.getPayLoad().iterator();
        for (int i = 0; iter.hasNext(); i++) {
          if (i > 0) sb.append(' ');
          sb.append(iter.next().toString());
        }
      }
      byte[] b = sb.toString().getBytes();
      DatagramPacket packet = new DatagramPacket(b, Math.min(b.length, 1024), host, port);
      try {
        socket.send(packet);
      } catch (IOException e) {
        ev.addMessage("--- SysLogListener error ---");
        ev.addMessage(e);
      }
    }
    return ev;
  }
Beispiel #15
0
 public String select(long id, Serializable ser) {
   Context ctx = (Context) ser;
   String name = cfg.get("name");
   String action = ctx.get(name) != null ? YES : NO;
   return cfg.get(action, UNKNOWN);
 }
Beispiel #16
0
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   super.setConfiguration(cfg);
   schema = cfg.get("schema");
 }