Skip to content

Extending the Database Connector

The Database Connector supports a custom extension point that lets you transform, enrich, or filter database rows before they are indexed. Extensions are Java classes that implement the DumDbExtCustomImpl interface from the db-commons library.


<!-- Source: https://mvnrepository.com/artifact/com.viglet.dumont/db-commons -->
<dependency>
<groupId>com.viglet.dumont</groupId>
<artifactId>db-commons</artifactId>
<version>2026.2.3</version>
<scope>compile</scope>
</dependency>

public interface DumDbExtCustomImpl {
Map<String, Object> run(Connection connection, Map<String, Object> attributes);
}
Parameter Description
Connection connection The active JDBC connection: you can execute additional queries to enrich the row
Map<String, Object> attributes Mutable map of column values from the current row (column aliases become keys)

Return: The modified attributes map. The returned map is what gets indexed.


For each row in the SQL result set, the connector:

  1. Reads all columns into an attributes map (Map<String, Object>)
  2. Applies value formatting (HTML tag removal, date formatting)
  3. Calls your custom class via run(connection, attributes)
  4. Processes multi-valued fields
  5. Creates a Job Item and sends it to the pipeline
%%{init: {'theme': 'base', 'themeVariables': {'fontSize': '13px', 'primaryColor': '#fff', 'primaryBorderColor': '#c0c0c0', 'lineColor': '#888', 'textColor': '#333'}}}%%
graph LR
    SQL["🗄️ SQL Query"] --> ROW["📄 Read Row"]
    ROW --> MAP["📋 Map Columns → Attributes"]
    MAP --> CUSTOM["⚙️ Your Custom Class\n(DumDbExtCustomImpl)"]
    CUSTOM --> ITEM["📦 Create Job Item"]
    ITEM --> PIPE["📨 Pipeline"]

    classDef blue fill:#dbeafe,stroke:#4A90D9,stroke-width:2px,color:#1a1a1a
    classDef purple fill:#ede9fe,stroke:#9B6EC5,stroke-width:2px,color:#1a1a1a
    classDef amber fill:#fef3c7,stroke:#E8A838,stroke-width:2px,color:#1a1a1a

    class SQL,ROW blue
    class MAP,CUSTOM purple
    class ITEM,PIPE amber

A minimal example that prefixes every title with a label:

package com.example.ext;
import com.viglet.dumont.connector.db.ext.DumDbExtCustomImpl;
import java.sql.Connection;
import java.util.Map;
public class MyDbCustom implements DumDbExtCustomImpl {
private static final String TITLE = "title";
@Override
public Map<String, Object> run(Connection connection,
Map<String, Object> attributes) {
if (attributes.containsKey(TITLE)) {
attributes.replace(TITLE,
String.format("Product: %s", attributes.get(TITLE)));
}
return attributes;
}
}

Use the JDBC connection to run additional queries and add data:

public class EnrichWithCategory implements DumDbExtCustomImpl {
@Override
public Map<String, Object> run(Connection connection,
Map<String, Object> attributes) {
Object categoryId = attributes.get("category_id");
if (categoryId != null) {
try (var stmt = connection.prepareStatement(
"SELECT name FROM categories WHERE id = ?")) {
stmt.setObject(1, categoryId);
try (var rs = stmt.executeQuery()) {
if (rs.next()) {
attributes.put("category", rs.getString("name"));
}
}
} catch (Exception e) {
// log and continue
}
}
return attributes;
}
}

Pass the fully-qualified class name with the --class-name parameter:

Terminal window
java -cp dumont-db-indexer.jar:my-db-extensions.jar \
com.viglet.dumont.connector.db.DumDbImportTool \
--class-name com.example.ext.MyDbCustom \
--server http://localhost:30130 \
--api-key <API_KEY> \
--driver org.mariadb.jdbc.Driver \
--connect "jdbc:mariadb://localhost:3306/shop" \
--query "SELECT id, name AS title, price FROM products" \
--site ProductCatalog \
--locale en_US

<project>
<groupId>com.example</groupId>
<artifactId>my-db-extensions</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>com.viglet.dumont</groupId>
<artifactId>db-commons</artifactId>
<version>2026.2.3</version>
</dependency>
</dependencies>
</project>
package com.example.ext;
import com.viglet.dumont.connector.db.ext.DumDbExtCustomImpl;
import java.sql.Connection;
import java.util.Map;
public class MyDbCustom implements DumDbExtCustomImpl {
@Override
public Map<String, Object> run(Connection connection,
Map<String, Object> attributes) {
// Transform, enrich, or filter attributes
return attributes;
}
}
Terminal window
mvn clean package
Terminal window
java -cp dumont-db-indexer.jar:target/my-db-extensions-1.0.0.jar \
com.viglet.dumont.connector.db.DumDbImportTool \
--class-name com.example.ext.MyDbCustom \
--server http://localhost:30130 \
--api-key <API_KEY> \
...
  • Public no-argument constructor
  • On the classpath (via -cp)
  • Thread-safe: one instance processes all rows sequentially, but should avoid mutable shared state

Page Description
Database Connector CLI parameters, SQL examples, supported databases
Extending the AEM Connector AEM extension interfaces and configuration JSON
Developer Guide Project structure, build, and contribution guide