public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Add config.preload_frameworks to load all frameworks at startup. Default to 
false so Rails autoloads itself as it's used.
jeremy (author)
Mon Nov 24 18:43:04 -0800 2008
commit  104f3a57768602289299b3be0fab5b1ed21d7653
tree    8e467393ec0541d3db1cacd895e094e995574eb4
parent  d01f75b1f091c37d14ece70cbe5f52f20f25d64c
...
57
58
59
60
61
...
57
58
59
 
 
0
@@ -57,5 +57,3 @@ end
0
 
0
 autoload :MailHelper, 'action_mailer/mail_helper'
0
 autoload :TMail, 'action_mailer/vendor/tmail'
0
-
0
-ActionMailer.load_all! unless ENV['LAZY']
...
100
101
102
103
104
...
100
101
102
 
 
0
@@ -100,5 +100,3 @@ autoload :Mime, 'action_controller/mime_type'
0
 
0
 autoload :HTML, 'action_controller/vendor/html-scanner'
0
 autoload :Rack, 'action_controller/vendor/rack'
0
-
0
-ActionController.load_all! unless ENV['LAZY']
...
55
56
57
58
59
...
55
56
57
 
 
0
@@ -55,5 +55,3 @@ class ERB
0
 end
0
 
0
 I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
0
-
0
-ActionView.load_all! unless ENV['LAZY']
...
75
76
77
78
79
...
75
76
77
 
 
0
@@ -75,5 +75,3 @@ end
0
 
0
 require 'active_record/i18n_interpolation_deprecation'
0
 I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml'
0
-
0
-ActiveRecord.load_all! unless ENV['LAZY']
...
55
56
57
58
59
...
55
56
57
 
 
0
@@ -55,5 +55,3 @@ require 'active_support/core_ext'
0
 require 'active_support/json'
0
 
0
 I18n.load_path << "#{File.dirname(__FILE__)}/active_support/locale/en.yml"
0
-
0
-ActiveSupport.load_all! unless ENV['LAZY']
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *2.3.0 [Edge]*
0
 
0
+* Add config.preload_frameworks to load all frameworks at startup. Default to false so Rails autoloads itself as it's used. Turn this on for Passenger and JRuby. Also turned on by config.threadsafe!  [Jeremy Kemper]
0
+
0
 * Add a rake task to generate dispatchers : rake rails:generate_dispatchers [Pratik]
0
 
0
 * "rails <app>" will not generate public/dispatch.cgi/fcgi/rb files by default now. Please use "--with-dispatchers" option if you need them. [Yaroslav Markin, Pratik Naik]
...
136
137
138
 
139
140
141
...
264
265
266
 
 
 
 
 
 
 
 
 
 
 
 
 
267
268
269
...
602
603
604
 
 
 
605
606
607
...
768
769
770
 
771
772
773
...
810
811
812
 
813
814
815
...
955
956
957
 
 
 
 
958
959
960
...
136
137
138
139
140
141
142
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
...
616
617
618
619
620
621
622
623
624
...
785
786
787
788
789
790
791
...
828
829
830
831
832
833
834
...
974
975
976
977
978
979
980
981
982
983
0
@@ -136,6 +136,7 @@ module Rails
0
       add_gem_load_paths
0
 
0
       require_frameworks
0
+      preload_frameworks
0
       set_autoload_paths
0
       add_plugin_load_paths
0
       load_environment
0
@@ -264,6 +265,19 @@ module Rails
0
       raise e.to_s
0
     end
0
 
0
+    # Preload all frameworks specified by the Configuration#frameworks.
0
+    # Used by Passenger to ensure everything's loaded before forking and
0
+    # to avoid autoload race conditions in JRuby.
0
+    def preload_frameworks
0
+      if configuration.preload_frameworks
0
+        configuration.frameworks.each do |framework|
0
+          # String#classify and #constantize aren't available yet.
0
+          toplevel = Object.const_get(framework.to_s.gsub(/(?:^|_)(.)/) { $1.upcase })
0
+          toplevel.load_all!
0
+        end
0
+      end
0
+    end
0
+
0
     # Add the load paths used by support functions such as the info controller
0
     def add_support_load_paths
0
     end
0
@@ -602,6 +616,9 @@ Run `rake gems:install` to install the missing gems.
0
     # A stub for setting options on ActiveSupport.
0
     attr_accessor :active_support
0
 
0
+    # Whether to preload all frameworks at startup.
0
+    attr_accessor :preload_frameworks
0
+
0
     # Whether or not classes should be cached (set to false if you want
0
     # application classes to be reloaded on each request)
0
     attr_accessor :cache_classes
0
@@ -768,6 +785,7 @@ Run `rake gems:install` to install the missing gems.
0
       self.log_level                    = default_log_level
0
       self.view_path                    = default_view_path
0
       self.controller_paths             = default_controller_paths
0
+      self.preload_frameworks           = default_preload_frameworks
0
       self.cache_classes                = default_cache_classes
0
       self.dependency_loading           = default_dependency_loading
0
       self.whiny_nils                   = default_whiny_nils
0
@@ -810,6 +828,7 @@ Run `rake gems:install` to install the missing gems.
0
     # multiple database connections. Also disables automatic dependency loading
0
     # after boot
0
     def threadsafe!
0
+      self.preload_frameworks = true
0
       self.cache_classes = true
0
       self.dependency_loading = false
0
       self.action_controller.allow_concurrency = true
0
@@ -955,6 +974,10 @@ Run `rake gems:install` to install the missing gems.
0
         true
0
       end
0
 
0
+      def default_preload_frameworks
0
+        false
0
+      end
0
+
0
       def default_cache_classes
0
         true
0
       end

Comments