use of org.apache.knox.gateway.services.Service in project knox by apache.
the class CryptoServiceFactory 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 DefaultCryptoService();
((DefaultCryptoService) service).setKeystoreService(getKeystoreService(gatewayServices));
((DefaultCryptoService) service).setAliasService(getAliasService(gatewayServices));
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class SslServiceFactory 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 JettySSLService();
((JettySSLService) service).setKeystoreService(getKeystoreService(gatewayServices));
((JettySSLService) service).setAliasService(getAliasService(gatewayServices));
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class TokenServiceFactory 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 DefaultTokenAuthorityService();
((DefaultTokenAuthorityService) service).setKeystoreService(getKeystoreService(gatewayServices));
((DefaultTokenAuthorityService) service).setAliasService(getAliasService(gatewayServices));
}
return service;
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class ServiceFactoryTest method shouldReturnCustomImplementation.
private void shouldReturnCustomImplementation(AbstractServiceFactory serviceFactory, ServiceType matchingServiceType) throws Exception {
final Service service = serviceFactory.create(gatewayServices, matchingServiceType, null, null, "org.apache.knox.gateway.services.TestService");
assertTrue(service instanceof TestService);
}
use of org.apache.knox.gateway.services.Service in project knox by apache.
the class ServiceDiscoveryFactory method get.
public static ServiceDiscovery get(String type, Service... gatewayServices) {
ServiceDiscovery sd = null;
// Look up the available ServiceDiscovery types
ServiceLoader<ServiceDiscoveryType> loader = ServiceLoader.load(ServiceDiscoveryType.class);
for (ServiceDiscoveryType sdt : loader) {
if (sdt.getType().equalsIgnoreCase(type)) {
try {
ServiceDiscovery instance = sdt.newInstance();
// (is this necessary?)
if (instance.getType().equalsIgnoreCase(type)) {
sd = instance;
// Inject any gateway services that were specified, and which are referenced in the impl
if (gatewayServices != null && gatewayServices.length > 0) {
for (Field field : sd.getClass().getDeclaredFields()) {
if (field.getDeclaredAnnotation(GatewayService.class) != null) {
for (Service s : gatewayServices) {
if (s != null) {
if (field.getType().isAssignableFrom(s.getClass())) {
field.setAccessible(true);
field.set(sd, s);
}
}
}
}
}
}
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return sd;
}
Aggregations