Gang- 1. Is there anything in Ruby that handles the .properites files similar to the J2EE application servers. Or do I need to define all of the properties as constants? 2. Is there anyway I can load some of my classes (such as singletons) during the startup? I am looking for the startup classes that J2EE containers provide. Thanks -- Posted via http://www.ruby-forum.com/.
1. You can store/access config information in .yml files, similar to the way that you configure your database connections in Rails. 2. I''m afraid this question doesn''t make too much sense without additional context. Are you referring to shared services of some sort? Do you understand the way that Rails processes are "shared-nothing", meaning each would have its own set of "singletons"? Maybe if you share a little bit more information about what you''re trying to accomplish we could give you a better answer? On 1/8/06, thila thila <isputnik_98@yahoo.com> wrote:> Gang- > 1. Is there anything in Ruby that handles the .properites files similar > to the J2EE application servers. Or do I need to define all of the > properties as constants? > > 2. Is there anyway I can load some of my classes (such as singletons) > during the startup? I am looking for the startup classes that J2EE > containers provide. > > Thanks > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
thila thila wrote:> 2. Is there anyway I can load some of my classes (such as singletons) > during the startup? I am looking for the startup classes that J2EE > containers provide.Like Obie said, I think you might be trying to do the Wrong Thing here. But any code in e.g. config/environment.rb will be executed as the application is being loaded. Try just putting "puts ''hello world''" in the file and starting the WEBrick server. NB: This will happen once (I think) when you''re running in WEBrick, but it might happen many times in a CGI context - I have not checked. Be careful... ~Johannes -- Posted via http://www.ruby-forum.com/.
On 9/01/2006, at 5:33 AM, thila thila wrote:> 1. Is there anything in Ruby that handles the .properites files > similar > to the J2EE application servers. Or do I need to define all of the > properties as constants?You can use YAML to load a config file, but constants in environment.rb are fine for basic configuration. If you have a complex configuration file you''re probably doing something wrong.> 2. Is there anyway I can load some of my classes (such as singletons) > during the startup? I am looking for the startup classes that J2EE > containers provide.You''re thinking in J2EE application server terms. Rails does not provide an application server, it just processes requests as they come past. Some state may be maintained in sessions, but there is no other preserved state. As for singletons, Ruby classes are objects, use them. You can also check out the singleton mixin at http://www.ruby-doc.org/stdlib/ libdoc/singleton/rdoc/index.html. -- Phillip Hutchings phillip.hutchings@sitharus.com
On 1/8/06, thila thila <isputnik_98@yahoo.com> wrote:> Gang- > 1. Is there anything in Ruby that handles the .properites files similar > to the J2EE application servers. Or do I need to define all of the > properties as constants?Let me take this opportunity to shamelessly pimp my own custom solution: http://blog.lavalamp.ca/articles/2005/12/30/application-specific-configuration -Steven
> 2. Is there anyway I can load some of my classes (such as singletons) > during the startup? I am looking for the startup classes that J2EE > containers provide.Hi could you describe your (functional) goal ? For instance, you may wish to start background working services (such as a scheduler) at startup ? This way more people will be likely to answer. Thibaut -- [blog] http://www.dotnetguru2.org/tbarrere -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/5ed65ead/attachment.html
> >> 1. Is there anything in Ruby that handles the .properites files >> similar >> to the J2EE application servers. Or do I need to define all of the >> properties as constants? > > You can use YAML to load a config file, but constants in > environment.rb are fine for basic configuration. If you have a > complex configuration file you''re probably doing something wrong.I use YAML files as well for configuration. What makes you think that a complex configuration file is "the wrong thing"? The application I have written runs embedded (a network monitoring tool). There is only one user, and there''s a bunch of configuration stuff. The alternative would have been to create a database table to hold the configuration (which might make sense in a multi user environment). There ARE uses where you want complex configurations.... cu jc -- InVisible GmbH, Langgr?tstrasse 172, 8047 Z?rich Phone: +41 44 401 09 30 http://www.invisible.ch http://not.invisible.ch -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2361 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060109/3e373244/smime-0001.bin