com.netflix.zuul.FilterFileManager Java Examples

The following examples show how to use com.netflix.zuul.FilterFileManager. 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: GroovyLoadInitListener.java    From pig with MIT License 5 votes vote down vote up
@EventListener(value = {EmbeddedServletContainerInitializedEvent.class})
public void init() {
    MonitoringHelper.initMocks();
    FilterLoader.getInstance().setCompiler(new GroovyCompiler());
    FilterFileManager.setFilenameFilter(new GroovyFileFilter());
    try {
        FilterFileManager.init(10, groovyPath);
    } catch (Exception e) {
        log.error("初始化网关Groovy 文件失败 {}", e);
    }
    log.warn("初始化网关Groovy 文件成功");
}
 
Example #2
Source File: ZuulSampleModule.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    // 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(FilterFileManager.class).asEagerSingleton();

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

    // access logger, including request ID generator
    bind(AccessLogPublisher.class).toInstance(new AccessLogPublisher("ACCESS",
            (channel, httpRequest) -> ClientRequestReceiver.getRequestFromChannel(channel).getContext().getUUID()));
}
 
Example #3
Source File: ZuulApplication.java    From spring-cloud-docker-microservice-book-code with Apache License 2.0 5 votes vote down vote up
@Override
public void run(String... args) throws Exception {
  MonitoringHelper.initMocks();
  FilterLoader.getInstance().setCompiler(new GroovyCompiler());
  try {
    FilterFileManager.setFilenameFilter(new GroovyFileFilter());

    String basePath = "D:/写书/code/microservice-gateway-zuul-filter-groovy/src/main/filters/";

    FilterFileManager.init(1, basePath + "pre", basePath + "post");
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example #4
Source File: ZuulApplication.java    From spring-cloud-docker-microservice-book-code with Apache License 2.0 5 votes vote down vote up
@Override
public void run(String... args) throws Exception {
  MonitoringHelper.initMocks();
  FilterLoader.getInstance().setCompiler(new GroovyCompiler());
  try {
    FilterFileManager.setFilenameFilter(new GroovyFileFilter());

    String basePath = "D:/写书/code/microservice-gateway-zuul-filter-groovy/src/main/filters/";

    FilterFileManager.init(1, basePath + "pre", basePath + "post");
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example #5
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()));
}