Example usage for java.util StringTokenizer nextElement

List of usage examples for java.util StringTokenizer nextElement

Introduction

In this page you can find the example usage for java.util StringTokenizer nextElement.

Prototype

public Object nextElement() 

Source Link

Document

Returns the same value as the nextToken method, except that its declared return value is Object rather than String .

Usage

From source file:org.kchine.r.server.DirectJNI.java

public static String[] getROptions() {
    String[] roptions = new String[] { "--no-save" };

    if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) {
        roptions = new String[] { "--no-save", "--internet2" };
    }/* w ww. j  av a  2 s . co  m*/

    if (System.getProperty("r.options") != null && !System.getProperty("r.options").equals("")) {
        Vector<String> roptionsVector = new Vector<String>();
        StringTokenizer st = new StringTokenizer(System.getProperty("r.options"), " ");
        while (st.hasMoreElements())
            roptionsVector.add((String) st.nextElement());
        roptions = roptionsVector.toArray(new String[0]);
    }
    System.out.println("r options:" + Arrays.toString(roptions));
    return roptions;
}

From source file:stg.pr.engine.CProcessRequestEngine.java

/**
 * Constructor of the class.//from   w  ww  . j ava 2  s .  co m
 * <p>
 * This constructor accepts a String variable that has the path of the init
 * file that has the path of all the property files that have to be loaded.
 * The engine only accesses properties from the pr.properties file. However
 * if the processes, that have to be executed, require any more property
 * files, then the path of these files can also be mentioned in this init
 * file
 * </p>
 * 
 * <p>
 * <ul>
 * <li>
 * Once the property file is loaded using the CSettings class, all the
 * attributes that the engine might access are retrieved and initialized to
 * the corresponding private member variables</li>
 * 
 * <li>
 * The max size defined for both the log files are checked, against the
 * respective buffer sizes, to see that max size's specified are greater
 * than the buffer sizes</li>
 * 
 * <li>
 * Engine log file is initialized and a database connection pool is created</li>
 * 
 * <li>
 * A Shutdown hook is added that listens for a termination event for eg:
 * CTRL-C Once the event occurs appropriate action is taken to release
 * resources.</li>
 * </ul>
 * </p>
 * 
 * @param pstrInitFile
 *            String path of the init file that has the path of all the
 *            property files that have to be loaded
 * @param pstrLoggerFile
 *            Log4J.properties file.
 * @throws Exception
 * 
 */
