SLING-7798 Switch from JSR-305 annotations to JetBrains Nullable/NotNull annotations
diff --git a/pom.xml b/pom.xml
index 8129281..7e8a759 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,9 +94,10 @@
<artifactId>osgi.core</artifactId>
</dependency>
<dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <version>2.0.1</version>
+ <groupId>org.jetbrains</groupId>
+ <artifactId>annotations</artifactId>
+ <version>16.0.2</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
diff --git a/src/main/java/org/apache/sling/jobs/Job.java b/src/main/java/org/apache/sling/jobs/Job.java
index 5c55a71..7005b7e 100644
--- a/src/main/java/org/apache/sling/jobs/Job.java
+++ b/src/main/java/org/apache/sling/jobs/Job.java
@@ -21,9 +21,8 @@
import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
/**
@@ -53,14 +52,14 @@
* The job queue. - immutable.
* @return The job queue name
*/
- @Nonnull
+ @NotNull
Types.JobQueue getQueue();
/**
* Unique job ID. immutable.
* @return The unique job ID.
*/
- @Nonnull
+ @NotNull
String getId();
@@ -69,13 +68,13 @@
* to accept.
* @return the job type.
*/
- @Nonnull
+ @NotNull
Types.JobType getJobType();
/**
* @return a map of all properties.
*/
- @Nonnull
+ @NotNull
Map<String,Object> getProperties();
/**
@@ -109,14 +108,14 @@
* Get the job state
* @return the job state.
*/
- @Nonnull
+ @NotNull
JobState getJobState();
/**
* Set the new state.
* @param newState the new state.
*/
- void setState(@Nonnull JobState newState);
+ void setState(@NotNull JobState newState);
/**
@@ -138,7 +137,7 @@
*
* @return a Job update builder.
*/
- @Nonnull
+ @NotNull
JobUpdateBuilder newJobUpdateBuilder();
@@ -153,7 +152,7 @@
* Set the current job controller.
* @param jobController the job controller.
*/
- void setJobController(@Nonnull JobController jobController);
+ void setJobController(@NotNull JobController jobController);
/**
diff --git a/src/main/java/org/apache/sling/jobs/JobBuilder.java b/src/main/java/org/apache/sling/jobs/JobBuilder.java
index cabfd4f..406eb21 100644
--- a/src/main/java/org/apache/sling/jobs/JobBuilder.java
+++ b/src/main/java/org/apache/sling/jobs/JobBuilder.java
@@ -19,11 +19,10 @@
package org.apache.sling.jobs;
+import org.jetbrains.annotations.NotNull;
import org.osgi.annotation.versioning.ProviderType;
-import javax.annotation.Nonnull;
import java.util.Map;
-
/**
* A JobBuilder allows users of the JobSystem to modify the properties of the Job and submit it for processing.
*/
@@ -35,14 +34,14 @@
* @param props The properties of the job. All values must be {@code java.io.Serializable}.
* @return The job builder to continue building.
*/
- @Nonnull
- JobBuilder addProperties(@Nonnull Map<String, Object> props);
+ @NotNull
+ JobBuilder addProperties(@NotNull Map<String, Object> props);
/**
* Add the job for processing.
* @return The job or <code>null</code>
*/
- @Nonnull
+ @NotNull
Job add();
}
diff --git a/src/main/java/org/apache/sling/jobs/JobConsumer.java b/src/main/java/org/apache/sling/jobs/JobConsumer.java
index af808db..cbe0685 100644
--- a/src/main/java/org/apache/sling/jobs/JobConsumer.java
+++ b/src/main/java/org/apache/sling/jobs/JobConsumer.java
@@ -19,10 +19,9 @@
package org.apache.sling.jobs;
+import org.jetbrains.annotations.NotNull;
import org.osgi.annotation.versioning.ProviderType;
-import javax.annotation.Nonnull;
-
/**
* Components that implement JobConsumers are registered with the Job Sub System by an OSGi Whiteboard pattern. Once
* registered the component will be offered jobs matching the job types set as the OSGi property JobConsumer.JOB_TYPES.
@@ -45,6 +44,6 @@
* @param callback called when the job is completed.
* @throws RuntimeException or any subclass when the Job offered in initialState cant be accepted for execution.
*/
- @Nonnull
- void execute(@Nonnull Job initialState, @Nonnull JobUpdateListener listener, @Nonnull JobCallback callback);
+ @NotNull
+ void execute(@NotNull Job initialState, @NotNull JobUpdateListener listener, @NotNull JobCallback callback);
}
diff --git a/src/main/java/org/apache/sling/jobs/JobManager.java b/src/main/java/org/apache/sling/jobs/JobManager.java
index c0eaa60..8494179 100644
--- a/src/main/java/org/apache/sling/jobs/JobManager.java
+++ b/src/main/java/org/apache/sling/jobs/JobManager.java
@@ -18,9 +18,8 @@
*/
package org.apache.sling.jobs;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
/**
@@ -40,8 +39,8 @@
* process the job.
* @return A job builder
*/
- @Nonnull
- JobBuilder newJobBuilder(@Nonnull Types.JobQueue queue, @Nonnull Types.JobType jobType);
+ @NotNull
+ JobBuilder newJobBuilder(@NotNull Types.JobQueue queue, @NotNull Types.JobType jobType);
/**
* Return a job based on the unique id.
@@ -54,7 +53,7 @@
*/
@Nullable
- Job getJobById(@Nonnull String jobId);
+ Job getJobById(@NotNull String jobId);
/**
@@ -79,7 +78,7 @@
* must match the template (AND query).
* @return A job or <code>null</code>
* @Nullable
- * Job getJob(@Nonnull Types.JobQueue queue, @Nonnull Map<String, Object> template);
+ * Job getJob(@NotNull Types.JobQueue queue, @NotNull Map<String, Object> template);
*
*/
@@ -128,8 +127,8 @@
* must match the template (AND query). By providing several maps, different filters
* are possible (OR query).
* @return A collection of jobs - the collection might be empty.
- * @Nonnull
- * Collection<Job> findJobs(@Nonnull QueryType type, @Nonnull Types.JobQueue queue, long limit, @Nullable Map<String, Object>... templates);
+ * @NotNull
+ * Collection<Job> findJobs(@NotNull QueryType type, @NotNull Types.JobQueue queue, long limit, @Nullable Map<String, Object>... templates);
*/
/**
@@ -139,7 +138,7 @@
* permanently failed or being retried.
* @param jobId the job id to stop.
*/
- void stopJobById(@Nonnull String jobId);
+ void stopJobById(@NotNull String jobId);
/**
* Aborts a job by sending an abort message, may or may not be successful.
@@ -149,7 +148,7 @@
* @return <code>true</code> if the job could be removed or does not exist anymore.
* <code>false</code> if the job is not know to the job manager, however the abort message should be sent anyway.
*/
- boolean abortJob(@Nonnull String jobId);
+ boolean abortJob(@NotNull String jobId);
/**
@@ -161,7 +160,7 @@
* @return If the job is requeued, the new job object otherwise <code>null</code>
*/
@Nullable
- Job retryJobById(@Nonnull String jobId);
+ Job retryJobById(@NotNull String jobId);
}
diff --git a/src/main/java/org/apache/sling/jobs/JobTypeValve.java b/src/main/java/org/apache/sling/jobs/JobTypeValve.java
index 3be4f34..a4a1efa 100644
--- a/src/main/java/org/apache/sling/jobs/JobTypeValve.java
+++ b/src/main/java/org/apache/sling/jobs/JobTypeValve.java
@@ -18,10 +18,9 @@
*/
package org.apache.sling.jobs;
+import org.jetbrains.annotations.NotNull;
import org.osgi.annotation.versioning.ProviderType;
-import javax.annotation.Nonnull;
-
/**
* An interface to allow a component, normally a JobConsumer to inspect a JobType and indicate that
* it can perform further actions on it. JobTypeValves are used in place of static JobType declarations.
@@ -35,5 +34,5 @@
* @param jobType the job type.
* @return true if can be processed.
*/
- boolean accept(@Nonnull Types.JobType jobType);
+ boolean accept(@NotNull Types.JobType jobType);
}
diff --git a/src/main/java/org/apache/sling/jobs/JobUpdate.java b/src/main/java/org/apache/sling/jobs/JobUpdate.java
index 4e5bd8e..aa0ea7e 100644
--- a/src/main/java/org/apache/sling/jobs/JobUpdate.java
+++ b/src/main/java/org/apache/sling/jobs/JobUpdate.java
@@ -20,9 +20,8 @@
import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
/**
@@ -65,7 +64,7 @@
* execute the Job.
* @return the job type.
*/
- @Nonnull
+ @NotNull
Types.JobType getJobType();
enum JobUpdateCommand {
@@ -85,7 +84,7 @@
/**
* @return the type of update.
*/
- @Nonnull
+ @NotNull
JobUpdateCommand getCommand();
@@ -93,21 +92,21 @@
* The job queue. - immutable.
* @return The job queue
*/
- @Nonnull
+ @NotNull
Types.JobQueue getQueue();
/**
* Unique job ID. immutable.
* @return The unique job ID.
*/
- @Nonnull
+ @NotNull
String getId();
/**
*
* @return the new state of the job, may not have changed from the old state.
*/
- @Nonnull
+ @NotNull
Job.JobState getState();
enum JobPropertyAction {
@@ -119,7 +118,7 @@
* Property types cant be changed in 1 message.
* @return the map of property changes, will be <code>null</code> if the update message does not contain property changes.
*/
- @Nonnull
+ @NotNull
Map<String, Object> getProperties();
/**
diff --git a/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java b/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
index e4c938d..62eb294 100644
--- a/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
+++ b/src/main/java/org/apache/sling/jobs/JobUpdateBuilder.java
@@ -19,22 +19,21 @@
package org.apache.sling.jobs;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.util.Map;
-
/**
* Create a job update ading properties and building.
*/
@ProviderType
public interface JobUpdateBuilder {
- @Nonnull
- JobUpdateBuilder command(@Nonnull JobUpdate.JobUpdateCommand command);
+ @NotNull
+ JobUpdateBuilder command(@NotNull JobUpdate.JobUpdateCommand command);
- @Nonnull
+ @NotNull
JobUpdate build();
/**
@@ -43,9 +42,9 @@
* @param value the value of the property which may be null. To remove the property set the value to JobUpdate.JobPropertyAction.REMOVE.
* @return this JobBuilder instance.
*/
- @Nonnull
- JobUpdateBuilder put(@Nonnull String name, @Nullable Object value);
+ @NotNull
+ JobUpdateBuilder put(@NotNull String name, @Nullable Object value);
- @Nonnull
- JobUpdateBuilder putAll(@Nonnull Map<String, Object> properties);
+ @NotNull
+ JobUpdateBuilder putAll(@NotNull Map<String, Object> properties);
}
diff --git a/src/main/java/org/apache/sling/jobs/JobUpdateListener.java b/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
index 3e6e90d..9afd147 100644
--- a/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
+++ b/src/main/java/org/apache/sling/jobs/JobUpdateListener.java
@@ -18,10 +18,9 @@
*/
package org.apache.sling.jobs;
+import org.jetbrains.annotations.NotNull;
import org.osgi.annotation.versioning.ProviderType;
-import javax.annotation.Nonnull;
-
/**
* Listens for JobUpdate messages.
* Examples of a JobUpdateListener include implementations of a Job that consumes JobUpdateMessages, or JobConsumers that execute a Job.
@@ -33,5 +32,5 @@
* Update the job state with a message.
* @param update update message.
*/
- void update(@Nonnull JobUpdate update);
+ void update(@NotNull JobUpdate update);
}
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobBuilderImpl.java b/src/main/java/org/apache/sling/jobs/impl/JobBuilderImpl.java
index 8450718..4839e3b 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobBuilderImpl.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobBuilderImpl.java
@@ -21,12 +21,11 @@
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobBuilder;
import org.apache.sling.jobs.Types;
import org.apache.sling.jobs.impl.spi.JobStarter;
+import org.jetbrains.annotations.NotNull;
/**
* Provides an implementation of a JobBuilder.
@@ -49,14 +48,14 @@
}
- @Nonnull
+ @NotNull
@Override
- public JobBuilder addProperties(@Nonnull Map<String, Object> props) {
+ public JobBuilder addProperties(@NotNull Map<String, Object> props) {
this.properties.putAll(props);
return this;
}
- @Nonnull
+ @NotNull
@Override
public Job add() {
return jobStarter.start(new JobImpl(topic, id, jobType, properties));
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobImpl.java b/src/main/java/org/apache/sling/jobs/impl/JobImpl.java
index be965d2..73f9d92 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobImpl.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobImpl.java
@@ -21,15 +21,14 @@
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobController;
import org.apache.sling.jobs.JobUpdate;
import org.apache.sling.jobs.JobUpdateBuilder;
import org.apache.sling.jobs.JobUpdateListener;
import org.apache.sling.jobs.Types;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* JobImpl is a data object to hold the current state of the job in the current JVM as loaded into memory.
@@ -50,7 +49,7 @@
private JobController jobController;
private Types.JobType jobType;
- public JobImpl(@Nonnull Types.JobQueue jobQueue, @Nonnull String id, @Nonnull Types.JobType jobType, @Nonnull Map<String, Object> properties) {
+ public JobImpl(@NotNull Types.JobQueue jobQueue, @NotNull String id, @NotNull Types.JobType jobType, @NotNull Map<String, Object> properties) {
this.jobQueue = jobQueue;
this.jobType = jobType;
this.id = id;
@@ -67,25 +66,25 @@
updateProperties(update.getProperties());
}
- @Nonnull
+ @NotNull
@Override
public Types.JobQueue getQueue() {
return jobQueue;
}
- @Nonnull
+ @NotNull
@Override
public String getId() {
return id;
}
- @Nonnull
+ @NotNull
@Override
public Types.JobType getJobType() {
return jobType;
}
- @Nonnull
+ @NotNull
@Override
public Map<String, Object> getProperties() {
return properties;
@@ -111,14 +110,14 @@
return createdAt;
}
- @Nonnull
+ @NotNull
@Override
public JobState getJobState() {
return jobState;
}
@Override
- public void setState(@Nonnull JobState newState) {
+ public void setState(@NotNull JobState newState) {
jobState = newState;
}
@@ -141,7 +140,7 @@
}
@Override
- public void setJobController(@Nonnull JobController jobController) {
+ public void setJobController(@NotNull JobController jobController) {
this.jobController = jobController;
}
@@ -155,7 +154,7 @@
* @param jobUpdate job update.
*/
@Override
- public void update(@Nonnull JobUpdate jobUpdate) {
+ public void update(@NotNull JobUpdate jobUpdate) {
if ( id.equals(jobUpdate.getId()) && ( jobQueue == Types.ANY_JOB_QUEUE || jobQueue.equals(jobUpdate.getQueue()))) {
// Start Job commands always go onto a queue and dont expire.
if ( jobUpdate.getCommand() != JobUpdate.JobUpdateCommand.START_JOB && jobUpdate.expires() < System.currentTimeMillis()) {
@@ -206,7 +205,7 @@
* Update the properties taking into account any PropertyActions required.
* @param properties the update properties.
*/
- private void updateProperties(@Nonnull Map<String, Object> properties) {
+ private void updateProperties(@NotNull Map<String, Object> properties) {
if ( properties == null ) {
throw new IllegalArgumentException("Properties cant be null.");
}
@@ -227,7 +226,7 @@
* Update the jobstate data for the job.
* @param jobUpdate
*/
- private void updateState(@Nonnull JobUpdate jobUpdate) {
+ private void updateState(@NotNull JobUpdate jobUpdate) {
retryCount = jobUpdate.getRetryCount();
jobType = jobUpdate.getJobType();
numberOfRetries = jobUpdate.getNumberOfRetries();
@@ -242,7 +241,7 @@
* Get a JobUpdateBuilder for this Job.
* @return the job update builder.
*/
- @Nonnull
+ @NotNull
@Override
public JobUpdateBuilder newJobUpdateBuilder() {
return new JobUpdateBuilderImpl(this);
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobManagerImpl.java b/src/main/java/org/apache/sling/jobs/impl/JobManagerImpl.java
index 0850bd7..62e1a12 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobManagerImpl.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobManagerImpl.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.jobs.impl;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobBuilder;
import org.apache.sling.jobs.JobManager;
@@ -29,6 +26,8 @@
import org.apache.sling.jobs.Types;
import org.apache.sling.jobs.impl.spi.JobStarter;
import org.apache.sling.jobs.impl.spi.JobStorage;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Implements a JobManager, storing Jobs in a JobStorage implementation.
@@ -60,20 +59,20 @@
this.messageSender = messageSender;
}
- @Nonnull
+ @NotNull
@Override
- public JobBuilder newJobBuilder(@Nonnull Types.JobQueue queue, @Nonnull Types.JobType jobType) {
+ public JobBuilder newJobBuilder(@NotNull Types.JobQueue queue, @NotNull Types.JobType jobType) {
return new JobBuilderImpl(this, queue, jobType);
}
@Nullable
@Override
- public Job getJobById(@Nonnull String jobId) {
+ public Job getJobById(@NotNull String jobId) {
return jobStorage.get(jobId);
}
@Override
- public void stopJobById(@Nonnull String jobId) {
+ public void stopJobById(@NotNull String jobId) {
Job job = getJobById(jobId);
if ( job != null) {
messageSender.update(job.newJobUpdateBuilder().command(JobUpdate.JobUpdateCommand.STOP_JOB).build());
@@ -81,7 +80,7 @@
}
@Override
- public boolean abortJob(@Nonnull String jobId) {
+ public boolean abortJob(@NotNull String jobId) {
Job job = getJobById(jobId);
if ( job != null) {
messageSender.update(job.newJobUpdateBuilder().command(JobUpdate.JobUpdateCommand.ABORT_JOB).build());
@@ -94,7 +93,7 @@
@Nullable
@Override
- public Job retryJobById(@Nonnull String jobId) {
+ public Job retryJobById(@NotNull String jobId) {
Job job = getJobById(jobId);
if (job != null) {
messageSender.update(job.newJobUpdateBuilder().command(JobUpdate.JobUpdateCommand.RETRY_JOB).build());
@@ -112,7 +111,7 @@
@Override
- public void update(@Nonnull JobUpdate update) {
+ public void update(@NotNull JobUpdate update) {
Job j = jobStorage.get(update.getId());
if ( j instanceof JobUpdateListener ) {
((JobUpdateListener) j).update(update);
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobQueueConsumerFactory.java b/src/main/java/org/apache/sling/jobs/impl/JobQueueConsumerFactory.java
index d4f9b41..1f3d8fe 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobQueueConsumerFactory.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobQueueConsumerFactory.java
@@ -23,8 +23,6 @@
import java.util.Map;
import java.util.Set;
-import javax.annotation.Nonnull;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobCallback;
import org.apache.sling.jobs.JobConsumer;
@@ -37,6 +35,7 @@
import org.apache.sling.mom.RequeueMessageException;
import org.apache.sling.mom.TopicManager;
import org.apache.sling.mom.Types;
+import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
@@ -91,7 +90,7 @@
((JobConsumer)jobManager).execute(job, new JobUpdateListener() {
@Override
- public void update(@Nonnull JobUpdate update) {
+ public void update(@NotNull JobUpdate update) {
if (update.getId() != job.getId() || !ALLOWED_COMMANDS.contains(update.getCommand())) {
throw new IllegalArgumentException("Not allowed to update other jobs or issue reserved commands when updating the state of a running job.");
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java b/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java
index bed86dc..f7860ea 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobSubsystem.java
@@ -27,9 +27,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobBuilder;
import org.apache.sling.jobs.JobCallback;
@@ -42,6 +39,8 @@
import org.apache.sling.jobs.impl.storage.InMemoryJobStorage;
import org.apache.sling.mom.QueueManager;
import org.apache.sling.mom.TopicManager;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@@ -94,31 +93,31 @@
}
// --- Job Manager.
- @Nonnull
+ @NotNull
@Override
- public JobBuilder newJobBuilder(@Nonnull Types.JobQueue queue, @Nonnull Types.JobType jobType) {
+ public JobBuilder newJobBuilder(@NotNull Types.JobQueue queue, @NotNull Types.JobType jobType) {
return manager.newJobBuilder(queue, jobType);
}
@Nullable
@Override
- public Job getJobById(@Nonnull String jobId) {
+ public Job getJobById(@NotNull String jobId) {
return manager.getJobById(jobId);
}
@Override
- public void stopJobById(@Nonnull String jobId) {
+ public void stopJobById(@NotNull String jobId) {
manager.stopJobById(jobId);
}
@Override
- public boolean abortJob(@Nonnull String jobId) {
+ public boolean abortJob(@NotNull String jobId) {
return manager.abortJob(jobId);
}
@Nullable
@Override
- public Job retryJobById(@Nonnull String jobId) {
+ public Job retryJobById(@NotNull String jobId) {
return manager.retryJobById(jobId);
}
@@ -147,9 +146,9 @@
// ------- job execution, invoked by JobQueueConsumerFactory.
- @Nonnull
+ @NotNull
@Override
- public void execute(@Nonnull Job initialState, @Nonnull JobUpdateListener listener, @Nonnull JobCallback callback) {
+ public void execute(@NotNull Job initialState, @NotNull JobUpdateListener listener, @NotNull JobCallback callback) {
// iterate over the entries. This should cause the entries to come out in natural key order
// which should respect any priority applied to the Services via ServiceReference. (TODO: check that is the case)
// TODO: add a Job controller to the job before executing.
@@ -205,7 +204,7 @@
@Override
- public boolean accept(@Nonnull Types.JobType jobType) {
+ public boolean accept(@NotNull Types.JobType jobType) {
if ( consumer instanceof JobTypeValve) {
return ((JobTypeValve) consumer).accept(jobType);
}
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobUpdateBuilderImpl.java b/src/main/java/org/apache/sling/jobs/impl/JobUpdateBuilderImpl.java
index 5347b5c..96a2f62 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobUpdateBuilderImpl.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobUpdateBuilderImpl.java
@@ -22,12 +22,11 @@
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobUpdate;
import org.apache.sling.jobs.JobUpdateBuilder;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
*/
@@ -42,12 +41,12 @@
* Create a JobUpdateBuilder from a job.
* @param job the job.
*/
- public JobUpdateBuilderImpl(@Nonnull Job job) {
+ public JobUpdateBuilderImpl(@NotNull Job job) {
this.job = job;
this.jobId = null;
}
- public JobUpdateBuilderImpl(@Nonnull String jobId) {
+ public JobUpdateBuilderImpl(@NotNull String jobId) {
this.jobId = jobId;
this.job = null;
@@ -58,9 +57,9 @@
* @param command the command.
* @return this JobBuilder instance.
*/
- @Nonnull
+ @NotNull
@Override
- public JobUpdateBuilder command(@Nonnull JobUpdate.JobUpdateCommand command) {
+ public JobUpdateBuilder command(@NotNull JobUpdate.JobUpdateCommand command) {
this.command = command;
return this;
}
@@ -71,9 +70,9 @@
* @param value the value of the property which may be null. To remove the property set the value to JobUpdate.JobPropertyAction.REMOVE.
* @return this JobBuilder instance.
*/
- @Nonnull
+ @NotNull
@Override
- public JobUpdateBuilder put(@Nonnull String name, @Nullable Object value) {
+ public JobUpdateBuilder put(@NotNull String name, @Nullable Object value) {
if ( value == null) {
this.updateProperties.put(name, JobUpdate.JobPropertyAction.REMOVE);
} else {
@@ -82,9 +81,9 @@
return this;
}
- @Nonnull
+ @NotNull
@Override
- public JobUpdateBuilder putAll(@Nonnull Map<String, Object> properties) {
+ public JobUpdateBuilder putAll(@NotNull Map<String, Object> properties) {
this.updateProperties.putAll(properties);
return this;
}
@@ -94,7 +93,7 @@
* Build the JobUpdate.
* @return the JobUpdate.
*/
- @Nonnull
+ @NotNull
@Override
public JobUpdate build() {
if ( job != null) {
diff --git a/src/main/java/org/apache/sling/jobs/impl/JobUpdateImpl.java b/src/main/java/org/apache/sling/jobs/impl/JobUpdateImpl.java
index 5fb8394..210207d 100644
--- a/src/main/java/org/apache/sling/jobs/impl/JobUpdateImpl.java
+++ b/src/main/java/org/apache/sling/jobs/impl/JobUpdateImpl.java
@@ -22,13 +22,12 @@
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.JobUpdate;
import org.apache.sling.jobs.Types;
import org.apache.sling.jobs.impl.spi.MapValueAdapter;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/**
* Represents messages sent to the Job via a message queue.
@@ -60,7 +59,7 @@
* @param command the command
* @param properties properties in the update message.
*/
- public JobUpdateImpl(@Nonnull Job job, @Nonnull JobUpdateCommand command, @Nonnull Map<String, Object> properties) {
+ public JobUpdateImpl(@NotNull Job job, @NotNull JobUpdateCommand command, @NotNull Map<String, Object> properties) {
if ( job == null ) {
throw new IllegalArgumentException("Job argument cant be null");
}
@@ -91,14 +90,14 @@
* Create a JobUpdateImpl based on a inbound message in the form of a Map.
* @param message a inbound message in map form.
*/
- public JobUpdateImpl(@Nonnull Map<String, Object> message) {
+ public JobUpdateImpl(@NotNull Map<String, Object> message) {
if ( message == null ) {
throw new IllegalArgumentException("Message cant be null");
}
fromMapValue(message);
}
- public JobUpdateImpl(@Nonnull String jobId, @Nonnull JobUpdateCommand command) {
+ public JobUpdateImpl(@NotNull String jobId, @NotNull JobUpdateCommand command) {
if ( jobId == null ) {
throw new IllegalArgumentException("JobId argument cant be null");
}
@@ -126,37 +125,37 @@
return expires;
}
- @Nonnull
+ @NotNull
@Override
public Types.JobType getJobType() {
return jobType;
}
- @Nonnull
+ @NotNull
@Override
public JobUpdateCommand getCommand() {
return command;
}
- @Nonnull
+ @NotNull
@Override
public Types.JobQueue getQueue() {
return jobQueue;
}
- @Nonnull
+ @NotNull
@Override
public String getId() {
return id;
}
- @Nonnull
+ @NotNull
@Override
public Job.JobState getState() {
return jobState;
}
- @Nonnull
+ @NotNull
@Override
public Map<String, Object> getProperties() {
return properties;
@@ -221,7 +220,7 @@
}
@Override
- @Nonnull
+ @NotNull
public Object toMapValue() {
final Map<String, Object> builder = new HashMap<>();
builder.put("tp", jobQueue.toString());
diff --git a/src/main/java/org/apache/sling/jobs/impl/OutboundJobUpdateListener.java b/src/main/java/org/apache/sling/jobs/impl/OutboundJobUpdateListener.java
index 734bb2a..7327295 100644
--- a/src/main/java/org/apache/sling/jobs/impl/OutboundJobUpdateListener.java
+++ b/src/main/java/org/apache/sling/jobs/impl/OutboundJobUpdateListener.java
@@ -18,12 +18,11 @@
*/
package org.apache.sling.jobs.impl;
-import javax.annotation.Nonnull;
-
import org.apache.sling.jobs.JobUpdate;
import org.apache.sling.jobs.JobUpdateListener;
import org.apache.sling.mom.QueueManager;
import org.apache.sling.mom.TopicManager;
+import org.jetbrains.annotations.NotNull;
/**
* Sends messages out to JMS Queues or topics. Normally called by the local JobManager Implementation.
@@ -48,7 +47,7 @@
@Override
- public void update(@Nonnull JobUpdate update) {
+ public void update(@NotNull JobUpdate update) {
if ( active ) {
switch(update.getCommand()) {
case START_JOB:
diff --git a/src/main/java/org/apache/sling/jobs/impl/Utils.java b/src/main/java/org/apache/sling/jobs/impl/Utils.java
index 6882303..f3880dd 100644
--- a/src/main/java/org/apache/sling/jobs/impl/Utils.java
+++ b/src/main/java/org/apache/sling/jobs/impl/Utils.java
@@ -28,10 +28,9 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import org.apache.sling.jobs.impl.spi.MapValueAdapter;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,7 +48,7 @@
* Gets a string
* @return
*/
- @Nonnull
+ @NotNull
private static String generateUniqueNamespace() {
String macAddress = null;
// get the MAC address of the primary interface, failing that use a fake.
@@ -88,8 +87,8 @@
return baseId;
}
- @Nonnull
- private static String tohex(@Nonnull byte[] bytes) {
+ @NotNull
+ private static String tohex(@NotNull byte[] bytes) {
StringBuilder sb = new StringBuilder();
for( byte b : bytes) {
sb.append(String.format("%02x",b));
@@ -101,7 +100,7 @@
* Generate an ID based on the unique name of the jvm process and a counter.
* @return a generated ID.
*/
- @Nonnull
+ @NotNull
public static String generateId() {
try {
return Utils.tohex(MessageDigest.getInstance("SHA1").digest((Utils.PROCESS_NAME+idCounter.incrementAndGet()).getBytes(UTF8)));
@@ -110,8 +109,8 @@
}
}
- @Nonnull
- public static Map<String, Object> toMapValue(@Nonnull Object msg) {
+ @NotNull
+ public static Map<String, Object> toMapValue(@NotNull Object msg) {
if (msg instanceof Map) {
//noinspection unchecked
return (Map<String, Object>) msg;
@@ -122,8 +121,8 @@
}
- @Nonnull
- public static <T> T getRequired(@Nonnull Map<String, Object> m, @Nonnull String name) {
+ @NotNull
+ public static <T> T getRequired(@NotNull Map<String, Object> m, @NotNull String name) {
if (m.containsKey(name)) {
//noinspection unchecked
if ( m.get(name) != null) {
@@ -134,7 +133,7 @@
}
@Nullable
- public static <T> T getOptional(@Nonnull Map<String, Object> m, @Nonnull String name, @Nullable T defaultValue) {
+ public static <T> T getOptional(@NotNull Map<String, Object> m, @NotNull String name, @Nullable T defaultValue) {
if (m.containsKey(name)) {
//noinspection unchecked
Object o = m.get(name);
diff --git a/src/main/java/org/apache/sling/jobs/impl/spi/JobStorage.java b/src/main/java/org/apache/sling/jobs/impl/spi/JobStorage.java
index bd421ab..32e852f 100644
--- a/src/main/java/org/apache/sling/jobs/impl/spi/JobStorage.java
+++ b/src/main/java/org/apache/sling/jobs/impl/spi/JobStorage.java
@@ -20,11 +20,10 @@
package org.apache.sling.jobs.impl.spi;
import org.apache.sling.jobs.Job;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
/**
* Provides JobStorage local to the JVM. Implementation may or may not decide to persist over restarts, page, etc
*/
@@ -38,15 +37,15 @@
* @return the job or null of the job doesn't exist.
*/
@Nullable
- Job get(@Nonnull String jobId);
+ Job get(@NotNull String jobId);
/**
* Put a Job into the Job Storage.
* @param job the job.
* @return the job just added.
*/
- @Nonnull
- Job put(@Nonnull Job job);
+ @NotNull
+ Job put(@NotNull Job job);
/**
* Remove the Job
@@ -54,7 +53,7 @@
* @return the job removed or null if not present.
*/
@Nullable
- Job remove(@Nonnull String jobId);
+ Job remove(@NotNull String jobId);
/**
* Remove the Job, returning the job removed.
@@ -62,7 +61,7 @@
* @return the job removed, if the the job was present, otherwise null.
*/
@Nullable
- Job remove(@Nonnull Job job);
+ Job remove(@NotNull Job job);
/**
* Dispose of the JobStorage.
diff --git a/src/main/java/org/apache/sling/jobs/impl/storage/InMemoryJobStorage.java b/src/main/java/org/apache/sling/jobs/impl/storage/InMemoryJobStorage.java
index 222e339..574e321 100644
--- a/src/main/java/org/apache/sling/jobs/impl/storage/InMemoryJobStorage.java
+++ b/src/main/java/org/apache/sling/jobs/impl/storage/InMemoryJobStorage.java
@@ -20,12 +20,11 @@
import org.apache.sling.jobs.Job;
import org.apache.sling.jobs.impl.spi.JobStorage;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
/**
* An unbounded local JVM job store.
*/
@@ -36,14 +35,14 @@
@Nullable
@Override
- public Job get(@Nonnull String jobId) {
+ public Job get(@NotNull String jobId) {
check();
return store.get(jobId);
}
- @Nonnull
+ @NotNull
@Override
- public Job put(@Nonnull Job job) {
+ public Job put(@NotNull Job job) {
check();
store.put(job.getId(), job);
return job;
@@ -51,7 +50,7 @@
@Nullable
@Override
- public Job remove(@Nonnull String jobId) {
+ public Job remove(@NotNull String jobId) {
check();
Job j = store.get(jobId);
store.remove(jobId);
@@ -60,7 +59,7 @@
@Nullable
@Override
- public Job remove(@Nonnull Job job) {
+ public Job remove(@NotNull Job job) {
check();
return remove(job.getId());
}
diff --git a/src/main/java/org/apache/sling/jobs/package-info.java b/src/main/java/org/apache/sling/jobs/package-info.java
index 8fa9d1b..12de886 100644
--- a/src/main/java/org/apache/sling/jobs/package-info.java
+++ b/src/main/java/org/apache/sling/jobs/package-info.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-@Version("1.0.0")
+@Version("1.0.1")
package org.apache.sling.jobs;
import org.osgi.annotation.versioning.Version;