JavaEE REST (Wink) - Can be REST Api class defines as singleton?

162 views Asked by At

I am using J2EE with WASLiberty & Apache Wink (REST Impl). I would need in some cases to have api class to be singleton, however private constructor probably wont work with REST. Has anyone used api to be singleton ? any hints ?

1

There are 1 answers

4
Shmil The Cat On

As per Wink doc

The @Scope annotation According to the JAX-RS specification, by default, provider and resource classes are instantiated once for each JAX-RS application. This instantiation involves the default constructor for the class being called, with the injection of dependencies happening afterwards.

Since the instantiation of your resource class (in your words, API class) will be carried out by injection, I don't think the default ctor visibility will be an issue (In the worst case, make it public)