private CProcessRequestEngine(String pstrInitFile, String pstrLoggerFile, int iRebootCntr) throws Exception {

    try {
        PropertyConfigurator.configure(pstrLoggerFile);
        CSettings.getInstance().load(pstrInitFile);
        objEngineLogger_.log(LogLevel.NOTICE, info.toString());
        context_ = new PREContextImpl();
        context_.setPREinfo(info);
        if (objEngineLogger_.isInfoEnabled()) {
            objEngineLogger_.info("Initializing Engine");
        }
        setRebootCounter(iRebootCntr);
        //         System.setProperty("java.util.prefs.PreferencesFactory",
        //               "stg.utils.prefs.PREPreferencesFactoryImpl");
        //         System.setProperty("java.util.prefs.PreferencesFactory.file",
        //               CSettings.get("pr.java.util.prefs.PreferencesFactory.file",
        //                     null));
        //         try {
        //            installLic(); // always install the license so that if the
        //            // license is changed in between it will get
        //            // reflected.
        //            licContent_ = readLicense();
        //            LicenseVerifier.verify(licContent_);
        //            objEngineLogger_.log(LogLevel.NOTICE, "Licensed to "
        //                  + licContent_.getHolder().getName() + " for usage of "
        //                  + licContent_.getConsumerAmount() + " threads.");
        //            objEngineLogger_.log(LogLevel.NOTICE, "Valid up to "
        //                  + licContent_.getNotAfter());
        //            Day now = new Day();
        //            objEngineLogger_.log(LogLevel.NOTICE, "Days remaining "
        //                  + Math.abs(now.daysBetween(licContent_.getNotAfter())));
        //         } catch (LicenseContentException lce) {
        //            generateLicenseRequest();
        //            objEngineLogger_.log(LogLevel.FATAL, "Invalid license.");
        ////            System.err.println(lce.getLocalizedMessage());
        //            throw new Exception(lce.getLocalizedMessage());
        //         } catch (Exception e2) {
        //             objEngineLogger_.log(LogLevel.FATAL, "Invalid license.");
        //            generateLicenseRequest();
        ////            System.err.println(e2.getLocalizedMessage());
        //            throw new Exception(e2.getLocalizedMessage());
        //         }

        lStuckThreadMonitorInterval_ = Math
                .abs(Long.parseLong(CSettings.get("pr.stuckthreadmonitorinterval", "0")));
        if (lStuckThreadMonitorInterval_ <= 0) {
            throw new IllegalArgumentException(
                    "Property stuckthreadmonitorinterval should be greater than zero");
        }
        if (objEngineLogger_.isEnabledFor(LogLevel.FINEST)) {
            objEngineLogger_.log(LogLevel.FINEST, "Redirecting System.out and System.err to log4j");
        }
        System.setErr(
                new PrintStream(new LoggingOutputStream(Logger.getLogger("System.err"), Level.WARN), true));
        System.setOut(
                new PrintStream(new LoggingOutputStream(Logger.getLogger("System.out"), Level.INFO), true));
    } catch (Exception e) {
        throw e;
    }

    if (objEngineLogger_.isInfoEnabled()) {
        objEngineLogger_.info("CLASSPATH=" + System.getProperty("java.class.path"));
    }

    strReqLogFilePath_ = CSettings.get("pr.requestlogfilepath");
    strReqLogFileUrl_ = CSettings.get("pr.requestlogfileurl");
    strReqLogFileExtension_ = CSettings.get("pr.requestlogfileextension");
    paramSimpleDateFormat_ = new SimpleDateFormat(CSettings.get("pr.paramdateformat"));
    paramSimpleTimeFormat_ = new SimpleDateFormat(CSettings.get("pr.paramtimeformat"));
    paramSimpleDateTimeFormat_ = new SimpleDateFormat(CSettings.get("pr.paramdatetimeformat"));
    strParamArrValueDelim_ = CSettings.get("pr.paramarrvaluedelim");

    FILTER_CONDITION = CSettings.get("pr.requesttypefilter", "XYZ");
    if (!FILTER_CONDITION.equals("INCLUDE") && !FILTER_CONDITION.equals("EXCLUDE")) {
        throw new CProcessRequestEngineException(
                "Invalid FILTER type specified for property requesttypefilter.");
    }
    iStandAloneMaximumThread_ = CSettings.getInteger("pr.standalonemaxiumthreads");
    iGroupMaximumThread_ = CSettings.getInteger("pr.groupmaxiumthreads");
    if (iStandAloneMaximumThread_ <= 0) {
        throw new CProcessRequestEngineException("Invalid maximum threads for StandAlone engine configured.");
    }
    if (iGroupMaximumThread_ <= 0) {
        throw new CProcessRequestEngineException("Invalid maximum threads for Group engine configured.");
    }
    String strRequestTypes = CSettings.get("pr.processrequesttype", null);
    if (strRequestTypes == null) {
        throw new CProcessRequestEngineException(
                "Invalid processrequesttype defined. There must be a default value.");
    }
    StringTokenizer tokenizer = new StringTokenizer(strRequestTypes, ",");
    StringBuffer buffer = new StringBuffer();
    while (tokenizer.hasMoreTokens()) {
        buffer.append("'");
        buffer.append(tokenizer.nextElement());
        buffer.append("'");
        buffer.append(",");
    }
    buffer.deleteCharAt(buffer.length() - 1);
    if (FILTER_CONDITION.equals("INCLUDE")) {
        FILTER_CONDITION = "req_type IN (" + buffer.toString() + ")";
    } else {
        FILTER_CONDITION = "req_type NOT IN (" + buffer.toString() + ")";
    }

    try {
        (CCustomClassLoaderFactory.getInstance()).getClassLoader(this);
        // dummy call As this is a SingleTon Factory Pattern
    } catch (Exception e) {
        throw e;
        // throw new CProcessRequestEngineException("ClassLoader: " +
        // e.getMessage());
    }

    iMaximumFetchSizeAtATime_ = Math.abs(
            Integer.parseInt(CSettings.get("pr.maximumfetchsizeinsinglefetch", CSettings.get("pr.dbcon"))));
    iThreadCounter_ = new AtomicInteger(1);
    iGrpThreadCounter_ = new AtomicInteger(1);
    setRebootMaxCounter(Integer.parseInt(CSettings.get("pr.rebootmaxcounter", "-1")));
    setRebootSleepTime(Long.parseLong(CSettings.get("pr.sleepbeforereboottime", "5")));

    hmWhereCondition_ = new HashMap<String, String>();
    hmWhereCondition_.put("getScheduledTime", " <= ");

    bGroupEngineToBeStarted_ = ((CSettings.get("pr.groupengine", "OFF").equals("OFF")) ? false : true);

    httpserver_ = new CHttpServer(); // instantiate http server

    // bEngineTerminationConfirmed_ = false;

    vectorThreads_ = new Vector<Thread>(); // Inital size will be equal to
    // the total threads
    vectorThreadsGroup_ = new Vector<Thread>(); // =================== ""
    // =======================

    // These NET properties are available only in JDK1.4.x and above.
    // Added by Kedar on July 31, 2004 .....SouthField Detroit USA
    System.setProperty("http.keepAlive", CSettings.get("pr.http.keepAlive", "true"));
    System.setProperty("http.maxConnections", CSettings.get("pr.http.maxConnections", "5"));
    System.setProperty("sun.net.client.defaultConnectTimeout",
            CSettings.get("pr.sun.net.client.defaultConnectTimeout", "10000"));
    System.setProperty("sun.net.client.defaultReadTimeout",
            CSettings.get("pr.sun.net.client.defaultReadTimeout", "10000"));

    try {
        jobMonitorEscalationTimeInterval_ = Math
                .abs(Integer.parseInt(CSettings.get("pr.jobmonitorescalationtimeinterval", "30")));
    } catch (NumberFormatException e) {
        objEngineLogger_.error("Invalid value specified for jobmonitorescalationtimeinterval in properties.");
        if (objEngineLogger_.isInfoEnabled()) {
            objEngineLogger_.info("Defaulting jobmonitorescalationtimeinterval to 30 minutes.");
        }
        jobMonitorEscalationTimeInterval_ = 30;
    }

    /*
     * Anonymous inner class passed as a parameter to addShutdownHook This
     * thread is registered with the JVM, and the JVM starts this just
     * before shutting down. For eg: when u try to abort by pressing Ctrl-C.
     * Hence run method is called and in turn terminateEngine method is
     * called where resources are released.
     */
    if (objEngineLogger_.isInfoEnabled()) {
        objEngineLogger_.info("Add ShutDown Hook ....");
    }
    if (objEngineLogger_.isInfoEnabled()) {
        objEngineLogger_.info("ShutDown Hook Added....");
        objEngineLogger_.info("Initializing Connection Pool ....");
    }
    Class<?> c = Class.forName(
            CSettings.get("pr.dataSourceFactory", "stg.pr.engine.datasource.defaultimpl.PREDataSourceFactory"));
    Object obj = c.newInstance();
    if (obj instanceof IDataSourceFactory) {
        dataSourceFactory_ = (IDataSourceFactory) obj;
        if (!dataSourceFactory_.initialize(new File(CSettings.get("pr.dataSourceFactoryConfigFile")))) {
            throw new CProcessRequestEngineException("Could not initialize the data source factory.");
        }
    } else {
        throw new CProcessRequestEngineException("Class does not implement IDataSource");
    }

    if (objEngineLogger_.isInfoEnabled()) {
        objEngineLogger_.info("Initiating the cluster using the configuration from file "
                + System.getProperty("hazelcast.config"));
    }
    Config config = ConfigLoader.load(System.getProperty("hazelcast.config"));
    Hazelcast.init(config);

    loadStartupClasses();

    for (Entry<String, Service> entry : services_.entrySet()) {
        Service service = entry.getValue();
        if (service instanceof Singleton<?>) {
            Singleton<?> singleton = (Singleton<?>) service;
            context_.addSingletonIfAbsent(entry.getKey(), singleton);
            if (objEngineLogger_.isInfoEnabled()) {
                objEngineLogger_.info("Service " + entry.getKey() + ":" + entry.getValue().getClass().getName()
                        + "made available to the context.. ");
            }
        } else {
            if (objEngineLogger_.isInfoEnabled()) {
                objEngineLogger_.info("Service " + entry.getKey() + ":" + entry.getValue().getClass().getName()
                        + "is unavailable to the context.. ");
            }
        }
    }

    startWebServer();

    //      if (CSettings.get("pr.reportService", "OFF").equalsIgnoreCase("ON")) {
    //         if (objEngineLogger_.isInfoEnabled()) {
    //            objEngineLogger_.info("Starting the Report Services.");
    //         }
    //         try {
    //            EngineConfig reportConfig = new EngineConfig();
    //            reportConfig.setBIRTHome(CSettings.get("pr.birt.home"));
    //            reportConfig.setLogConfig(CSettings.get("pr.birt.log.dir"),
    //                  java.util.logging.Level.parse(CSettings
    //                        .get("pr.birt.log.level")));
    //            reportConfig.setProperty("ThreadPoolServiceSize", CSettings
    //                  .getInt("pr.birt.threadpoolsize", 3));
    //            reportService = ReportService.getService(reportConfig);
    //            if (objEngineLogger_.isEnabledFor(LogLevel.NOTICE)) {
    //               objEngineLogger_.log(LogLevel.NOTICE,
    //                     "Report Services started");
    //            }
    //         } catch (ReportServiceException e) {
    //            objEngineLogger_.fatal("Report Service exception encountered",
    //                  e);
    //            if (objEngineLogger_.isEnabledFor(LogLevel.NOTICE)) {
    //               objEngineLogger_.log(LogLevel.NOTICE,
    //                     "Unable to start the report services.");
    //            }
    //         }
    //      }

    if (objEngineLogger_.isInfoEnabled()) {
        objEngineLogger_.info("Engine Initialized");
    }
    // This thread is now assigned upfront as in the Terminate engine if
    // called from Reboot Sequence then
    // the shutdown hook has to be removed from the Runtime instance.
    tInterrupt_ = new Thread("shutdown") {

        public void run() {
            objEngineLogger_.log(LogLevel.NOTICE, "ShutDown Hook In Running mode.");
            terminateEngine();
        }
    };
    Runtime.getRuntime().addShutdownHook(tInterrupt_);

}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/directory/dept/delete", method = RequestMethod.POST)
public String consoleDeptDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        departmentDao.deleteDepartment(id);
    }/*from   w  ww  .  j  a  v a2 s .  c om*/
    return "console/directory/orgList";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/directory/grade/delete", method = RequestMethod.POST)
