use of org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteStepProcessor in project knox by apache.
the class UrlRewriteStepProcessorHolder method initialize.
@Override
@SuppressWarnings("unchecked")
public void initialize(UrlRewriteEnvironment environment, UrlRewriteStepDescriptor descriptor) throws Exception {
UrlRewriteStepProcessor processor = UrlRewriteStepProcessorFactory.create(descriptor);
processor.initialize(environment, descriptor);
initialize(environment, descriptor, processor);
}
use of org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteStepProcessor in project knox by apache.
the class UrlRewriteStepProcessorFactory method loadStepProcessors.
private static Map<Class<? extends UrlRewriteStepDescriptor>, Map<String, Class<? extends UrlRewriteStepProcessor>>> loadStepProcessors() {
Map<Class<? extends UrlRewriteStepDescriptor>, Map<String, Class<? extends UrlRewriteStepProcessor>>> descriptorMap = new HashMap<>();
ServiceLoader<UrlRewriteStepProcessor> processors = ServiceLoader.load(UrlRewriteStepProcessor.class);
for (UrlRewriteStepProcessor processor : processors) {
Class<? extends UrlRewriteStepDescriptor> descriptorInterface = getDescriptorInterface(processor);
Map<String, Class<? extends UrlRewriteStepProcessor>> typeMap = descriptorMap.get(descriptorInterface);
if (typeMap == null) {
typeMap = new HashMap<>();
descriptorMap.put(descriptorInterface, typeMap);
}
String processorType = processor.getType();
typeMap.put(processorType, processor.getClass());
}
return descriptorMap;
}
use of org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteStepProcessor in project knox by apache.
the class UrlRewriteStepProcessorFactory method create.
public static UrlRewriteStepProcessor create(UrlRewriteStepDescriptor descriptor) throws IllegalAccessException, InstantiationException {
UrlRewriteStepProcessor processor;
Map<String, Class<? extends UrlRewriteStepProcessor>> typeMap;
typeMap = MAP.get(descriptor.getClass());
if (typeMap == null) {
Class<? extends UrlRewriteStepDescriptor> descriptorInterface = getDescriptorInterface(descriptor);
typeMap = MAP.get(descriptorInterface);
}
if (typeMap == null) {
throw new IllegalArgumentException(descriptor.getClass().getName());
} else {
String type = descriptor.type();
Class<? extends UrlRewriteStepProcessor> processorClass = typeMap.get(type);
if (processorClass == null) {
throw new IllegalArgumentException(type);
} else {
processor = processorClass.newInstance();
}
}
return processor;
}
Aggregations