private void runJob(final CronJob cronJob) throws IOException { final Element elementJob = cronJob.getElement(); final Element element = ((elementJob == null) ? fabricateElement(cronJob) : elementJob); final CronJob cronJob1 = new CronJob(cronJob.getName(), cronJob.isEnabled(), cronJob.getLine(), element); final Properties properties = CronProperties.getProperties(); final String className = properties.getProperty(element.getLocalName()); if (className != null) { runJob(cronJob1, className); } }
private RowTyped createRow(final Date date, final CronJob cronJob) { final RowSet rowSet = executor.getRowSet(); final Row row = new InsertRow(rowSet).getRow(); rowSet.add(row); final RowTyped rowTyped = new RowTyped(rowSet.getMetaData(), row); rowTyped.update("cronTab", executor.getCronTab().getName()); // i18n metadata rowTyped.update("cronJob", cronJob.getName()); // i18n metadata rowTyped.update("command", cronJob.getLine()); // i18n metadata rowTyped.update( "principal", ((invokerPrincipal == null) ? null : invokerPrincipal.getName())); // i18n meta rowTyped.update("date", date); // i18n metadata return rowTyped; }
private CronParams getParams(final Date date, final CronJob cronJob) { final String authorization = executor.getAuthorization(); final Principal principal = executor.getPrincipal(); final CronTab cronTab = executor.getCronTab(); final Element element = cronJob.getElement(); final RowTyped row = createRow(date, cronJob); return new CronParams(context, authorization, principal, date, cronTab, cronJob, element, row); }
private void runJob(final CronJob cronJob, final String className) { final CronTab cronTab = executor.getCronTab(); final ExecutorService executorService = executor.getExecutorService(); final CronParams params = getParams(dateSchedule, cronJob); final CronRunnable runnable = getRunnable(className, params); if (runnable != null) { logger.info( String.format("execute(%s/%s)", cronTab.getName(), cronJob.getName())); // i18n log executorService.execute(runnable); } }
private Element fabricateElement(final CronJob cronJob) throws IOException { final String command = cronJob.getCommand(); final String[] tokens = command.split(StringU.Const.WHITESPACE); final NameTypeValues arguments = HttpArguments.toArguments(tokens[1]); final Element element = DocumentU.createDocument(tokens[0], XMLConstants.NULL_NS_URI).getDocumentElement(); for (final NameTypeValue argument : arguments) { ElementU.setAttribute(element, argument.getName(), argument.getValueS()); } return element; }