users@jersey.java.net

[Jersey] Re: Jersey2: How to pass parameters from web.xml to the Application?

From: Joseph Mocker <jmocker_at_velti.com>
Date: Fri, 25 Oct 2013 21:42:31 +0000

Yeah I haven’t found the link between ServletContainer and ResourceConfig either.

But, if you are going to have different web.xml files for your dev and prod environments, why not just have two different ResourceConfig subclasses, one for each environment?

With my suggestion, it may be ugly, but you are never generating multiple WARs, your environment specific parameters are held outside the WAR. That’s nice from a management/deployment standpoint.

I’ll bet something similar could be done with JNDI.

  —joe

On Oct 25, 2013, at 2:24 PM, cowwoc <cowwoc_at_bbs.darktech.org> wrote:

>
> Jeez. That's very ugly.
>
> Isn't there a way for me to pass variables from web.xml to ServletContainer and from there to ResourceConfig.getProperties()? I haven't tried this yet because the migration process is not complete, but surely there should be a way to do this using existing Jersey mechanisms...?
>
> Gili
>
> On 25/10/2013 4:42 PM, Joseph Mocker wrote:
>> A slightly more elegant way than Ivar’s suggestion would be to put a properties file in the classpath somewhere (for example, with Tomcat, you could put it in tomcat’s lib/) folder, then in your ResourceConfig, do a getResourceAsStream(“/config.properties”) and look for some property to tell you the mode you are running in.
>>
>>
>> Joseph Mocker | Velti | Senior Software Architect
>> t +1.415.315.4314 m +1.650.566.7033
>> e jmocker_at_velti.com @VeltiMobile
>>
>> The leading global technology provider of
>> mobile marketing and advertising solutions
>>
>> On Oct 25, 2013, at 12:46 PM, Ivar <ivarconr_at_gmail.com> wrote:
>>
>>> Use regular jvm properties to set a debug property?
>>>
>>> ​Ivar
>