Merge pull request #83 from j-be/readme-jdk8

Fix wrong JDK version in README.md.
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/InjectableResource.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/InjectableResource.java
index aaffc27..4b40788 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/InjectableResource.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/InjectableResource.java
@@ -37,11 +37,11 @@
  * <b>Example:</b>
  * <pre>
  * &#064;Inject
- * &#064;InjectableResource("myfile.properties")
+ * &#064;InjectableResource(location="myfile.properties")
  * private Properties props;
  *
  * &#064;Inject
- * &#064;InjectableResource("config.xml")
+ * &#064;InjectableResource(location="config.xml")
  * private InputStream inputStream;
  * </pre>
  *
diff --git a/deltaspike/modules/scheduler/api/src/main/java/org/apache/deltaspike/scheduler/spi/SchedulerControl.java b/deltaspike/modules/scheduler/api/src/main/java/org/apache/deltaspike/scheduler/spi/SchedulerControl.java
new file mode 100644
index 0000000..1c6f0a0
--- /dev/null
+++ b/deltaspike/modules/scheduler/api/src/main/java/org/apache/deltaspike/scheduler/spi/SchedulerControl.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package org.apache.deltaspike.scheduler.spi;
+
+/**
+ * This interface provides high-level controls for the scheduler.
+ *
+ * It allows to control the scheduler as a whole ({@link #isSchedulerEnabled()}()) and on a per-job basis
+ * ({@link #vetoJobExecution(Class)}.
+ *
+ * The interface is meant to be implemented by a CDI bean.
+ */
+public interface SchedulerControl
+{
+    /**
+     * Control whether or not the scheduler should be started.
+     *
+     * @return if {@code true} the scheduler will be started, else not.
+     */
+    default boolean isSchedulerEnabled()
+    {
+        return true;
+    }
+
+    /**
+     * Invoked each time a job is triggered, this controls whether the given job shall be started or not.
+     *
+     * NOTE: This only applies if the scheduler is actually running (see {@link #isSchedulerEnabled()}).
+     *
+     *  @param jobClass the job which was triggered
+     * @return if {@code false} the job will be executed, else not.
+     */
+    default boolean vetoJobExecution(Class<?> jobClass)
+    {
+        return false;
+    }
+}
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/AbstractJobAdapter.java b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/AbstractJobAdapter.java
new file mode 100644
index 0000000..7180c1c
--- /dev/null
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/AbstractJobAdapter.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package org.apache.deltaspike.scheduler.impl;
+
+import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.util.ClassUtils;
+import org.apache.deltaspike.core.util.ProxyUtils;
+import org.apache.deltaspike.scheduler.spi.SchedulerControl;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import java.util.logging.Logger;
+
+public abstract class AbstractJobAdapter<T> implements Job
+{
+    private static final Logger LOG = Logger.getLogger(AbstractJobAdapter.class.getName());
+
+    @Inject
+    private BeanManager beanManager;
+
+    @Override
+    public void execute(JobExecutionContext context)
+    {
+        Class<? extends T> jobClass =
+                ClassUtils.tryToLoadClassForName(context.getJobDetail().getKey().getName(), getJobBaseClass());
+
+        SchedulerControl schedulerControl = BeanProvider.getContextualReference(SchedulerControl.class, true);
+        if (schedulerControl != null && schedulerControl.vetoJobExecution(jobClass))
+        {
+            LOG.info("Execution of job " + jobClass + " has been vetoed by " +
+                    ProxyUtils.getUnproxiedClass(schedulerControl.getClass()));
+            return;
+        }
+
+        T job = BeanProvider.getContextualReference(jobClass);
+
+        try
+        {
+            execute(job, context);
+        }
+        catch (Throwable t)
+        {
+            //just in this case to reduce the implementation(s) of runnable (annotated with @Scheduled)
+            //to an absolute minimum.
+            //(custom implementations of org.quartz.Job need to do it on their own)
+            this.beanManager.fireEvent(new ExceptionToCatchEvent(t));
+        }
+    }
+
+    protected abstract Class<T> getJobBaseClass();
+
+    public abstract void execute(T job, JobExecutionContext context) throws JobExecutionException;
+}
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobAdapter.java b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobAdapter.java
new file mode 100644
index 0000000..5cc8be7
--- /dev/null
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobAdapter.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+package org.apache.deltaspike.scheduler.impl;
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import javax.enterprise.inject.Typed;
+
+//configured via SchedulerBaseConfig
+@Typed()
+public class JobAdapter extends AbstractJobAdapter<Job>
+{
+    @Override
+    protected Class<Job> getJobBaseClass()
+    {
+        return Job.class;
+    }
+
+    @Override
+    public void execute(Job job, JobExecutionContext context) throws JobExecutionException
+    {
+        job.execute(context);
+    }
+}
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobQuartzScheduler.java b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobQuartzScheduler.java
index 785026e..bb88295 100644
--- a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobQuartzScheduler.java
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobQuartzScheduler.java
@@ -24,8 +24,14 @@
 public class JobQuartzScheduler extends AbstractQuartzScheduler<Job>
 {
     @Override
+    protected String getJobName(Class<?> jobClass)
+    {
+        return jobClass.getName();
+    }
+
+    @Override
     protected Class<? extends Job> createFinalJobClass(Class<? extends Job> jobClass)
     {
-        return jobClass;
+        return JobAdapter.class;
     }
 }
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
index 7891fb2..4c75bef 100644
--- a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/JobRunnableAdapter.java
@@ -18,42 +18,23 @@
  */
 package org.apache.deltaspike.scheduler.impl;
 
