Permalink
Browse files

cleanup

  • Loading branch information...
1 parent 2a0a541 commit 52a7a07a777ffb8d2b5886a1c1aa32164133661a @burtbeckwith burtbeckwith committed Nov 27, 2013
View
@@ -5,3 +5,5 @@ target
*.zip
plugin.xml
.idea
+*.log
+/web-app/WEB-INF
@@ -4,16 +4,11 @@ class QuartzMonitorGrailsPlugin {
def version = "0.3-RC2"
def grailsVersion = "1.2 > *"
def dependsOn = [quartz:"1.0-RC4"]
- def pluginExcludes = [
- "grails-app/views/error.gsp"
- ]
def author = "James Cook"
def authorEmail = "grails@jamescookie.com"
- def title = "Monitor your Quartz jobs"
- def description = '''\\
-One clear and concise page that enables you to administer all your Quartz jobs.
-'''
+ def title = "Quartz Monitor Grails Plugin"
+ def description = 'One clear and concise page that enables you to administer all your Quartz jobs'
def documentation = "http://grails.org/plugin/quartz-monitor"
View
@@ -1,4 +1,2 @@
-#Grails Metadata file
-#Thu Jan 03 13:05:56 GMT 2013
app.grails.version=2.1.1
app.name=quartz-monitor
@@ -1,46 +1,29 @@
-grails.project.class.dir = "target/classes"
-grails.project.test.class.dir = "target/test-classes"
-grails.project.test.reports.dir = "target/test-reports"
-//grails.project.war.file = "target/${appName}-${appVersion}.war"
+grails.project.work.dir = 'target'
+
grails.project.dependency.resolution = {
- // inherit Grails' default dependencies
- inherits("global") {
- // uncomment to disable ehcache
- // excludes 'ehcache'
- }
- log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+
+ inherits 'global'
+ log 'warn'
+
repositories {
- grailsPlugins()
- grailsHome()
grailsCentral()
- grailsRepo "http://grails.org/plugins"
-
- // uncomment the below to enable remote dependency resolution
- // from public Maven repositories
- //mavenLocal()
- //mavenCentral()
- //mavenRepo "http://snapshots.repository.codehaus.org"
- //mavenRepo "http://repository.codehaus.org"
- //mavenRepo "http://download.java.net/maven/2/"
- //mavenRepo "http://repository.jboss.com/maven2/"
+ mavenLocal()
+ mavenCentral()
}
+
+ dependencies {
+ }
+
plugins {
- build(":release:2.0.3") {
- export = false
- }
- runtime ':quartz:1.0-RC4'
+
compile ':quartz:1.0-RC4'
- compile(':rest-client-builder:1.0.2') {
- export = false
- }
+
compile(":hibernate:$grailsVersion") {
export = false
}
- }
- dependencies {
- // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
- // runtime 'mysql:mysql-connector-java:5.1.13'
+ build ':release:2.2.1', ':rest-client-builder:1.0.3', {
+ export = false
+ }
}
}
-grails.release.scm.enabled = false
@@ -1,26 +1,6 @@
-// configuration for plugin testing - will not be included in the plugin zip
-
log4j = {
- // Example of changing the log pattern for the default console
- // appender:
- //
- //appenders {
- // console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
- //}
-
- error 'org.codehaus.groovy.grails.web.servlet', // controllers
- 'org.codehaus.groovy.grails.web.pages', // GSP
- 'org.codehaus.groovy.grails.web.sitemesh', // layouts
- 'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
- 'org.codehaus.groovy.grails.web.mapping', // URL mapping
- 'org.codehaus.groovy.grails.commons', // core / classloading
- 'org.codehaus.groovy.grails.plugins', // plugins
- 'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
- 'org.springframework',
- 'org.hibernate',
- 'net.sf.ehcache.hibernate'
-
- warn 'org.mortbay.log'
+ error 'org.codehaus.groovy.grails',
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
}
-grails.views.default.codec="none" // none, html, base64
-grails.views.gsp.encoding="UTF-8"
@@ -1,43 +1,14 @@
dataSource {
pooled = true
- driverClassName = "org.h2.Driver"
- username = "sa"
- password = ""
+ driverClassName = 'org.h2.Driver'
+ username = 'sa'
+ password = ''
+ dbCreate = 'update'
+ url = 'jdbc:h2:mem:testDb'
}
+
hibernate {
- cache.use_second_level_cache = true
+ cache.use_second_level_cache = false
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
-// environment specific settings
-environments {
- development {
- dataSource {
- dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
- url = "jdbc:h2:mem:devDb;MVCC=TRUE"
- }
- }
- test {
- dataSource {
- dbCreate = "update"
- url = "jdbc:h2:mem:testDb;MVCC=TRUE"
- }
- }
- production {
- dataSource {
- dbCreate = "update"
- url = "jdbc:h2:prodDb;MVCC=TRUE"
- pooled = true
- properties {
- maxActive = -1
- minEvictableIdleTimeMillis=1800000
- timeBetweenEvictionRunsMillis=1800000
- numTestsPerEvictionRun=3
- testOnBorrow=true
- testWhileIdle=true
- testOnReturn=true
- validationQuery="SELECT 1"
- }
- }
- }
-}
@@ -1,12 +1,12 @@
package grails.plugins.quartz
+import static org.quartz.impl.matchers.GroupMatcher.jobGroupEquals
+
+import org.quartz.CronTrigger
import org.quartz.Scheduler
import org.quartz.Trigger
-import org.quartz.impl.matchers.GroupMatcher
import org.quartz.TriggerKey
-import org.quartz.CronTrigger
-
-import static org.quartz.impl.matchers.GroupMatcher.jobGroupEquals
+import org.quartz.impl.matchers.GroupMatcher
class QuartzController {
static final Map<String, Trigger> triggers = [:]
@@ -19,7 +19,7 @@ class QuartzController {
def list = {
def jobsList = []
- def listJobGroups = quartzScheduler.getJobGroupNames()
+ def listJobGroups = quartzScheduler.jobGroupNames
listJobGroups?.each {jobGroup ->
quartzScheduler.getJobKeys(jobGroupEquals(jobGroup))?.each {jobKey ->
def jobName = jobKey.name
@@ -41,13 +41,11 @@ class QuartzController {
[jobs: jobsList, now: new Date(), scheduler: quartzScheduler]
}
- private def createJob(String jobGroup, String jobName, ArrayList jobsList, triggerName = "") {
- def currentJob = [:]
- currentJob.group = jobGroup
- currentJob.name = jobName
- def map = QuartzMonitorJobFactory.jobRuns.get(triggerName)
+ private createJob(String jobGroup, String jobName, List jobsList, String triggerName = "") {
+ def currentJob = [group: jobGroup, name: jobName]
+ def map = QuartzMonitorJobFactory.jobRuns[triggerName]
if (map) currentJob << map
- jobsList.add(currentJob)
+ jobsList << currentJob
return currentJob
}
@@ -57,7 +55,7 @@ class QuartzController {
if (key) {
def trigger = quartzScheduler.getTrigger(key)
if (trigger) {
- triggers.put(params.jobName, trigger)
+ triggers[params.jobName] = trigger
quartzScheduler.unscheduleJob(key)
} else {
flash.message = "No trigger could be found for $key"
@@ -69,7 +67,7 @@ class QuartzController {
}
def start = {
- def trigger = triggers.get(params.jobName)
+ def trigger = triggers[params.jobName]
if (trigger) {
quartzScheduler.scheduleJob(trigger)
} else {
@@ -123,7 +121,7 @@ class QuartzController {
def editCronTrigger = {
def trigger = quartzScheduler.getTrigger(new TriggerKey(params.triggerName, params.triggerGroup))
- if (!(trigger instanceof org.quartz.CronTrigger)) {
+ if (!(trigger instanceof CronTrigger)) {
flash.message = "This trigger is not a cron trigger"
redirect(action: "list")
return
@@ -146,14 +144,13 @@ class QuartzController {
}
try {
- trigger.setCronExpression(params.cronexpression)
- quartzScheduler.rescheduleJob(new TriggerKey(params.triggerName, params.triggerGroup), trigger);
+ trigger.cronExpression = params.cronexpression
+ quartzScheduler.rescheduleJob(new TriggerKey(params.triggerName, params.triggerGroup), trigger)
} catch (Exception ex) {
flash.message = "cron expression (${params.cronexpression}) was not correct: $ex"
render(view: "editCronTrigger", model: [trigger: trigger])
return
}
redirect(action: "list")
}
-
}
@@ -1,4 +1,3 @@
-<%@ page import="org.quartz.Trigger" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
@@ -24,7 +23,7 @@
<div>
<label>Cron Expression</label>
<span class="required-indicator">*</span>
- <g:textField name="cronexpression" value="${trigger.getCronExpression()}"/>
+ <g:textField name="cronexpression" value="${trigger.cronExpression}"/>
</div>
</fieldset>
<fieldset class="buttons">
@@ -8,37 +8,37 @@ import org.quartz.JobExecutionException
/**
* Quartz Job implementation that invokes execute() on the GrailsTaskClassJob instance whilst recording the time
*/
-public class QuartzDisplayJob implements Job {
+class QuartzDisplayJob implements Job {
GrailsJobFactory.GrailsJob job
Map<String, Object> jobDetails
private SessionFactory sessionFactory
- public QuartzDisplayJob(GrailsJobFactory.GrailsJob job, Map<String, Object> jobDetails, SessionFactory sessionFactory) {
+ QuartzDisplayJob(GrailsJobFactory.GrailsJob job, Map<String, Object> jobDetails, SessionFactory sessionFactory) {
this.job = job
this.jobDetails = jobDetails
this.sessionFactory = sessionFactory
}
- public void execute(final JobExecutionContext context) throws JobExecutionException {
+ void execute(final JobExecutionContext context) throws JobExecutionException {
jobDetails.clear()
- jobDetails.put("lastRun", new Date())
- jobDetails.put("status", "running")
+ jobDetails.lastRun = new Date()
+ jobDetails.status = "running"
long start = System.currentTimeMillis()
try {
job.execute(context)
if (shouldFlushSession(job.job)) {
org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(sessionFactory, false)?.flush()
}
} catch (Throwable e) {
- jobDetails.put("error", e.message)
- jobDetails.put("status", "error")
+ jobDetails.error = e.message
+ jobDetails.status = "error"
if (e instanceof JobExecutionException) {
- throw (JobExecutionException) e
+ throw e
}
throw new JobExecutionException(e.message, e)
}
- jobDetails.put("status", "complete")
- jobDetails.put("duration", System.currentTimeMillis() - start)
+ jobDetails.status = "complete"
+ jobDetails.duration = System.currentTimeMillis() - start
}
private boolean shouldFlushSession(job) {
@@ -1,9 +1,8 @@
package grails.plugins.quartz
-import org.quartz.spi.TriggerFiredBundle;
+import org.quartz.spi.TriggerFiredBundle
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap
/**
* Job factory which enhances GrailsJobFactory.
@@ -12,22 +11,24 @@ import java.util.Map;
* @since 0.1
*/
class QuartzMonitorJobFactory extends GrailsJobFactory {
- static final java.util.Map<String, Map<String, Object>> jobRuns = new ConcurrentHashMap<String, Map<String, Object>>();
+
+ static final Map<String, Map<String, Object>> jobRuns = new ConcurrentHashMap<String, Map<String, Object>>()
+
def sessionFactory
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
- String uniqueTriggerName = bundle.getTrigger().getKey().getName();
- Object job = super.createJobInstance(bundle);
+ String uniqueTriggerName = bundle.trigger.key.name
+ Object job = super.createJobInstance(bundle)
if (job instanceof GrailsJobFactory.GrailsJob) {
- Map<String, Object> map;
+ Map<String, Object> map
if (jobRuns.containsKey(uniqueTriggerName)) {
- map = jobRuns.get(uniqueTriggerName);
+ map = jobRuns[uniqueTriggerName]
} else {
- map = new ConcurrentHashMap<String, Object>();
- jobRuns.put(uniqueTriggerName, map);
+ map = new ConcurrentHashMap<String, Object>()
+ jobRuns[uniqueTriggerName] = map
}
- job = new QuartzDisplayJob((GrailsJobFactory.GrailsJob) job, map, sessionFactory);
+ job = new QuartzDisplayJob((GrailsJobFactory.GrailsJob) job, map, sessionFactory)
}
- return job;
+ return job
}
}
@@ -7,5 +7,5 @@ enum TriggerState {
private final int value
- public int value() { return value }
-}
+ int value() { value }
+}

0 comments on commit 52a7a07

Please sign in to comment.