Dan,
Indeed, I believe we are arriving at a nice common ground. Thank you for the
clarifications. I'm glad that you are accepting of our stance and see this as a very
positive discussion. I have just a few more points to add...
On Dec 19, 2009, at 8:25 AM, Dan Allen wrote:
What I would really like to see is us figuring out the most possible common ground between
CDI and Spring when showing examples that are alternative to the JSF managed bean
facility.
Absolutely. I think if the goal is to demonstrate a common ground solution, then a
@javax.annotation.ManagedBean with @javax.inject.Inject is the way to go. If the
presentation or demonstration has either a more Java EE-centric theme or a more
Spring-centric theme, then naturally the recommendation can swing to the respective side.
Perhaps one of the first things we should do is update the "Get Started" on
www.javaserverfaces.org<http://www.javaserverfaces.org> to show both options. This
would require both a Weld archetype (which I think you've been working on?) and one
for Spring 3 (I could work on providing one).
Agreed, in this particular example, I would not recommend this approach. What about
@ViewScoped though? That's one of the more useful pieces of JSF 2 in my opinion. I
don't believe there is an out-of-the-box CDI-equivalent, right? I would assume
it's not hard to implement a custom @ViewScoped that CDI would recognize?
There isn't a CDI equivalent of @ViewScoped in the CDI spec, but Weld/Seam will be
providing a portable extension, hopefully getting weaved back into a revision of the spec.
We shouldn't have to revert to @javax.faces.ManagedBean just to get this feature.
Right, and we can provide a similar extension in Spring, but I'm wondering if we can
find some sort of shared approach...
Then we're back to the problem of the scopes. We of course support various scope
annotations in Spring, and support something equivalent to your above example, but
don't specifically support the CDI scope annotations. What really has me a bit
confused is why the CDI scopes don't use @Scope from JSR-330 and instead use the
JSR-299-specific @NormalScope. The JSF scopes don't either, for that matter, but I
assume that's because 330 was finalized well after. See, this is what I mean by it
being a bit of a mess. We've got some JSF-specific scopes, we've got CDI-specific
scopes, we've got Spring-specific scopes, etc. Spring can and will ultimately support
the equivalent of all of the useful ones (including @ConversationScoped in the near
future...I really wish we could have just relied on JSF or CDI for that), but it sadly
seems like we ended up with more fragmentation rather than less.
I'll admit that I don't know the story behind the choice to not align the scope
annotations. And already we are hearing from developers that having the javax.faces.*
stuff in there is adding to the confusion. That's why, to start, we need to get that
stuff deprecated. Then, I think, we should figure out how to get the number of duplicate
scopes down to one. I encourage you guys to pursue this goal over on the JSR-299 EG. The
only way this is going to get resolved is if communication happens. We can't really
solve that problem here.
To be fair, we aren't yet providing any out-of-the-box implementations of
JSR-330's @Scope other than the @Singleton that is required by by the spec. Maybe
this is an opportunity for further collaboration, outside of the scope of the EG. It
would be really cool if we could establish a single common and complete set of scope
annotations as portable extensions usable in both Seam and Spring...I'm not entirely
certain yet how technically feasible this would be...just something to think about.
So in the above example, we at least have @Named and @Inject as commonly supported things.
I really wish there were one common, complete and portable set of scope annotations we
could support in Spring, but there isn't.
The one consolation is that the semantics are exactly the same. A scope is a scope and
it's defined on the bean class. So we have to fudge this around for now, but again, as
long as we are staying away from @javax.faces we are heading in the right direction.
+1
But as the collective EG whose goal is to see as much adoption as possible of JSF 2, and
given the corporate realities of how soon most people are going to be using an EE 6
container, I don't see how we can be asked to promote it as *the* choice of the EG.
This has been a great discussion. I think what we can agree on is what we don't
recommend, the JSF managed bean container. What we can both get behind is a common set of
annotations to hook into stronger bean containers such platform managed beans + CDI or
platform managed bean annotations with Spring. @javax.annotation.ManagedBean +
@javax.inject.Inject and do what you can to find a common ground for scopes ;)
+1
I'm glad that we can communicate with friendly exchanges and I always look forward to
getting your perspective. Frankly, I think that's what defines this EG, as Andy so
elegantly pointed out in his blog.
Indeed, it is quite refreshing to be able to have such discussions without things
degenerating into TSS-style bickering. As can seen by taking a look at some of the
arguments on the JSR-330 list, for example, EG's are not by rule free of such
nonsense. I am thankful for your open-ness and for Ed and everyone else's roles in
fostering such an environment, and look forward to seeing it continue.
Cheers,
Jeremy