-import org.apache.deltaspike.core.api.exception.control.event.ExceptionToCatchEvent;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.core.util.ClassUtils;
-import org.quartz.Job;
 import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
 
 import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
 
 //configured via SchedulerBaseConfig
 @Typed()
-public class JobRunnableAdapter implements Job
+public class JobRunnableAdapter extends AbstractJobAdapter<Runnable>
 {
-    @Inject
-    private BeanManager beanManager;
+    @Override
+    protected Class<Runnable> getJobBaseClass()
+    {
+        return Runnable.class;
+    }
 
     @Override
-    public void execute(JobExecutionContext context) throws JobExecutionException
+    public void execute(Runnable job, JobExecutionContext context)
     {
-        Class<? extends Runnable> jobClass =
-            ClassUtils.tryToLoadClassForName(context.getJobDetail().getKey().getName(), Runnable.class);
-
-        Runnable runnableBean = BeanProvider.getContextualReference(jobClass);
-
-        try
-        {
-            runnableBean.run();
-        }
-        catch (Throwable t)
-        {
-            //just in this case to reduce the implementation(s) of runnable (annotated with @Scheduled)
-            //to an absolute minimum.
-            //(custom implementations of org.quartz.Job need to do it on their own)
-            this.beanManager.fireEvent(new ExceptionToCatchEvent(t));
-        }
+        job.run();
     }
 }
diff --git a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerExtension.java b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerExtension.java
index 6bb5790..f96b665 100644
--- a/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerExtension.java
+++ b/deltaspike/modules/scheduler/impl/src/main/java/org/apache/deltaspike/scheduler/impl/SchedulerExtension.java
@@ -18,20 +18,18 @@
  */
 package org.apache.deltaspike.scheduler.impl;
 
+import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
 import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.core.util.ClassUtils;
+import org.apache.deltaspike.core.util.ProxyUtils;
 import org.apache.deltaspike.core.util.ServiceUtils;
 import org.apache.deltaspike.scheduler.api.Scheduled;
+import org.apache.deltaspike.scheduler.spi.SchedulerControl;
 import org.apache.deltaspike.scheduler.spi.Scheduler;
 
 import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.BeforeBeanDiscovery;
-import javax.enterprise.inject.spi.BeforeShutdown;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.*;
 
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -111,7 +109,7 @@
         return classNamesToVeto.contains(beanClass.getName());
     }
 
