Results 1 to 4 of 4

Thread: ApplicationContext: initializing with a list of files

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    Bonn/Germany
    Posts
    10

    Default ApplicationContext: initializing with a list of files

    Hello out there!

    I've asked this before on the SourceForge list, but it seems to be pretty much dead. I'm completely new to Spring so I may be getting at this from an entirely wrong angle. Here's my app scenario. I'm keeping several XML files in WEB-INF/data. At startup, those files should each be digested into object hierarchies and registered with a manager objects.

    I see more or less how I could define, in applicationContext.xml, a bean for each of the hierarchies that gets initialized through a factory method. Then I could set a property of the manager bean with the list of the hierarchy beans.

    What I don't like about this, is that I'd have to explicitly, repetitively, and errorpronely define all the beans. I'd rather like to
    have a declarative way to achieve my goal. Inspired by Ant it could
    something like this

    Code:
    <bean id='manager'
     class='....myapp.Manager'>
      <call-method name='register'>
        <mapper name='digest' class='....myapp.MyDigester'/>
        <fileset dir='.../WEB-INF/data'>
          <include name='*.xml'/>
        </fileset>
      </call-method>
    </bean>

    This is supposed to mean that
    • * register is a method taking a single argument
      * the arguments for repetitive calls are taken from a fileset
      * before the argument objects are passed to register, they are transmogrified into appropriate object hierarchies by a call to the (static) method digest.


    Of course, this is all very ad hoc and probably doesn't generalize well. I'm grateful for any suggestion.

    Michael

  2. #2
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    Hmmmm. I like it. But, I'm an Ant fanatic.

    I would add the ability to reference bean settings. That is, singletonness, lazy-load and all that are named attribute sets. Also, I would add that in the config file, the list of POJOs to beanify are also in a ref.

    The main problem with all this of course is that this is just for simple beans that have very little DI required. Which is the whole point of IoC, IMHO. And that is where the human comes into the picture, but some of the ant stuff is very applicable. Ooops, forgot about the autowire stuff. Autowire could be used here.

    I had the idea to have an ant task that could generate even the whole config file. Just point it at a package, use a regex filter, and some reflective capability, and it will 'investigate' a package to see what could be done (we don't want to create beans from interfaces, etc). Probably only good for initial creation of stuff or prototyping.

    But, an IDE that did this with suitable wizards would be cool. Like Drag and drop classes into a context definition. I never tried it with the current spring eclipse plug-in, maybe it does this.

  3. #3
    Join Date
    Aug 2004
    Location
    Burgas, Bulgaria
    Posts
    37

    Default

    Have you tried the XDoclet plugin at
    XDoclet for this kind of thing?

  4. #4
    Join Date
    Sep 2004
    Location
    Bonn/Germany
    Posts
    10

    Default

    Quote Originally Posted by khote
    Have you tried the XDoclet plugin at
    XDoclet for this kind of thing?
    I have had a look at it and I must admit that I don't understand what it does. I've been learning about J2EE development for a few weeks right now, and so far I haven't looked into XDoclet at all.

    What I do know, though, is that XDoclet works at compile-time. I'm looking for something that works at runtime.

    Michael

Similar Threads

  1. Replies: 2
    Last Post: Sep 1st, 2009, 09:24 AM
  2. Glazed lists
    By adepue in forum Swing
    Replies: 14
    Last Post: Aug 2nd, 2006, 07:13 AM
  3. Replies: 2
    Last Post: Jul 29th, 2005, 11:52 AM
  4. Odd behaviour when injecting TransactionTemplate
    By damon311 in forum Container
    Replies: 3
    Last Post: Jul 23rd, 2005, 11:21 AM
  5. initializing a bean with a list properties
    By masrawi in forum Container
    Replies: 3
    Last Post: Jul 8th, 2005, 08:37 AM

Posting Permissions

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