Crucible 2.0 : The Crucible API
This page last changed on Jun 23, 2009 by edawson.
This page covers the Crucible API and how you can use service interfaces that are exposed to plugins. On this page: ServicesCrucible 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. OverviewThe 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 PluginThe 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 SpringIf 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> |
![]() |
Document generated by Confluence on Jul 09, 2009 19:51 |