List of usage examples for org.springframework.scheduling.quartz MethodInvokingJobDetailFactoryBean afterPropertiesSet
@Override
public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodException
From source file:com.linuxbox.enkive.statistics.consolidation.ConsolidationRunner.java
@PostConstruct public void init() throws Exception { // create factory MethodInvokingJobDetailFactoryBean jobDetail = new MethodInvokingJobDetailFactoryBean(); jobDetail.setTargetObject(this); jobDetail.setName("ConsolidationRunnerJob"); jobDetail.setTargetMethod("run"); jobDetail.setConcurrent(false);// w w w .j ava2 s . c o m jobDetail.afterPropertiesSet(); // create trigger CronTriggerBean trigger = new CronTriggerBean(); trigger.setBeanName("ConsolidationRunnerTrigger"); trigger.setJobDetail((JobDetail) jobDetail.getObject()); trigger.setCronExpression(schedule); trigger.afterPropertiesSet(); // add to schedule defined in spring xml scheduler.scheduleJob((JobDetail) jobDetail.getObject(), trigger); }
From source file:com.thinkbiganalytics.scheduler.QuartzScheduler.java
private JobDetail getJobDetail(JobIdentifier jobIdentifier, Object task, String runMethod) throws NoSuchMethodException, ClassNotFoundException { MethodInvokingJobDetailFactoryBean bean = new MethodInvokingJobDetailFactoryBean(); bean.setTargetObject(task);/*www .j av a 2s . c o m*/ bean.setTargetMethod(runMethod); bean.setName(jobIdentifier.getName()); bean.setGroup(jobIdentifier.getGroup()); bean.afterPropertiesSet(); return bean.getObject(); }
From source file:ome.services.blitz.test.mock.MockFixture.java
public MockFixture(MockObjectTestCase test, OmeroContext ctx) { this.test = test; this.ctx = ctx; this.ring = (Ring) ctx.getBean("ring"); this.ex = (Executor) ctx.getBean("executor"); this.ss = (SecuritySystem) ctx.getBean("securitySystem"); this.mgr = (SessionManager) ctx.getBean("sessionManager"); this.sql = (SqlAction) ctx.getBean("simpleSqlAction"); // -------------------------------------------- InitializationData id = new InitializationData(); id.properties = Ice.Util.createProperties(); //// w w w .ja v a 2s . co m // The follow properties are necessary for Gateway // // Collocation isn't working (but should) id.properties.setProperty("Ice.Default.CollocationOptimized", "0"); // Gateway calls back on the SF and so needs another thread or // blocks. id.properties.setProperty("Ice.ThreadPool.Client.Size", "2"); id.properties.setProperty("Ice.ThreadPool.Client.SizeMax", "50"); id.properties.setProperty("Ice.ThreadPool.Server.Size", "10"); id.properties.setProperty("Ice.ThreadPool.Server.SizeMax", "100"); // For testing large calls id.properties.setProperty("Ice.MessageSizeMax", "4096"); // Basic configuration id.properties.setProperty("BlitzAdapter.Endpoints", "default -h 127.0.0.1"); // Cluster configuration from etc/internal.cfg id.properties.setProperty("Cluster.Endpoints", "udp -h 224.0.0.5 -p 10000"); id.properties.setProperty("ClusterProxy", "Cluster:udp -h 224.0.0.5 -p 10000"); /* Node node = new Node(); this.mock("executorMock").expects(test.once()).method("execute").will(test.returnValue(node)); this.mock("executorMock").expects(test.once()).method("execute").will(test.returnValue(true)); this.mock("executorMock").expects(test.once()).method("execute").will(test.returnValue(Collections.EMPTY_LIST)); */ blitz = new BlitzConfiguration(id, ring, mgr, ss, ex); this.sm = (SessionManagerI) blitz.getBlitzManager(); this.sm.setApplicationContext(ctx); this.ctx.addApplicationListener(this.sm); /* UNUSED // The following is a bit of spring magic so that we can configure // the adapter in code. If this can be pushed to BlitzConfiguration // for example then we might not need it here anymore. HotSwappableTargetSource ts = (HotSwappableTargetSource) ctx .getBean("swappableAdapterSource"); ts.swap(blitz.getBlitzAdapter()); */ // Add our topic manager TopicManager tm = new TopicManager.Impl(blitz.getCommunicator()); this.ctx.addApplicationListener(tm); // Setup mock router which allows us to use omero.client // rather than solely ServiceFactoryProxies, though it is // still necessary to call the proper mock methods. Ice.ObjectPrx prx = blitz.getBlitzAdapter().add(new MockRouter(this.sm), Ice.Util.stringToIdentity("OMERO.Glacier2/router")); router = "OMERO.Glacier2/router:" + prx.ice_getEndpoints()[0]._toString(); // Finally, starting a scheduler to act like a real // server try { MethodInvokingJobDetailFactoryBean runBeats = new MethodInvokingJobDetailFactoryBean(); runBeats.setBeanName("runBeats"); runBeats.setTargetMethod("requestHeartBeats"); runBeats.setTargetObject(blitz.getBlitzManager()); runBeats.afterPropertiesSet(); CronTriggerBean triggerBeats = new CronTriggerBean(); triggerBeats.setBeanName("triggerBeats"); triggerBeats.setJobDetail((JobDetail) runBeats.getObject()); triggerBeats.setCronExpression("0-59/5 * * * * ?"); triggerBeats.afterPropertiesSet(); scheduler = new SchedulerFactoryBean(); scheduler.setApplicationContext(ctx); scheduler.setTriggers(new Trigger[] { triggerBeats }); scheduler.afterPropertiesSet(); scheduler.start(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.fineract.infrastructure.jobs.service.JobRegisterServiceImpl.java
private JobDetail createJobDetail(final ScheduledJobDetail scheduledJobDetail) throws Exception { final FineractPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); final ClassMethodNamesPair jobDetails = CronMethodParser .findTargetMethodDetails(scheduledJobDetail.getJobName()); if (jobDetails == null) { throw new IllegalArgumentException( "Code has no @CronTarget with this job name (@see JobName); seems like DB/code are not in line: " + scheduledJobDetail.getJobName()); }/*from www . j a v a2 s. c o m*/ final Object targetObject = getBeanObject(Class.forName(jobDetails.className)); final MethodInvokingJobDetailFactoryBean jobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean(); jobDetailFactoryBean.setName(scheduledJobDetail.getJobName() + "JobDetail" + tenant.getId()); jobDetailFactoryBean.setTargetObject(targetObject); jobDetailFactoryBean.setTargetMethod(jobDetails.methodName); jobDetailFactoryBean.setGroup(scheduledJobDetail.getGroupName()); jobDetailFactoryBean.setConcurrent(false); jobDetailFactoryBean.afterPropertiesSet(); return jobDetailFactoryBean.getObject(); }
From source file:org.mifosplatform.infrastructure.jobs.service.JobRegisterServiceImpl.java
private JobDetail createJobDetail(final ScheduledJobDetail scheduledJobDetail) throws Exception { final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); final ClassMethodNamesPair jobDetails = CronMethodParser .findTargetMethodDetails(scheduledJobDetail.getJobName()); if (jobDetails == null) { throw new IllegalArgumentException( "Code has no @CronTarget with this job name (@see JobName); seems like DB/code are not in line: " + scheduledJobDetail.getJobName()); }/*w w w .ja v a 2 s . c om*/ final Object targetObject = getBeanObject(Class.forName(jobDetails.className)); final MethodInvokingJobDetailFactoryBean jobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean(); jobDetailFactoryBean.setName(scheduledJobDetail.getJobName() + "JobDetail" + tenant.getId()); jobDetailFactoryBean.setTargetObject(targetObject); jobDetailFactoryBean.setTargetMethod(jobDetails.methodName); jobDetailFactoryBean.setGroup(scheduledJobDetail.getGroupName()); jobDetailFactoryBean.setConcurrent(false); jobDetailFactoryBean.afterPropertiesSet(); return jobDetailFactoryBean.getObject(); }