|
From: Andy D. <an...@ma...> - 2005-06-16 18:29:58
|
This is awesome stuff! How flexible is it? Take a look at this
"afterPropertiesSet()":
-----
public final void afterPropertiesSet() throws Exception
{
if(getViewPrototypeBeanName() == null) {
throw new IllegalArgumentException("viewPrototypeBeanName property must
be set.");
}
if(getBeanFactory() == null) {
throw new IllegalArgumentException("beanFactory property must be set.");
}
if(!getBeanFactory().containsBean(getViewPrototypeBeanName())) {
throw new IllegalArgumentException("There is no bean in the bean factory
with the given name '" + getViewPrototypeBeanName() + "'");
}
if(getBeanFactory().isSingleton(getViewPrototypeBeanName())) {
throw new IllegalArgumentException("View bean '" +
getViewPrototypeBeanName() + "' must be a prototype (singleton=\"false\").");
}
if(!View.class.isAssignableFrom(getBeanFactory().getType(getViewPrototypeBeanName())))
{
throw new IllegalArgumentException("Prototype View bean '" +
getViewPrototypeBeanName() + "' does not implement the View interface.");
}
}
-----
I would love to do away with this method entirely by just annotating the
class.
- Andy
On Thursday 16 June 2005 11:04 am, Seth Ladd wrote:
> On 6/16/05, Heino Magnus <mag...@lm...> wrote:
> > http://opensource.atlassian.com/projects/spring/browse/SPR-1047
> >
> > Good/bad idea? Has someone else done a better implementation thats
> > already integrated that I have missed?
>
> I think it's a great idea. Of course, I'm biased, as I also wrote an
> implementation of this concept.
>
> http://opensource.atlassian.com/projects/spring/browse/SPR-774
>
> Two major differences between 774 and 1047:
>
> My impl uses the attributes facade, so that pre 1.5 installs can use
> this functionality.
>
> It also can handle primitives. That is, it can check if the value of
> a primitive was not set in the bean definition.
>
> My favorite part about this idea is it gets rid of all that code
> inside afterPropertiesSet(), where many beans check if their
> dependencies are set. Each bean shouldn't have to do that, IMHO.
>
> Seth
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=Click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|