smolnar82 commented on a change in pull request #361:
URL: https://github.com/apache/knox/pull/361#discussion_r454396302
##########
File path:
gateway-server/src/main/java/org/apache/knox/gateway/services/factory/AbstractServiceFactory.java
##########
@@ -47,22 +52,38 @@ public Service create(GatewayServices gatewayServices,
ServiceType serviceType,
@Override
public Service create(GatewayServices gatewayServices, ServiceType
serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String
implementation)
throws ServiceLifecycleException {
- Service service = null;
- if (getServiceType() == serviceType) {
- service = createService(gatewayServices, serviceType, gatewayConfig,
options, implementation);
- if (service == null && StringUtils.isNotBlank(implementation)) {
- // no known service implementation created, try to create the custom
one
- try {
- service =
Service.class.cast(Class.forName(implementation).newInstance());
- logServiceUsage(implementation, serviceType);
- } catch (InstantiationException | IllegalAccessException |
ClassNotFoundException e) {
- throw new ServiceLifecycleException("Errror while instantiating " +
serviceType.getShortName() + " service implementation " + implementation, e);
+ Service service = fetchFromCache(serviceType, implementation);
+ if (service == null) {
+ if (getServiceType() == serviceType) {
+ service = createService(gatewayServices, serviceType, gatewayConfig,
options, implementation);
+ if (service == null && StringUtils.isNotBlank(implementation)) {
Review comment:
We **do** have a fallback. There are 2 types of service factories:
1. there is only one known implementation - in this case, that known
implementation will be created if it's not overwritten in `gatewy-site.xml`
2. there are more than one known implementations - in this case, one of the
known implementations (typically the first one in the `if-else` branches) will
be the default one (i.e. none is defined in `gateway-site.xml`)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]