Development Guide

PETEP Listener

PETEP Listener allows you to take action when PETEP loads, starts and stops. It also provides PetepHelper instance, so you can work with the PETEP core.

You can register your own PETEP Listener using ExtensionHelper.

Warning #1: Listeners are persisted using weak references, so you have to keep the strong reference yourself (avoid lambdas).

Warning #2: After the core stops you should not keep PetepHelper and any of the data you obtained from it. (Otherwise the memory will not be released properly.)

PetepListener interface

com.warxim.petep.core.listener.PetepListener
/**
 * PETEP listener interface. Allows extensions to listen for PETEP events and also allows them to obtain PetepHelper.
 * <p>
 *    <b>Warning #1</b>: Extensions should remove PetepHelper from their memory after PETEP stops, so that GC can collect resources.
 *    (This, of course, applies to all other resources that are connected to PETEP instance.)
 * </p>
 * <p>
 *    <b>Warning #2</b>: Listeners are called in parallel, so be careful when accessing the same data in two listeners.
 * </p>
 */
@PetepAPI
public interface PetepListener {
    /**
     * Event before prepare step is processed.
     * @param helper PETEP helper for currently running core
     */
    default void beforeCorePrepare(PetepHelper helper) {
    }

    /**
     * Event after prepare step is processed.
     * @param helper PETEP helper for currently running core
     */
    default void afterCorePrepare(PetepHelper helper) {
    }

    /**
     * Event before start step is processed.
     * @param helper PETEP helper for currently running core
     */
    default void beforeCoreStart(PetepHelper helper) {
    }

    /**
     * Event after start step is processed.
     * @param helper PETEP helper for currently running core
     */
    default void afterCoreStart(PetepHelper helper) {
    }

    /**
     * Event before stop step is processed.
     * @param helper PETEP helper for currently running core
     */
    default void beforeCoreStop(PetepHelper helper) {
    }

    /**
     * Event after stop step is processed.
     * @param helper PETEP helper for currently running core
     */
    default void afterCoreStop(PetepHelper helper) {
    }
}