Annotation Interface Config
The methods of the interface annotated with Attribute
form the schema of the service,
which will be used by SMS to automatically generate REST endpoints for manipulating the service.
All methods MUST be annotated with Attribute
, Id
, SubConfig
or have a default implementation.
The schema created for a particular annotated method is controlled by a TypeAdapter
. The
adapter for a method is chosen as follows:
- If the method has an annotation that implies a
TypeAdapter
, it is used. - Otherwise, the
TypeAdapter
is inferred from the return type of the method.
Interfaces annotated with this annotation should be registered with the AnnotatedServiceRegistry
. The
registry can then be used to obtain concrete implementations of the interface.
Example:
@Config(scope = GLOBAL)
interface MyGlobalServiceConfig {
@Attribute(order = 100)
String myAttribute();
@Attribute(order = 300)
default int myDefaultedAttribute() {
return 5;
}
@Attribute(order = 200)
@MyType
CustomType anotherAttribute();
}
- Since:
- AM 5.5.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The types of visibility available for a service. -
Required Element Summary
Modifier and TypeRequired ElementDescriptionThe scope of the service configuration. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Whether multiple instances are supported for this service.boolean
Whether to create a sub-schema container entry.The key for the service description in the i18n bundle.boolean
Whether the config service should be hidden from the config UI.The name of the i18n bundle file (without.properties
suffix), relative to the root package.The name of the service.The resource name of the service in the REST endpoints.boolean
Whether this service is enabled for REST.Class<?>
A validator to apply to the entire configuration object.The version number of the service.
-
Element Details
-
scope
Config.Scope scopeThe scope of the service configuration.- Returns:
- the scope.
-
-
-
name
String nameThe name of the service. If not provided, the simple name of the annotated interface is used.- Returns:
- the name.
- Default:
- ""
-
version
String versionThe version number of the service.- Returns:
- the version.
- Default:
- "1.0"
-
resourceName
String resourceNameThe resource name of the service in the REST endpoints. If not provided, the name of the service is used.- Returns:
- the resource name.
- See Also:
- Default:
- ""
-
collection
boolean collectionWhether multiple instances are supported for this service.- Returns:
- true if the config is for a collection.
- Default:
- false
-
container
boolean containerWhether to create a sub-schema container entry.Generally this should not be changed from the default.
- Returns:
- true if the sub-schema requires a nested container entry.
- Default:
- true
-
i18nFile
String i18nFileThe name of the i18n bundle file (without.properties
suffix), relative to the root package.If not provided, this will default to the interface name, with the slash-separated package prefix.
- Returns:
- the i18n file name.
- Default:
- ""
-
descriptionKey
String descriptionKeyThe key for the service description in the i18n bundle.- Returns:
- the i18n description key.
- Default:
- "serviceDescription"
-
validator
Class<?> validatorA validator to apply to the entire configuration object.If set, the value must be a class implementing the
ServiceConfigValidator
interface.- Returns:
- the validator class.
- Default:
- java.lang.Void.class
-
restEnabled
boolean restEnabledWhether this service is enabled for REST. Defaults to true.- Returns:
- whether this service is enabled for REST.
- Default:
- true
-