com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

TenantMgtListener

Multitenancy in WSO2 Carbon was introduced with the goal of maximizing resource sharing. It could provide tenant isolation, data isolation, execution isolation and performance isolation. The TenantMgtListner interface is an extension that allows a component developer to execute any custom code during the different stages of a tenant’s lifecycle.

In order to use this extension point, a developer needs to implement the TenantMgtListener interface. ThemeLoadingListerner is an example of an implementation of this interface. Following are the methods that need to be overridden:

METHODDESCRIPTION

public void onTenantCreate(TenantInfoBean tenantInfo)

Contains the implementation of tasks that need to be performed after a tenant gets created.

public void onTenantUpdate(TenantInfoBean tenantInfo)

Contains the implementation of tasks that need to be performed whenever a tenant’s information is updated.

public void onTenantDelete(int tenantId)

Contains the implementation of tasks that need to be performed after a tenant is deleted.

public void onTenantRename(int tenantId, String oldDomainName, String newDomainName)

Contains the implementation of tasks that need to be performed after a tenant is renamed.

public void onTenantInitialActivation(int tenantId)

Contains the implementation of tasks that need to be performed when each tenant is activated for the first time.

public void onTenantActivation(int tenantId)

Contains the implementation of tasks that need to be performed when a tenant is activated.

public void onTenantDeactivation(int tenantId)

Contains the implementation of tasks that need to be performed when a tenant is deactivated.

public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan)

Contains the implementation of tasks that need to be performed when a subscription plan changes.

public int getListenerOrder()

Contains the implementation logic for returning the rank of this listener.

public void onPreDelete(int tenantId)

Contains the implementation of tasks that need to be performed before a tenant is deleted

Following is a sample implementation of a TenantMgtListener interface:

package org.example.tenantmgtlistener;

import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
import org.wso2.carbon.stratos.common.exception.StratosException;
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;

public class SampleTenantMgtListener implements TenantMgtListener {
  @Override public void onTenantCreate(TenantInfoBean tenantInfoBean) throws StratosException
  {
      // Any work to be performed after a tenant creation
  }

  @Override public void onTenantUpdate(TenantInfoBean tennantInfoBean) throws StratosException {
      // Any work to be performed after a tenant information update happens
  }

  @Override public void onTenantDelete(int i) {
      // Any work to be performed after a tenant deletion.
  }

  @Override public void onTenantRename(int i, String s, String s1) throws StratosException {
      // Any work to be performed after a tenant rename happens
  }

  @Override public void onTenantInitialActivation(int i) throws StratosException {
      // Any work to be performed after a tenant's initial actication happens
  }

  @Override public void onTenantActivation(int i) throws StratosException {
      // Any work to be performed after a tenant activation.
  }

  @Override public void onTenantDeactivation(int i) throws StratosException {
      // Any work to be performed after a tenant deactivation
  }

  @Override public void onSubscriptionPlanChange(int i, String s, String s1) throws StratosException {     
  }

  @Override public int getListenerOrder() {
      return 0;
  }

  @Override public void onPreDelete(int i) throws StratosException {
      // Any work to be performed before a tenant is deleted
  }
}

Following maven dependency will be needed for the above implementation.

<dependency>
  <groupId>org.wso2.carbon.commons</groupId>
  <artifactId>org.wso2.carbon.tenant.common</artifactId>
  <version>4.5.0</version>
</dependency>

After implementing the TenantMgtListener interface the implementation class needs to be registered as an OSGI service for the server to recognize it. Following is a sample bundle activator inside which the service is registered.

package org.example.tenantmgtlistener.internal;
 
import org.example.tenantmgtlistener.SampleTenantMgtListener;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
public class SampleActivator implements BundleActivator {
  @Override public void start(BundleContext bundleContext) throws Exception {
      bundleContext.registerService(TenantMgtListener.class.getName(), new SampleTenantMgtListener() , null);
  }
  @Override public void stop(BundleContext bundleContext) throws Exception {
  }
}

Your custom TenantMgtListener implementtaion should be packaged in an OSGi bundle and added to the <PRODUCT_HOME>/repository/components/dropins directory.

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.