On 05/20/2010 03:02 PM, Paul Sandoz wrote:
>
>>> Yes, it should be possible to do the following:
>>>
>>> public MyApp extends Application {
>>> @Context ServletConfig sc;
>>> }
>> I tried that. When I read sc in the constructor, it's null.
>>
>
>
> Yes, that is because field injection occurs after construction. You
> need to use a @PostConstruct annotated method to access such values.
>
Like this?
public class MyApp extends PackagesResourceConfig {
@Context ServletConfig sc;
public AddressFetcher() {
super("no.uio.ifi.martingi.addresses");
}
@PostConstruct
public void readInitParams() {
//System.out.println(sc.getInitParameter("no.uio.ifi.martingi.addresses.userid"));
System.out.println(sc);
}
}
The @PostConstruct method is not called :-(
Martin