You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by David Blevins <da...@gmail.com> on 2011/07/14 04:51:19 UTC

Thought: Lazily create @New bean defs

Kind of a random thought.  Not sure if it's even possible, but....

There's nothing particularly fancy about @New beans.  Perhaps we don't need to be eagerly creating these things.  Resolving references involves a lot of list iteration for us and the eager creation of @New bean definitions bloats our lists by more or less double.  Meanwhile I'm not sure how popular they really are.

Couldn't we create these NewManagedBean defs on demand when someone actually asks for an @New bean reference?  So we don't have to always iterate over them and add them to the list of potentially matching beans only to then filter them out and return the non-@New bean.

I know that with some recent changes in EJB-type things the EJB implementation itself is typically creating @New bean definitions.  Seems a little factory method somewhere in the EJB plugin API could do the trick.  Something like:

   NewBean<T> getNewBean(BaseEjbBean<T> bean);
or 
   NewBean<T> getNewBean(Bean<T> bean);

We could cache them after first call, but I can't imagine that creating a NewBean copy of a bean is very expensive.

Don't have time to work on it :)  But I thought I'd throw it out there for feedback in case someone thinks it's a good idea and wants to take a swing at it.


-David