On 24.05.11 21:46 Pete Muir wrote:
On 24 May 2011, at 20:42, Mark Struberg wrote:
> Imo it is surprising, since it would break all kinds of 'business
>injections' (as opposed to classic 'resource injections' - Jens Schumann
>can explain this well ;)
Can you make him explain it for our edification?
Haha Mark;)
Just a brief answer - since I crossed the critical wake period already...
What I call 'business injection' (the German term 'fachliche injection'
is
more precise) shouldn't be any news to you guys. I keep telling my
audience that CDI helps me to go beyond classic infrastructure injection
towards a more domain / business oriented approach. Instead of injecting
data sources, services or DAO's I am able to inject the current user, a
selected item or a newly created customer - across application layers.
This - in combination with "business driven" event handling [1] - is what
I
love about CDI;)
On 24.05.11 21:24 Pete Muir wrote:
> Thus if you would require all contextual instances being created
>immediately, then you would get a ContextNotActiveException...
Yes, but this isn't that surprising and the principle of least surprise
is a good one to follow ;-)
As Mark said before: Think about the current authenticated user that
should be available to infrastructure code. Enforcing all contextual
instances being created immediately would kill that feature - as far I
understand.
Hope that helps,
Jens
[1] sendWelcomeEmail(@Observes @Created Customer newCustomer)