Forum: Ruby on Rails J2EE equivalent

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Thila T. (Guest)
on 2006-01-08 18:33
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
Obie F. (Guest)
on 2006-01-08 20:22
(Received via mailing list)
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?
Johannes Brodwall (Guest)
on 2006-01-08 23:40
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
Phillip H. (Guest)
on 2006-01-09 00:57
(Received via mailing list)
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 H.
removed_email_address@domain.invalid
Steven R. Baker (Guest)
on 2006-01-09 10:30
(Received via mailing list)
On 1/8/06, thila thila <removed_email_address@domain.invalid> 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/applic...

-Steven
Thibaut Barrère (Guest)
on 2006-01-09 13:05
(Received via mailing list)
> 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
Jens-Christian F. (Guest)
on 2006-01-09 15:02
(Received via mailing list)
>
>> 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
This topic is locked and can not be replied to.