public
Fork of nicksieger/warbler
Description: Warbler chirpily constructs .war files of your Rails applications.
Homepage: http://caldersphere.rubyforge.org/warbler
Clone URL: git://github.com/dysinger/warbler.git
Search Repo:
Further work to support arbitrary custom context parameters in web.xml.

- Update config.webxml attribute rdoc
- Allow for more than one jndi name/resoure-ref
nicksieger (author)
Sun May 04 17:18:03 -0700 2008
commit  a453fa37d94732534cf877a3c9f1699e09b21de3
tree    447659e90e54a2868b104f54b1a9dccebc120435
parent  a5c01687d1f2b0f4a69e690808df257de94fc16d
...
57
58
59
60
61
 
 
62
63
64
...
57
58
59
 
 
60
61
62
63
64
0
@@ -57,8 +57,8 @@
0
   # Control the pool of Rails runtimes. Leaving unspecified means
0
   # the pool will grow as needed to service requests. It is recommended
0
   # that you fix these values when running a production server!
0
- # config.webxml.min.runtimes = 2
0
- # config.webxml.max.runtimes = 4
0
+ # config.webxml.jruby.min.runtimes = 2
0
+ # config.webxml.jruby.max.runtimes = 4
0
 
0
   # JNDI data source name
0
   # config.webxml.jndi = 'jdbc/rails'
...
51
52
53
54
55
56
57
58
59
60
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
 
 
 
83
84
85
...
131
132
133
 
134
135
136
...
175
176
177
 
 
178
179
180
...
51
52
53
 
 
 
 
 
 
 
 
 
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70
71
72
73
74
75
...
121
122
123
124
125
126
127
...
166
167
168
169
170
171
172
173
0
@@ -51,35 +51,25 @@
0
     # the Rails application
0
     attr_accessor :war_name
0
 
0
- # Extra configuration for web.xml/goldspike. These options are particular
0
- # to Goldspike's Rails servlet and web.xml file.
0
- #
0
- # * <tt>webxml.standalone</tt> -- whether the .war file is "standalone",
0
- # meaning JRuby, all java and gem dependencies are completely embedded
0
- # in file. One of +true+ (default) or +false+.
0
- # * <tt>webxml.jruby_home</tt> -- required if standalone is false. The
0
- # directory containing the JRuby installation to use when the app is
0
- # running.
0
- # * <tt>webxml.rails_env</tt> -- the Rails environment to use for the
0
+ # Extra configuration for web.xml. Controls how the dynamically-generated web.xml
0
+ # file is generated.
0
+ #
0
+ # * <tt>webxml.jndi</tt> -- the name of one or more JNDI data sources name to be
0
+ # available to the application. Places appropriate &lt;resource-ref&gt; entries
0
+ # in the file.
0
+ # * <tt>webxml.ignored</tt> -- array of key names that will be not used to
0
+ # generate a context param. Defaults to ['jndi', 'booter']
0
+ #
0
+ # Any other key/value pair placed in the open structure will be dumped as a
0
+ # context parameter in the web.xml file. Some of the recognized values are:
0
+ #
0
+ # * <tt>webxml.rails.env</tt> -- the Rails environment to use for the
0
     # running application, usually either development or production (the
0
     # default).
0
- # * <tt>webxml.pool.maxActive</tt> -- maximum number of pooled Rails
0
- # application runtimes (default 4)
0
- # * <tt>webxml.pool.minIdle</tt> -- minimum number of pooled runtimes to
0
- # keep around during idle time (default 2)
0
- # * <tt>webxml.pool.checkInterval</tt> -- how often to check whether the
0
- # pool size is within minimum and maximum limits, in milliseconds
0
- # (default 0)
0
- # * <tt>webxml.pool.maxWait</tt> -- how long a waiting thread should wait
0
- # for a runtime before giving up, in milliseconds (default 30000)
0
- # * <tt>webxml.jndi</tt> -- the name of a JNDI data source name to be
0
- # available to the application
0
- # * <tt>webxml.servlet_name</tt> -- the name of the servlet to receive all
0
- # requests. One of +files+ or +rails+. Goldspike's default behavior is
0
- # to route first through the FileServlet, and if the file isn't found,
0
- # it is forwarded to the RailsServlet. Use +rails+ if your application
0
- # server is fronted by Apache or something else that will handle static
0
- # files.
0
+ # * <tt>webxml.jruby.min.runtimes</tt> -- minimum number of pooled runtimes to
0
+ # keep around during idle time
0
+ # * <tt>webxml.jruby.max.runtimes</tt> -- maximum number of pooled Rails
0
+ # application runtimes
0
     attr_accessor :webxml
