Smile CDR v2024.08.PRE
On this page:

12.2.1Starter Project


The cdr-interceptor-starterproject contains a complete example Maven-based Java project to define an interceptor that can be imported into Smile CDR. It is available for download at the following links:

This project also contains an example showing a Java Consent Service implementation.

12.2.2Using the Starter Project


To use the starter project:

  • Download the project using the link above, and extract the archive locally.

  • Edit the pom.xml file. The <groupId>, <artifactId>, and <name> tags all contain placeholders. You can leave the examples if you are just experimenting, but it is recommended to replace these with something more useful before committing your code to source control.

  • Open the project in your favorite IDE. This project is designed to use Apache Maven for building, so it can be imported natively as a Maven project in Eclipse and IntelliJ IDEA.

  • The project contains a number of example interceptors. Pick the one you want to start with, or create your own from scratch. You may want to move the class to a more sensible package name for your organization.

  • Build the project by executing the following command:

mvn clean install
  • Maven will create a JAR containing your interceptor classes in the target/ directory. The exact name of the JAR file will vary depending on the groupId and artifactId you picked, but by default it will be called: cdr-interceptor-starterproject-[version].jar.

    • Copy this JAR file to the customerlib/ directory in your Smile CDR installation
    • Restart Smile CDR.
  • Edit the module configuration for the relevant module to either:

    • add the fully qualified class name for your interceptor (e.g. com.smilecdr.demo.fhirstorage.ExampleAttributeEnhancingInterceptor) to the Interceptor Bean Types property in your module configuration;
    • or add the fully qualified class name for your interceptor Spring Configuration class (annotated with @Configuration e.g. com.smilecdr.demo.server.r4.TestServerAppCtx) to the Interceptor Bean Types property in your module configuration, which will allow you to register one or more interceptor beans and use dependency injection with your interceptors
  • Restart the module.

12.2.3Interceptor Template classes


In the starter project, many template classes are provided as starter interceptor and implement one hook method for every available pointcuts and their expected parameters: