Skip navigation links
Oracle REST Data Services Java API Reference
19.2

F20371-01

Package oracle.dbtools.plugin.api.conf

Services for defining and introspecting Configuration Settings

See: Description

Package oracle.dbtools.plugin.api.conf Description

Services for defining and introspecting Configuration Settings

About Configuration Settings

Each plugin may contribute zero or more ConfigurationSetting values. By declaring discoverable ConfigurationSetting values a plugin enables two things:

Declaring a Configuration Setting

Each setting is uniquely defined by it's name. It must have a data-type and may also have the following optional attributes:

Best practice is to define a constant for the setting name and use that constant rather than a literal string. The ConfigurationSetting should be defined as a final static constant. The field must be annotated with Named to indicate the unique name of the setting.

The field or it's enclosing type must be annotated with Provides so that the field is discoverable.

Supported data types

ConfigurationSetting data-types must be one of the following:

Examples

Undocumented Integer Setting

 
 public interface PluginSettings {
        static final String SETTING_FOO = "my.plugin.setting.foo";
 }
 
 @Provides
 class PluginImpl {
        @Named(PluginSettings.SETTING_FOO)
        static final ConfigurationSetting FOO = ConfigurationSetting.setting(10);
 }
 

Documented Enum Setting

 
 public interface PluginSettings {
        static final String ACCESS_MODE_SETTING = "my.plugin.accessMode";
 }
 
 @Provides
 class PluginImpl {
        @Named(PluginSettings.ACCESS_MODE_SETTING)
        @ConfigurationSetting.Description(@TranslatableDescription(type = MyPluginMessages.class, id = MyPluginMessages.ACCESS_MODE_DESCRIPTION))
        static final ConfigurationSetting ACCESS_MODE = ConfigurationSetting.setting(java.nio.AccessMode.class,
                        java.nio.AccessMode.READ);
 }
 

Injecting Configuration Settings

When a ConfigurationSetting is declared as outlined above, the Dependency Injection runtime is able to map each setting to a concrete value derived from the Configuration instance applicable to the current scope. Thus instead of invoking Configuration.get(String) (which is strongly discouraged) a plugin service can just declare a dependency on the configuration setting value via an appropriately typed and Named parameter in it's constructor

For example to inject the my.plugin.setting.foo configuration setting value into some service, one would do:

 @Provides
 class MyPluginService implements SomeService {
   @Inject
   MyPluginService(final @Named(PluginSettings.FOO_SETTING) int foo) {
    ...
   }
 }
 

Boxing and Unboxing of Primitive Types

For ease of use, injection sites may use primitive types where applicable.

Note in each case if no default value is specified for the setting and the Configuration also lacks a value for the setting then a runtime error will occur during creation of the service and likely lead to the application not starting.

Author:
cdivilly
Skip navigation links
Oracle REST Data Services Java API Reference
19.2

F20371-01

Copyright © 2010, 2019, Oracle and/or its affiliates. All rights reserved.