This group is locked. No changes can be made to the group while it is locked.
Michael Vorburger <vorburger@...>
The way NeutronCRUDInterfaces (called from AbstractNeutronNorthbound) is currently implemented, by dynamically looking-up INeutronCRUD implementations from the OSGi registry, every time, isn't great... for understanding the code, for use of Neutron outside of an OSGi environment (e.g. opendaylight-simple; and that's my primary motivation here...), and for performance (and I wonder anyway if that getService() which never does an ungetService() won't cause any OSGi issues; that's not how this is supposed to be used).
A better solution IMHO would be to simply hold direct references to the required service in the respectice JAX RS resource class. For example, NeutronNetworksNorthbound really should just have a private final NeutronNetworkInterface networkInterfacez; field.
The minor trouble, of course, is that NeutronNetworksNorthbound gets created by Jersey by way of NeutronNorthboundRSApplication, which is registered in the web.xml - so one cannot "just" use e.g. BP @Inject, as elsewhere.
I believe this problem (web vs. OSGi) can be solved though. Specifically, I think the web.xml indirection is more pain than gain, and a direct programmatic registration of web objects is simpler for a numbe of reasons incl. dependency injection (DI), but also to avoid the manual listing of Import-Package instructions for BND / maven-bundle-plugin in the northbound-api.
This general topic affects all ODL projects with web components (also e.g. aaa and netconf), and I'd like to illustrate how to do this differently first in neutron, with the idea to then replicate that in other projects (by other people, hopefully).
Would the Neutron project be open to a contribution re. this? What's currently missing is something for convenient programmatic registration of web components such as servlets, filters and listeners - basically to write what today is in web.xml in a few lines of Java code. I could provide this in infrautils, but wanted to check if the Neutron project would be willing to have a dependency to infrautils to adopt this approach? I would do all the required work up to the Gerrit for Neutron, but it's a bit of work, so first I wanted to be 101% sure that the Neutron project is OK to go in this direction.