# Class ServiceBindingPropertySource

java.lang.Object
org.apache.tomcat.util.digester.ServiceBindingPropertySource

All Implemented Interfaces:
  `IntrospectionUtils.PropertySource`

public class ServiceBindingPropertySource extends Object implements IntrospectionUtils.PropertySource
A `IntrospectionUtils.PropertySource` that uses Kubernetes service bindings to resolve expressions.

The Kubernetes service binding specification can be found at https://servicebinding.io/.

Usage example:

Configure the certificate with a service binding.

When the service binding is constructed as follows:

       $SERVICE_BINDING_ROOT/
                            /custom-certificate/
                                               /keyFile
                                               /file
                                               /chainFile
                                               /keyPassword

        <SSLHostConfig>
              <Certificate certificateKeyFile="${custom-certificate.keyFile}"
                           certificateFile="${custom-certificate.file}"
                           certificateChainFile="${custom-certificate.chainFile}"
                           certificateKeyPassword="${chomp:custom-certificate.keyPassword}"
                           type="RSA" />
        </SSLHostConfig>

The optional `chomp:` prefix will cause the ServiceBindingPropertySource to trim a single newline (`\r\n`, `\r`, or `\n`) from the end of the file, if it exists. This is a convenience for hand-edited files/values where removing a trailing newline is difficult, and trailing whitespace changes the meaning of the value.

How to configure:

      echo "org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource" >> conf/catalina.properties

or add this to `CATALINA_OPTS`

      -Dorg.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.ServiceBindingPropertySource

NOTE: When configured the PropertySource for resolving expressions from system properties is still active.

See Also:
  - `Digester`
  - Tomcat Configuration Reference System Properties

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ServiceBindingPropertySource()`
  Default constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getProperty(String key)`
  Resolves a property key using Kubernetes service bindings.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ServiceBindingPropertySource

    public ServiceBindingPropertySource()
    Default constructor.

- ## Method Details

  - ### getProperty

    public String getProperty(String key)
    Resolves a property key using Kubernetes service bindings.

    Keys are expected in the format `<binding-name>.<key>`, which maps to `$SERVICE_BINDING_ROOT/<binding-name>/<key>`. The optional `chomp:` prefix trims a trailing newline from the file content.

    Specified by:
      `getProperty` in interface `IntrospectionUtils.PropertySource`
    Parameters:
      `key` - the property key to resolve
    Returns:
      the resolved property value, or `null` if not found