Examples of Properties


Examples of java.util.Properties

   *            a String of this form: 'key1="value1"; key2="value2";...
   *            keyN="valueN" '
   * @return a Properties object
   */
  public static Properties parseAttributes(String string) {
    Properties result = new Properties();
    if (string == null)
      return result;
    StringTokenizer keyValuePairs = new StringTokenizer(string, ";");
    StringTokenizer keyValuePair;
    String key;
    String value;
    while (keyValuePairs.hasMoreTokens()) {
      keyValuePair = new StringTokenizer(keyValuePairs.nextToken(), ":");
      if (keyValuePair.hasMoreTokens())
        key = keyValuePair.nextToken().trim();
      else
        continue;
      if (keyValuePair.hasMoreTokens())
        value = keyValuePair.nextToken().trim();
      else
        continue;
      if (value.startsWith("\""))
        value = value.substring(1);
      if (value.endsWith("\""))
        value = value.substring(0, value.length() - 1);
      result.setProperty(key.toLowerCase(), value);
    }
    return result;
  }
View Full Code Here

Examples of java.util.Properties

   * @param props
   * @throws HibernateException
   */
  protected synchronized void initDataSource(Properties props) throws HibernateException {
    String dataSourceClass = null;
    Properties new_props = new Properties();
    Iterator keys = props.keySet().iterator();
    while(keys.hasNext()){
      String key = (String)keys.next();
      //System.out.println(key+"="+props.getProperty(key));
      if(ENCODING_KEY.equalsIgnoreCase(key)){
        encoding = "true".equalsIgnoreCase(props.getProperty(key));
        useProxy = true;
      }
      else if(DATASOURCE_KEY.equalsIgnoreCase(key)){
        dataSourceClass = props.getProperty(key);
      }
      else if(key.startsWith(BASE_KEY)){
        String value = props.getProperty(key);
        value = StringUtils.replace(value, "{DLOG4J}", Globals.WEBAPP_PATH);
        new_props.setProperty(key.substring(BASE_KEY.length()), value);
      }
    }
    if(dataSourceClass == null)
      throw new HibernateException("Property 'dscp.datasource' no defined.");
    try {
View Full Code Here

Examples of java.util.Properties

   */
  protected Properties startHandler(Properties prop) throws Exception {
    if (logger.isLoggable(BasicLevel.DEBUG)) {
      logger.log(BasicLevel.DEBUG, "AcquisitionQueue.startHandler(" + prop + ')');
    }
    Properties p = prop;
    if (p == null)
      p = properties;
    return acquisitionModule.startHandler(p);
  }
View Full Code Here

Examples of java.util.Properties

   */
  protected Properties stopHandler(Properties prop) throws Exception {
    if (logger.isLoggable(BasicLevel.DEBUG)) {
      logger.log(BasicLevel.DEBUG, "AcquisitionQueue.stopHandler(" + prop + ')');
    }
    Properties p = prop;
    if (p == null)
      p = properties;
    return acquisitionModule.stopHandler(p);
  }
View Full Code Here

Examples of java.util.Properties

  private void loadServiceSettings(TvDataServiceProxy service) {
    File f=new File(Settings.getUserSettingsDirName(),service.getId()+".service");
    if (f.exists()) {
      try {
        Properties p=new Properties();
        BufferedInputStream in = new BufferedInputStream(new FileInputStream(f), 0x1000);
        p.load(in);
        in.close();
        service.loadSettings(p);
      } catch (IOException exc) {
        String msg = mLocalizer.msg("error.3", "Loading settings for plugin {0} failed!\n({1})",
            service.getInfo().getName(), f.getAbsolutePath(), exc);
        ErrorHandler.handle(msg, exc);
      }
    }else{
      service.loadSettings(new Properties());
    }
  }
View Full Code Here

Examples of java.util.Properties

      service.loadSettings(new Properties());
    }
  }

  private void storeServiceSettings(TvDataServiceProxy service) {
    final Properties prop = service.storeSettings();
    if (prop!=null) {
      String dir=Settings.getUserSettingsDirName();
      File f=new File(dir);
      if (!f.exists()) {
        f.mkdir();
      }
      f=new File(dir,service.getId()+".service");
      try {
        StreamUtilities.outputStream(f, new OutputStreamProcessor() {
          public void process(OutputStream outputStream) throws IOException {
            prop.store(outputStream, "settings");
          }
        });
      } catch (IOException exc) {
        String msg = mLocalizer.msg("error.4", "Saving settings for plugin {0} failed!\n({1})",
            service.getInfo().getName(), f.getAbsolutePath(), exc);
View Full Code Here

Examples of java.util.Properties

        ProtocolStack stack=ch.getProtocolStack();
        Protocol discovery=stack.removeProtocol("TCPPING");
        if(discovery != null){
            Protocol transport = stack.getTransport();
            MPING mping=new MPING();
            InetAddress bindAddress=Util.getBindAddress(new Properties());
            mping.setBindAddr(bindAddress);
            mping.setMulticastAddress("230.1.2.3");
            mping.setMcastPort(8888);           
            stack.insertProtocol(mping, ProtocolStack.ABOVE, transport.getName());
            mping.setProtocolStack(ch.getProtocolStack());
View Full Code Here

Examples of java.util.Properties

    }
  }

  private static Session initMailSession(){
        //Checks the pool and delivers a mail message
        Properties props = new Properties();
        //Not needed for production environment
        props.put("mail.debug", "false");
        //Prevents problems encountered with 250 OK Messages
        props.put("mail.smtp.ehlo", "false");
        //Sets timeout on going connections
        props.put("mail.smtp.timeout", smtpTimeout + "");

        props.put("mail.smtp.connectiontimeout", connectionTimeout + "");
        props.put("mail.smtp.sendpartial",String.valueOf(sendPartial));

        return Session.getInstance(props, null);
  }
View Full Code Here

Examples of java.util.Properties

        long period = getLong(FileMonitoringTimerTask.MONITORING_CONFIG_PERIOD_PROPERTY,
                              FileMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PERIOD).longValue();
        String results = getProperty(FileMonitoringTimerTask.MONITORING_RESULT_PATH_PROPERTY,
                                     FileMonitoringTimerTask.DEFAULT_MONITORING_RESULT_PATH);
       
        Properties monitoringProps = new Properties();
        monitoringProps.load(new FileInputStream(file));
       
        fileMonitoringTimerTask = new FileMonitoringTimerTask(getTimer(), period, monitoringProps, results);
        if (fileMonitoringTimerTask != null) {
          try {
            MXWrapper.registerMBean(fileMonitoringTimerTask,
                                    "AgentServer", "server=" + getName() + ",cons=FileMonitoring");
          } catch (Exception exc) {
            if (logmon == null)
              logmon = Debug.getLogger(AgentServer.class.getName());
            logmon.log(BasicLevel.ERROR, getName() + " jmx failed", exc);
          }
        }
      }
    } catch (Exception exc) {
      logmon.log(BasicLevel.WARN, getName() + "Cannot read monitoring configuration file: " + config, exc);
    }
   
    config = getProperty(LogMonitoringTimerTask.MONITORING_CONFIG_PATH_PROPERTY,
                         LogMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PATH);
    try {
      // if "logMonitoring.props" file exists configure a FileMonitoringTimerTask.
      File file = new File(config);
      if (file.exists()) {
        long period = getLong(LogMonitoringTimerTask.MONITORING_CONFIG_PERIOD_PROPERTY,
                              LogMonitoringTimerTask.DEFAULT_MONITORING_CONFIG_PERIOD).longValue();       
        String logname = getProperty(LogMonitoringTimerTask.MONITORING_RESULT_LOGGER_PROPERTY,
                                     LogMonitoringTimerTask.DEFAULT_MONITORING_RESULT_LOGGER);
        Logger logger = Debug.getLogger(logname);
        int loglevel = getInteger(LogMonitoringTimerTask.MONITORING_RESULT_LEVEL_PROPERTY,
                                  LogMonitoringTimerTask.DEFAULT_MONITORING_RESULT_LEVEL).intValue();
        String logmsg = getProperty(LogMonitoringTimerTask.MONITORING_RESULT_MESSAGE_PROPERTY,
                                    LogMonitoringTimerTask.DEFAULT_MONITORING_RESULT_MESSAGE);
       
        Properties monitoringProps = new Properties();
        monitoringProps.load(new FileInputStream(file));
       
        logMonitoringTimerTask = new LogMonitoringTimerTask(getTimer(), period, monitoringProps,
                                                            logger, logmsg, loglevel);

        if (logMonitoringTimerTask != null) {
View Full Code Here

Examples of java.util.Properties

     */
    private PersistenceManager createManagerFile(String filePath)
    {

            if(log.isInfoEnabled()) log.info("Creating file manager: " + filePath);
        Properties props;

        try
        {
            if (_manager == null)
            {
                props=readProps(filePath);
                String classname=props.getProperty(filePersistMgr);
                if(classname != null)
                {
                    Class cl=Util.loadClass(classname, this.getClass());
                    Constructor ctor=cl.getConstructor(new Class[]{String.class});
                    _manager=(PersistenceManager)ctor.newInstance(new Object[]{filePath});
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.