Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by rsand2
at 2024-08-03 21:03:59
Point:500 Replies:2 POST_ID:828693USER_ID:11587
Topic:
Miscellaneous Programming;;Java Programming Language
I am trying to understand how to properly use the ResourceConfig class in Jersey 2.0. What is the proper Jersey2 pattern for configuring a web application with environment-specific parameters (e.g. backend database connection info)? The point is to configure the application when deployed on Jersey Server, and also to configure the application when launched via JerseyTest.
Can I use ResourceConfig for this purpose? If so, can someone point to an example of how to use it to configure an Application in a Jersey Server?
Some more background on my question and what I'm trying to achieve:
Here's a simple example of what I'm doing with my other servlets (e.g. unrelated to Jersey):
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.idfconnect.MyServlet</servlet-class>
<init-param>
<param-name>myAppConfigFile</param-name>
<param-value>/etc/idfconnect/myapp.conf</param-value>
</init-param>
</servlet>
You can see, my servlet reads the param, gets the path to the conf file, and loads
the conf file, which has all of its environment-specific configuration properties.
So the reason for this post is that I want to use a similar approach with my Jersey2 application - when deployed on a Jersey server, I have some mechanism to pass in initialization parameters, and when deployed using JerseyTest, I have an alternate mechanism to pass in such parameters. My question is what is the proper technique in Jersey2 to accomplish this?
Thanks for any help!
Can I use ResourceConfig for this purpose? If so, can someone point to an example of how to use it to configure an Application in a Jersey Server?
Some more background on my question and what I'm trying to achieve:
Here's a simple example of what I'm doing with my other servlets (e.g. unrelated to Jersey):
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.idfconnect.MyServlet</servlet-class>
<init-param>
<param-name>myAppConfigFile</param-name>
<param-value>/etc/idfconnect/myapp.conf</param-value>
</init-param>
</servlet>
You can see, my servlet reads the param, gets the path to the conf file, and loads
the conf file, which has all of its environment-specific configuration properties.
So the reason for this post is that I want to use a similar approach with my Jersey2 application - when deployed on a Jersey server, I have some mechanism to pass in initialization parameters, and when deployed using JerseyTest, I have an alternate mechanism to pass in such parameters. My question is what is the proper technique in Jersey2 to accomplish this?
Thanks for any help!
Author: rsand2 replied at 2024-08-03 21:12:02
:) That thread is also me, asking the same question. The answer provided in that thread didn't actually answer my question and I haven't gotten any replies to my subsequent posts to that mailing list, so I figured I'd try here
Expert: duncanb7 replied at 2024-08-03 21:09:35
That link may help you
http://jersey.576304.n2.nabble.com/question-about-ResourceConfig-td7580974.html
http://jersey.576304.n2.nabble.com/question-about-ResourceConfig-td7580974.html