1. Atlassian Labs
  2. Atlassian Labs
  3. async-events-tutorial

Commits

Brad Baker [Atlassian]  committed 6023ccb

Better log messages and Spring lifecycle management

  • Participants
  • Parent commits 63f2189
  • Branches master

Comments (0)

Files changed (4)

File README

View file
  • Ignore whitespace
-A tutorial on Asynchronous Events in Atlassian Plugins
+A tutorial on Asynchronous Events in Atlassian Plugins.  It demonstrates how you can use both Synchronous and Asynchronous events in a plugin
 
 Here are the SDK commands you'll use immediately:
 

File src/main/java/com/atlassian/jira/tutorial/AsyncEventListenerImpl.java

View file
  • Ignore whitespace
 
 import com.atlassian.event.api.EventListener;
 import com.atlassian.event.api.EventPublisher;
-import com.atlassian.sal.api.lifecycle.LifecycleAware;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
     }
 
     @Override
-    public void afterPropertiesSet()throws Exception
+    public void afterPropertiesSet()
+            throws Exception
     {
         eventPublisher.register(this);
     }
 
     @Override
-    public void destroy()throws Exception
+    public void destroy()
+            throws Exception
     {
         eventPublisher.unregister(this);
     }
     private void performLongTask()
     {
         long then = System.currentTimeMillis();
-        while (System.currentTimeMillis() - then < 5000) {
+        while (System.currentTimeMillis() - then < 5000)
+        {
             log.error("Performing a long task simulation here....");
             try
             {
             }
             catch (InterruptedException e)
             {
-               return;
+                return;
             }
         }
     }

File src/main/java/com/atlassian/jira/tutorial/SyncEventListenerImpl.java

View file
  • Ignore whitespace
 import com.atlassian.event.api.EventListener;
 import com.atlassian.event.api.EventPublisher;
 import com.atlassian.jira.event.issue.IssueEvent;
-import com.atlassian.sal.api.lifecycle.LifecycleAware;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
     }
 
     @Override
-    public void afterPropertiesSet()throws Exception
+    public void afterPropertiesSet()
+            throws Exception
     {
         eventPublisher.register(this);
     }
 
     @Override
-    public void destroy()throws Exception
+    public void destroy()
+            throws Exception
     {
         eventPublisher.unregister(this);
     }

File src/main/resources/asynch-events.properties

View file
  • Ignore whitespace
-#put any key/value pairs here
-my.plugin.name=MyPlugin