The Spring Framework is used extensively in all inspectIT components. Currently we still have some differences between the components. This page tries to document the different ways we use Spring
Commons / CommonsCS
Both projects are Spring-enabled. Although they both do not start a Spring context, one can assume that all services are used from a spring container. Thus you can use Spring annotation like @Autowired to mark fields to be injected by Spring.
Agent
The agent is fully Spring annotation enabled. Spring beans do not have to be configured in any configuration file, but with common Spring annotations (like @Service)
CMR
The CMR is fully Spring annotation enabled. Spring bean should be defined in the spring context. No requirement to have a setter for injection.
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 through the InspectIT class.
VersionService versionService = InspectIT.getService(VersionService.class)
Please note that in order for the injection to work you need to:
- Define the bean (in this example the version service) as a spring bean in context-model-main
- Publish the bean as osgi service in spring-context-model-osgi
- Provide a setter in the bean that you want to inject the bean into!