techwhizbang-jruby-quartz 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +11 -0
- data/README +79 -0
- data/Rakefile +42 -0
- data/test/all_tests.rb +1 -0
- metadata +60 -0
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Copyright (c) 2009 Nick Zalabak
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
7
|
+
the License is distributed on an "AS IS" BASIS,
|
8
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
9
|
+
either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
= jruby-quartz
|
2
|
+
|
3
|
+
== Instructions
|
4
|
+
|
5
|
+
Requires the following jars in your application container
|
6
|
+
|
7
|
+
commons-collections-3.2.x.jar
|
8
|
+
commons-logging.jar
|
9
|
+
log4j.jar
|
10
|
+
quartz-1.6.x.jar
|
11
|
+
|
12
|
+
If you are running a current version of JBoss you already have these!
|
13
|
+
If you are running an alternative container you will need to check it's lib
|
14
|
+
directory for the presence of these jars.
|
15
|
+
|
16
|
+
If you need these jars you can find them within the apache commons project and
|
17
|
+
the quartz jar on opensymphony
|
18
|
+
|
19
|
+
== Installation
|
20
|
+
|
21
|
+
gem install git://github.com/techwhizbang/jruby-quartz.git
|
22
|
+
|
23
|
+
== Usage
|
24
|
+
|
25
|
+
The best way to leverage jruby-quartz is to simply extend the BaseScheduler and
|
26
|
+
implement any number of jobs you need to run.
|
27
|
+
|
28
|
+
For example all you need to do is specify some basic attributes including the
|
29
|
+
cron expression representing the frequency of the job(s) you want to with it:
|
30
|
+
|
31
|
+
class IntegrationScheduler < BaseScheduler
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
super
|
37
|
+
@base_jobs_group = "IntegrationJobs"
|
38
|
+
@base_triggers_group = "IntegrationTriggers"
|
39
|
+
@cron_expression = "0 0/1 * * * ?"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Then just extend the base job by putting all of the work you want to perform inside the
|
44
|
+
perform_job method.
|
45
|
+
|
46
|
+
class IntegrationJob < Jobs::BaseJob
|
47
|
+
|
48
|
+
def perform_job
|
49
|
+
worker_one = mock('worker class one', :whatever => "123")
|
50
|
+
worker_two = mock('worker class two', :whatever => '123')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
If you are running Rails you can throw the schedule! method into a custom initializer.
|
55
|
+
An example of this would be like so:
|
56
|
+
Notice the Rails.env /container/, I defined custom environments that only run when
|
57
|
+
inside a Java container so that the schedule! method doesn't get fired off during
|
58
|
+
testing.
|
59
|
+
|
60
|
+
****If you don't do this the schedule! method is fired off a Quartz thread pool
|
61
|
+
is spun up.****
|
62
|
+
|
63
|
+
if RUBY_PLATFORM =~ /java/ && Rails.env =~ /container/
|
64
|
+
|
65
|
+
CustomerLoadScheduler.instance.schedule!(Jobs::CustomerLoadJob)
|
66
|
+
LoggerOneScheduler.instance.schedule!(Jobs::LoggerOneJob)
|
67
|
+
LoggerTwoScheduler.instance.schedule!(Jobs::LoggerTwoJob)
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
If you are planning on using this with a Rails stack, I would recommend using this
|
72
|
+
only with Rails 2.2 or higher because thread safety == 1 runtime
|
73
|
+
|
74
|
+
1 runtime means your schedule initializer is only called once.
|
75
|
+
|
76
|
+
=== Other
|
77
|
+
|
78
|
+
Problems, comments, and suggestions all welcome. nick@controlaltcreate.com or visit my blog
|
79
|
+
http://techwhizbang.com
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
task :default => :test
|
6
|
+
|
7
|
+
task :test do
|
8
|
+
require File.dirname(__FILE__) + '/test/all_tests.rb'
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Generate RDoc'
|
12
|
+
Rake::RDocTask.new do |task|
|
13
|
+
task.main = 'README'
|
14
|
+
task.title = 'jruby-quartz'
|
15
|
+
task.rdoc_dir = 'doc'
|
16
|
+
task.options << "--line-numbers" << "--inline-source"
|
17
|
+
task.rdoc_files.include('README', 'lib/**/*.rb')
|
18
|
+
end
|
19
|
+
|
20
|
+
specification = Gem::Specification.new do |s|
|
21
|
+
s.name = "jruby-quartz"
|
22
|
+
s.summary = "Jruby-Quartz is a wrapper library for the Java based Quartz scheduling framework."
|
23
|
+
s.version = "0.1"
|
24
|
+
s.author = 'Nick Zalabak'
|
25
|
+
s.description = "Jruby-Quartz is a wrapper library for the Java based Quartz scheduling framework."
|
26
|
+
s.email = 'nick@controlaltcreate.com'
|
27
|
+
s.homepage = 'http://techwhizbang.com'
|
28
|
+
s.rubyforge_project = 'Jruby-Quartz'
|
29
|
+
|
30
|
+
s.has_rdoc = true
|
31
|
+
s.extra_rdoc_files = ['README']
|
32
|
+
s.rdoc_options << '--title' << 'Jruby-Quartz' << '--main' << 'README' << '--line-numbers'
|
33
|
+
|
34
|
+
s.autorequire = 'jruby-quartz'
|
35
|
+
s.files = FileList['{lib,test}/**/*.rb', 'LICENSE', 'README', 'Rakefile'].to_a
|
36
|
+
s.test_file = "test/all_tests.rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::GemPackageTask.new(specification) do |package|
|
40
|
+
package.need_zip = false
|
41
|
+
package.need_tar = false
|
42
|
+
end
|
data/test/all_tests.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir['**/*_test.rb'].each { |test_case| require test_case }
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: techwhizbang-jruby-quartz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Zalabak
|
8
|
+
autorequire: jruby-quartz
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-05 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Jruby-Quartz is a wrapper library for the Java based Quartz scheduling framework.
|
17
|
+
email: nick@controlaltcreate.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- "{lib,test}/**/*.rb"
|
26
|
+
- LICENSE
|
27
|
+
- README
|
28
|
+
- Rakefile
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: http://techwhizbang.com
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options:
|
33
|
+
- --title
|
34
|
+
- Jruby-Quartz
|
35
|
+
- --main
|
36
|
+
- README
|
37
|
+
- --line-numbers
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.2.0
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: A JRuby implementation of the Quartz scheduling framework that makes it easy to integrate into Ruby and Rails based projects.
|
59
|
+
test_files:
|
60
|
+
- test/all_tests.rb
|