Skip to content

Commit

Permalink
Merge pull request #105 from OP-TED/feature/TEDEFO-3286-symbolresolve…
Browse files Browse the repository at this point in the history
…r-constructors

ComponentFactory: Improve SymbolResolver creation (TEDEFO-3286)
  • Loading branch information
bertrand-lorentz authored Apr 18, 2024
2 parents 718e8c8 + 9b8a7de commit 8a28468
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/eu/europa/ted/eforms/sdk/ComponentFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,30 @@ public static SymbolResolver getSymbolResolver(final String sdkVersion, final Pa
*/
public static SymbolResolver getSymbolResolver(final String sdkVersion, final String qualifier,
final Path sdkRootPath) throws InstantiationException {
return getSymbolResolver(sdkVersion, qualifier, sdkRootPath);
}

/**
* Gets the single instance containing the symbols defined in the given version of the eForms SDK.
*
* @param sdkVersion Version of the SDK
* @param qualifier Qualifier to choose between several implementations
* @param parameters Array of objects to be passed as arguments to the constructor of the
* SymbolResolver implementation
* @return The single instance containing the symbols defined in the given version of the eForms
* SDK.
* @throws InstantiationException If the SDK version is not supported.
*/
public static SymbolResolver getSymbolResolver(final String sdkVersion, final String qualifier,
Object... parameters) throws InstantiationException {

VersionQualifier key = ComponentFactory.INSTANCE.new VersionQualifier(sdkVersion, qualifier);

return instances.computeIfAbsent(key, k -> {
try {
return ComponentFactory.INSTANCE.getComponentImpl(sdkVersion,
SdkComponentType.SYMBOL_RESOLVER, qualifier, SymbolResolver.class, sdkVersion,
sdkRootPath);
parameters);
} catch (InstantiationException e) {
throw new RuntimeException(MessageFormat.format(
"Failed to instantiate SDK Symbol Resolver for SDK version [{0}]", sdkVersion), e);
Expand Down

0 comments on commit 8a28468

Please sign in to comment.