polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [2/3] zest-java git commit: ZEST-128 - Chasing race condition problems.
Date Sun, 15 Nov 2015 11:05:51 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpression.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpression.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpression.java
deleted file mode 100644
index abba61b..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpression.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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
- *
- * 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.apache.zest.library.scheduler.schedule.cron;
-
-import java.lang.annotation.Retention;
-import org.apache.zest.api.constraint.ConstraintDeclaration;
-import org.apache.zest.api.constraint.Constraints;
-import org.apache.zest.library.constraints.annotation.InstanceOf;
-import org.apache.zest.library.constraints.annotation.NotEmpty;
-
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@ConstraintDeclaration
-@Retention( RUNTIME )
-@NotEmpty
-@InstanceOf( String.class )
-@Constraints( CronExpressionConstraint.class )
-public @interface CronExpression
-{
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpressionConstraint.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpressionConstraint.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpressionConstraint.java
deleted file mode 100644
index 02013e7..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronExpressionConstraint.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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
- *
- * 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.apache.zest.library.scheduler.schedule.cron;
-
-import org.codeartisans.sked.cron.CronSchedule;
-import org.apache.zest.api.constraint.Constraint;
-
-public class CronExpressionConstraint
-    implements Constraint<CronExpression, String>
-{
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public boolean isValid( CronExpression annotation, String cronExpression )
-    {
-        return CronSchedule.isExpressionValid( cronExpression );
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
deleted file mode 100644
index 4597e75..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/CronSchedule.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved.
- * 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.apache.zest.library.scheduler.schedule.cron;
-
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.library.scheduler.schedule.Schedule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Mixins( CronSchedule.CronScheduleMixin.class )
-public interface CronSchedule
-    extends Schedule
-{
-    /**
-     * The Cron expression indicating when the Schedule is to be run.
-     * The Schedule can NOT be changed once it is set. If this is needed, delete this Schedule
and attach the Task
-     * to a new Schedule.
-     *
-     * @return The cron expression that will be used on {@link org.apache.zest.api.unitofwork.UnitOfWork}
completion to compute next run
-     */
-    @CronExpression
-    @Immutable
-    Property<String> cronExpression();
-
-    abstract class CronScheduleMixin
-        implements CronSchedule
-    {
-        private static final Logger LOGGER = LoggerFactory.getLogger( Schedule.class );
-
-        @Override
-        public void taskStarting()
-        {
-        }
-
-        @Override
-        public void taskCompletedSuccessfully()
-        {
-        }
-
-        @Override
-        public void taskCompletedWithException( Throwable ex )
-        {
-        }
-
-        @Override
-        public String presentationString()
-        {
-            return cronExpression().get();
-        }
-
-        @Override
-        public long nextRun( long from )
-        {
-            long actualFrom = from;
-            long firstRun = start().get().getMillis();
-            if( firstRun > from )
-            {
-                actualFrom = firstRun;
-            }
-            Long nextRun = createCron().firstRunAfter( actualFrom );
-            LOGGER.info( "CronSchedule::nextRun({}) is {}", from, firstRun );
-            return nextRun;
-        }
-
-        private org.codeartisans.sked.cron.CronSchedule createCron()
-        {
-            return new org.codeartisans.sked.cron.CronSchedule( cronExpression().get() );
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/package.html
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/package.html
deleted file mode 100644
index f3fd2c2..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/cron/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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.
--->
-<html>
-    <body>
-        <h2>Scheduler CRON Schedules.</h2>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
deleted file mode 100644
index 8c78cc6..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/OnceSchedule.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2010-2012, Paul Merlin. All Rights Reserved.
- * 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.apache.zest.library.scheduler.schedule.once;
-
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.library.scheduler.schedule.Schedule;
-
-@Mixins( OnceSchedule.OnceScheduleMixin.class )
-public interface OnceSchedule
-    extends Schedule
-{
-    abstract class OnceScheduleMixin
-        implements OnceSchedule
-    {
-        @Override
-        public void taskStarting()
-        {
-        }
-
-        @Override
-        public void taskCompletedSuccessfully()
-        {
-        }
-
-        @Override
-        public void taskCompletedWithException( Throwable ex )
-        {
-        }
-
-        @Override
-        public long nextRun( long from )
-        {
-            if( done().get() )
-            {
-                return Long.MIN_VALUE;
-            }
-            done().set( true );
-            long runAt = start().get().getMillis();
-            if( runAt >= from )
-            {
-                return runAt;
-            }
-            return from;
-        }
-
-        @Override
-        public String presentationString()
-        {
-            return start().get().toString();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/package.html
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/package.html
deleted file mode 100644
index c12fd5b..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/once/package.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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.
--->
-<html>
-    <body>
-        <h2>Scheduler Once Schedules.</h2>
-    </body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
index 6bb5c3e..2ec856d 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
@@ -26,7 +26,7 @@ import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.library.scheduler.schedule.Schedule;
+import org.apache.zest.library.scheduler.Schedule;
 
 public abstract class TimelineForScheduleConcern
     extends ConcernOf<Schedule>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
index d66898e..01d9628 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
@@ -21,12 +21,11 @@ import java.util.Collections;
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
-import org.joda.time.DateTime;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.library.scheduler.schedule.Schedule;
+import org.apache.zest.library.scheduler.Schedule;
 
 public class TimelineScheduleMixin
     implements Timeline

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
index 3e097b4..d04934c 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
@@ -25,8 +25,8 @@ import org.apache.zest.api.structure.Module;
 import org.apache.zest.functional.Iterables;
 import org.apache.zest.library.scheduler.SchedulerService;
 import org.apache.zest.library.scheduler.SchedulesHandler;
-import org.apache.zest.library.scheduler.schedule.Schedule;
-import org.apache.zest.library.scheduler.schedule.Schedules;
+import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.internal.Schedules;
 
 /**
  * WARN TimelineService Mixin use SortedSets to keep records ordered and repeatedly search
for the next run.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
index 76063f0..ad210a2 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
@@ -22,13 +22,13 @@ package org.apache.zest.library.scheduler;
 
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.value.ValueSerialization;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
-import org.apache.zest.library.scheduler.schedule.cron.CronSchedule;
 import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
 import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
 import org.joda.time.DateTime;
 import org.junit.Test;
 
@@ -41,7 +41,8 @@ public class CronScheduleTest extends AbstractZestTest
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
-        new OrgJsonValueSerializationAssembler().assemble( module );
+        module.services( OrgJsonValueSerializationService.class )
+            .taggedWith( ValueSerialization.Formats.JSON );
         module.services( MemoryEntityStoreService.class );
         module.services( UuidIdentityGeneratorService.class );
         module.entities( CronSchedule.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
index 5c0a226..15a356c 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
@@ -27,7 +27,6 @@ import org.apache.zest.api.usecase.UsecaseBuilder;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.library.scheduler.bootstrap.SchedulerAssembler;
-import org.apache.zest.library.scheduler.schedule.Schedule;
 import org.apache.zest.library.scheduler.timeline.Timeline;
 import org.joda.time.DateTime;
 import org.joda.time.Interval;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/73b7f196/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
index 9a78638..998d36b 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
@@ -27,7 +27,7 @@ import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkRetry;
 import org.apache.zest.library.scheduler.Scheduler;
 import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.library.scheduler.schedule.Schedule;
+import org.apache.zest.library.scheduler.Schedule;
 import org.apache.zest.library.scheduler.timeline.Timeline;
 
 public class SchedulerDocs


Mime
View raw message