The code example in Section 3.6.2 of the reference manual is wrong:
XmlBeanFactory factory = new XmlBeanFactory(new FileInputStream("beans.xml"));
Properties props = new Properties();
props.load(new FileInputStream("jdbc.properties"));
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(props);
cfg.postProcessBeanFactory(factory);
PropertyPlaceholderConfigurer only have a default constructor, so the
setProperties must be used.
Also, the other day I sent some questions regarding the docs, but nobody
noticed... I'm sending them again, in the hope to have the already good
reference manual being always improved.
-----
I have some observations on some points that should be clarified in the
document:
1.1 - The term "messaging" reminds me of Middleware. It should be replaced
everywhere by text messages, resource bundle or something similar.
3.1 - BeanFactories are thread safe?
3.2.4 - why there are two ways to identify beans, using name/id attributes? When
use one or another?
3.2.5 - A singleton bean is unique per BeanFactory or the entire JVM?
3.3.3 - What happens if the dependency check failed?
If dependency check is on all setter methods must be called?
3.4.2 - It would be good to explain that these are callback methods that will be
called by the BeanFactory and must me implemented by the JavaBeans.
3.4.3 - Typo "The org.springframework.beans.factory.FactoryBean is to be
implemented *BY* objects that are..."
When I have to implement a FactoryBean? Maybe this section should be moved to 3.6
3.5 - Typo "maintaining a registry oof"
3.6 - Is it really so advanced? Its name can scare users and keep them of
reading useful information like PropertyPlaceholderConfigurer.
3.6.2 - In the third box there is a floating "=" in the first line
A few line breaks would make the code look clearer:
XmlBeanFactory factory = new XmlBeanFactory(new FileInputStream("beans.xml"));
Properties props = new Properties();
props.load(new FileInputStream("jdbc.properties"));
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(props);
cfg.postProcessBeanFactory(factory);
And for the above code to work, must I say that the beans are constructed on
demand, even singletons, and not at the instantiation of the factory?
3.7.1 - What if there is no default constructor? And when there are
constructor-args?
7. The so called init-method?
It's not clear exactly when the destruction methods will be called, only when
the vm is shutting down, or it can be done programatically?
3.8.3 - This section should be a subsection of 3.8.2
ref looks up for beans by the id or name attribute?
List elements and Map values can be properties, lists, maps or refs?
There is no support for arrays?
3.9 - Typo "constructor-based depenency injection"
Is it right to say that as a rule of thumb, I should use BeanFactory in a
standalone application, and ApplicationContext in web and ejb applications?
3.10 - It starts to talk about ApplicationContext funcionality but it don't
explain how can I get an instance of it! Where it would come from? A simple
application example would be useful here.
Typo "The ResourceBundleMessageSource is more interesting and is the one we
will provide(s) an example for"
3.10.2- Table 3.4 - Typo "Closed here means that are singletos are destroyed"
In the examples, setters should not be ommitted for brevity, but should be
included for clarity (they are not that long)
General -
What spring jars are available? Whats their dependency?
Formating: the text should not be right justified and should not use
hyphenation, to ease reading.
Authors?
|