com.netflix.zuul.filters.FilterRegistry Java Examples

The following examples show how to use com.netflix.zuul.filters.FilterRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterceptorFileService.java    From heimdall with Apache License 2.0 6 votes vote down vote up
/**
 * Removes a {@link Interceptor} file.
 *
 * @param interceptor {@link InterceptorFileDTO}
 */
public void removeFileInterceptor(InterceptorFileDTO interceptor) {

    File interceptorFile = new File(interceptor.getPath());

    if (interceptorFile.exists() && interceptorFile.isFile()) {
        String filter = interceptorFile.getAbsolutePath() + interceptorFile.getName();
        if (interceptorFile.delete()) {
            log.info("File - Removing File Filter: {}", interceptorFile.getAbsolutePath());
            FilterRegistry.instance().remove(filter);
            clearLoaderCache();
            log.debug("FilterRegistry - Removing File Filter {}", filter);
        } else {
            log.warn("Not possible to remove File: {} with Interceptor ID: {}", interceptorFile.getAbsolutePath(), interceptor.getId());
        }
    }
}
 
Example #2
Source File: ZuulSampleModule.java    From zuul with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    try {
      ConfigurationManager.loadCascadedPropertiesFromResources("application");
    } catch (Exception ex) {
      throw new RuntimeException("Error loading configuration: " + ex.getMessage(), ex);
    }

    bind(AbstractConfiguration.class).toInstance(ConfigurationManager.getConfigInstance());
    bind(DynamicCodeCompiler.class).to(GroovyCompiler.class);
    bind(FilenameFilter.class).to(GroovyFileFilter.class);

    install(new EurekaModule());

    // sample specific bindings
    bind(BaseServerStartup.class).to(SampleServerStartup.class);

    // use provided basic netty origin manager
    bind(OriginManager.class).to(BasicNettyOriginManager.class);

    // zuul filter loading
    install(new ZuulFiltersModule());
    bind(FilterLoader.class).to(DynamicFilterLoader.class);
    bind(FilterRegistry.class).to(MutableFilterRegistry.class);
    bind(FilterFileManager.class).asEagerSingleton();


    // general server bindings
    bind(ServerStatusManager.class); // health/discovery status
    bind(SessionContextDecorator.class).to(ZuulSessionContextDecorator.class); // decorate new sessions when requests come in
    bind(Registry.class).to(DefaultRegistry.class); // atlas metrics registry
    bind(RequestCompleteHandler.class).to(BasicRequestCompleteHandler.class); // metrics post-request completion
    bind(RequestMetricsPublisher.class).to(BasicRequestMetricsPublisher.class); // timings publisher

    // access logger, including request ID generator
    bind(AccessLogPublisher.class).toInstance(new AccessLogPublisher("ACCESS",
            (channel, httpRequest) -> ClientRequestReceiver.getRequestFromChannel(channel).getContext().getUUID()));
}
 
Example #3
Source File: DynamicFilterLoader.java    From zuul with Apache License 2.0 5 votes vote down vote up
@Inject
public DynamicFilterLoader(
        FilterRegistry filterRegistry,
        DynamicCodeCompiler compiler,
        FilterFactory filterFactory) {
    this.filterRegistry = filterRegistry;
    this.compiler = compiler;
    this.filterFactory = filterFactory;
}
 
Example #4
Source File: FiltersRegisteringService.java    From Sentinel with Apache License 2.0 4 votes vote down vote up
@Inject
public FiltersRegisteringService(FilterRegistry filterRegistry, Set<ZuulFilter> filters) {
    this.filters = new ArrayList<>(filters);
    this.filterRegistry = filterRegistry;
}