Annotation Interface BeanSocket


@Retention(CLASS) @Target({CONSTRUCTOR,METHOD}) public @interface BeanSocket

A bean socket represents a bean dependency, a bean required or desirable by a bean to operate properly. Sockets are basically defined to connect beans together through dependency injection. By convention, constructor arguments and setter methods are implicit bean sockets. This annotation allow to specify bean sockets in an explicit way. This is typically needed on a constructor or a method in case of ambiguities.

An ambiguity arises when a bean defines more than one constructor which can be removed by annotating the right constructor which is the one that must be used to instantiate the bean and inject required dependencies.

Ambiguities can also arise when some setter methods must not be considered as bean sockets. In that case, all setter methods that must be considered by the compiler must be annotated explicitly. This basically means that if no setter methods is annotated, all setter methods are implicitly considered but if at least one setter method is annotated, then only annotated methods shall be considered and all others ignored.

A bean socket can also be explicitly ignored by setting the enabled() attribute to false in which case the annotated setter method or constructor will be simply ignored by the compiler.

The usage of @BeanSocket is exclusive, if it is specified, only annotated methods or constructors shall be considered. In case of constructor, exactly one constructor must be annotated with enabled() set to true.

Since:
1.0
Author:
Jeremy Kuhn
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Explicitly marks a socket as enabled or disabled.
  • Element Details

    • enabled

      boolean enabled

      Explicitly marks a socket as enabled or disabled.

      A disabled socket will be ignored by the compiler. This is set to true by default.

      Returns:
      true to explicitly enable a socket, false otherwise
      Default:
      true