Repository: zest-qi4j Updated Branches: refs/heads/master a675e78c5 -> 74ee70365
Scheduler, minor: java 7 changes, 2.0 usage, formatting Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/b65ecb6f Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/b65ecb6f Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/b65ecb6f Branch: refs/heads/master Commit: b65ecb6ff009589a357cba4555b85e3cb87798d7 Parents: 592bb1f Author: Paul Merlin <[email protected]> Authored: Thu Feb 20 22:04:58 2014 +0100 Committer: Paul Merlin <[email protected]> Committed: Thu Feb 20 22:04:58 2014 +0100 ---------------------------------------------------------------------- libraries/scheduler/build.gradle | 16 +++---- libraries/scheduler/src/docs/scheduler.txt | 2 +- .../org/qi4j/library/scheduler/Scheduler.java | 21 +++++---- .../library/scheduler/SchedulerActivation.java | 48 -------------------- .../scheduler/SchedulerConfiguration.java | 23 ++++++---- .../qi4j/library/scheduler/SchedulerMixin.java | 38 +++++++++------- .../library/scheduler/SchedulerService.java | 39 ++++++++-------- .../java/org/qi4j/library/scheduler/Task.java | 31 +++++++------ .../scheduler/bootstrap/SchedulerAssembler.java | 30 ++++++------ .../library/scheduler/schedule/Schedule.java | 23 ++++++---- .../scheduler/schedule/ScheduleFactory.java | 7 ++- .../scheduler/schedule/ScheduleTime.java | 10 +--- .../library/scheduler/schedule/Schedules.java | 4 +- .../scheduler/schedule/cron/CronExpression.java | 20 ++++---- .../schedule/cron/CronExpressionConstraint.java | 24 +++++----- .../scheduler/schedule/cron/CronSchedule.java | 7 +-- .../schedule/cron/CronScheduleEntity.java | 23 ---------- .../schedule/cron/CronScheduleValue.java | 23 ---------- .../scheduler/schedule/once/OnceSchedule.java | 9 ++-- .../schedule/once/OnceScheduleEntity.java | 23 ---------- .../schedule/once/OnceScheduleValue.java | 23 ---------- .../library/scheduler/timeline/Timeline.java | 20 ++++---- .../timeline/TimelineForScheduleConcern.java | 20 ++++---- .../scheduler/timeline/TimelineRecord.java | 22 +++++---- .../scheduler/timeline/TimelineRecordStep.java | 21 +++++---- .../timeline/TimelineScheduleMixin.java | 11 ++--- .../timeline/TimelineScheduleState.java | 1 - .../timeline/TimelineSchedulerServiceMixin.java | 17 +++---- .../scheduler/AbstractSchedulerTest.java | 27 ++++++----- .../org/qi4j/library/scheduler/Constants.java | 24 +++++----- .../org/qi4j/library/scheduler/FooTask.java | 24 ++++++---- .../scheduler/docsupport/SchedulerDocs.java | 30 +++++++++--- 32 files changed, 287 insertions(+), 374 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/build.gradle ---------------------------------------------------------------------- diff --git a/libraries/scheduler/build.gradle b/libraries/scheduler/build.gradle index 4a6e91d..82d7ebb 100644 --- a/libraries/scheduler/build.gradle +++ b/libraries/scheduler/build.gradle @@ -4,13 +4,13 @@ jar { manifest { name = "Qi4j Library - Scheduler" }} dependencies { - compile( project( ":org.qi4j.core:org.qi4j.core.bootstrap" ) ) - compile( project( ':org.qi4j.libraries:org.qi4j.library.constraints' ) ) - compile( libraries.sked ) + compile project( ":org.qi4j.core:org.qi4j.core.bootstrap" ) + compile project( ':org.qi4j.libraries:org.qi4j.library.constraints' ) + compile libraries.sked - testCompile( project( ":org.qi4j.core:org.qi4j.core.testsupport" ) ) - testCompile( project( ":org.qi4j.extensions:org.qi4j.extension.indexing-rdf" ) ) + testCompile project( ":org.qi4j.core:org.qi4j.core.testsupport" ) + testCompile project( ":org.qi4j.extensions:org.qi4j.extension.indexing-rdf" ) - testRuntime( project( ":org.qi4j.core:org.qi4j.core.runtime" ) ) - testRuntime( libraries.logback ) -} \ No newline at end of file + testRuntime project( ":org.qi4j.core:org.qi4j.core.runtime" ) + testRuntime libraries.logback +} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/docs/scheduler.txt ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/docs/scheduler.txt b/libraries/scheduler/src/docs/scheduler.txt index ee88d75..aef4486 100644 --- a/libraries/scheduler/src/docs/scheduler.txt +++ b/libraries/scheduler/src/docs/scheduler.txt @@ -42,7 +42,7 @@ tag=configuration == Writing Tasks == -To write a schedulable Task, compose an EntityComposite using Task to be able to schedule it. +To write a schedulable Task, compose an Entity with the Task type to be able to schedule it. The Task contract is quite simple: http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java index b4b9ebc..1b30045 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; @@ -41,7 +45,6 @@ import static org.qi4j.api.unitofwork.concern.UnitOfWorkPropagation.Propagation. @Concerns( UnitOfWorkConcern.class ) public interface Scheduler { - /** * Schedule a Task to be run after a given initial delay in seconds. * http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerActivation.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerActivation.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerActivation.java deleted file mode 100644 index 0cb4209..0000000 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerActivation.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2012, Paul Merlin. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.qi4j.library.scheduler; - -import org.qi4j.api.activation.ActivatorAdapter; -import org.qi4j.api.service.ServiceReference; - -public interface SchedulerActivation -{ - - void activateScheduler() - throws Exception; - - void passivateScheduler() - throws Exception; - - class Activator - extends ActivatorAdapter<ServiceReference<SchedulerActivation>> - { - - @Override - public void afterActivation( ServiceReference<SchedulerActivation> activated ) - throws Exception - { - activated.get().activateScheduler(); - } - - @Override - public void beforePassivation( ServiceReference<SchedulerActivation> passivating ) - throws Exception - { - passivating.get().passivateScheduler(); - } - - } - -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerConfiguration.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerConfiguration.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerConfiguration.java index 39db4f3..35d3f37 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerConfiguration.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerConfiguration.java @@ -1,22 +1,25 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; import org.qi4j.api.common.Optional; import org.qi4j.api.common.UseDefaults; -import org.qi4j.api.configuration.ConfigurationComposite; import org.qi4j.api.property.Property; /** @@ -24,7 +27,7 @@ import org.qi4j.api.property.Property; * * Every property has a default value, you can use a {@link Scheduler} without providing any. */ -public interface SchedulerConfiguration extends ConfigurationComposite +public interface SchedulerConfiguration { // START SNIPPET: configuration /** http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java index 14e1c09..9058f45 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; @@ -29,6 +33,7 @@ import org.qi4j.api.configuration.Configuration; import org.qi4j.api.injection.scope.Service; import org.qi4j.api.injection.scope.Structure; import org.qi4j.api.injection.scope.This; +import org.qi4j.api.service.ServiceActivation; import org.qi4j.api.structure.Module; import org.qi4j.api.unitofwork.NoSuchEntityException; import org.qi4j.api.unitofwork.UnitOfWork; @@ -44,7 +49,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SchedulerMixin - implements Scheduler, SchedulerActivation + implements Scheduler, ServiceActivation { private static final Logger LOGGER = LoggerFactory.getLogger( Scheduler.class ); private static final int DEFAULT_WORKERS_COUNT = Runtime.getRuntime().availableProcessors() + 1; @@ -53,7 +58,7 @@ public class SchedulerMixin @Service private ScheduleFactory scheduleFactory; - private final SortedSet<ScheduleTime> timingQueue = new TreeSet<ScheduleTime>(); + private final SortedSet<ScheduleTime> timingQueue = new TreeSet<>(); private ScheduledExecutorService managementExecutor; private ThreadPoolExecutor taskExecutor; @@ -191,10 +196,9 @@ public class SchedulerMixin } @Override - public void activateScheduler() + public void activateService() throws Exception { - // Handle configuration defaults SchedulerConfiguration configuration = config.get(); Integer workersCount = configuration.workersCount().get(); @@ -260,7 +264,7 @@ public class SchedulerMixin } @Override - public void passivateScheduler() + public void passivateService() throws Exception { LOGGER.debug( "Passivated" ); @@ -273,7 +277,6 @@ public class SchedulerMixin class ScheduleHandler implements Runnable { - private ScheduleRunner scheduleRunner; private ScheduledFuture<?> future; @@ -305,9 +308,9 @@ public class SchedulerMixin public static class ScheduleRunner implements Runnable { - private Module module; - private ScheduleTime schedule; - private SchedulerMixin schedulerMixin; + private final Module module; + private final ScheduleTime schedule; + private final SchedulerMixin schedulerMixin; public ScheduleRunner( ScheduleTime schedule, SchedulerMixin schedulerMixin, Module module ) { @@ -354,4 +357,5 @@ public class SchedulerMixin } } } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerService.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerService.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerService.java index 7d7df6c..8cb8264 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerService.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerService.java @@ -1,51 +1,53 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2014, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicInteger; -import org.qi4j.api.activation.Activators; -import org.qi4j.api.configuration.Configuration; +import org.qi4j.api.entity.Identity; import org.qi4j.api.injection.scope.This; import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceComposite; +import org.qi4j.api.service.ServiceActivation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Mixins( { SchedulerMixin.class, SchedulerService.ThreadFactory.class, SchedulerService.RejectionHandler.class } ) -@Activators( SchedulerActivation.Activator.class ) -public interface SchedulerService extends Scheduler, SchedulerActivation, Configuration, ServiceComposite +public interface SchedulerService + extends Scheduler, ServiceActivation, Identity { class RejectionHandler implements RejectedExecutionHandler { - public static final Logger logger = LoggerFactory.getLogger( SchedulerService.class ); + private static final Logger LOGGER = LoggerFactory.getLogger( SchedulerService.class ); @Override public void rejectedExecution( Runnable r, ThreadPoolExecutor executor ) { - logger.error( "Runnable [" + r + "] was rejected by executor [" + executor + "]" ); + LOGGER.error( "Runnable [" + r + "] was rejected by executor [" + executor + "]" ); } } class ThreadFactory implements java.util.concurrent.ThreadFactory { - - private static final AtomicInteger poolNumber = new AtomicInteger( 1 ); + private static final AtomicInteger POOL_NUMBER = new AtomicInteger( 1 ); private final ThreadGroup group; private final AtomicInteger threadNumber = new AtomicInteger( 1 ); private final String namePrefix; @@ -54,7 +56,7 @@ public interface SchedulerService extends Scheduler, SchedulerActivation, Config { SecurityManager sm = System.getSecurityManager(); group = ( sm != null ) ? sm.getThreadGroup() : Thread.currentThread().getThreadGroup(); - namePrefix = me.identity().get() + "-P" + poolNumber.getAndIncrement() + "W"; + namePrefix = me.identity().get() + "-P" + POOL_NUMBER.getAndIncrement() + "W"; } @Override @@ -72,4 +74,5 @@ public interface SchedulerService extends Scheduler, SchedulerActivation, Config return thread; } } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Task.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Task.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Task.java index f8f75e9..84c034c 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Task.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Task.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; @@ -27,14 +31,14 @@ import org.qi4j.api.unitofwork.UnitOfWork; * * Here is a simple example: * <pre> - * interface MyTaskEntity - * extends Task, EntityComposite + * interface MyTask + * extends Task * { * Property<String customState(); * Association<AnotherEntity> anotherEntity(); * } * - * abstract class MyTaskMixin + * class MyTaskMixin * implements Runnable * { * @This MyTaskEntity me; @@ -44,16 +48,15 @@ import org.qi4j.api.unitofwork.UnitOfWork; * } * } * </pre> + * Finaly, {@literal MyTask} must be assembled into an {@literal EntityComposite}. */ // START SNIPPET: task public interface Task - extends Runnable + extends Runnable { - Property<String> name(); @UseDefaults Property<List<String>> tags(); - } // END SNIPPET: task http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/bootstrap/SchedulerAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/bootstrap/SchedulerAssembler.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/bootstrap/SchedulerAssembler.java index 16372a5..9981c0c 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/bootstrap/SchedulerAssembler.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/bootstrap/SchedulerAssembler.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.bootstrap; @@ -24,10 +28,8 @@ import org.qi4j.library.scheduler.SchedulerConfiguration; import org.qi4j.library.scheduler.SchedulerService; import org.qi4j.library.scheduler.schedule.ScheduleFactory; import org.qi4j.library.scheduler.schedule.Schedules; -import org.qi4j.library.scheduler.schedule.cron.CronScheduleEntity; -import org.qi4j.library.scheduler.schedule.cron.CronScheduleValue; -import org.qi4j.library.scheduler.schedule.once.OnceScheduleEntity; -import org.qi4j.library.scheduler.schedule.once.OnceScheduleValue; +import org.qi4j.library.scheduler.schedule.cron.CronSchedule; +import org.qi4j.library.scheduler.schedule.once.OnceSchedule; import org.qi4j.library.scheduler.timeline.Timeline; import org.qi4j.library.scheduler.timeline.TimelineForScheduleConcern; import org.qi4j.library.scheduler.timeline.TimelineRecord; @@ -72,9 +74,9 @@ public class SchedulerAssembler { assembly.services( ScheduleFactory.class ); assembly.entities( Schedules.class ); - EntityDeclaration scheduleEntities = assembly.entities( CronScheduleEntity.class, OnceScheduleEntity.class ); + EntityDeclaration scheduleEntities = assembly.entities( CronSchedule.class, OnceSchedule.class ); - ValueDeclaration scheduleValues = assembly.values( CronScheduleValue.class, OnceScheduleValue.class ); + ValueDeclaration scheduleValues = assembly.values( CronSchedule.class, OnceSchedule.class ); ServiceDeclaration schedulerDeclaration = assembly.services( SchedulerService.class ) .visibleIn( visibility() ) http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java index c8b34c9..5fba485 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.schedule; @@ -24,7 +28,8 @@ import org.qi4j.library.scheduler.Task; /** * Represent the scheduling of a {@link Task}. */ -public interface Schedule extends Identity +public interface Schedule + extends Identity { /** * @return The Association to the Task to be executed when it is time. http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java index 0e7ece5..7f5b88c 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java @@ -20,7 +20,6 @@ import org.qi4j.api.entity.EntityBuilder; import org.qi4j.api.injection.scope.Service; import org.qi4j.api.injection.scope.Structure; import org.qi4j.api.mixin.Mixins; -import org.qi4j.api.service.ServiceComposite; import org.qi4j.api.structure.Module; import org.qi4j.api.unitofwork.UnitOfWork; import org.qi4j.api.value.ValueBuilder; @@ -32,14 +31,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Mixins( ScheduleFactory.Mixin.class ) -public interface ScheduleFactory extends ServiceComposite +public interface ScheduleFactory { - Schedule newCronSchedule( Task task, String cronExpression, DateTime start, boolean durable ); Schedule newOnceSchedule( Task task, DateTime runAt, boolean durable ); - abstract class Mixin + class Mixin implements ScheduleFactory { private static final Logger logger = LoggerFactory.getLogger( ScheduleFactory.class ); @@ -118,4 +116,5 @@ public interface ScheduleFactory extends ServiceComposite return schedule; } } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java index db67c4a..7bf07d9 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.schedule; public final class ScheduleTime @@ -44,19 +43,12 @@ public final class ScheduleTime { return false; } - ScheduleTime that = (ScheduleTime) o; - if( nextTime != that.nextTime ) { return false; } - if( !scheduleIdentity.equals( that.scheduleIdentity ) ) - { - return false; - } - - return true; + return scheduleIdentity.equals( that.scheduleIdentity ); } @Override http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedules.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedules.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedules.java index a987647..9df8b61 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedules.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedules.java @@ -14,13 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.schedule; import org.qi4j.api.association.ManyAssociation; -import org.qi4j.api.entity.EntityComposite; -public interface Schedules extends EntityComposite +public interface Schedules { ManyAssociation<Schedule> schedules(); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpression.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpression.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpression.java index f75ff32..fb5160b 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpression.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpression.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.schedule.cron; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpressionConstraint.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpressionConstraint.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpressionConstraint.java index 4b2ecfb..bf9f480 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpressionConstraint.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronExpressionConstraint.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.schedule.cron; @@ -18,9 +22,8 @@ import org.codeartisans.sked.cron.CronSchedule; import org.qi4j.api.constraint.Constraint; public class CronExpressionConstraint - implements Constraint<CronExpression, String> + implements Constraint<CronExpression, String> { - private static final long serialVersionUID = 1L; @Override @@ -28,5 +31,4 @@ public class CronExpressionConstraint { return CronSchedule.isExpressionValid( cronExpression ); } - } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java index 0a9ae16..a1645bf 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java @@ -14,10 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.schedule.cron; -import org.qi4j.api.entity.EntityComposite; import org.qi4j.api.mixin.Mixins; import org.qi4j.api.property.Immutable; import org.qi4j.api.property.Property; @@ -26,7 +24,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Mixins( CronSchedule.CronScheduleMixin.class ) -public interface CronSchedule extends Schedule, EntityComposite +public interface CronSchedule + extends Schedule { /** * The Cron expression indicating when the Schedule is to be run. @@ -72,6 +71,7 @@ public interface CronSchedule extends Schedule, EntityComposite @Override public boolean isTaskRunning() { + // See SchedulerMixin.ScheduleRunner::run return false; } @@ -88,4 +88,5 @@ public interface CronSchedule extends Schedule, EntityComposite return nextRun; } } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleEntity.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleEntity.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleEntity.java deleted file mode 100644 index 626b933..0000000 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleEntity.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.library.scheduler.schedule.cron; - -import org.qi4j.api.entity.EntityComposite; - -public interface CronScheduleEntity extends CronSchedule, EntityComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleValue.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleValue.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleValue.java deleted file mode 100644 index e621c24..0000000 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronScheduleValue.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.library.scheduler.schedule.cron; - -import org.qi4j.api.value.ValueComposite; - -public interface CronScheduleValue extends CronSchedule, ValueComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java index 03eb45f..637e3d2 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java @@ -14,20 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.schedule.once; -import org.qi4j.api.entity.EntityComposite; import org.qi4j.api.mixin.Mixins; import org.qi4j.library.scheduler.schedule.Schedule; @Mixins( OnceSchedule.OnceScheduleMixin.class ) -public interface OnceSchedule extends Schedule, EntityComposite +public interface OnceSchedule + extends Schedule { abstract class OnceScheduleMixin implements OnceSchedule { - private boolean running; @Override @@ -71,4 +69,5 @@ public interface OnceSchedule extends Schedule, EntityComposite return start().get().toString(); } } -} \ No newline at end of file + +} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleEntity.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleEntity.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleEntity.java deleted file mode 100644 index 0392b96..0000000 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleEntity.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.library.scheduler.schedule.once; - -import org.qi4j.api.entity.EntityComposite; - -public interface OnceScheduleEntity extends OnceSchedule, EntityComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleValue.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleValue.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleValue.java deleted file mode 100644 index 895dd00..0000000 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceScheduleValue.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.qi4j.library.scheduler.schedule.once; - -import org.qi4j.api.value.ValueComposite; - -public interface OnceScheduleValue extends OnceSchedule, ValueComposite -{ -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java index 7067962..9c77162 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.timeline; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java index 70dab94..60bedba 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java @@ -1,19 +1,20 @@ /* - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2012, Niclas Hedhman. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.timeline; import java.io.BufferedOutputStream; @@ -27,7 +28,8 @@ import org.qi4j.api.structure.Module; import org.qi4j.api.value.ValueBuilder; import org.qi4j.library.scheduler.schedule.Schedule; -public abstract class TimelineForScheduleConcern extends ConcernOf<Schedule> +public abstract class TimelineForScheduleConcern + extends ConcernOf<Schedule> implements Schedule { @This http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java index 08fdd82..f4ac63f 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java @@ -1,16 +1,20 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.timeline; @@ -31,7 +35,6 @@ import org.qi4j.library.scheduler.Scheduler; public interface TimelineRecord extends Comparable<TimelineRecord>, ValueComposite { - /** * @return Identity of the associated {@link Scheduler} */ @@ -72,4 +75,5 @@ public interface TimelineRecord return timestamp().get().compareTo( o.timestamp().get() ); } } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecordStep.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecordStep.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecordStep.java index 9138365..fd329c7 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecordStep.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecordStep.java @@ -1,22 +1,25 @@ /* - * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved. - * Copyright (c) 2012, Niclas Hedhman. All Rights Reserved. + * Copyright (c) 2010-2012, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler.timeline; public enum TimelineRecordStep { - STARTED, SUCCESS, FAILURE, http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java index d50c185..eb91f1c 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.timeline; import java.util.Collection; @@ -49,7 +48,7 @@ public class TimelineScheduleMixin { return Collections.unmodifiableCollection( timelineRecords ); } - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); for( int i = size - maxResults; i < size; i++ ) { result.add( timelineRecords.get( i ) ); @@ -60,7 +59,7 @@ public class TimelineScheduleMixin @Override public Iterable<TimelineRecord> getNextRecords( int maxResults ) { - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); long time = System.currentTimeMillis(); for( int i = 0; i < maxResults; i++ ) { @@ -80,7 +79,7 @@ public class TimelineScheduleMixin public Iterable<TimelineRecord> getRecords( long from, long to ) { long now = System.currentTimeMillis(); - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); result.addAll( getPastRecords( from ) ); result.addAll( getFutureRecords( now, to ) ); return result; @@ -88,7 +87,7 @@ public class TimelineScheduleMixin private Collection<? extends TimelineRecord> getPastRecords( long from ) { - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); List<TimelineRecord> timelineRecords = state.history().get(); for( TimelineRecord record : timelineRecords ) { @@ -108,7 +107,7 @@ public class TimelineScheduleMixin return Collections.emptyList(); } - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); long time = now; while( time <= to ) { http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleState.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleState.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleState.java index 45c3558..43790c1 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleState.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleState.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.timeline; import java.util.List; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java index f41e72b..8a55520 100644 --- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java +++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.qi4j.library.scheduler.timeline; import java.util.SortedSet; @@ -25,22 +24,18 @@ import org.qi4j.api.service.ServiceComposite; import org.qi4j.api.structure.Module; import org.qi4j.api.unitofwork.UnitOfWork; import org.qi4j.functional.Iterables; -import org.qi4j.library.scheduler.Scheduler; import org.qi4j.library.scheduler.SchedulerMixin; import org.qi4j.library.scheduler.SchedulerService; import org.qi4j.library.scheduler.schedule.Schedule; import org.qi4j.library.scheduler.schedule.Schedules; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * WARN TimelineService Mixin use SortedSets to keep records ordered and repeatedly search for the next run. Could be greedy with large intervals + * WARN TimelineService Mixin use SortedSets to keep records ordered and repeatedly search for the next run. + * Could be greedy with large intervals */ public abstract class TimelineSchedulerServiceMixin implements Timeline, ServiceComposite { - private static final Logger LOGGER = LoggerFactory.getLogger( Scheduler.class ); - @Structure private Module module; @@ -50,7 +45,7 @@ public abstract class TimelineSchedulerServiceMixin @Override public Iterable<TimelineRecord> getLastRecords( int maxResults ) { - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); UnitOfWork uow = module.currentUnitOfWork(); String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler ); @@ -67,7 +62,7 @@ public abstract class TimelineSchedulerServiceMixin @Override public Iterable<TimelineRecord> getNextRecords( int maxResults ) { - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); UnitOfWork uow = module.currentUnitOfWork(); String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler ); Schedules schedules = uow.get( Schedules.class, schedulesName ); @@ -83,7 +78,7 @@ public abstract class TimelineSchedulerServiceMixin @Override public Iterable<TimelineRecord> getRecords( DateTime from, DateTime to ) { - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); UnitOfWork uow = module.currentUnitOfWork(); String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler ); @@ -100,7 +95,7 @@ public abstract class TimelineSchedulerServiceMixin @Override public Iterable<TimelineRecord> getRecords( long from, long to ) { - SortedSet<TimelineRecord> result = new TreeSet<TimelineRecord>(); + SortedSet<TimelineRecord> result = new TreeSet<>(); UnitOfWork uow = module.currentUnitOfWork(); String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler ); http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/AbstractSchedulerTest.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/AbstractSchedulerTest.java b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/AbstractSchedulerTest.java index cf7a133..19ea3f5 100644 --- a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/AbstractSchedulerTest.java +++ b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/AbstractSchedulerTest.java @@ -1,15 +1,19 @@ /* - * Copyright (c) 2010, Paul Merlin. All Rights Reserved. + * Copyright (c) 2010-2014, Paul Merlin. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; @@ -22,11 +26,11 @@ import org.qi4j.test.AbstractQi4jTest; import org.qi4j.test.EntityTestAssembler; public abstract class AbstractSchedulerTest - extends AbstractQi4jTest + extends AbstractQi4jTest { - + @Override public final void assemble( ModuleAssembly assembly ) - throws AssemblyException + throws AssemblyException { assembly.entities( FooTask.class ); @@ -37,7 +41,7 @@ public abstract class AbstractSchedulerTest } protected abstract void onAssembly( ModuleAssembly module ) - throws AssemblyException; + throws AssemblyException; protected final FooTask createFooTask( UnitOfWork uow, String name, String input ) { @@ -47,5 +51,4 @@ public abstract class AbstractSchedulerTest task.input().set( input ); return builder.newInstance(); } - } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/Constants.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/Constants.java b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/Constants.java index e270a59..6f8b13e 100644 --- a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/Constants.java +++ b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/Constants.java @@ -1,24 +1,26 @@ /* - * Copyright (c) 2010, Paul Merlin. All Rights Reserved. + * Copyright (c) 2010-2014, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; +// TODO Rename to TestConstants public interface Constants { - - Integer PULSE_RHYTHM_SECS = Integer.valueOf( 10 ); - Integer GC_RHYTHM_SECS = Integer.valueOf( 4200 ); - String FOO = "foo"; String BAR = "bar"; String BAZAR = "bazar"; } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java index 90a55f2..f46a256 100644 --- a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java +++ b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java @@ -1,15 +1,19 @@ /* - * Copyright (c) 2010, Paul Merlin. All Rights Reserved. + * Copyright (c) 2010-2014, Paul Merlin. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ package org.qi4j.library.scheduler; @@ -22,9 +26,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Mixins( FooTask.Mixin.class ) -public interface FooTask extends Task, EntityComposite +public interface FooTask + extends Task, EntityComposite { - Property<String> input(); @Optional @@ -39,6 +43,7 @@ public interface FooTask extends Task, EntityComposite @This private FooTask me; + @Override public void run() { LOGGER.info( "FooTaskEntity.run({})", me.input().get() ); @@ -55,4 +60,5 @@ public interface FooTask extends Task, EntityComposite } } } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b65ecb6f/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/docsupport/SchedulerDocs.java ---------------------------------------------------------------------- diff --git a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/docsupport/SchedulerDocs.java b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/docsupport/SchedulerDocs.java index 1a15239..25e45e2 100644 --- a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/docsupport/SchedulerDocs.java +++ b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/docsupport/SchedulerDocs.java @@ -1,7 +1,24 @@ +/* + * Copyright (c) 2010-2014, Paul Merlin. + * Copyright (c) 2012, Niclas Hedhman. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.qi4j.library.scheduler.docsupport; import org.qi4j.api.association.Association; -import org.qi4j.api.entity.EntityComposite; import org.qi4j.api.injection.scope.Service; import org.qi4j.api.injection.scope.This; import org.qi4j.api.property.Property; @@ -24,7 +41,8 @@ public class SchedulerDocs public void method() { MyTaskEntity myTask = todo(); - Schedule schedule = scheduler.scheduleOnce( myTask, 10, false ); // myTask will be run in 10 seconds from now + Schedule schedule = scheduler.scheduleOnce( myTask, 10, false ); + // myTask will be run in 10 seconds from now } // END SNIPPET: 2 @@ -33,18 +51,18 @@ public class SchedulerDocs } // START SNIPPET: 1 - interface MyTaskEntity extends Task, EntityComposite + interface MyTaskEntity extends Task { - Property<String> myTaskState(); Association<AnotherEntity> anotherEntity(); } - abstract class MyTaskMixin implements Runnable + class MyTaskMixin implements Runnable { @This MyTaskEntity me; + @Override public void run() { me.myTaskState().set(me.anotherEntity().get().doSomeStuff(me.myTaskState().get())); @@ -52,7 +70,7 @@ public class SchedulerDocs } // END SNIPPET: 1 - interface AnotherEntity extends EntityComposite + interface AnotherEntity { String doSomeStuff(String p); }
