Skip to content

Commit

Permalink
use static property to handle update for grails 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamun Sardar committed Aug 29, 2017
1 parent db22a8d commit 6d8ce4e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ The current master branch is for 2.x versions of the plugin compatible with Grai
### Quick start
To start using Quartz plugin just simply add ```compile 'org.grails.plugins:quartz:2.0.1'``` in your ```build.gradle```.

##### 2.0.13 for Grails 3.3.*
Properties changed to `static` from `def`.<br>For example:
`def concurrent` will be now `static concurrent`.



### Scheduling Jobs
To create a new job run the `grails create-job` command and enter the name of the job. Grails will create a new job and place it in the `grails-app/jobs` directory:

Expand Down
8 changes: 4 additions & 4 deletions src/docs/guide/configuration.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ h4. Hibernate Sessions and Jobs
Jobs are configured by default to have Hibernate Session bounded to thread each time job is executed. This is required if you are using Hibernate code which requires open session (such as lazy loading of collections) or working with domain objects with unique persistent constraint (it uses Hibernate Session behind the scene). If you want to override this behavior (rarely useful) you can use 'sessionRequired' property:

{code}
def sessionRequired = false
static sessionRequired = false
{code}

h4. Configuring concurrent execution

By default Jobs are executed in concurrent fashion, so new Job execution can start even if previous execution of the same Job is still running. If you want to override this behavior you can use 'concurrent' property, in this case Quartz's StatefulJob will be used (you can find more info about it here):

{code}
def concurrent = false
static concurrent = false
{code}

h4. Configuring Job Enabled

By default all jobs are considered enabled. In some cases it may be desired to temporarily disable a job. This can be done by overriding the jobEnabled property behavior

{code}
def jobEnabled = false
static jobEnabled = false
{code}

h4. Configuring description

Quartz allows for each job to have a short description. This may be configured by adding a description field to your Job. The description can be accessed at runtime using the JobManagerService and inspecting the JobDetail object.

{code}
def description = "Example Job Description"
static description = "Example Job Description"
{code}

h4. Clustering
Expand Down
8 changes: 4 additions & 4 deletions src/docs/guide/scheduling.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class MyJob {
static triggers = {
simple name: 'mySimpleTrigger', startDelay: 60000, repeatInterval: 1000
}
def group = "MyGroup"
def description = "Example job with Simple Trigger"
static group = "MyGroup"
static description = "Example job with Simple Trigger"

void execute() {
println "Job run!"
Expand All @@ -30,8 +30,8 @@ class MyJob {
static triggers = {
cron name: 'myTrigger', cronExpression: "0 0 6 * * ?"
}
def group = "MyGroup"
def description = "Example job with Cron Trigger"
static group = "MyGroup"
static description = "Example job with Cron Trigger"

void execute() {
println "Job run!"
Expand Down
30 changes: 15 additions & 15 deletions src/main/groovy/grails/plugins/quartz/DefaultGrailsJobClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ private void evaluateTriggers() {
// registering additional triggersClosure from 'triggersClosure' closure if present
Closure triggersClosure = (Closure) GrailsClassUtils.getStaticPropertyValue(getClazz(), "triggers");

TriggersConfigBuilder builder = new TriggersConfigBuilder(getFullName(),grailsApplication);
TriggersConfigBuilder builder = new TriggersConfigBuilder(getFullName(), grailsApplication);

if (triggersClosure != null) {
builder.build(triggersClosure);
triggers = (Map) builder.getTriggers();
}
triggersEvaluated = true;
triggersEvaluated = true;
}

public void execute() {
Expand All @@ -68,35 +68,35 @@ public void execute(JobExecutionContext context) {
}

public String getGroup() {
String group = (String) getPropertyOrStaticPropertyOrFieldValue(GROUP, String.class);
String group = getStaticPropertyValue(GROUP, String.class);
if (group == null || "".equals(group)) return DEFAULT_GROUP;
return group;
}

public boolean isConcurrent() {
Boolean concurrent = getPropertyValue(CONCURRENT, Boolean.class);
Boolean concurrent = getStaticPropertyValue(CONCURRENT, Boolean.class);
return concurrent == null ? DEFAULT_CONCURRENT : concurrent;
}

public boolean isSessionRequired() {
Boolean sessionRequired = getPropertyValue(SESSION_REQUIRED, Boolean.class);
Boolean sessionRequired = getStaticPropertyValue(SESSION_REQUIRED, Boolean.class);
return sessionRequired == null ? DEFAULT_SESSION_REQUIRED : sessionRequired;
}

public boolean isDurability() {
Boolean durability = getPropertyValue(DURABILITY, Boolean.class);
Boolean durability = getStaticPropertyValue(DURABILITY, Boolean.class);
return durability == null ? DEFAULT_DURABILITY : durability;
}

public boolean isRequestsRecovery() {
Boolean requestsRecovery = getPropertyValue(REQUESTS_RECOVERY, Boolean.class);
Boolean requestsRecovery = getStaticPropertyValue(REQUESTS_RECOVERY, Boolean.class);
return requestsRecovery == null ? DEFAULT_REQUESTS_RECOVERY : requestsRecovery;
}

public boolean isEnabled() {
Boolean enabled = getPropertyValue(ENABLED, Boolean.class);
return enabled == null ? DEFAULT_ENABLED : enabled;
}
public boolean isEnabled() {
Boolean enabled = getStaticPropertyValue(ENABLED, Boolean.class);
return enabled == null ? DEFAULT_ENABLED : enabled;
}

public String getDescription() {
String description = (String) getPropertyOrStaticPropertyOrFieldValue(DESCRIPTION, String.class);
Expand All @@ -105,9 +105,9 @@ public String getDescription() {
}

public Map getTriggers() {
if(triggersEvaluated == false){
evaluateTriggers();
}
return triggers;
if (triggersEvaluated == false) {
evaluateTriggers();
}
return triggers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DefaultGrailsJobClassTests extends GroovyTestCase {
def testClosure = { wasExecuted = true }
Class jobClass = gcl.parseClass("""
class TestJob {
def testClosure
static testClosure
def execute() {
testClosure.call()
}
Expand All @@ -53,7 +53,7 @@ class DefaultGrailsJobClassTests extends GroovyTestCase {
void testSessionRequiredParameter() {
Class jobClass = gcl.parseClass("""
class TestJob {
def sessionRequired = false
static sessionRequired = false
def execute() {}
}
""".stripIndent())
Expand All @@ -64,7 +64,7 @@ class DefaultGrailsJobClassTests extends GroovyTestCase {
void testConcurrentParameter() {
Class jobClass = gcl.parseClass("""
class TestJob {
def concurrent = false
static concurrent = false
def execute() {}
}
""".stripIndent())
Expand All @@ -75,7 +75,7 @@ class DefaultGrailsJobClassTests extends GroovyTestCase {
void testGroupParameter() {
Class jobClass = gcl.parseClass("""
class TestJob {
def group = 'myGroup'
static group = 'myGroup'
def execute() {}
}
""".stripIndent())
Expand Down

0 comments on commit 6d8ce4e

Please sign in to comment.