# Cluster Manager Examples

This page contains example interceptors that can be registered with [Cluster Manager](/content/docs/modules/cluster_mgr.html)

# 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.

```java
/*-
 * #%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](/content/docs/interceptors/examples_channel_import.html)

Examples: Cluster Manager

Interceptors

[Interceptors](/content/docs/interceptors/interceptors.html)
[Pointcuts](/content/docs/interceptors/pointcuts.html)
[Starter Project](/content/docs/interceptors/starter_project.html)
[Examples: FHIR Endpoints](/content/docs/interceptors/examples_fhir_endpoint.html)
[Examples: HL7v2 Endpoints](/content/docs/interceptors/examples_hl7v2_endpoint.html)
[Examples: FHIR Storage](/content/docs/interceptors/examples_fhir_storage.html)
[Examples: FHIR Gateway](/content/docs/interceptors/examples_fhir_gateway.html)
[Examples: FHIR Client](/content/docs/interceptors/examples_fhir_client.html)
[Examples: MDM](/content/docs/interceptors/examples_mdm.html)
[Examples: Subscription](/content/docs/interceptors/examples_subscription.html)
[Examples: Channel Import](/content/docs/interceptors/examples_channel_import.html)
[Examples: Cluster Manager](/content/docs/interceptors/examples_cluster_manager.html)
[Examples: App Sphere](/content/docs/interceptors/examples_app_sphere.html)
[Examples: System To System Data Exchange](/content/docs/interceptors/examples_s2s_data_exchange.html)
[2024.02.01 Migration Guide](/content/docs/interceptors/jakarta_upgrade.html)

[Examples: App Sphere](/content/docs/interceptors/examples_app_sphere.html)
