How can I set JNDI configuration in a Docker overrides.yaml file?

ghz 1years ago ⋅ 8061 views

Question

If I have a java configuration bean, saying:

package com.mycompany.app.configuration;

// whatever imports

public class MyConfiguration {

  private String someConfigurationValue = "defaultValue"; 

  // getters and setters etc
}

If I set that using jetty for local testing I can do so using a config.xml file in the following form:

  <myConfiguration class="com.mycompany.app.configuration.MyConfiguration" context="SomeContextAttribute">
    <someConfigurationValue>http://localhost:8080</someConfigurationValue>
  </myConfiguration>

However in the deployed environment in which I need to test, I will need to use docker to set these configuration values, we use jboss.

Is there a way to directly set these JNDI values? I've been looking for examples for quite a while but cannot find any. This would be in the context of a yaml file which is used to configure a k8 cluster. Apologies for the psuedocode, I would post the real code but it's all proprietary so I can't.

What I have so far for the overrides.yaml snippet is of the form:

env:
    'MyConfig.SomeContextAttribute':
      class_name: 'com.mycompany.app.configuration.MyConfiguration'
      someConfigurationValue: 'http://localhost:8080'

However this is a complete guess.


Answer

The way to do this is as follows:

If you are attempting to set a value that looks like this in terms of fully qualified name:

com.mycompany.app.configuration.MyConfiguration#someConfigurationValue 

Then that will look like the following in a yaml file:

com_mycompany_app_configuration_MyConfiguration_someConfigurationValue: 'blahValue'

It really is that simple. It does need to be set as an environment variable in the yaml, but I'm not sure whether it needs to be under env: or if that's specific to us.

I don't think there's a way of setting something in YAML that in XML would be an attribute, however. I've tried figuring that part out, but I haven't been able to.