Dashboard > BobsGear Main Space > ... > Confluence Plugin Development Diary > Confluence Development Environment Setup > Survey of Bundled Plugin Functionality > First Try At Making New Plugin From Amazon - Amazonmy
First Try At Making New Plugin From Amazon - Amazonmy
Added by Garnet R. Chaney, last edited by Garnet R. Chaney on May 01, 2007  (view change)
Labels: 
(None)


Copy plugins\amazon to plugins\amazonmy

Edit amazonmy\src\etc\atlassian-plugin.xml

  • change key to confluence.extra.amazonmy
  • For <macro> change name to asinmy, and key to asinmy, class extra.amazon to extra.amazonmy

rename plugins\amazonmy\src\etc\templates\extra\amazon to amazonmy

rename plugins\amazonmy\src\java\com\atlassian\confluence\extra\amazon to amnazonmy

In *.java change package name from .amazon to .amazonmy

Look for path to velocity macro and change amazon to amazonmy

The confluence logs are here:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\logs

My Environment Setup

Building

  • Go to C:\projects\confluence-2.4.5.earwar\plugins
  • ..\tools\ant\bin\ant -Dlibrary=amazonmy build

Web pages to open

File Explorers To Open

  • C:\projects\confluence-2.4.5.earwar\confluence\WEB-INF\lib
  • Directory of C:\projects\confluence-2.4.5.earwar\plugins\amazonmy\dist

Editor

  • c:\tsepro\g32 amazonmy\src\java\com\atlassian\confluence\extra\amazonmy\[AmazonAsinMacro].java

Basic functionality working:

  • Display Amazon book info, plus log to a second page "Asinmy Called" each rendering of the macro.

  • Add an event listener, and mark the occurrence of the macro on the page when the page is edited. Look at [Confluence Example Plugin - Auditer]
    • auditor\src\java\com\atlassian\confluence\extra\auditer\[AuditListener].java

      NOTE: Can not add this to the [AmazonAsinMacro] - Must add to a new file: [AmazonListener].java

      Add these imports:
      import com.atlassian.event.Event;
      import com.atlassian.event.[EventListener];

      public class [AmazonListener] implements [EventListener]
      {

      }

      First error encountered

          [javac] C:\projects\confluence-2.4.5.earwar\plugins\amazonmy\src\java\com\at
      lassian\confluence\extra\amazonmy\AmazonListener.java:42: com.atlassian.confluen
      ce.extra.amazonmy.AmazonListener is not abstract and does not override abstract
      method getHandledEventClasses() in com.atlassian.event.EventListener
          [javac] public class AmazonListener implements EventListener
          [javac]        ^
      

001_[AmazonListener].java attached.


Now find a more complicated example of an event listener. Specifically want to get page creation or page edit events.

Try plugins\workflow\src\java\com\atlassian\confluence\extra\workflow\[WorkflowListener].java

  • Implements a single [WorkflowEvent].class listener, which is an extension to a [ConfluenceEvent]

Try [PageEditListener].java:

Add the listener defintion from atlassian-plugin.xml:

    <listener name='Page Event Listener' 
     class='com.atlassian.confluence.extra.amazonmy.AmazonListener' key='pagelistener'>
        <description>Converts edit/view events on pages into workflow events.</description>
    </listener>

002_[AmazonListener].java - Logs a line to "Asinmy Called" everytime a page is edited.


Factor functionality To do:

  • Next: Regexp for factor macro, and modify text of editted page

Amazon linkin functionality To do:

  • Storing per space developer key, or per space affiliate id, configurable within space administration. - unknown
  • Could also be from a list on an admin only page. - Easy, known
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.4.3 Build:#705 Mar 21, 2007) - Bug/feature request - Contact Administrators
Complete Wiki Notation Guide