Your SlideShare is downloading. ×
  • Like
Using ActiveObjects in Atlassian Plugins
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Using ActiveObjects in Atlassian Plugins

  • 3,114 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
3,114
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
13
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. Using ActiveObjects inAtlassian PluginsWe don’t like databases either.Ben SpeakmonDeveloper Relations, Atlassian 2
  • 2. Agenda• What is ActiveObjects?• Example• Using it in your plugins• Resources 3
  • 3. What is ActiveObjects?• Implements the Active Record pattern• Models an object (entity) as a database table: • Object class name is the table name • Object field names are column names • Any single object instance is one row• Exposes state methods -- persist object changes to database 4
  • 4. Entity objectsimport net.java.ao.Entity; // adds getID() for primary keypublic interface Page extends Entity { String getTitle(); void setTitle(String title); ContentWrapper getBody(); void setBody(ContentWrapper content);} 5
  • 5. ActiveObjects EntityManagerimport com.atlassian.activeobjects.external.ActiveObjects asao;// create an active objectPage page = ao.create(Page.class);// retrieve an object from the DB by primary keyPage dbPage = ao.get(Page.class, 843);// update the objectpage.setTitle(“new title”);// save the object, persisting properties to DBpage.save();// make it go away 6ao.delete(page);
  • 6. More interesting things// count all pagesint totalPages = ao.count(Page.class);// find and retrieve all pages as objectsPage[] allPages = ao.find(Page.class);// find pages based on titlePage[] filteredPages = ao.find(Page.class, Query.select().where(“title ~ ?”, “Documentation”));// migrate DB schema based on updated objectTask dbMigrationTask = new PluginUpgradeTask() { ao.migrate(Page.class, BlogPost.class, Issue.class);} 7
  • 7. “ But Im losing my edge to better-looking people with better ideas and more talent. ” And theyre actually really, really nice. LCD Soundsystem, articulating our #1 fear 8
  • 8. ActiveObjects details• Open source project on java.net• Packaged as plugin for Atlassian products • ActiveObjects services imported as components• Currently supports JIRA and Confluence • Bundled in JIRA 4.4, Confluence 4.0 9
  • 9. Ego: Integration withAtlassian products• Uses the same DB the product uses; no additional configuration• Transparent backup/restore • Tables are backed up/restored by same process as rest of product• Each plugin client has a private table “space” • Plugins can’t share tables; use components instead 10
  • 10. ActiveObjects in your plugin<component-import key="ao" name="Active Objects service"interface="com.atlassian.activeobjects.external.ActiveObjects">  <description>Component to access Active Objectsfunctionality from the plugin</description></component-import><ao key="ao-module">  <description>The module configuring the Active Objectsservice used by this plugin</description>  <entity>com.atlassian.summit.Page</entity></ao> 11
  • 11. ActiveObjects in your plugin<dependency>  <groupId>com.atlassian.activeobjects</groupId>  <artifactId>activeobjects-plugin</artifactId>  <version>0.9.7</version>  <scope>provided</scope></dependency> 12
  • 12. Wrap-up• In-depth tutorial: atlss.in/AOGettingStarted• Documentation: atlss.in/AODocumentation• Plugin SDK: atlss.in/PluginSDK 13