Spring Integration: Difference between revisions

From Obsidian Scheduler
Jump to navigationJump to search
No edit summary
Line 5: Line 5:
As of Obsidian 2.2.0, Obsidian has greatly improved the integration with your Spring dependency injection container. Obsidian does not include any Spring libraries and will defer to the version and libraries you include with your application. It supports versions of Spring from 2.5 onward.  
As of Obsidian 2.2.0, Obsidian has greatly improved the integration with your Spring dependency injection container. Obsidian does not include any Spring libraries and will defer to the version and libraries you include with your application. It supports versions of Spring from 2.5 onward.  


Obsidian uses the <code>@Component</code> and any Spring or custom extensions of those annotations as a basis for knowing which job implementations (either SchedulableJob implementations or Obsidian Annotation jobs) should be retrieved from the Spring context. Even if you are not using Spring annotations to wire your classes, you will need to add the annotation to your job classes to serve as a [http://en.wikipedia.org/wiki/Marker_interface_pattern Marker] to Obsidian.
Obsidian uses the <code>@Component</code> and any Spring or custom extensions of those annotations (such as <code>@Service</code> and <code>@Repository</code>) as a basis for knowing which job implementations should be retrieved from the Spring context. These job classes can be either <code>SchedulableJob</code> implementations or annotated jobs. Even if you are not using Spring annotations to wire your classes, you will need to add the annotation to your job classes to serve as a [http://en.wikipedia.org/wiki/Marker_interface_pattern Marker] to Obsidian.
 
'''Note:''' If you have multiple beans wired for the same class, you must specify the bean name in the applicable Spring annotation.


You will also need to ensure Obsidian's [http://docs.spring.io/spring/docs/2.5.6/api/org/springframework/context/ApplicationContextAware.html ApplicationContextAware] implementation is known to Spring.  If you are using Spring's scanning, you can use the following approach to add an additional package to your configuration:
You will also need to ensure Obsidian's [http://docs.spring.io/spring/docs/2.5.6/api/org/springframework/context/ApplicationContextAware.html ApplicationContextAware] implementation is known to Spring.  If you are using Spring's scanning, you can use the following approach to add an additional package to your configuration:

Revision as of 01:45, 19 October 2013

Though Obsidian works great on its own, Obsidian also supports seamless integration with Spring. This page outlines how to set up Spring integration and execute jobs which are configured as Spring components.

Dependency Injection via Spring

As of Obsidian 2.2.0, Obsidian has greatly improved the integration with your Spring dependency injection container. Obsidian does not include any Spring libraries and will defer to the version and libraries you include with your application. It supports versions of Spring from 2.5 onward.

Obsidian uses the @Component and any Spring or custom extensions of those annotations (such as @Service and @Repository) as a basis for knowing which job implementations should be retrieved from the Spring context. These job classes can be either SchedulableJob implementations or annotated jobs. Even if you are not using Spring annotations to wire your classes, you will need to add the annotation to your job classes to serve as a Marker to Obsidian.

Note: If you have multiple beans wired for the same class, you must specify the bean name in the applicable Spring annotation.

You will also need to ensure Obsidian's ApplicationContextAware implementation is known to Spring. If you are using Spring's scanning, you can use the following approach to add an additional package to your configuration:

<context:component-scan base-package="com.my.package.scan.base, com.carfey.ops.job.di"/>

Another option is to extend our com.carfey.ops.job.di.SpringContextAware class with a do nothing extension class in one of your currently scanned packages.

If you are not using scanning, simply ensure you wire in our com.carfey.ops.job.di.SpringContextAware class.

If you have multiple instances of a given bean type in your Spring context, please ensure you use the value="" when you annotate your job with @Component or its specializations as this is how Obsidian will uniquely identify the job within the Spring context.