Package org.qi4j.library.scheduler.schedule

Examples of org.qi4j.library.scheduler.schedule.Schedule


    @Override
    public Schedule scheduleOnce( Task task, int initialSecondsDelay, boolean durable )
    {
        long now = System.currentTimeMillis();
        Schedule schedule = scheduleFactory.newOnceSchedule( task, new DateTime( now + initialSecondsDelay * 1000 ), durable );
        if( durable )
        {
            Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
            schedules.schedules().add( schedule );
        }
View Full Code Here


    }

    @Override
    public Schedule scheduleOnce( Task task, DateTime runAt, boolean durable )
    {
        Schedule schedule = scheduleFactory.newOnceSchedule( task, runAt, durable );
        dispatchForExecution( schedule );
        if( durable )
        {
            Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
            schedules.schedules().add( schedule );
View Full Code Here

    @Override
    public Schedule scheduleCron( Task task, String cronExpression, boolean durable )
    {
        DateTime now = new DateTime();
        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, now, durable );
        if( durable )
        {
            Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
            schedules.schedules().add( schedule );
        }
View Full Code Here

    }

    @Override
    public Schedule scheduleCron( Task task, @CronExpression String cronExpression, DateTime start, boolean durable )
    {
        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start, durable );
        if( durable )
        {
            Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
            schedules.schedules().add( schedule );
        }
View Full Code Here

    @Override
    public Schedule scheduleCron( Task task, String cronExpression, long initialDelay, boolean durable )
    {
        DateTime start = new DateTime( System.currentTimeMillis() + initialDelay );
        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start, durable );
        if( durable )
        {
            Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
            schedules.schedules().add( schedule );
        }
View Full Code Here

            System.out.println( "Running Schedule" );
            Usecase usecase = UsecaseBuilder.newUsecase( "ScheduleRunner" );
            UnitOfWork uow = module.newUnitOfWork( usecase );
            try
            {
                Schedule schedule = uow.get( Schedule.class, this.schedule.scheduleIdentity );
                Task task = schedule.task().get();
                schedule = uow.get( Schedule.class, this.schedule.scheduleIdentity );
                try
                {
                    schedule.taskStarting();
                    task.run();
                    schedule.taskCompletedSuccessfully();
                }
                catch( RuntimeException ex )
                {
                    schedule.taskCompletedWithException( ex );
                }
                schedulerMixin.dispatchForExecution( schedule );
                uow.complete();
            }
            catch( UnitOfWorkCompletionException ex )
View Full Code Here

    @Service Scheduler scheduler;

    public void method()
    {
        MyTaskEntity myTask = todo();
        Schedule schedule = scheduler.scheduleOnce( myTask, 10, false );
        // myTask will be run in 10 seconds from now
    }
View Full Code Here

TOP

Related Classes of org.qi4j.library.scheduler.schedule.Schedule

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.