jrubycipango 0.1.2
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.
- checksums.yaml +15 -0
- data/lib/jrubycipango.rb +151 -0
- data/lib/jrubycipango/factory.rb +36 -0
- data/lib/jrubycipango/jars/cipango-annotations-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/cipango-callflow-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/cipango-dar-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/cipango-deploy-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/cipango-jmx-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/cipango-plus-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/cipango-server-2.0.0.jar +0 -0
- data/lib/jrubycipango/jars/commons-jexl-1.1.jar +0 -0
- data/lib/jrubycipango/jars/commons-logging-1.0.3.jar +0 -0
- data/lib/jrubycipango/jars/jetty-continuation-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-deploy-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-http-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-io-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-security-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-server-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-servlet-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-servlets-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-util-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-webapp-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jetty-xml-7.2.2.v20101205.jar +0 -0
- data/lib/jrubycipango/jars/jruby-rack-1.1.13.1.jar +0 -0
- data/lib/jrubycipango/jars/servlet-api-2.5.jar +0 -0
- data/lib/jrubycipango/jars/sip-api-1.1.jar +0 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTVkMmMwYTViOTcxY2JkZDY0MDAwYzg0YWRkYTYwNzYzMmJkN2ZiZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjdjMzk1MjNiMjZhY2EyOGMwZTRmYmEyN2YyNTdlNTRiNDc2M2I0Ng==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDQ4MGJkMDgzZWQ2MmQxYjkxNTc1YWY2OWQyNGY3YWNkZDljZjk0ODk2N2Yw
|
10
|
+
NDhmZDFhMmMzYWRmYzEzNGU4YWFmM2ZkNjcwNTFiMjk5YjJhZDViNGRhYmZl
|
11
|
+
YjE1OWU2MTdkYzViZWRlNjRhYzE3MTZlZTY1OGFiNGU5MWY5NGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODAwMGFhN2JkYjI5ODgxZGNhZjAxZWExZjUwYTI5Njk3ZTQ0NTYyZDU0MTZj
|
14
|
+
NWEzYjhlOGYwZDczNzQwYjcwZDkwYmM0ZjgzZmU0ZjJkNGM1MzBlYjUwY2I1
|
15
|
+
MzdiY2UzM2NkZDAwY2IwYjU4ZmQ4ODEzYWQwMDE3NTczZWI5ODQ=
|
data/lib/jrubycipango.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# jrubyciango gem
|
2
|
+
# Embedding Cipango HTTP/SIP application server into a JRuby application
|
3
|
+
|
4
|
+
require 'java'
|
5
|
+
|
6
|
+
# --- Cipango/Jetty and JRuby Rack jars -----
|
7
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
8
|
+
Dir[dir + "/jrubycipango/jars/*.jar"].each { |jar| require jar }
|
9
|
+
|
10
|
+
require 'jrubycipango/factory'
|
11
|
+
|
12
|
+
module JRubyCipango
|
13
|
+
%w[
|
14
|
+
org.cipango.server.handler.SipContextHandlerCollection
|
15
|
+
org.cipango.server.Server
|
16
|
+
org.cipango.dar.DefaultApplicationRouter
|
17
|
+
org.cipango.server.bio.UdpConnector
|
18
|
+
org.cipango.server.bio.TcpConnector
|
19
|
+
org.cipango.server.SipConnector
|
20
|
+
org.cipango.sipapp.SipAppContext
|
21
|
+
org.cipango.servlet.SipServletHolder
|
22
|
+
org.eclipse.jetty.server.bio.SocketConnector
|
23
|
+
org.eclipse.jetty.server.Connector
|
24
|
+
org.eclipse.jetty.server.Handler
|
25
|
+
org.eclipse.jetty.servlet.ServletHolder
|
26
|
+
org.eclipse.jetty.servlet.DefaultServlet
|
27
|
+
org.eclipse.jetty.servlet.FilterMapping
|
28
|
+
java.util.HashMap
|
29
|
+
].each {|cl| java_import cl }
|
30
|
+
|
31
|
+
|
32
|
+
class CipangoServer
|
33
|
+
attr_accessor :context_path, :resource_base
|
34
|
+
|
35
|
+
# Initialize converged server's instance
|
36
|
+
# Options:
|
37
|
+
# :host_ip_address
|
38
|
+
# :http_port
|
39
|
+
# :sip_port
|
40
|
+
# :context_path
|
41
|
+
# :resource_base
|
42
|
+
def initialize(params={})
|
43
|
+
@host_ip_address = params[:host_ip_address] || '0.0.0.0'
|
44
|
+
@http_port = params[:http_port] || 8080
|
45
|
+
@sip_port = params[:sip_port] || 5060
|
46
|
+
|
47
|
+
@context_path = params[:context_path] || '/'
|
48
|
+
@resource_base = params[:resource_base] || '.'
|
49
|
+
|
50
|
+
@http_servlets = []
|
51
|
+
@sip_servlets = []
|
52
|
+
@has_rack_app = false
|
53
|
+
end
|
54
|
+
|
55
|
+
# Add http servlet
|
56
|
+
def add_http_servlet http_app, init_params={}, context_path= '/*'
|
57
|
+
@http_servlets << {
|
58
|
+
:app => http_app,
|
59
|
+
:init_params => init_params,
|
60
|
+
:context_path => context_path
|
61
|
+
} if http_app
|
62
|
+
end
|
63
|
+
|
64
|
+
# Add rack application
|
65
|
+
# Options:
|
66
|
+
# :rackup_file - default 'config.ru'
|
67
|
+
# :static_path - path to static content, default '/public'
|
68
|
+
def add_rackup rackup_options = {}
|
69
|
+
rackup_options[:rackup_file] ||= 'config.ru'
|
70
|
+
rackup_options[:static_path] ||= '/public'
|
71
|
+
@resource_base = ".#{rackup_options[:static_path]}"
|
72
|
+
@rackup_options = rackup_options
|
73
|
+
@has_rack_app = true
|
74
|
+
end
|
75
|
+
|
76
|
+
# add SIP servlet object
|
77
|
+
# :options => {:is_event_listener => false}
|
78
|
+
# if :is_event_listener is true the servlet must include javax.servlet.sip.SipSessionListener or other Java Sip listener interface
|
79
|
+
def add_sip_servlet sip_servlet, options={}
|
80
|
+
options[:options] ||= {}
|
81
|
+
options[:options][:is_event_listener] ||= false
|
82
|
+
@sip_servlets << {:servlet => sip_servlet, :options => options[:options]} if sip_servlet
|
83
|
+
end
|
84
|
+
|
85
|
+
# Start the Cipango server
|
86
|
+
def start
|
87
|
+
@cipango = cipango = Server.new
|
88
|
+
|
89
|
+
# Don't open SIP ports if there is no SIP servlets
|
90
|
+
if @sip_servlets.size > 0
|
91
|
+
udp_sip = UdpConnector.new
|
92
|
+
tcp_sip = TcpConnector.new
|
93
|
+
udp_sip.host = @host_ip_address
|
94
|
+
udp_sip.port = @sip_port
|
95
|
+
tcp_sip.host = udp_sip.host
|
96
|
+
tcp_sip.port = udp_sip.port
|
97
|
+
cipango.connector_manager.connectors = [udp_sip, tcp_sip].to_java(SipConnector)
|
98
|
+
end
|
99
|
+
|
100
|
+
tcp_http = SocketConnector.new
|
101
|
+
tcp_http.port = @http_port
|
102
|
+
cipango.connectors = [tcp_http].to_java(Connector)
|
103
|
+
|
104
|
+
context = SipAppContext.new
|
105
|
+
context.context_path = @context_path
|
106
|
+
context.resource_base = @resource_base
|
107
|
+
$servlet_context = context.servlet_context
|
108
|
+
|
109
|
+
context.set_init_parameter('jruby.max.runtimes', '1')
|
110
|
+
#context.set_init_parameter('org.eclipse.jetty.servlet.Default.resourceCache', '0')
|
111
|
+
#context.set_init_parameter('org.eclipse.jetty.servlet.Default.relativeResourceBase', '/public')
|
112
|
+
|
113
|
+
#def_http_servlet_holder = ServletHolder.new(DefaultServlet.new)
|
114
|
+
#include javax.servlet.sip.SipSessionListener
|
115
|
+
#def_http_servlet_holder.set_init_parameter('org.eclipse.jetty.servlet.Default.relativeResourceBase', '/')
|
116
|
+
|
117
|
+
if @has_rack_app
|
118
|
+
context.set_init_parameter('rackup', File.read(@rackup_options[:rackup_file]))
|
119
|
+
context.add_filter("org.jruby.rack.RackFilter", "/*", FilterMapping::DEFAULT)
|
120
|
+
context.add_event_listener( Factory::JRCRackListener.new )
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
@http_servlets.each do |servlet|
|
125
|
+
servlet_holder = ServletHolder.new(servlet[:app])
|
126
|
+
params = servlet[:init_params]
|
127
|
+
params.each{|k, v| servlet_holder.set_init_parameter(k, v) }
|
128
|
+
# puts "Context path: " + servlet[:context_path]
|
129
|
+
|
130
|
+
context.add_servlet(servlet_holder, servlet[:context_path])
|
131
|
+
end
|
132
|
+
|
133
|
+
# It has to be a custom listener, not the Rack listener, in order to be in the same runtime and have access to the Rack application's namespace.
|
134
|
+
# context.add_event_listener( Factory::RackServletContextListener.new )
|
135
|
+
|
136
|
+
@sip_servlets.each do |servlet_data|
|
137
|
+
puts "servlet data #{servlet_data[:options]}"
|
138
|
+
context.add_sip_servlet(SipServletHolder.new(servlet_data[:servlet]))
|
139
|
+
context.add_event_listener(servlet_data[:servlet]) if servlet_data[:options][:is_event_listener]
|
140
|
+
end
|
141
|
+
|
142
|
+
context_collection = SipContextHandlerCollection.new
|
143
|
+
context_collection.add_handler(context)
|
144
|
+
|
145
|
+
cipango.handler = context_collection
|
146
|
+
cipango.start
|
147
|
+
cipango.join
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
# ne zaboraviti u config/production.rb postaviti config.precompiled_assets ili tako nesto na true
|
3
|
+
module JRubyCipango
|
4
|
+
module Factory
|
5
|
+
['org.jruby.rack.DefaultRackApplicationFactory',
|
6
|
+
'org.jruby.rack.SharedRackApplicationFactory',
|
7
|
+
'org.jruby.rack.RackServletContextListener',
|
8
|
+
'org.jruby.rack.rails.RailsServletContextListener',
|
9
|
+
'org.jruby.Ruby'
|
10
|
+
].each {|c| java_import c }
|
11
|
+
|
12
|
+
class JRCRackFactory < DefaultRackApplicationFactory
|
13
|
+
field_accessor :rackContext
|
14
|
+
def newRuntime
|
15
|
+
runtime = Ruby.get_global_runtime
|
16
|
+
$servlet_context=rackContext
|
17
|
+
require 'rack/handler/servlet'
|
18
|
+
return runtime
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class JRCRackListener < RackServletContextListener
|
23
|
+
field_reader :factory
|
24
|
+
def newApplicationFactory(context)
|
25
|
+
if factory
|
26
|
+
return factory
|
27
|
+
else
|
28
|
+
return (
|
29
|
+
SharedRackApplicationFactory.new(JRCRackFactory.new)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jrubycipango
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amer Hasanovic
|
8
|
+
- Edin Pjanic
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Create SIP/HTTP applications using embedded Cipago server.
|
15
|
+
email:
|
16
|
+
- amer@ictlab.com.ba
|
17
|
+
- edin@ictlab.com.ba
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/jrubycipango.rb
|
23
|
+
- lib/jrubycipango/factory.rb
|
24
|
+
- lib/jrubycipango/jars/cipango-dar-2.0.0.jar
|
25
|
+
- lib/jrubycipango/jars/cipango-callflow-2.0.0.jar
|
26
|
+
- lib/jrubycipango/jars/jetty-server-7.2.2.v20101205.jar
|
27
|
+
- lib/jrubycipango/jars/jetty-io-7.2.2.v20101205.jar
|
28
|
+
- lib/jrubycipango/jars/jetty-deploy-7.2.2.v20101205.jar
|
29
|
+
- lib/jrubycipango/jars/jetty-security-7.2.2.v20101205.jar
|
30
|
+
- lib/jrubycipango/jars/cipango-jmx-2.0.0.jar
|
31
|
+
- lib/jrubycipango/jars/commons-jexl-1.1.jar
|
32
|
+
- lib/jrubycipango/jars/jetty-webapp-7.2.2.v20101205.jar
|
33
|
+
- lib/jrubycipango/jars/jetty-servlet-7.2.2.v20101205.jar
|
34
|
+
- lib/jrubycipango/jars/servlet-api-2.5.jar
|
35
|
+
- lib/jrubycipango/jars/jetty-continuation-7.2.2.v20101205.jar
|
36
|
+
- lib/jrubycipango/jars/jetty-http-7.2.2.v20101205.jar
|
37
|
+
- lib/jrubycipango/jars/sip-api-1.1.jar
|
38
|
+
- lib/jrubycipango/jars/jetty-xml-7.2.2.v20101205.jar
|
39
|
+
- lib/jrubycipango/jars/cipango-server-2.0.0.jar
|
40
|
+
- lib/jrubycipango/jars/cipango-annotations-2.0.0.jar
|
41
|
+
- lib/jrubycipango/jars/jetty-servlets-7.2.2.v20101205.jar
|
42
|
+
- lib/jrubycipango/jars/commons-logging-1.0.3.jar
|
43
|
+
- lib/jrubycipango/jars/cipango-deploy-2.0.0.jar
|
44
|
+
- lib/jrubycipango/jars/jetty-util-7.2.2.v20101205.jar
|
45
|
+
- lib/jrubycipango/jars/jruby-rack-1.1.13.1.jar
|
46
|
+
- lib/jrubycipango/jars/cipango-plus-2.0.0.jar
|
47
|
+
homepage: http://github.com/edictlab/JRubyCipango
|
48
|
+
licenses: []
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.0.3
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: JRubyCipango - embedded Cipango HTTP/SIP server
|
70
|
+
test_files: []
|