-    public <X> void scheduleJobs(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
+    public <X> void validateJobs(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
     {
         if (!this.isActivated)
         {
@@ -130,7 +128,23 @@
             return;
         }
 
-        initScheduler(afterBeanDiscovery);
+    }
+
+    public <X> void scheduleJobs(@Observes AfterDeploymentValidation afterDeploymentValidation, BeanManager beanManager)
+    {
+        if (!this.isActivated)
+        {
+            return;
+        }
+
+        SchedulerControl schedulerControl = BeanProvider.getContextualReference(SchedulerControl.class, true);
+        if (schedulerControl != null && !schedulerControl.isSchedulerEnabled())
+        {
+            LOG.info("Scheduler has been disabled by " + ProxyUtils.getUnproxiedClass(schedulerControl.getClass()));
+            return;
+        }
+
+        initScheduler(afterDeploymentValidation);
 
         if (this.scheduler == null)
         {
@@ -144,7 +158,7 @@
         {
             if (foundJobNames.contains(jobClass.getSimpleName()))
             {
-                afterBeanDiscovery.addDefinitionError(
+                afterDeploymentValidation.addDeploymentProblem(
                     new IllegalStateException("Multiple Job-Classes found with name " + jobClass.getSimpleName()));
             }
 
@@ -204,7 +218,7 @@
         }
     }
 
-    private void initScheduler(AfterBeanDiscovery afterBeanDiscovery)
+    private void initScheduler(AfterDeploymentValidation afterDeploymentValidation)
     {
         List<Scheduler> availableSchedulers = ServiceUtils.loadServiceImplementations(Scheduler.class, true);
 
@@ -218,7 +232,7 @@
             }
             catch (Throwable t)
             {
-                afterBeanDiscovery.addDefinitionError(t);
+                afterDeploymentValidation.addDeploymentProblem(t);
             }
         }
         else if (!this.foundManagedJobClasses.isEmpty())
diff --git a/deltaspike/modules/test-control/impl/pom.xml b/deltaspike/modules/test-control/impl/pom.xml
index 68df2fa..b040940 100644
--- a/deltaspike/modules/test-control/impl/pom.xml
+++ b/deltaspike/modules/test-control/impl/pom.xml
@@ -116,7 +116,7 @@
         <dependency>
             <groupId>org.apache.deltaspike.core</groupId>
             <artifactId>deltaspike-core-impl</artifactId>
-            <scope>test</scope>
+            <scope>runtime</scope>
         </dependency>
     </dependencies>
 
diff --git a/documentation/src/main/asciidoc/core.adoc b/documentation/src/main/asciidoc/core.adoc
index 9fd5dce..94fc16d 100644
--- a/documentation/src/main/asciidoc/core.adoc
+++ b/documentation/src/main/asciidoc/core.adoc
@@ -639,7 +639,7 @@
 [source,java]
 ----------------------------------------
 @Inject
-@InjectableResource("myfile.properties")
+@InjectableResource(location="myfile.properties")
 private InputStream inputStream;
 ----------------------------------------
 
diff --git a/documentation/src/main/asciidoc/data.adoc b/documentation/src/main/asciidoc/data.adoc
index 50407d2..5ea0ed5 100644
--- a/documentation/src/main/asciidoc/data.adoc
+++ b/documentation/src/main/asciidoc/data.adoc
@@ -1290,7 +1290,7 @@
 [source,java]

 -------------------------------------------------------------------------------------

 @Repository

-public abstract class PersonRepository extends AbstractEntityRepository<Person, Long>

+public abstract class PersonRepository extends AbstractFullEntityRepository<Person, Long>

 {

 

     public List<Person> findByCompanyName(String companyName)

@@ -1312,7 +1312,7 @@
 

 [source,java]

 -------------------------------------------------------------------------------------

-public abstract class PersonRepository extends AbstractEntityRepository<Person, Long>

+public abstract class PersonRepository extends AbstractFullEntityRepository<Person, Long>

 {

 

     public Person findBySSN(String ssn)

@@ -1335,7 +1335,7 @@
 

 [source,java]

 -------------------------------------------------------------------------------------

-public abstract class PersonRepository extends AbstractEntityRepository<Person, Long>

+public abstract class PersonRepository extends AbstractFullEntityRepository<Person, Long>

 {

 

     public List<Person> findAdults()

@@ -1363,7 +1363,7 @@
 

 [source,java]

 ------------------------------------------------------------------------------------------------------

-public abstract class PersonRepository extends AbstractEntityRepository<Person, Long>

+public abstract class PersonRepository extends AbstractFullEntityRepository<Person, Long>

 {

 

     public Statistics ageStatsFor(Segment segment)

diff --git a/pom.xml b/pom.xml
index fd58019..52c5c44 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,8 +48,8 @@
 
     <properties>
         <asciidoctor.version>1.5.2</asciidoctor.version>
-        <version.deltaspike.latest.stable>1.8.2</version.deltaspike.latest.stable>
-        <version.deltaspike.latest.snapshot>1.9.0-SNAPSHOT</version.deltaspike.latest.snapshot>
+        <version.deltaspike.latest.stable>1.9.0</version.deltaspike.latest.stable>
+        <version.deltaspike.latest.snapshot>1.9.1-SNAPSHOT</version.deltaspike.latest.snapshot>
         <svn.scmPubCheckoutDirectory>${project.build.directory}/co-site</svn.scmPubCheckoutDirectory>
     </properties>
 
diff --git a/site/src/main/asciidoc/index.adoc b/site/src/main/asciidoc/index.adoc
index 63e234d..700e3f1 100644
--- a/site/src/main/asciidoc/index.adoc
+++ b/site/src/main/asciidoc/index.adoc
@@ -36,7 +36,7 @@
 [options="header,footer"]
 |===
 |*News* | *Examples*
-| Apache DeltaSpike 1.8.1 is now out!
+| Apache DeltaSpike 1.9.0 is now out!
 
 link:/news.html[View details »]
 
diff --git a/site/src/main/asciidoc/news.adoc b/site/src/main/asciidoc/news.adoc
index f620a81..7c098d8 100644
--- a/site/src/main/asciidoc/news.adoc
+++ b/site/src/main/asciidoc/news.adoc
@@ -4,9 +4,14 @@
 
 :Notice: 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.
 
+== 32th Release (1.9.0) (2018-09-18)
+
+The Apache DeltaSpike team is pleased to announce the 32th release
+(v1.9.0).  Release notes can be found https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12312820&version=12342846[here]
+
 == 31th Release (1.8.2) (2018-06-01)
 
-The Apache DeltaSpike team is pleased to announce the 30th release
+The Apache DeltaSpike team is pleased to announce the 31th release
 (v1.8.2).  Release notes can be found https://s.apache.org/DeltaSpike_1.8.2[here]
 
 == 30th Release (1.8.1) (2018-01-01)