Results 1 to 2 of 2

Thread: method lookup

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Posts
    21

    Default method lookup

    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"?

    Code:
    class Author {
      public Author() {}
    
      public Author newAuthor() {
        return new Author();
      }
      ....
    }
    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?

    Mo

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default Re: method lookup

    Quote Originally Posted by moo
    Why can't I simply use prototype objects that know how to reproduce protoypes of them self?
    "principle of least astonishment"?

    Code:
    class Author {
      public Author() {}
    
      public Author newAuthor() {
        return new Author();
      }
      ....
    }
    Is the digester a class you wrote yourself?
    In that case: why don't you just configure the "prototype" instances for your digester with spring and use clone() for retrieving new instances from within your digester? (If you do not want to implement Cloneable, you can alternatively use serialization for creating copies)

    BTW: I would find it astonishing to have an instance (non-static) method for creating a new instance.

    Regards,
    Andreas

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. PerformanceMonitorInterceptor
    By tnist in forum AOP
    Replies: 3
    Last Post: Aug 24th, 2005, 01:39 PM
  5. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •