|
From: Rob H. <ro...@ca...> - 2004-07-31 11:46:14
|
Reading through the 1.1 docs it says that a parent bean can never be accessed directly in an app either through <ref> or getBean() yet I was able to do both. Is this an error in the doc or the code? Rob |
|
From: Colin S. <col...@ex...> - 2004-07-31 12:58:02
|
Rob Harrop wrote: > Reading through the 1.1 docs it says that a parent bean can never > be accessed directly in an app either through <ref> or getBean() yet I > was able to do both. Is this an error in the doc or the code? > > Rob This is prefaced with the text 'In the case that the parent definition does not specify a class' before the sample... If it has a class, it's usable as its own bean, and in fact you need to make it lazy-init=true or singleton=true to stop the factory from pre-instantiating it. I need to update the docs to specifically mention that. Colin |
|
From: Colin S. <col...@ex...> - 2004-07-31 12:58:57
|
Colin Sampaleanu wrote: > Rob Harrop wrote: > >> Reading through the 1.1 docs it says that a parent bean can never >> be accessed directly in an app either through <ref> or getBean() yet >> I was able to do both. Is this an error in the doc or the code? >> >> Rob > > > This is prefaced with the text 'In the case that the parent definition > does not specify a class' before the sample... > > If it has a class, it's usable as its own bean, and in fact you need > to make it lazy-init=true or singleton=true to stop the factory from > pre-instantiating it. I need to update the docs to specifically > mention that. We could consider an 'abstract' attribute actually, to stop a bean from ever being instantiated... Colin |
|
From: Colin S. <col...@ex...> - 2004-07-31 14:26:01
|
Colin Sampaleanu wrote: > Colin Sampaleanu wrote: > >> Rob Harrop wrote: >> >>> Reading through the 1.1 docs it says that a parent bean can never >>> be accessed directly in an app either through <ref> or getBean() yet >>> I was able to do both. Is this an error in the doc or the code? >>> >>> Rob >> >> >> >> This is prefaced with the text 'In the case that the parent >> definition does not specify a class' before the sample... >> >> If it has a class, it's usable as its own bean, and in fact you need >> to make it lazy-init=true or singleton=true to stop the factory from >> pre-instantiating it. I need to update the docs to specifically >> mention that. > > > We could consider an 'abstract' attribute actually, to stop a bean > from ever being instantiated... I've clarified the text a bit in the manual: """ In the case that the parent definition does not specify a class: ... a sample here with no class set the parent bean can not get instantiated on its own; it's just a pure template or abstract bean definition that serves as parent definition for children. Trying to use such parent beans on it's own (by referring to it as a ref property of another bean, or doing an explicit getBean() call with the parent bean id, will result in an error. Similarly, the container's internal /preInstantiateSingletons/ method will completely ignore bean definitions which don't have either a parent or class attribute set, since they are not complete. /Important Note/: there is no way to explicitly declare a bean definition as abstract. As described above, if the definition does not have a class specified, then it is effectively be considered abstract, will not be pre-instantiated, and can not be instantiated at all (by the user). If the bean does have a class definition, then it can be instantiated. As well, XmlBeanFactory will by default pre-instantiate all singletons; so it is important that if you have a (parent) bean definition to be used only as a template, which specifies its class, and do not want the container to pre-instantiate it, you must make sure to set the /lazy-init/ attribute to /true/. """ Colin |
|
From: Rob H. <ro...@ca...> - 2004-07-31 14:36:07
|
I think that would be a good idea, be a bit more explicit. Colin Sampaleanu wrote: > Colin Sampaleanu wrote: > >> Rob Harrop wrote: >> >>> Reading through the 1.1 docs it says that a parent bean can never >>> be accessed directly in an app either through <ref> or getBean() yet >>> I was able to do both. Is this an error in the doc or the code? >>> >>> Rob >> >> >> >> This is prefaced with the text 'In the case that the parent >> definition does not specify a class' before the sample... >> >> If it has a class, it's usable as its own bean, and in fact you need >> to make it lazy-init=true or singleton=true to stop the factory from >> pre-instantiating it. I need to update the docs to specifically >> mention that. > > > We could consider an 'abstract' attribute actually, to stop a bean > from ever being instantiated... > > Colin > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Rob H. <ro...@ca...> - 2004-07-31 14:35:36
|
Damn, I should read more carefully. Colin Sampaleanu wrote: > Rob Harrop wrote: > >> Reading through the 1.1 docs it says that a parent bean can never >> be accessed directly in an app either through <ref> or getBean() yet >> I was able to do both. Is this an error in the doc or the code? >> >> Rob > > > This is prefaced with the text 'In the case that the parent definition > does not specify a class' before the sample... > > If it has a class, it's usable as its own bean, and in fact you need > to make it lazy-init=true or singleton=true to stop the factory from > pre-instantiating it. I need to update the docs to specifically > mention that. > > Colin > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Barry K. <gr...@me...> - 2004-07-31 20:47:53
|
> > If it has a class, it's usable as its own bean, and in fact you need to > make it lazy-init=true or singleton=true to stop the factory from Did you mean singleton="false" ?? |
|
From: Colin S. <col...@ex...> - 2004-08-01 03:28:31
|
Barry Kaplan wrote: >> >> If it has a class, it's usable as its own bean, and in fact you need >> to make it lazy-init=true or singleton=true to stop the factory from > > > Did you mean singleton="false" ?? Yes, sorry... |