J2EE equivalent


#1

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


#2
  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?


#3

thila thila wrote:

  1. 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


#4

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.

  1. 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


#5

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/application-specific-configuration

-Steven


#6
  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


#7
  1. 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