I am new to jax-rs and dependency injection, in my application I have a situation where a class uses a DAO object. I have an interface for the DAO and an implementation.
I am trying to inject the DAO object inside this class BusinessLogic using @Context
in jax-rs.
Ex:
Class BusinessLogic{
@Context
BackDAO backDAO;
public void doSomethig(){
backDAO.doSome()....
}
}
where BackDAO is the interface and its implementation is BackDAOImpl.
I want to know how to inject BackDAOImpl object instance here or is it possible to inject User-defined classes using @Context
, because as far as my research I think @Context
is used on
ServletConfig
, ServletContext
, HttpServletRequest
and HttpServletResponse
.
I don't want to do this with any frameworks and also without using @Inject
, is it possible?
I tried many links at stack-overflow and the javadocs didn't have any good examples.
Where do @Context objects come from