In this blog post I’m going to show you how easy it is to get started with ActiveObjects. This is by no means a fully detailed step by step guide on how to develop plugins with ActiveObjects, but I hope it helps understand the main steps to take to get there.

The sample code in this blog post is taken from the getting started guide that goes in much more details about developing your ActiveObjects capable plugins.

The obvious first step is to get a working plugin project. If you don’t have a plugin you can work with and don’t know how to create such a project I suggest you have a look at our documentation.

Then as we will be working with the new ActiveObjects module, we need to add the following maven dependency to your plugin:

<dependency>
<groupId>com.atlassian.activeobjects</groupId>
<artifactId>activeobjects-plugin</artifactId>
<version>0.9.6</version>
<scope>provided</scope>
</dependency>

ActiveObjects is not yet bundled in the products and is only compatible with Jira and Confluence at this time of writing. We are working on extending this support.
In the meantime with a bit of configuration you can easily get it working with the Atlassian Plugin SDK. Here is the kind of configuration that’s required in your pom.xml for Jira:

...
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>3.3</version>
<extensions>true</extensions>
<configuration>
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.activeobjects</groupId>
<artifactId>activeobjects-plugin</artifactId>
<version>0.9.6</version>
</pluginArtifact>
<pluginArtifact>
<groupId>com.atlassian.activeobjects</groupId>
<artifactId>activeobjects-jira-spi</artifactId>
<version>0.9.6</version>
</pluginArtifact>
</pluginArtifacts>
<productVersion>4.3</productVersion>
</configuration>
</plugin>
...

The configuration is very similar for Confluence. You can find more details about this configuration in the getting started guide.

Now that our project is correctly configured we can start using ActiveObjects within our plugin. Let’s add an ao module and import the ActiveObjects service within your atlassian-plugin.xml:

<ao key="ao-module">
<description>The configuration of the Active Objects service</description>
<entity>com.atlassian.todo.Todo</entity>
</ao>
<component-import key="ao" name="Active Objects components"
interface="com.atlassian.activeobjects.external.ActiveObjects">
<description>Access to the Active Objects service</description>
</component-import>

The next step is to write your entity, let’s have a look at the code for the Todo entity referenced above:

public interface Todo extends Entity
{
String getDescription();
void setDescription(String description);
boolean isComplete();
void setComplete(boolean complete);
}

That’s all it takes. From here on you can easily create, retrieve and delete todo items within your plugin code as shown in the sample below:

Creating a Todo:

Todo todo = ao.create(Todo.class);
todo.setDescription(description);
todo.setComplete(complete);
todo.save();

Getting a Todo:

Todo todo = ao.get(Todo.class, id);

Deleting a Todo:

ao.delete(todo);

This couldn’t be simpler. You don’t need to configure any database nor create tables, all of this is taken care of for you by the ActiveObjects plugin.

I strongly suggest you have a look at the getting started guide on the project’s wiki to find out more about the plugin.

If you have any question please comment on the blog post or contact us directly. We’ll be happy to listen to your feedback and help you get your plugin working.

And of course don’t forget to submit your plugin into the codegeist competition.

Fresh ideas, announcements, and inspiration for your team, delivered weekly.

Subscribe now