public String consoleGradeDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        gradeDao.deleteGrade(id);//  w w  w .j a  va  2  s  .  co m
    }
    return "console/directory/orgList";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/directory/group/delete", method = RequestMethod.POST)
public String consoleGroupDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        groupDao.deleteGroup(id);//w  w w .j  ava 2 s .  c o m
    }
    return "console/directory/groupList";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/monitor/process/delete", method = RequestMethod.POST)
public String consoleMonitorProcessDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        workflowManager.removeProcessInstance(id);
    }//  w w w  . j av  a 2 s  .  c om
    return "console/dialogClose";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/setting/message/delete", method = RequestMethod.POST)
public String consoleSettingMessageDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        ResourceBundleMessage o = rbmDao.getMessageById(id);
        rbmDao.delete(o);/*from  w  w  w  . j av  a2 s .c o  m*/
    }
    return "console/dialogClose";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/setting/eaContent/delete", method = RequestMethod.POST)
public String consoleSettingEmailApprovalContentDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        EmailApprovalContent eaContent = eaContentDao.getEmailApprovalContentById(id);
        eaContentDao.delete(eaContent);//  ww  w . j  a  v a 2 s .  com
    }
    return "console/dialogClose";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/setting/scheduler/delete", method = RequestMethod.POST)
public String consoleSettingSchedulerDelete(@RequestParam(value = "ids") String ids) {
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        SchedulerDetails details = schedulerDetailsDao.getSchedulerDetailsById(id);
        schedulerManager.deleteJob(details);
    }// ww w  .  ja  v a  2  s  .  co  m
    return "console/dialogClose";
}

From source file:org.joget.apps.app.controller.ConsoleWebController.java

@RequestMapping(value = "/console/app/(*:appId)/(~:version)/datalist/delete", method = RequestMethod.POST)
public String consoleDatalistDelete(@RequestParam(value = "ids") String ids, @RequestParam String appId,
        @RequestParam(required = false) String version) {
    AppDefinition appDef = appService.getAppDefinition(appId, version);
    StringTokenizer strToken = new StringTokenizer(ids, ",");
    while (strToken.hasMoreTokens()) {
        String id = (String) strToken.nextElement();
        datalistDefinitionDao.delete(id, appDef);
    }//w  w w. j  av  a2s.c om
    return "console/dialogClose";
}