Valid PETEP extension is any JAR file that contains package "petep" with class "PetepExtension" that extends the Extension class and implements all the abstract methods.
/**
* Superclass for extensions.
* <p>Each extension is identified by its code, so it has to be unique across the whole application.</p>
*/
@Getter
@PetepAPI
@AllArgsConstructor
public abstract class Extension {
/**
* Path where the extension .jar file is located.
*/
private final String path;
/**
* Initializes the extension.
* @param helper Helper for working with PETEP
*/
public void init(ExtensionHelper helper) {}
/**
* Runs before extensions are initialized.
* @param helper Helper for working with PETEP
*/
public void beforeInit(ExtensionHelper helper) {}
/**
* Runs after extensions are initialized.
* @param helper Helper for working with PETEP
*/
public void afterInit(ExtensionHelper helper) {}
/**
* Initializes the extension GUI.
* @param helper Helper for working with PETEP GUI
*/
public void initGui(GuiHelper helper) {}
/**
* Runs before extension GUIs are initialized.
* @param helper Helper for working with PETEP GUI
*/
public void beforeInitGui(GuiHelper helper) {}
/**
* Runs after extension GUIs are initialized.
* @param helper Helper for working with PETEP GUI
*/
public void afterInitGui(GuiHelper helper) {}
/**
* Destroys the extension.
*/
public void destroy() {}
/**
* Obtains extension code.
* @return Code of the extension
*/
public abstract String getCode();
/**
* Obtains extension name.
* @return Name of the extension
*/
public abstract String getName();
/**
* Obtains extension description.
* @return Description of the extension
*/
public abstract String getDescription();
/**
* Obtains extension version.
* @return Version of the extension
*/
public abstract String getVersion();
}
If you want to send data across different extensions, you can use Receiver class. (You can register receivers or obtain them through extension helper.) For example, you can send SerializedPdu or PDU to Repeater extension, which adds them to Repeater tabs.
Warning: Receivers are persisted using weak references, so you have to keep the strong reference yourself (avoid lambdas).
/**
* Receiver for cross extension data transfer.
* <p>Receivers are identified by their code, so it has to be unique across the application.</p>
* <p>Receivers can be registered through {@link com.warxim.petep.helper.ExtensionHelper}.</p>
* <p><b>Note:</b> Receivers are kept using weak references, so they have to be stored somewhere as strong reference.</p>
*/
@PetepAPI
public interface Receiver {
/**
* Obtains name of the receiver.
* @return Name for displaying in the GUI
*/
String getName();
/**
* Obtains code of the receiver.
* @return Code for identifying the receiver
*/
String getCode();
/**
* Checks whether the receiver supports specified class (as input data).
* @param clazz Class to check
* @return {@code true} if the receiver supports given class
*/
boolean supports(Class<?> clazz);
/**
* Receives data in receiver.
* @param data Data to be received
*/
void receive(Object data);
}