How can I inject a data source dependency into a RESTful web service with Jersey (Test Framework)?

After digging through the Jersey Test Framework source, I've discovered an elegant way to inject dependencies into my RESTful resource classes.

After digging through the Jersey Test Framework source, I've discovered an elegant way to inject dependencies into my RESTful resource classes. In my test class (which extends JerseyTest), I've added only an implementation for the configure() method: public AppDescriptor configure() { return new WebAppDescriptor.Builder() . ContextListenerClass(ContextLoaderListener.

Class) . ContextParam("contextConfigLocation", "classpath:applicationContext. Xml") .

InitParam("com.sun.jersey.config.property. Packages", "resource package") .build(); } This effectively provides a custom built WebAppDescriptor instead of relying on Jersey Test's Grizzly Web container to build one. This will use the "applicationContext.

Xml" file on the classpath, which can be configured differently for running JUnit tests. Effectively, I have two different applicationContext. Xml files: one for my JUnit tests, and the other for production code.

The test's applicationContext. Xml will configure the data access dependency object differently.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions