开发者

Using Spring IOC when gradual or iterative user input is required?

I have a desktop application I wish to migrate to Spring (3.0.5) which involves "steps" where user decisions are needed before certain objects (or beans) can be instantiated.

Hypothetical example: Suppose the application allows the user to convert mailboxes from a mail-reader program.

  1. User picks a directory,
  2. Application analyzes a meta-data file in directory
  3. User picks a file from a provided selection of valid "mailbox" files
  4. Application analyzes source file details to determine appropriate default output settings
  5. User customized destination directory and output settings
  6. Application does conversion and saving

From what I can tell it seems there are a few options for ways to handle this in Spring:

  1. Create a set of nested (parent/child) ApplicationContext objects as the necessary pieces of information arrive.
  2. Create some "data holding" beans, and rely on simply not calling certain code-paths while they might be "empty". Ex: If I have a WriteToFile bean which needs a File destination chosen by the user, re-factor it to instead require a FileHolder which is interrogated whenever WriteToFile.go() is called.
  3. Use some combination of lazy-init, scope="prototype开发者_高级运维", and MethodInvokingFactoryBean so that "later" beans are lazily-initialized only when the source information (on other beans) is available.

Do any of those seem better than the others? Am I missing an option?

Right now #3 with perhaps a little bit of #1 sounds preferable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