These are chat archives for spring-cloud/spring-cloud

23rd
Jan 2017
Bryan Perino
@bryantp
Jan 23 2017 00:14
@dsyer Having an issue assigning a request scoped bean to ResourceServerProperties
I am using the bpp, but when I create the bean, I get this error: Scope 'request' is not active for the current thread
    @Bean(name = "customResourceServerProperties")
    @Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
    @Primary
    public ResourceServerProperties resourceServerProperties() {
        return new ResourceServerProperties(this.credentials.getClientId(),
                this.credentials.getClientSecret());
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
      if(bean instanceof  ResourceServerProperties && !beanName.equals("customResourceServerProperties")){
            return replaceWithCustomResourceProperties();
        }
        return bean;
    }

    private Object replaceWithCustomResourceProperties(){
        return context.getBean("customResourceServerProperties");
    }
When I make the proxy mode be Interface, it says it can't assign an injection of ResourceServerProperties to an object of type Proxy.
Mike Liu
@mikexliu
Jan 23 2017 05:55
is there a way to link eureka-client with hystrix-dashboard?
(just curious)
Dave Syer
@dsyer
Jan 23 2017 07:16
Isn't that what Turbine does?
@bryantp you need @Lazy on that @Bean I think
Or maybe that's not it.
It's a @ConfigurationProperties, so it's quite likely it will get used on startup (when there is no request).
You'd have to provide an implementation that worked on startup, and injected the request to be used in that context, if you need something from that bean to be per-request.