Last updated Dec 22, 2021

Rate this page:

Migrating atlassian-app-cloud-migration-tracker to discoverable listener

Introduction

This tutorial shows you how to migrate your app from atlassian-app-cloud-migration-tracker to the discoverable listener in the atlassian-app-cloud-migration-listener library.

See a sample app

This section provides a sample app that you can use to verify your implementation. You can clone the repository that contains the source code of the sample app from Bitbucket.

Getting started

There are two main steps to change your app code to using the discoverable listener in the atlassian-app-cloud-migration-listener library.

Step 1: Update dependency management

Step 2: Change to the DiscoverableListener interface

Step 3: Atlassian Spring Scanner and atlassian-plugin.xml

Detailed steps

Step 1: Update dependency management

These examples are for your pom.xml and maven, but the steps are similar for other dependency management systems.

Remove the package com.atlassian.migration.app from your <DynamicImport-Package> instruction. Remove !com.atlassian.migration.app from your <Import-Package> instruction.

Change the atlassian-app-cloud-migration-tracker library from pom.xml

1
2
<dependency>
    <groupId>com.atlassian</groupId>
    <artifactId>atlassian-app-cloud-migration-tracker</artifactId>
    <version>1.26.1</version>
</dependency>

to the atlassian-app-cloud-migration-listener library

1
2
<dependency>
    <groupId>com.atlassian</groupId>
    <artifactId>atlassian-app-cloud-migration-listener</artifactId>
    <version>1.0.3</version>
</dependency>

It is likely you will not need org.osgi.util.tracker either.

1
2
<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.util.tracker</artifactId>
    <version>1.5.1</version>
    <scope>provided</scope>
</dependency>

Step 2: Change to the DiscoverableListener interface

Change your class to implement only DiscoverableListener. It no longer needs to implement InitializingBean nor DisposableBean so you do not need to register your class in afterPropertiesSet() nor deregister your class in destroy().

1
2
public class MyPluginComponentImpl implements DiscoverableListener { }

You will no longer need an implementation of ApplicationContextAware, and it is not needed in the class constructor.

The first argument of onStartAppMigration() is now AppCloudMigrationGateway. You do not need to store a reference to it.

1
2
 public void onStartAppMigration(AppCloudMigrationGateway gateway, String transferId, MigrationDetailsV1 migrationDetails) { }

If your app key is different to your OSGi bundle name then you will need to implement getServerAppKey() from DiscoverableListener.

1
2
@Override
public String getServerAppKey() {
    return "my-server-app-key";
}

If your app key is the same as your OSGi bundle name, then you don't need to implement getServerAppKey() as we provide a default implementation.

Step 3: Atlassian Spring Scanner and atlassian-plugin.xml

Atlassian Spring Scanner 1.0

If you are using Spring Scanner 1.0, then in your atlassian-plugin.xml add

1
2
<component key="myPlugin" class="com.vendor.impl.MyPluginComponentImpl" public="true">
    <interface>com.atlassian.migration.app.listener.DiscoverableListener</interface>
</component>

Atlassian Spring Scanner 2.0

If you are using Spring Scanner 2.0, then add the @ExportAsService annotation to your class along with Spring's @Component.

1
2
@ExportAsService
@Component
public class MyPluginComponentImpl implements DiscoverableListener { }

Rate this page: