Examples: Cluster Manager - Smile CDR Documentation

Cluster Manager Examples

This page contains example interceptors that can be registered with Cluster Manager

Example: Starter Server interceptor for Auditing and Open ID Connect Client Pointcuts

The following example shows an interceptor that can be used as a starter interceptor, implementing a hook method for pointcuts available on the Cluster Manager.

/*-
 * #%L
 * Smile CDR - CDR
 * %%
 * Copyright (C) 2016 - 2026 Smile CDR, Inc.
 * %%
 * All rights reserved.
 * #L%
 */
package com.smilecdr.demo.clustermgr;

import ca.cdr.api.fhir.interceptor.CdrHook;
import ca.cdr.api.fhir.interceptor.CdrPointcut;
import ca.cdr.api.i18n.ILocalizer;
import ca.cdr.api.model.json.AuditEventJson;
import ca.cdr.api.model.json.AuditEventPrePersistJson;
import ca.cdr.api.model.json.IOAuth2ClientDetails;
import ca.cdr.api.model.json.OAuth2ClientDetailsJson;
import ca.cdr.api.model.json.UserSessionDetailsJson;
import ca.cdr.api.transactionlog.ITransactionLogFetchingSvc;
import ca.cdr.api.transactionlog.ITransactionLogStoringSvc;
import ca.uhn.fhir.interceptor.api.Interceptor;
import jakarta.annotation.Nullable;
import org.apache.pulsar.client.api.ConsumerBuilder;
import org.apache.pulsar.client.api.ProducerBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Sample Cluster Manager Interceptor implementing all pointcuts available in the Cluster Manager.
 * Note that the autowired beans are unused in the template, and are just here to show what is available to implementers.
 */
@SuppressWarnings({"unused", "EmptyTryBlock"})
@Interceptor
public class ClusterManagerTemplate {

@Autowired
    private ITransactionLogFetchingSvc myTransactionLogFetchingSvc;

@Autowired
    private ITransactionLogStoringSvc myTransactionLogStoringSvc;

@Autowired
    private ILocalizer myLocalizer;

private static final Logger ourLog = LoggerFactory.getLogger(ClusterManagerTemplate.class);

@CdrHook(CdrPointcut.SMART_OIDC_CLIENT_SAVING)
    public void oidcClientSaving(IOAuth2ClientDetails theClientDetails) {
        // Insert custom code here.
    }

@CdrHook(CdrPointcut.SMART_OIDC_CLIENT_SAVED)
    public void oidcClientSaved(IOAuth2ClientDetails theClientDetails) {
        // Insert custom code here.
    }

@CdrHook(CdrPointcut.AUDIT_EVENT_PRE_PERSIST)
    public void auditEventPrePersist(
            AuditEventJson theAuditEventJson,
            @Nullable UserSessionDetailsJson theUserSessionDetails,
            @Nullable OAuth2ClientDetailsJson theClientDetailsJson,
            AuditEventPrePersistJson theAuditEventPrePersistJson) {
        // Insert custom code here.
    }

@CdrHook(CdrPointcut.PULSAR_CONSUMER_BUILDER)
    public void onConsumerBuilder(ConsumerBuilder<?> theConsumerBuilder) {
        // Insert custom code here
    }

@CdrHook(CdrPointcut.PULSAR_PRODUCER_BUILDER)
    public void onProducerBuilder(ProducerBuilder<?> theProducerBuilder) {
        // Insert custom code here
    }
}

Copy

Examples: Channel Import

Examples: Cluster Manager

Interceptors

Interceptors Pointcuts Starter Project Examples: FHIR Endpoints Examples: HL7v2 Endpoints Examples: FHIR Storage Examples: FHIR Gateway Examples: FHIR Client Examples: MDM Examples: Subscription Examples: Channel Import Examples: Cluster Manager Examples: App Sphere Examples: System To System Data Exchange 2024.02.01 Migration Guide

Examples: App Sphere