Skip to content

Commit

Permalink
Merge pull request #866 from b00lean/master
Browse files Browse the repository at this point in the history
BATM-5644 -   Create template module for customers to develop their extensions
  • Loading branch information
generalbytes authored Nov 20, 2023
2 parents 8995d49 + 13dde99 commit 7852c62
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
33 changes: 33 additions & 0 deletions server_extensions_template/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id("shared-build-conventions")
id("shared-repositories-ext-conventions")
}

group = projectGroup
version = projectVersion

jar {
archiveFileName = "myfirstextension.${archiveExtension.get()}"
}

configurations {
artifactOnly

// handle Github (e.g. community) vs GENERAL BYTES dichotomy
generalBytesCompile
githubCompile
if (hasGbArtifactory) {
implementation { extendsFrom generalBytesCompile }
} else {
implementation { extendsFrom githubCompile }
}
}

artifacts {
artifactOnly jar
}

dependencies {
implementation project(":server_extensions_api")
implementation project(":currencies")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mygreatcompany.batm.server.extensions.myfirstextension;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.IExtensionContext;

public class MyFirstExtension extends AbstractExtension {

@Override
public String getName() {
return "My first extension";
}

@Override
public void init(IExtensionContext ctx) {
super.init(ctx);
ctx.addTransactionListener(new MyTransactionListener(ctx));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.mygreatcompany.batm.server.extensions.myfirstextension;

import com.generalbytes.batm.server.extensions.IExtensionContext;
import com.generalbytes.batm.server.extensions.ITransactionDetails;
import com.generalbytes.batm.server.extensions.ITransactionListener;

import java.util.Map;

public class MyTransactionListener implements ITransactionListener {
private IExtensionContext ctx;

public MyTransactionListener(IExtensionContext ctx) {
this.ctx = ctx;
}

@Override
public Map<String, String> onTransactionCreated(ITransactionDetails transactionDetails) {
System.out.println("Bravo! Transaction has been created! Here are the details: = " + transactionDetails);
return null;
}

@Override
public Map<String, String> onTransactionUpdated(ITransactionDetails transactionDetails) {
System.out.println("Hey! Transaction has been updated! Here are the details: " + transactionDetails);
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<extensions>
<extension class="com.mygreatcompany.batm.server.extensions.myfirstextension.MyFirstExtension" />
</extensions>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include ':server_extensions_api'
include ':server_extensions_extra'
include ':server_extensions_test'
include ':server_extensions_template'
include ':currencies'
include ':batm_ssh_tunnel'
include ':operators_sample_website'
Expand Down

0 comments on commit 7852c62

Please sign in to comment.