Hi David,
I can live without loose coupling in most cases. I would allow both. It is then the developers decision, whether he needs loose coupling or not.
In all my projects, I would go with direct class dependencies...
thanks!,
adam
On 09.11.2011, at 16:42, David Blevins wrote:
>
> On Nov 8, 2011, at 6:05 PM, Marina Vatkina wrote:
>
>> @DependsOn defines the order in addition to the dependency. Annotation on the @EJB doesn't allow that. Also, you might want to depend on a bean and do not need to inject it...
>
> Right, as mentioned the traditional @DependsOn at the class level covers the non-injection case.
>
> For the injection case I don't see the issue. The ordering isn't strict to the point were something like this is illegal:
>
> @Singleton
> @DependsOn({"red", "green"})
> public class CircleBean {
> }
>
> @Singleton
> @DependsOn({"green", "red"})
> public class SquareBean {
> }
>
> Here the start order is red or green followed by circle or square.
>
> If they were to add this:
>
> @Singleton(name="red")
> @DependsOn({"green"})
> public class RedBean {
> }
>
> The start order would be green, red then circle or square.
>
> Ultimately @DependsOn only states "start these things before me". If that requirement can't be met, there's a circular dependency and the app isn't valid. In all other cases, the app is startable and the ultimate order is whatever path the container was able to work out that satisfies "start these things before me" for all objects in the graph.
>
> So given that the list of each @DependsOn doesn't dictate order in a strict sense, specifying the @DependsOn on the @EJB injection point itself (should there be one) and not implying this other ordering is in some way more honest.
>
> Then we gain the ability to not have to specify the bean name, which is what I suspect Adam is really getting at.
>
> I can see the desirability in that as you may not have wanted to specify the bean name in the @EJB injection point at all, so having to specify it in the @DependsOn can ultimately ruin whatever loose coupling you might have been going for. In the case where you did specify the name in the @EJB injection point, having to specify it again in the @DependsOn is somewhat annoying.
>
>
> -David
>