![]() | The content on this page is deprecated. Please see the separate documentation space for developer reference material about FishEye and Crucible. |
This page covers the Crucible API and how you can use service interfaces that are exposed to plugins.
On this page:
Services
Crucible exposes a set of service interfaces to plugins. The parameters and return types of the methods on these interfaces are 'plain old Java objects'. Having an API specifically designed to be used by plugins protects plugins from internal changes in Crucible's implementation, and presents plugins with a simpler API.
Overview
The service interfaces are in the package com.atlassian.crucible.spi.services
.
The types the use as parameters are in the package com.atlassian.crucible.spi.data
.
Refer to the Crucible API javadoc for details of the services.
Using a Service in your Plugin
The services are all available in your plugin's Spring context.
We can inject a spring bean using constructor injection, e.g.:
public class ExampleServlet extends HttpServlet { private ProjectService projectService; @Autowired public ExampleServlet(ProjectService projectService) { this.projectService = projectService; } ... }
You can also use setter injection on your plugin class:
public void setReviewService(ReviewService reviewService) { this.reviewService = reviewService; }
Note that you cannot mix constructor and setter injection in the same class – if you mark a constructor with @Autowired
, no setters will be used for injection.
All plugin module classes which are created by the plugin system are injected by Spring. That is, the HttpServlet
subclass of a servlet plugin module, the SCMModule
implementation of a Light SCM plugin module and the EventListener
implementation of an event listener plugin module.
Maven dependencies for Spring
If you are using Spring annotations in your plugin you will need the following dependencies in your pom.xml
:
<dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> </dependencies>