use of org.apache.knox.gateway.services.Service in project knox by apache.
the class AliasServiceFactory method createService.
@Override
protected Service createService(GatewayServices gatewayServices, ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String implementation) throws ServiceLifecycleException {
Service service = null;
if (shouldCreateService(implementation)) {
final AliasService defaultAliasService = new DefaultAliasService();
((DefaultAliasService) defaultAliasService).setMasterService(getMasterService(gatewayServices));
((DefaultAliasService) defaultAliasService).setKeystoreService(getKeystoreService(gatewayServices));
// invoking init on DefaultAliasService twice is ok (in case implementation is set to 'default')
defaultAliasService.init(gatewayConfig, options);
if (matchesImplementation(implementation, DefaultAliasService.class, true)) {
service = defaultAliasService;
} else if (matchesImplementation(implementation, HashicorpVaultAliasService.class)) {
service = new HashicorpVaultAliasService(defaultAliasService);
} else if (matchesImplementation(implementation, RemoteAliasService.class)) {
service = new RemoteAliasService(defaultAliasService, getMasterService(gatewayServices));
} else if (matchesImplementation(implementation, ZookeeperRemoteAliasService.class)) {
service = new ZookeeperRemoteAliasServiceProvider().newInstance(gatewayServices, defaultAliasService, getMasterService(gatewayServices));
}
logServiceUsage(implementation, serviceType);
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class KeystoreServiceFactory method createService.
@Override
protected Service createService(GatewayServices gatewayServices, ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String implementation) throws ServiceLifecycleException {
Service service = null;
if (shouldCreateService(implementation)) {
service = new DefaultKeystoreService();
((DefaultKeystoreService) service).setMasterService(getMasterService(gatewayServices));
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class ServiceRegistryServiceFactory method createService.
@Override
protected Service createService(GatewayServices gatewayServices, ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String implementation) throws ServiceLifecycleException {
Service service = null;
if (shouldCreateService(implementation)) {
service = new DefaultServiceRegistryService();
((DefaultServiceRegistryService) service).setCryptoService(gatewayServices.getService(ServiceType.CRYPTO_SERVICE));
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class AbstractServiceFactory method create.
@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.forName(implementation).newInstance();
logServiceUsage(implementation, serviceType);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new ServiceLifecycleException("Error while instantiating " + serviceType.getShortName() + " service implementation " + implementation, e);
}
}
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class ClusterConfigurationMonitorServiceFactory method createService.
@Override
protected Service createService(GatewayServices gatewayServices, ServiceType serviceType, GatewayConfig gatewayConfig, Map<String, String> options, String implementation) throws ServiceLifecycleException {
Service service = null;
if (shouldCreateService(implementation)) {
service = new DefaultClusterConfigurationMonitorService();
((DefaultClusterConfigurationMonitorService) service).setAliasService(getAliasService(gatewayServices));
((DefaultClusterConfigurationMonitorService) service).setKeystoreService(getKeystoreService(gatewayServices));
}
return service;
}
Aggregations