| | |
| | | package com.ximple.eofms; |
| | | |
| | | import java.util.Date; |
| | | import javax.swing.JFrame; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.apache.commons.cli.CommandLine; |
| | | import org.apache.commons.cli.CommandLineParser; |
| | | import org.apache.commons.cli.HelpFormatter; |
| | | import org.apache.commons.cli.Option; |
| | | import org.apache.commons.cli.OptionBuilder; |
| | | import org.apache.commons.cli.Options; |
| | | import org.apache.commons.cli.ParseException; |
| | | import org.apache.commons.cli.PosixParser; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.awl.Wizard; |
| | | import org.quartz.JobDetail; |
| | | import org.quartz.Scheduler; |
| | | import org.quartz.SchedulerException; |
| | |
| | | public class XQuartzJobCarrier |
| | | { |
| | | static Log logger = LogFactory.getLog(XQuartzJobCarrier.class); |
| | | static Options options = new Options(); |
| | | |
| | | private static final String VERSION = "0.8.0"; |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | XQuartzJobCarrier instance = new XQuartzJobCarrier(); |
| | | instance.startScheduler(); |
| | | instance.initializeOption(); |
| | | instance.execute(args); |
| | | } |
| | | |
| | | private void initializeOption() |
| | | { |
| | | Option option; |
| | | option = OptionBuilder.create("help"); |
| | | option.setDescription("print this message"); |
| | | options.addOption(option); |
| | | |
| | | option = OptionBuilder.create("version"); |
| | | option.setDescription("print the version information and exit"); |
| | | options.addOption(option); |
| | | |
| | | option = OptionBuilder.create("wizard"); |
| | | option.setDescription("start wizard mode"); |
| | | options.addOption(option); |
| | | |
| | | option = OptionBuilder.create("verbose"); |
| | | option.setDescription("be extra verbose"); |
| | | options.addOption(option); |
| | | |
| | | option = OptionBuilder.create("debug"); |
| | | option.setDescription("print debugging information"); |
| | | options.addOption(option); |
| | | |
| | | option = OptionBuilder.create("jobfile"); |
| | | option.setDescription("use given jobfile"); |
| | | option.setArgName("file"); |
| | | options.addOption(option); |
| | | |
| | | } |
| | | |
| | | private void execute(String[] args) |
| | | { |
| | | // CommandLineParser parser = new GnuParser(); |
| | | CommandLineParser parser = new PosixParser(); |
| | | CommandLine commandLine = null; |
| | | try |
| | | { |
| | | // parse the command commandLine arguments |
| | | commandLine = parser.parse(options, args); |
| | | } |
| | | catch (ParseException exp) |
| | | { |
| | | // oops, something went wrong |
| | | System.err.println("Parsing failed. Reason: " + exp.getMessage()); |
| | | } |
| | | |
| | | if ((commandLine != null) && (commandLine.getOptions().length > 0)) |
| | | { |
| | | if (commandLine.hasOption("help")) |
| | | { |
| | | printHelpMessage(); |
| | | } else if (commandLine.hasOption("version")) |
| | | { |
| | | printVersionMessage(); |
| | | } else if (commandLine.hasOption("wizard")) |
| | | { |
| | | startWizardMode(); |
| | | } |
| | | return; |
| | | } |
| | | startScheduler(); |
| | | } |
| | | |
| | | private void printHelpMessage() |
| | | { |
| | | HelpFormatter formatter = new HelpFormatter(); |
| | | formatter.printHelp("XQuartzJobCarrier", options); |
| | | } |
| | | |
| | | private void printVersionMessage() |
| | | { |
| | | System.out.println("XQuartzJobCarrier - " + VERSION); |
| | | } |
| | | |
| | | public void startWizardMode() |
| | | { |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | Wizard wizard = new XQuartzJobWizard((JFrame) null); |
| | | |
| | | wizard.pack(); |
| | | wizard.setVisibleOnCenterOfScreen(); |
| | | } |
| | | }; |
| | | try |
| | | { |
| | | SwingUtilities.invokeLater(runnable); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void startScheduler() |