开发者

Object creation and initialization sequence using Spring

Background

A system has the following high-level steps:

  1. Main. Create the system entry point (e.g., the ReportBean).
  2. Report Factory. Create a class that hides knowledge of how reports are created. As reports are created using a Report Creator, this class can be considered a report factory factory.
  3. Report Creator. Create a class that can instantiate the appropriate class given a specific report type. Report Creators are tightly coupled to a specific reporting tool implementation.
  4. Controller Factory. Create a class that hides knowledge of how controllers are created. For example, if the software development architecture is Servlets-based, then the factory will create a controller that can read parameters, write to streams using the API, and set the fully qualified directory path in which reports are saved.
  5. Parameters Factory. Create a class that hides knowledge of how parameters are converted from user inputs (provided by the controller, which may or may not be strongly typed) to strongly typed report-specific parameters.
  6. Report. Create a class that can execute a report. The reason why the previous steps are necessary is summarized by the following requirements chain:

    (a) The report requires a report type.

    (b) The report type requires an input parameter.

    (c) The input parameters must be populated by the controller.

    (d) The controller integrates with an application framework.

The sequence diagram resembles:

Object creation and initialization sequence using Spring

Questions

  1. Can Spring be used to implement such a sequence?
  2. If so, 开发者_开发百科what would be involved in configuring Spring to do so?
  3. If not, what container would you use?

Thank you!


Yes spring can do that, this is basic dependency injection. More exactly, you will define dependancies between your services. The exact initialisation order will be the results of theses dependancies.

You can use any valid spring way to do that like annotations or xml configuration file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