本文整理汇总了Java中org.quartz.core.QuartzSchedulerResources类的典型用法代码示例。如果您正苦于以下问题:Java QuartzSchedulerResources类的具体用法?Java QuartzSchedulerResources怎么用?Java QuartzSchedulerResources使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QuartzSchedulerResources类属于org.quartz.core包,在下文中一共展示了QuartzSchedulerResources类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: instantiate
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
@Override
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs)
{
Scheduler scheduler = super.instantiate(rsrcs, qs);
JobStore jobStore = rsrcs.getJobStore();
if (jobStore instanceof SchedulerAware)
{
((SchedulerAware) jobStore).setScheduler(scheduler);
}
return scheduler;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:AlfrescoSchedulerFactory.java
示例2: instantiate
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs) {
SchedulingContext schedCtxt = new SchedulingContext();
schedCtxt.setInstanceId(rsrcs.getInstanceId());
Scheduler scheduler = new StdScheduler(qs, schedCtxt);
return scheduler;
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:8,代码来源:StdSchedulerFactory.java
示例3: createAndUpdateSchedule
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
@Test
public void createAndUpdateSchedule() throws Exception {
final ApplicationContext mockContext = Mockito.mock(ApplicationContext.class);
final VmScheduleRepository vmScheduleRepository = Mockito.mock(VmScheduleRepository.class);
final VmResource mockResource = Mockito.mock(VmResource.class);
final Subscription entity = this.subscriptionRepository.findOneExpected(subscription);
Mockito.when(mockContext.getBean(VmScheduleRepository.class)).thenReturn(vmScheduleRepository);
Mockito.when(mockContext.getBean(SecurityHelper.class)).thenReturn(Mockito.mock(SecurityHelper.class));
Mockito.when(mockContext.getBean(VmResource.class)).thenReturn(mockResource);
final StdScheduler scheduler = (StdScheduler) vmSchedulerFactoryBean.getScheduler();
final QuartzScheduler qscheduler = (QuartzScheduler) FieldUtils.getField(StdScheduler.class, "sched", true).get(scheduler);
final QuartzSchedulerResources resources = (QuartzSchedulerResources) FieldUtils.getField(QuartzScheduler.class, "resources", true)
.get(qscheduler);
final JobDetail jobDetail = scheduler.getJobDetail(scheduler.getJobKeys(GroupMatcher.anyJobGroup()).iterator().next());
// "ON" call would fail
Mockito.doThrow(new RuntimeException()).when(mockResource).execute(entity, VmOperation.ON);
try {
// Mock the factory
jobDetail.getJobDataMap().put("context", mockContext);
((RAMJobStore) resources.getJobStore()).storeJob(jobDetail, true);
Assert.assertEquals(1, this.vmScheduleRepository.findAll().size());
// Schedule all operations within the next 2 seconds
final String cron = "" + ((DateUtils.newCalendar().get(Calendar.SECOND) + 2) % 60) + " * * * * ?";
final int id = mockSchedule(vmScheduleRepository, resource.createSchedule(newSchedule(cron, VmOperation.OFF)));
mockSchedule(vmScheduleRepository, resource.createSchedule(newSchedule(cron + " *", VmOperation.ON)));
Assert.assertEquals(3, this.vmScheduleRepository.findAll().size());
// Yield for the schedules
Thread.sleep(2500);
// Check the executions
Mockito.verify(mockResource).execute(entity, VmOperation.OFF);
Mockito.verify(mockResource).execute(entity, VmOperation.ON); // Failed
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.REBOOT);
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.RESET);
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.SHUTDOWN);
Mockito.verify(mockResource, Mockito.never()).execute(entity, VmOperation.SUSPEND);
// Update the CRON and the operation
final VmScheduleVo vo = newSchedule("" + ((DateUtils.newCalendar().get(Calendar.SECOND) + 2) % 60) + " * * * * ?",
VmOperation.SHUTDOWN);
vo.setId(id);
vo.setSubscription(subscription);
resource.updateSchedule(vo);
Assert.assertEquals(3, this.vmScheduleRepository.findAll().size());
// Yield for the schedules
Thread.sleep(2500);
Mockito.verify(mockResource).execute(entity, VmOperation.SHUTDOWN);
} finally {
// Restore the factory's context
jobDetail.getJobDataMap().put("context", applicationContext);
((RAMJobStore) resources.getJobStore()).storeJob(jobDetail, true);
}
}
开发者ID:ligoj,项目名称:plugin-vm,代码行数:61,代码来源:VmResourceTest.java
示例4: instantiate
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
protected Scheduler instantiate(QuartzSchedulerResources rsrcs, QuartzScheduler qs) {
Scheduler scheduler = new StdScheduler(qs);
return scheduler;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:StdSchedulerFactory.java
示例5: createRemoteScheduler
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
/**
* Same as
* {@link DirectSchedulerFactory#createRemoteScheduler(String rmiHost, int rmiPort)},
* with the addition of specifying the scheduler name, instance ID, and rmi
* bind name. This scheduler can only be retrieved via
* {@link DirectSchedulerFactory#getScheduler(String)}
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param rmiBindName
* The name of the remote scheduler in the RMI repository. If null
* defaults to the generated unique identifier.
* @param rmiHost
* The hostname for remote scheduler
* @param rmiPort
* Port for the remote scheduler. The default RMI port is 1099.
* @throws SchedulerException
* if the remote scheduler could not be reached.
*/
public void createRemoteScheduler(String schedulerName,
String schedulerInstanceId, String rmiBindName, String rmiHost, int rmiPort)
throws SchedulerException {
SchedulingContext schedCtxt = new SchedulingContext();
schedCtxt.setInstanceId(schedulerInstanceId);
String uid = (rmiBindName != null) ? rmiBindName :
QuartzSchedulerResources.getUniqueIdentifier(
schedulerName, schedulerInstanceId);
RemoteScheduler remoteScheduler = new RemoteScheduler(schedCtxt, uid,
rmiHost, rmiPort);
SchedulerRepository schedRep = SchedulerRepository.getInstance();
schedRep.bind(remoteScheduler);
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:38,代码来源:DirectSchedulerFactory.java
示例6: createRemoteScheduler
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
/**
* Same as
* {@link DirectSchedulerFactory#createRemoteScheduler(String rmiHost, int rmiPort)},
* with the addition of specifying the scheduler name, instance ID, and rmi
* bind name. This scheduler can only be retrieved via
* {@link DirectSchedulerFactory#getScheduler(String)}
*
* @param schedulerName
* The name for the scheduler.
* @param schedulerInstanceId
* The instance ID for the scheduler.
* @param rmiBindName
* The name of the remote scheduler in the RMI repository. If null
* defaults to the generated unique identifier.
* @param rmiHost
* The hostname for remote scheduler
* @param rmiPort
* Port for the remote scheduler. The default RMI port is 1099.
* @throws SchedulerException
* if the remote scheduler could not be reached.
*/
public void createRemoteScheduler(String schedulerName,
String schedulerInstanceId, String rmiBindName, String rmiHost, int rmiPort)
throws SchedulerException {
String uid = (rmiBindName != null) ? rmiBindName :
QuartzSchedulerResources.getUniqueIdentifier(
schedulerName, schedulerInstanceId);
RemoteScheduler remoteScheduler = new RemoteScheduler(uid, rmiHost, rmiPort);
SchedulerRepository schedRep = SchedulerRepository.getInstance();
schedRep.bind(remoteScheduler);
initialized = true;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:DirectSchedulerFactory.java
示例7: getScheduler
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
private QuartzScheduler getScheduler() {
Logger logger = LoggerFactory.getLogger(this.getClass());
if (scheduler == null) {
try {
QuartzSchedulerResources qsr = getQuartzSchedulerResources();
if (qsr.getThreadExecutor() == null) {
qsr.setThreadExecutor(new DefaultThreadExecutor());
}
qsr.getThreadPool().initialize();
QuartzScheduler qs = new QuartzScheduler(qsr, getDefaultIdleWaitTime(), -1);
ClassLoadHelper classLoadHelper = getJobStoreClassLoadHelper();
classLoadHelper.initialize();
qsr.getJobStore().initialize(classLoadHelper, qs.getSchedulerSignaler());
qsr.getJobRunShellFactory().initialize(this);
qs.initialize();
qs.setJobFactory(getInitialJobFactory());
logger.info("Quartz scheduler '" + qsr.getName());
logger.info("Quartz scheduler version: " + qs.getVersion());
scheduler = qs;
} catch (Exception ex) {
logger.error("Exception creating scheduler!", ex);
}
}
return scheduler;
}
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:38,代码来源:AbstractSchedulerProvider.java
示例8: getQuartzSchedulerResources
import org.quartz.core.QuartzSchedulerResources; //导入依赖的package包/类
/**
* Called when the scheduler is created to return a QuartzSchedulerResources that
* is used to configure the scheduler. This is called during scheduler creation only.
*
* The Quartz scheduler resource should have following set, at a minimum, to create a scheduler:
* <ul>
* <li>Name of the scheduler (setName)</li>
* <li>Instance name (setInstanceName)</li>
* <li>Job run shell factory (setJobRunShellFactory)</li>
* <li>Thread executor (setThreadExecutor)</li>
* <li>Job store (setJobStore)</li>
* <li>Thread pool (setThreadPool)</li>
* </ul>
*
* When the scheduler is created in the manager, the thread pool and job store will
* be initialized, so no need to do so in this function.
*
* Below is an example of creating and returning a scheduler resource:
* {@code
* if (qsr == null) {
* qsr = new QuartzSchedulerResources();
* qsr.setName(name);
* qsr.setJobRunShellFactory(new IPOJOJobRunShellFactory());
* qsr.setThreadExecutor(new DefaultThreadExecutor());
* qsr.setBatchTimeWindow(0l);
* qsr.setInstanceId(name + "_" + UUID.randomUUID().toString());
* qsr.setInterruptJobsOnShutdown(true);
* qsr.setInterruptJobsOnShutdownWithWait(true);
* qsr.setMaxBatchSize(1);
* qsr.setJobStore(new RAMJobStore());
* threadPool = new ResizableThreadPool(initialThreadPoolSize, threadPriority);
* qsr.setThreadPool(threadPool);
* }
* return qsr;
* }
*
* @see #getInitialJobFactory()
* @see #getJobStoreClassLoadHelper()
* @return QuartzSchedulerResource scheduler configuration
*/
protected abstract QuartzSchedulerResources getQuartzSchedulerResources();
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:42,代码来源:AbstractSchedulerProvider.java
注:本文中的org.quartz.core.QuartzSchedulerResources类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论