Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The CMR is fully Spring annotation enabled as well, but also defines number of beans via the .xml files as well. The current files (stored in src/spring) are:

  • spring-context-global.xml - Global settings, enable the annotation based component scan, deals with properties holder, etc.
  • spring-context-beans.xml - Contains beans that are created via factories or define lookup methods. It is expected that in future this file is removed and defined beans configured via annotations.
  • spring-context-database.xml - Defines database related beans and settings. 
  • spring-context-jetty.xml - Defines the settings for the Jetty web-server that is started on the CMR.
  • spring-context-processors.xml - Contains definitions for all implementations of the AbstractCmrDataProcessor that will be used on the CMR.

...

  • Since we have specific rules how we order and chain processors, we can not let Spring randomly create the processor collection via annotations. If you are writing a new data processor it's definitely a place where it needs to be defined.
  • spring-context-rest.xml - Defines settings for our Rest service

If you are developing a new bean for the CMR in most cases you should go for the annotation definition via @Component or similar.

User Interface

The user interface runs within an OSGI container. This makes the direct use of Spring a bit difficult. Currently the approach for the user interface is to publish the necessary spring beans as osgi service. You can afterwards lookup the bean , since all definition must be made explicitly via XML files. The files are located in the META-INF/spring folder:

  • spring-context-model-main.xml - Considered as the main definition that holds all necessary beans in order to correctly communicate with CMR. Also used in the inspectIT JMeter project, thus add a definition here if it's dependency for that project as well. Don't add any bean that depends on the RCP classes (even if it imports it) here, as this brings us risk of having problems in inspectIT JMeter project (use spring-context-model-other.xml).
  • spring-context-model-storage.xml - Contains storage related beans. 
  • spring-context-model-other.xml - Defines any other beans, especially those that have dependencies on the RCP framework in same case.
  • spring-context-model-osgi.xml - Defines OSGi exposed services.

Note that annotation scanning will not work on the User interface. Any new bean must be registered in the XML definition. Furthermore, if bean has other Spring related dependencies, then setters in the new bean are also required for dependency injection to work.

Note that any spring bean can be publish as OSGi service and can afterwards be used through the InspectIT class.

...

  1. Define the bean (in this example the version service) as a spring bean in context-model-mainin one of the context files
  2. Publish the bean as osgi service in spring-context-model-osgiProvide a setter in the bean that you want to inject the bean into!