|
From: Seth L. <set...@gm...> - 2005-06-16 18:55:47
|
On 6/16/05, Andy Depue <an...@ma...> wrote:
> This is awesome stuff! How flexible is it? Take a look at this
> "afterPropertiesSet()":
Well, it's only written to check that a property has been set. And
'set' is defined as:
- if property is an object, make sure it's not null
- if property is a primitive, make sure it's value isn't either the
default unset value, or the specified unset value
Your checks to see if something is a prototype aren't handled by this
code. But, it could easily be handled with something like
@@RequiredDependency(singleton=3D"false")
Which would have the semantics you want here. Of course, this would
be an optional check. That is, omitting it would not check that
singleton =3D true.
Seth
>=20
> -----
> public final void afterPropertiesSet() throws Exception
> {
> if(getViewPrototypeBeanName() =3D=3D null) {
> throw new IllegalArgumentException("viewPrototypeBeanName property =
must
> be set.");
> }
> if(getBeanFactory() =3D=3D null) {
> throw new IllegalArgumentException("beanFactory property must be se=
t.");
> }
> if(!getBeanFactory().containsBean(getViewPrototypeBeanName())) {
> throw new IllegalArgumentException("There is no bean in the bean fa=
ctory
> with the given name '" + getViewPrototypeBeanName() + "'");
> }
> if(getBeanFactory().isSingleton(getViewPrototypeBeanName())) {
> throw new IllegalArgumentException("View bean '" +
> getViewPrototypeBeanName() + "' must be a prototype (singleton=3D\"false\=
").");
> }
> if(!View.class.isAssignableFrom(getBeanFactory().getType(getViewProto=
typeBeanName())))
> {
> throw new IllegalArgumentException("Prototype View bean '" +
> getViewPrototypeBeanName() + "' does not implement the View interface.");
> }
> }
> -----
>=20
> I would love to do away with this method entirely by just annotating the
> class.
>=20
> - Andy
>
|