0
 
0
     def initialize(warbler_home = WARBLER_HOME)
0
@@ -131,6 +121,7 @@
0
       c.rails.env = "production"
0
       c.public.root = '/'
0
       c.jndi = nil
0
+ c.ignored = %w(jndi booter)
0
       c
0
     end
0
 
0
@@ -175,6 +166,8 @@
0
           params[k] = v.to_s
0
         end
0
       end
0
+ params.delete 'ignored'
0
+ self.ignored.each {|k| params.delete k }
0
       params
0
     end
0
   end
...
76
77
78
 
 
 
 
 
79
80
81
...
76
77
78
79
80
81
82
83
84
85
86
0
@@ -76,6 +76,11 @@
0
     config.webxml.servlet_context_listener.should == "org.jruby.rack.rails.RailsServletContextListener"
0
   end
0
 
0
+ it "should not include ignored webxml keys in the context params hash" do
0
+ Warbler::Config.new.webxml.context_params.should_not have_key('jndi')
0
+ Warbler::Config.new.webxml.context_params.should_not have_key('booter')
0
+ end
0
+
0
   #it "should automatically gems used by the web application" do
0
   # gem "actionpack"
0
   # config = Warbler::Config.new
...
85
86
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
89
90
...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
0
@@ -85,6 +85,51 @@
0
       ).first.text.should == "5"
0
   end
0
 
0
+ it "should include custom context parameters" do
0
+ @config.webxml.some.custom.config = "myconfig"
0
+ define_tasks "webxml"
0
+ Rake::Task["warble:webxml"].invoke
0
+ require 'rexml/document'
0
+ elements = File.open("#{@config.staging_dir}/WEB-INF/web.xml") do |f|
0
+ REXML::Document.new(f).root.elements
0
+ end
0
+ elements.to_a(
0
+ "context-param/param-name[text()='some.custom.config']"
0
+ ).should_not be_empty
0
+ elements.to_a(
0
+ "context-param/param-name[text()='some.custom.config']/../param-value"
0
+ ).first.text.should == "myconfig"
0
+ end
0
+
0
+ it "should allow one jndi resource to be included" do
0
+ @config.webxml.jndi = 'jndi/rails'
0
+ define_tasks "webxml"
0
+ Rake::Task["warble:webxml"].invoke
0
+ require 'rexml/document'
0
+ elements = File.open("#{@config.staging_dir}/WEB-INF/web.xml") do |f|
0
+ REXML::Document.new(f).root.elements
0
+ end
0
+ elements.to_a(
0
+ "resource-ref/res-ref-name[text()='jndi/rails']"
0
+ ).should_not be_empty
0
+ end
0
+
0
+ it "should allow multiple jndi resources to be included" do
0
+ @config.webxml.jndi = ['jndi/rails1', 'jndi/rails2']
0
+ define_tasks "webxml"
0
+ Rake::Task["warble:webxml"].invoke
0
+ require 'rexml/document'
0
+ elements = File.open("#{@config.staging_dir}/WEB-INF/web.xml") do |f|
0
+ REXML::Document.new(f).root.elements
0
+ end
0
+ elements.to_a(
0
+ "resource-ref/res-ref-name[text()='jndi/rails1']"
0
+ ).should_not be_empty
0
+ elements.to_a(
0
+ "resource-ref/res-ref-name[text()='jndi/rails2']"
0
+ ).should_not be_empty
0
+ end
0
+
0
   it "should use a config/web.xml if it exists" do
0
     define_tasks "webxml"
0
     mkdir_p "config"
...
22
23
24
25
 
26
27
 
28
29
30
31
 
32
...
22
23
24
 
25
26
 
27
28
29
30
 
31
32
0
@@ -22,12 +22,12 @@
0
     <listener-class><%= webxml.servlet_context_listener %></listener-class>
0
   </listener>
0
 
0
-<% if webxml.jndi %>
0
+<% if webxml.jndi then webxml.jndi.each do |jndi| %>
0
   <resource-ref>
0
- <res-ref-name><%= webxml.jndi %></res-ref-name>
0
+ <res-ref-name><%= jndi %></res-ref-name>
0
     <res-type>javax.sql.DataSource</res-type>
0
     <res-auth>Container</res-auth>
0
   </resource-ref>
0
-<% end end %>
0
+<% end; end %>
0
 </web-app>

Comments

    No one has commented yet.