Every configuration has a unique stereotype that is assigned automatically. This stereotype has the following characteristics:
-
Both the name and the namespace are made uppercase, and words are separated by underscores.
-
The namespace is the namespace of the extension, for example, "HTTP" for the HTTP Connector or "JMS" for the JMS Connector.
-
The name is the name of the configuration. For example, the stereotype name of the "requestConfig" configuration will be "REQUEST_CONFIG".
This default stereotype can be overwritten using the @Stereotype annotation.
You can use this stereotype to restrict a String parameter to a name of certain type of configuration by using the @ConfigReference annotation. This annotation requires the name and namespace of the configuration stereotype.
A usage example of this feature:
Developing an extension that uses the HttpService, which requires a HttpRequesterConfig for its use. Then, with the use of the Extension Client, the
HttpService will use the actual Configuration.
For example, if the HTTP Connector declares this HttpRequesterConfig:
@Configuration(name = "requestConfig")
@ConnectionProviders(HttpRequesterProvider.class)
@Operations({HttpRequestOperations.class})
public class HttpRequesterConfig {
// Parameters and getters for the Configuration
}
And the Web Service Consumer connector is defined like this:
@ErrorTypes(SoapErrors.class)
@Operations(ConsumeOperation.class)
@ConnectionProviders(SoapClientConnectionProvider.class) (1)
@SubTypeMapping(baseType = CustomTransportConfiguration.class, subTypes = CustomHttpTransportConfiguration.class)
@Extension(name = "Web Service Consumer")
@Xml(prefix = "wsc")
public class WebServiceConsumer {
}
| 1 |
This ConnectionProvider holds a parameter that is using the @ConfigReference annotation. Note that the default config is used because the connector does not declare any configuration. |
This is part of the declaration of the ConnectionProvider:
public class SoapClientConnectionProvider implements CachedConnectionProvider<SoapClientWrapper> {
// ...
@Inject
private HttpService httpService;
// ...
@Placement(tab = "Transport")
@Parameter
@Optional
@Expression(NOT_SUPPORTED)
@DisplayName("Transport Configuration")
private CustomTransportConfiguration customTransportConfiguration;
// ...
}
Here is where the @ConfigReference annotation is used:
@Alias("http-transport-configuration")
public class CustomHttpTransportConfiguration implements CustomTransportConfiguration {
@ConfigReference(namespace = "HTTP", name = "REQUEST_CONFIG") (1)
@Parameter
private String requesterConfig;
@Override
public MessageDispatcher buildDispatcher(ExtensionsClient client) {
return new HttpConfigBasedMessageDispatcher(requesterConfig, client); (2)
}
@Override
public TransportResourceLocator resourceLocator(ExtensionsClient client) {
return new HttpResourceLocator(requesterConfig, client); (2)
}
}
| 1 |
The String parameter requesterConfig must take the value of the name of a HttpRequesterConfig. |
| 2 |
The name of the configuration is used along with the ExtensionsClient |