Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Using ActiveObjects inAtlassian PluginsWe don’t like databases either.Ben SpeakmonDeveloper Relations, Atlassian          ...
Agenda• What is ActiveObjects?• Example• Using it in your plugins• Resources                             3
What is ActiveObjects?• Implements the Active Record pattern• Models an object (entity) as a database table: • Object clas...
Entity objectsimport net.java.ao.Entity;   // adds getID() for primary keypublic interface Page extends Entity {  String g...
ActiveObjects EntityManagerimport com.atlassian.activeobjects.external.ActiveObjects asao;// create an active objectPage p...
More interesting things// count all pagesint totalPages = ao.count(Page.class);// find and retrieve all pages as objectsPa...
“   But Im losing my edge to better-looking people    with better ideas and more talent.                                  ...
ActiveObjects details• Open source project on java.net• Packaged as plugin for Atlassian products • ActiveObjects services...
Ego: Integration withAtlassian products• Uses the same DB the product uses; no additional  configuration• Transparent back...
ActiveObjects in your plugin<component-import key="ao" name="Active Objects service"interface="com.atlassian.activeobjects...
ActiveObjects in your plugin<dependency>  <groupId>com.atlassian.activeobjects</groupId>  <artifactId>activeobjects-plugin...
Wrap-up• In-depth tutorial:  atlss.in/AOGettingStarted• Documentation:  atlss.in/AODocumentation• Plugin SDK:  atlss.in/Pl...
Using ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian Plugins
Upcoming SlideShare
Loading in …5
×

Using ActiveObjects in Atlassian Plugins

4,811 views

Published on

Published in: Technology
  • Be the first to comment

Using ActiveObjects in Atlassian Plugins

  1. 1. Using ActiveObjects inAtlassian PluginsWe don’t like databases either.Ben SpeakmonDeveloper Relations, Atlassian 2
  2. 2. Agenda• What is ActiveObjects?• Example• Using it in your plugins• Resources 3
  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. 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. 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. 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. 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. 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. 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. 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. 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. 12. Wrap-up• In-depth tutorial: atlss.in/AOGettingStarted• Documentation: atlss.in/AODocumentation• Plugin SDK: atlss.in/PluginSDK 13

×