Example usage for org.springframework.scheduling.quartz MethodInvokingJobDetailFactoryBean setBeanName

List of usage examples for org.springframework.scheduling.quartz MethodInvokingJobDetailFactoryBean setBeanName

Introduction

In this page you can find the example usage for org.springframework.scheduling.quartz MethodInvokingJobDetailFactoryBean setBeanName.

Prototype

@Override
    public void setBeanName(String beanName) 

Source Link

Usage

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.j  a va 2 s  . 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);
    }
}