Hi Nalla,
We do not have a strong convention for how to do autowiring but there
are some general guidelines. You would want to use constructor wiring
for constant, final values that will not change over the lifetime of the
object. Constructor wiring is also good if the class only has 1 or 2
fields that need to be injected since the constructors stay small. We
don't really want constructors with 5 or more arguments because that
makes it difficult to wire them with mock objects for unit tests. If you
have that many fields, use getter/setter injection instead.
As far as field versus getter/setter wiring... I think at this point
that most of the OpenNMS code uses getter/setter wiring even though it
requires more lines of code. It's a little better because it follows the
old javabean conventions and is easier for most developers to read.
Seth Leger
The OpenNMS Group
On 5/14/13 1:25 PM, vivek nalla wrote:
> Hi,
>
> Is there any recommended way of using autowired across OpenNMS source code.
> Is Constructor autowiring preferred over setter autowiring and field
> autowiring or it depends on the specific use case.
>
> Thanks,
> Nalla.
>
>
>
> ------------------------------------------------------------------------------
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
>
>
> _______________________________________________
> Please read the OpenNMS Mailing List FAQ:
> http://www.opennms.org/index.php/Mailing_List_FAQ
>
> opennms-devel mailing list
>
> To *unsubscribe* or change your subscription options, see the bottom of this
> page:
> https://lists.sourceforge.net/lists/listinfo/opennms-devel
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ
opennms-devel mailing list
To *unsubscribe* or change your subscription options, see the bottom of this
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel