jooor 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/models/ooor_java_client.rb +90 -0
- data/lib/commons-logging-1.1.jar +0 -0
- data/lib/jooor.rb +27 -0
- data/lib/ws-commons-util-1.0.2.jar +0 -0
- data/lib/xmlrpc-client-3.1.3.jar +0 -0
- data/lib/xmlrpc-common-3.1.3.jar +0 -0
- metadata +71 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
# OOOR: Open Object On Rails
|
2
|
+
# Copyright (C) 2011 Akretion LTDA (<http://www.akretion.com>).
|
3
|
+
# Author: Raphaël Valyi
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Affero General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of the
|
8
|
+
# License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
|
19
|
+
require "java"
|
20
|
+
|
21
|
+
module Ooor
|
22
|
+
class XMLJavaClient
|
23
|
+
|
24
|
+
def initialize(ooor, url, p, timeout)
|
25
|
+
@ooor = ooor
|
26
|
+
@config = org.apache.xmlrpc.client.XmlRpcClientConfigImpl.new
|
27
|
+
@config.setServerURL(java.net.URL.new(url))
|
28
|
+
@config.setEnabledForExtensions(true);
|
29
|
+
@client = org.apache.xmlrpc.client.XmlRpcClient.new
|
30
|
+
@client.setTransportFactory(org.apache.xmlrpc.client.XmlRpcLiteHttpTransportFactory.new(@client));
|
31
|
+
@client.setConfig(@config)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.new2(ooor, url, p, timeout)
|
35
|
+
XMLJavaClient.new(ooor, url, p, timeout)
|
36
|
+
end
|
37
|
+
|
38
|
+
def javaize_item(e)
|
39
|
+
if e.is_a? Array
|
40
|
+
return javaize_array(e)
|
41
|
+
elsif e.is_a? Integer
|
42
|
+
return e.to_java(java.lang.Integer)
|
43
|
+
elsif e.is_a? Hash
|
44
|
+
map = {}
|
45
|
+
e.each {|k, v| map[k] = javaize_item(v)}
|
46
|
+
return map
|
47
|
+
else
|
48
|
+
return e
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def javaize_array(array)
|
53
|
+
array.map{|e| javaize_item(e)} #TODO: test if we need a t=[] array
|
54
|
+
end
|
55
|
+
|
56
|
+
def rubyize(e)
|
57
|
+
if e.is_a? Java::JavaUtil::HashMap
|
58
|
+
map = {}
|
59
|
+
e.keys.each do |k|
|
60
|
+
v = e[k]
|
61
|
+
if (! v.is_a? String) && v.respond_to?('each') && (! v.is_a?(Java::JavaUtil::HashMap))
|
62
|
+
map[k] = v.map {|i| rubyize(i)} #array
|
63
|
+
else
|
64
|
+
map[k] = rubyize(v)#v
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
return map
|
69
|
+
|
70
|
+
elsif (! e.is_a? String) && e.respond_to?('each') && (! e.is_a?(Java::JavaUtil::HashMap))
|
71
|
+
return e.map {|i| rubyize(i)}
|
72
|
+
else
|
73
|
+
return e
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def call(method, *args)
|
78
|
+
begin
|
79
|
+
p "******* 1", args
|
80
|
+
res = @client.execute(method, javaize_array(args))
|
81
|
+
return rubyize(res)
|
82
|
+
rescue
|
83
|
+
p "******* 2", args
|
84
|
+
@error_ruby__wrapper ||= @ooor.get_ruby_rpc_client(@client.getConfig().getServerURL().to_s)
|
85
|
+
@error_ruby__wrapper.call2(method, *args)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
Binary file
|
data/lib/jooor.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# OOOR: Open Object On Rails
|
2
|
+
# Copyright (C) 20011 Akretion LTDA (<http://www.akretion.com>).
|
3
|
+
# Author: Raphaël Valyi
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Affero General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of the
|
8
|
+
# License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
%w[commons-logging-1.1.jar ws-commons-util-1.0.2.jar xmlrpc-client-3.1.3.jar xmlrpc-common-3.1.3.jar].each {|i| require i}
|
19
|
+
|
20
|
+
module Ooor
|
21
|
+
class Ooor
|
22
|
+
def get_java_rpc_client(url)
|
23
|
+
require 'app/models/ooor_java_client'
|
24
|
+
XMLJavaClient.new2(self, url, nil, @config[:rpc_timeout] || 900)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jooor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Raphael Valyi - www.akretion.com
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-25 00:00:00 -03:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: ooor
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "1.6"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: OOOR exposes business object proxies to your Ruby (Rails or not) application, that maps seamlessly to your remote OpenObject/OpenERP server using webservices. It extends the standard ActiveResource API. Running on JRuby, OOOR also offers a convenient bridge between OpenERP and the Java eco-system
|
28
|
+
email: rvalyi@akretion.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- lib/jooor.rb
|
37
|
+
- lib/app/models/ooor_java_client.rb
|
38
|
+
- lib/commons-logging-1.1.jar
|
39
|
+
- lib/ws-commons-util-1.0.2.jar
|
40
|
+
- lib/xmlrpc-client-3.1.3.jar
|
41
|
+
- lib/xmlrpc-common-3.1.3.jar
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/rvalyi/jooor
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.5.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Java XML RPC layer to boost OOOR speed dramatically when used from JRuby
|
70
|
+
test_files: []
|
71
|
+
|