currently I'm doing some XML bindung stuff with jakarta commons digester. If you haven't heard of it maybe you know XStream. The point is "digesting" my XML bindings consumes a lot of small prototype objects (e.g. author, adress...).
I wanted to get these prototype objects via spring but I couldn't because my digester instance has no relation to the framework after it gets constructed. After a while I found the topic "lookup-method injection" describing exactly my problem.
Proposed solutions:
Solution1: Make your class aware of Spring
Solution2: bytcode wizardry behinde the scenes + lookup hooks in your code
Why can't I simply use prototype objects that know how to reproduce protoypes of them self?
"principle of least astonishment"?
I inject Author prototype into xml digester. Every time the digester calls aAuthor.newAuthor() it acquires a new fresh prototyped author object. I`m not sure about this approach. Of couse, it doesn`t scale to heavyweight objectgraphs but in such case you shouldn't use prototyping anyway! right?Code:class Author { public Author() {} public Author newAuthor() { return new Author(); } .... }
Mo


Reply With Quote