Examples of Scheduler


Examples of org.apache.servicemix.components.varscheduler.Scheduler

    public synchronized void start() throws Exception {
        if (!started) {
            started = true;

            if (scheduler == null) {
                scheduler = new Scheduler(true);
            }
            if (scheduleIterator == null) {
                scheduleIterator = new PollingEndpoint.PollScheduleIterator();
            }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

    private static Scheduler getSingletonScheduler() throws Exception {
      if (singletonScheduler!=null) {
        return singletonScheduler;
      }
        final Scheduler newscheduler = new QuartzScheduler();
        final ThreadPoolManager tpm = new DefaultThreadPoolManager(null, null);
        try {
          PrivateAccessor.invoke(newscheduler, "bindThreadPoolManager",
              new Class[] { ThreadPoolManager.class },
              new Object[] { tpm });
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

    /**
     * run the runnable after the indicated number of seconds, once.
     * @return true if the scheduling of the runnable worked, false otherwise
     */
    private boolean runAfter(int seconds, final Runnable runnable) {
        final Scheduler theScheduler = scheduler;
      if (theScheduler == null) {
        logger.info("runAfter: no scheduler set");
        return false;
      }
      logger.debug("runAfter: trying with scheduler.fireJob");
      final Date date = new Date(System.currentTimeMillis() + seconds * 1000);
    try {
        theScheduler.fireJobAt(null, runnable, null, date);
      return true;
    } catch (Exception e) {
      logger.info("runAfter: could not schedule a job: "+e);
      return false;
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

        simpleReplicationQueueProvider.deleteQueue(queue);
    }

    @Test
    public void testEnableQueueProcessing() throws Exception {
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(scheduler.NOW(-1, 10)).thenReturn(options);
        when(options.canRunConcurrently(false)).thenReturn(options);
        when(options.name(any(String.class))).thenReturn(options);
        SimpleReplicationQueueProvider simpleReplicationQueueProvider = new SimpleReplicationQueueProvider(scheduler);
        ReplicationQueueProcessor processor = mock(ReplicationQueueProcessor.class);
        simpleReplicationQueueProvider.enableQueueProcessing("dummy-agent", processor);
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

        simpleReplicationQueueProvider.enableQueueProcessing("dummy-agent", processor);
    }

    @Test
    public void testDisableQueueProcessing() throws Exception {
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(scheduler.NOW(-1, 10)).thenReturn(options);
        when(options.canRunConcurrently(false)).thenReturn(options);
        when(options.name(any(String.class))).thenReturn(options);
        SimpleReplicationQueueProvider simpleReplicationQueueProvider = new SimpleReplicationQueueProvider(scheduler);
        simpleReplicationQueueProvider.disableQueueProcessing("dummy-agent");
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

    public void testRegister() throws Exception {
        for (ReplicationActionType action : ReplicationActionType.values()) {
            String path = "/path/to/somewhere";
            int interval = 10;
            ReplicationRequestHandler handler = mock(ReplicationRequestHandler.class);
            Scheduler scheduler = mock(Scheduler.class);
            ScheduleOptions options = mock(ScheduleOptions.class);
            when(scheduler.NOW(-1, interval)).thenReturn(options);
            when(options.name(handler.toString())).thenReturn(options);
            ScheduledReplicationTrigger scheduledReplicationTrigger = new ScheduledReplicationTrigger(action.name(), path, interval, scheduler);
            scheduledReplicationTrigger.register(handler);
        }
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

    @Test
    public void testUnregister() throws Exception {
        for (ReplicationActionType action : ReplicationActionType.values()) {
            String path = "/path/to/somewhere";
            int interval = 10;
            Scheduler scheduler = mock(Scheduler.class);
            ScheduledReplicationTrigger scheduledReplicationTrigger = new ScheduledReplicationTrigger(action.name(), path, interval, scheduler);
            ReplicationRequestHandler handlerId = mock(ReplicationRequestHandler.class);
            scheduledReplicationTrigger.unregister(handlerId);
        }
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

    public void testRegister() throws Exception {
        ReplicationRequestHandler handler = mock(ReplicationRequestHandler.class);
        String endpoint = "";
        TransportAuthenticationProvider<CredentialsProvider, CredentialsProvider> authProvider = mock(TransportAuthenticationProvider.class);
        when(authProvider.canAuthenticate(CredentialsProvider.class)).thenReturn(true);
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(options.name(handler.toString())).thenReturn(options);
        when(scheduler.NOW()).thenReturn(options);
        RemoteEventReplicationTrigger remoteEventReplicationTrigger = new RemoteEventReplicationTrigger(
                endpoint, authProvider, scheduler);
        remoteEventReplicationTrigger.register(handler);
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

    public void testUnregister() throws Exception {
        String endpoint = "";
        String handlerId = "handler-id-1";
        TransportAuthenticationProvider<CredentialsProvider, CredentialsProvider> authProvider = mock(TransportAuthenticationProvider.class);
        when(authProvider.canAuthenticate(CredentialsProvider.class)).thenReturn(true);
        Scheduler scheduler = mock(Scheduler.class);
        RemoteEventReplicationTrigger remoteEventReplicationTrigger = new RemoteEventReplicationTrigger(
                endpoint, authProvider, scheduler);
        ReplicationRequestHandler handler = mock(ReplicationRequestHandler.class);
        remoteEventReplicationTrigger.unregister(handler);
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.Scheduler

        this.running = false;
        this.stopScheduling();
    }

    private void stopScheduling() {
        final Scheduler localScheduler = this.scheduler;
        if ( localScheduler != null ) {
            for(final String id : this.startedSchedulerJobs ) {
                localScheduler.unschedule(id);
            }
        }
        this.startedSchedulerJobs.clear();

        // stop background threads by putting empty objects into the queue
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.