samedi 25 juillet 2015

Injecting beans to library which uses newInstance()

Today I want to ask question about spring and newInstance() method.

I'm using TyrusProject(generaly websockets in java). I created EndPoint bean and Server bean. Server depends on endpoint.

Its constructor looks like this:

Server(String path, int port, Class<?> endpoint)

And there is problem. EndPoint implements ApplicationContextAware, to get applicationContext. It is set at first, but then server creates it's own instance of endpoint and I get NullPointerException.

Is there any way I can do something about it?
Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire