You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Munroe <br...@gmail.com> on 2007/08/31 05:05:59 UTC

context-param vs env-entry. Ready? Fight!

I just started to help maintain an application that I didn't
originally develop.  It is using <context-param> elements and
getInitParameter() to access application configuration items in
web.xml.

I have always used <env-entry> elements and JNDI to store and read
these items, respectively.  Refactoring the code to use <env-entry>'s
could be tedious, so I am looking for any advantages or disadvantages
for using either method.

One thing I did learn is that <env-entry>'s can be modifed during
runtime?  Also, since they are using JNDI, if I needed to migrate the
configuration items to a different datastore, reworking the code might
be easier.

Any suggestions or opinions very much appreciated.

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] context-param vs env-entry. Ready? Fight!

Posted by Brian Munroe <br...@gmail.com>.
On 9/6/07, Christopher Schultz <ch...@christopherschultz.net> wrote:

> Finally Martin Fowler said "dependency injection", and nobody ever had
> to worry about programs making any kind of sense ever again. And it was
> Good (for hourly contractors!)
>

That's it, I'm going back to Perl CGI application development!  I
don't see any IoC frameworks for that.  :)

> Is it late enough to call it Friday?
>

Its Friday for someone, somewhere on this list!

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] context-param vs env-entry. Ready? Fight!

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Brian,

In The Beginning, there was only global scope, and it was Good.

Then someone said, "nested scopes would be really convenient, so we
don't have to manage stacks ourselves," and the nested scope was
created, and it was Good.

Then someone else said "global scope is evil, as it allows programmers
to be lazy and leads to bad design," and the global scope was abolished,
and it was Good.

Then yet another said "hey, when I need to pass new data into a highly
nested method, lack of global scope is a real PITA because I have to
change every method signature in my program," and JNDI was created, and
it was Good.

Finally Martin Fowler said "dependency injection", and nobody ever had
to worry about programs making any kind of sense ever again. And it was
Good (for hourly contractors!)

Is it late enough to call it Friday? ;)

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG4LUd9CaO5/Lv0PARAhmmAJ49Qc6nrfS5ACQ8VJQ3tEQx0oBU3ACeNKrB
PdPvlqRQ5suLzaIhEVCGZNw=
=c6nR
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: context-param vs env-entry. Ready? Fight!

Posted by Brian Munroe <br...@gmail.com>.
On 9/6/07, Lionel Crine <lc...@linagora.com> wrote:


> Of course, you ll have to define the JNDI variable in a different way.
> But most important, you'll don't have to change your java classes
> because the JNDI tree will stay the same.

Yep, that is what I am pushing for (JNDI)

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: context-param vs env-entry. Ready? Fight!

Posted by Lionel Crine <lc...@linagora.com>.
Hello,


IMO, you should use JNDI variable (env) instead of (context variable).
In that case, there will be no link the application server and you'll 
can deploy your application on another server.

Of course, you ll have to define the JNDI variable in a different way. 
But most important, you'll don't have to change your java classes 
because the JNDI tree will stay the same.






Lionel CRINE - GROUPE LINAGORA
Open Source Software Engineer
Tel. : 01 58 18 68 28 - Fax : 01 58 18 68 29
www.linagora.com / www.linagora.org


Tim Funk a écrit :
> Sort of. I mean any java class which saves, loads, or gets data from 
> somewhere and thus requires configuration at some time. Using IOC you 
> can hand wave around those configuration issues and having one "smarter" 
> class dependent on the servlet api which configures the rest of your 
> beans is OK.
> 
> -Tim
> 
> Brian Munroe wrote:
>> On 8/31/07, Tim Funk <fu...@joedog.org> wrote:
>>
>>> Do you really want code that has nothing to do with the servlet api
>>> dependent on ServletContext? Plugging in a new jndi lookup for testing
>>> is much easier.
>>>
>>
>> Forgive my ignorance here, but do you mean, say, in a bean?  That
>> doesn't inherit the servlet's scope?  I've never tried it because I
>> always use JNDI :)
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: context-param vs env-entry. Ready? Fight!

Posted by Tim Funk <fu...@joedog.org>.
Sort of. I mean any java class which saves, loads, or gets data from 
somewhere and thus requires configuration at some time. Using IOC you 
can hand wave around those configuration issues and having one "smarter" 
class dependent on the servlet api which configures the rest of your 
beans is OK.

-Tim

Brian Munroe wrote:
> On 8/31/07, Tim Funk <fu...@joedog.org> wrote:
> 
>> Do you really want code that has nothing to do with the servlet api
>> dependent on ServletContext? Plugging in a new jndi lookup for testing
>> is much easier.
>>
> 
> Forgive my ignorance here, but do you mean, say, in a bean?  That
> doesn't inherit the servlet's scope?  I've never tried it because I
> always use JNDI :)
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: context-param vs env-entry. Ready? Fight!

Posted by Brian Munroe <br...@gmail.com>.
On 8/31/07, Tim Funk <fu...@joedog.org> wrote:

> Do you really want code that has nothing to do with the servlet api
> dependent on ServletContext? Plugging in a new jndi lookup for testing
> is much easier.
>

Forgive my ignorance here, but do you mean, say, in a bean?  That
doesn't inherit the servlet's scope?  I've never tried it because I
always use JNDI :)

-- brian

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: context-param vs env-entry. Ready? Fight!

Posted by Tim Funk <fu...@joedog.org>.
context-param requires access to the servlet context.
env-entry requires access to jndi

Do you really want code that has nothing to do with the servlet api 
dependent on ServletContext? Plugging in a new jndi lookup for testing 
is much easier.

-Tim

Brian Munroe wrote:
> I just started to help maintain an application that I didn't
> originally develop.  It is using <context-param> elements and
> getInitParameter() to access application configuration items in
> web.xml.
> 
> I have always used <env-entry> elements and JNDI to store and read
> these items, respectively.  Refactoring the code to use <env-entry>'s
> could be tedious, so I am looking for any advantages or disadvantages
> for using either method.
> 
> One thing I did learn is that <env-entry>'s can be modifed during
> runtime?  Also, since they are using JNDI, if I needed to migrate the
> configuration items to a different datastore, reworking the code might
> be easier.
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org