Package org.quartz.impl

Examples of org.quartz.impl.StdSchedulerFactory


        Properties prop = loadProperties();
        if (prop != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Creating SchedulerFactory with properties: " + prop);
            }
            return new StdSchedulerFactory(prop);
        } else {
            return new StdSchedulerFactory();
        }
    }
View Full Code Here


  public boolean start() {
    try {
      //加载配置文件
      Properties properties = PropertiesKit.me().loadPropertyFile(config);
      //实例化
      QuartzFactory.me().sf = new StdSchedulerFactory(properties);
      //获取Scheduler
      Scheduler sched = QuartzFactory.me().sf.getScheduler();
      //内存,数据库的任务
      sched.start();
      //属性文件中的任务
View Full Code Here

    return scheduler == null ? null : scheduler.getSchedulerName();
  }

  public void setSchedulerName(String schedulerName)
      throws SchedulerException {
    this.scheduler = new StdSchedulerFactory().getScheduler(schedulerName);

    if (this.scheduler == null) {
      throw new IllegalArgumentException("Scheduler can not be found!");
    }
  }
View Full Code Here

    return scheduler == null ? null : scheduler.getSchedulerName();
  }

  public void setSchedulerName(String schedulerName)
      throws SchedulerException {
    this.scheduler = new StdSchedulerFactory().getScheduler(schedulerName);

    if (this.scheduler == null) {
      throw new IllegalArgumentException("Scheduler can not be found!");
    }
  }
View Full Code Here

  protected ExecutionSchedulerImpl(Configuration configuration) {
    this.configuration = configuration;
  }

  protected synchronized void initializeScheduler() {
    StdSchedulerFactory sf = new StdSchedulerFactory();
    Properties properties = getQuartzSchedulerProperties();
    try {
      sf.initialize(properties);
    } catch (SchedulerException e) {
      LOG.warn("Failed to initialize Request Execution Scheduler properties !");
      LOG.debug("Scheduler properties: \n" + properties);
      e.printStackTrace();
      return;
    }
    try {
      scheduler = sf.getScheduler();
      scheduler.setJobFactory(guiceJobFactory);
      isInitialized = true;
    } catch (SchedulerException e) {
      LOG.warn("Failed to create Request Execution scheduler !");
      e.printStackTrace();
View Full Code Here

  public static class TestExecutionScheduler extends ExecutionSchedulerImpl {
    @Inject
    public TestExecutionScheduler(Injector injector) {
      super(injector);
      try {
        StdSchedulerFactory factory = new StdSchedulerFactory();
        scheduler = factory.getScheduler();
        isInitialized = true;
      } catch (SchedulerException e) {
        e.printStackTrace();
        throw new ExceptionInInitializerError("Unable to instantiate " +
          "scheduler");
View Full Code Here

  }

  @Test
  @PrepareForTest({ ExecutionSchedulerImpl.class })
  public void testSchedulerStartStop() throws Exception {
    StdSchedulerFactory factory = createNiceMock(StdSchedulerFactory.class);
    Scheduler scheduler = createNiceMock(Scheduler.class);

    expect(factory.getScheduler()).andReturn(scheduler);
    expectPrivate(scheduler, "startDelayed", new Integer(180)).once();
    expectNew(StdSchedulerFactory.class).andReturn(factory);
    expectPrivate(scheduler, "shutdown").once();

    PowerMock.replay(factory, StdSchedulerFactory.class, scheduler);
View Full Code Here

  }

  @Test
  @PrepareForTest({ ExecutionSchedulerImpl.class })
  public void testSchedulerStartDelay() throws Exception {
    StdSchedulerFactory factory = createNiceMock(StdSchedulerFactory.class);
    Scheduler scheduler = createNiceMock(Scheduler.class);

    expect(factory.getScheduler()).andReturn(scheduler).anyTimes();
    expectNew(StdSchedulerFactory.class).andReturn(factory);
    expect(scheduler.isStarted()).andReturn(false).anyTimes();
    expectPrivate(scheduler, "startDelayed", new Integer(180)).once();
    expectPrivate(scheduler, "start").once();
View Full Code Here

        if (prop != null) {

            // force disabling update checker (will do online check over the internet)
            prop.put("org.quartz.scheduler.skipUpdateCheck", "true");

            answer = new StdSchedulerFactory(prop);
        } else {
            // read default props to be able to use a single scheduler per camel context
            // if we need more than one scheduler per context use setScheduler(Scheduler)
            // or setFactory(SchedulerFactory) methods

            // must use classloader from StdSchedulerFactory to work even in OSGi
            InputStream is = StdSchedulerFactory.class.getClassLoader().getResourceAsStream("org/quartz/quartz.properties");
            if (is == null) {
                throw new SchedulerException("Quartz properties file not found in classpath: org/quartz/quartz.properties");
            }
            prop = new Properties();
            try {
                prop.load(is);
            } catch (IOException e) {
                throw new SchedulerException("Error loading Quartz properties file from classpath: org/quartz/quartz.properties", e);
            }

            // camel context name will be a suffix to use one scheduler per context
            String identity = getCamelContext().getName();

            String instName = prop.getProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME);
            if (instName == null) {
                instName = "scheduler-" + identity;
            } else {
                instName = instName + "-" + identity;
            }
            prop.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instName);

            // force disabling update checker (will do online check over the internet)
            prop.put("org.quartz.scheduler.skipUpdateCheck", "true");

            answer = new StdSchedulerFactory(prop);
        }

        if (LOG.isDebugEnabled()) {
            String name = prop.getProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME);
            LOG.debug("Creating SchedulerFactory: {} with properties: {}", name, prop);
View Full Code Here

  public boolean start() {
    try {
      //加载配置文件
      Properties properties = PropertiesUtils.me().loadPropertyFile(config);
      //实例化
      QuartzFactory.me().sf = new StdSchedulerFactory(properties);
      //获取Scheduler
      Scheduler sched = QuartzFactory.me().sf.getScheduler();
      //内存,数据库的任务
      sched.start();
      //属性文件中的任务
View Full Code Here

TOP

Related Classes of org.quartz.impl.StdSchedulerFactory

Copyright © 2018 www.massapicom. 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.