jruby-hazelcast 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/INSTALL ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 adenenberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
File without changes
@@ -0,0 +1,14 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "jruby-hazelcast"
5
+ gemspec.summary = "ruby interface to Hazelcast Cache Cluster"
6
+ gemspec.description = ""
7
+ gemspec.email = "adam@dberg.org"
8
+ gemspec.homepage = "http://github.com/denen99/jruby-hazelcast"
9
+ gemspec.authors = ["Adam Denenberg"]
10
+ end
11
+ Jeweler::GemcutterTasks.new
12
+ rescue LoadError
13
+ puts "Jeweler not available. Install it with: gem install jeweler"
14
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,18 @@
1
+ require 'java'
2
+ require '../lib/jruby-hazelcast'
3
+
4
+ key = rand
5
+ value = rand
6
+
7
+ c = HazelcastCacheClient.instance
8
+ c.put(key,value)
9
+
10
+ resp = c.get(key)
11
+
12
+ if resp == value
13
+ puts "READ / WRITE WORKS !!"
14
+ else
15
+ puts "Something went wrong !!"
16
+ end
17
+
18
+ c.client.shutdown
@@ -0,0 +1,8 @@
1
+ production:
2
+
3
+ username: dev
4
+ password: dev-pass
5
+ hostname: 127.0.0.1
6
+ mapname: default
7
+
8
+ development:
Binary file
@@ -0,0 +1,106 @@
1
+ #--
2
+ # Copyright (c) 2010 Adam Denenberg
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
25
+
26
+ HAZELCAST_CLIENT_LIB = ENV['HAZELCAST_CLIENT_LIB'] || 'hazelcast-client-1.8.4.jar'
27
+
28
+ require 'java'
29
+ require HAZELCAST_CLIENT_LIB
30
+ require 'singleton'
31
+ require 'yaml'
32
+ require 'erb'
33
+
34
+ import com.hazelcast.client.HazelcastClient;
35
+ import java.util.Map;
36
+
37
+ class HazelcastCacheClient
38
+
39
+ include Singleton
40
+ attr_accessor :client, :map, :app_root, :hostname, :username, :password
41
+
42
+ class CacheException < StandardError; end
43
+
44
+ def initialize
45
+ @hostname = 'localhost'
46
+ @username = 'dev'
47
+ @password = 'dev-pass'
48
+ @mapname = 'default'
49
+ parse_options
50
+ @client = HazelcastClient.newHazelcastClient(@username, @password, @hostname);
51
+ @map = @client.getMap(@mapname);
52
+ end
53
+
54
+ def parse_options(app_root = Dir.pwd)
55
+ if defined?(RAILS_ROOT)
56
+ self.app_root = RAILS_ROOT + '/config/'
57
+ environment = RAILS_ENV || 'production'
58
+ else
59
+ self.app_root = app_root
60
+ environment = ENV['JRUBY_HAZELCAST_ENV'] || 'production'
61
+ end
62
+
63
+ config_file = self.app_root + '/hazelcast.yml'
64
+ if !File.exists?(config_file)
65
+ return puts "hazelcast.yml missing in directory " + self.app_root + ' , using defaults !!!'
66
+ return false
67
+ end
68
+
69
+ conf = YAML::load(ERB.new(IO.read(config_file)).result)[environment]
70
+ return if conf.nil?
71
+
72
+ conf.each do |key,value|
73
+ case key
74
+ when 'hostname'
75
+ @hostname = value
76
+ when 'username'
77
+ @username = value
78
+ when 'password'
79
+ @password = value
80
+ when 'mapname'
81
+ @mapname = value
82
+ end unless conf.nil?
83
+
84
+ end
85
+
86
+ end
87
+
88
+ def values
89
+ @map.values.to_a
90
+ end
91
+
92
+ def remove(k,v)
93
+ @map.remove(k,v)
94
+ end
95
+
96
+ def put(k,v)
97
+ return unless k && v
98
+ @map.put(k,v)
99
+ end
100
+
101
+ def get(k)
102
+ return unless k
103
+ @map.get(k)
104
+ end
105
+
106
+ end #class HazelcastCache
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby-hazelcast
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Adam Denenberg
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-22 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: ""
22
+ email: adam@dberg.org
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README
30
+ files:
31
+ - INSTALL
32
+ - LICENSE
33
+ - README
34
+ - Rakefile
35
+ - VERSION
36
+ - hazelcast.yml
37
+ - lib/hazelcast-1.8.4.jar
38
+ - lib/hazelcast-client-1.8.4.jar
39
+ - lib/jruby-hazelcast.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/denen99/jruby-hazelcast
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: ruby interface to Hazelcast Cache Cluster
70
+ test_files:
71
+ - examples/test1.rb