Java Code Examples for org.springframework.cloud.util.ProxyUtils#getTargetObject()
The following examples show how to use
org.springframework.cloud.util.ProxyUtils#getTargetObject() .
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: DiscoveryClientConfig.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Bean(destroyMethod = "shutdown") @RefreshScope public ApimlDiscoveryClient eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, EurekaInstanceConfig instance, @Autowired(required = false) HealthCheckHandler healthCheckHandler ) { ApplicationInfoManager appManager; if (AopUtils.isAopProxy(manager)) { appManager = ProxyUtils.getTargetObject(manager); } else { appManager = manager; } final ApimlDiscoveryClient discoveryClientClient = new ApimlDiscoveryClient(appManager, config, this.optionalArgs, this.context); discoveryClientClient.registerHealthCheck(healthCheckHandler); discoveryClientClient.registerEventListener(event -> { if (event instanceof CacheRefreshedEvent) { refreshableRouteLocators.forEach(RefreshableRouteLocator::refresh); zuulHandlerMapping.setDirty(true); } }); return discoveryClientClient; }
Example 2
Source File: DiscoveryClientTestConfig.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Bean(destroyMethod = "shutdown") @RefreshScope public ApimlDiscoveryClientStub eurekaClient(ApplicationInfoManager manager, EurekaClientConfig config, EurekaInstanceConfig instance, @Autowired(required = false) HealthCheckHandler healthCheckHandler, ApplicationRegistry applicationRegistry ) { ApplicationInfoManager appManager; if (AopUtils.isAopProxy(manager)) { appManager = ProxyUtils.getTargetObject(manager); } else { appManager = manager; } final ApimlDiscoveryClientStub discoveryClient = new ApimlDiscoveryClientStub(appManager, config, this.optionalArgs, this.context, applicationRegistry); discoveryClient.registerHealthCheck(healthCheckHandler); discoveryClient.registerEventListener(event -> { if (event instanceof CacheRefreshedEvent) { refreshableRouteLocators.forEach(RefreshableRouteLocator::refresh); zuulHandlerMapping.setDirty(true); } }); return discoveryClient; }
Example 3
Source File: ConfigurationPropertiesDestructionRebindingHelper.java From spring-cloud-formula with Apache License 2.0 | 5 votes |
@Override public void postProcessBeforeDestruction(Object bean, String name) throws BeansException { if (environment == null) { return; } Object target = bean; if (AopUtils.isAopProxy(bean)) { target = ProxyUtils.getTargetObject(target); } if (AnnotationUtils.findAnnotation(target.getClass(), ConfigurationProperties.class) == null) { return; } try { target.getClass().getConstructor(); } catch (NoSuchMethodException e) { logger.debug("can not found default constructor, skip it"); return; } try { ConfigurationProperties annotation = AnnotationUtils.findAnnotation( target.getClass(), ConfigurationProperties.class); String prefix = annotation.prefix(); Object result = Binder.get(environment).bind(prefix, (Class) target.getClass()).orElseCreate(target.getClass()); BeanUtils.copyProperties(result, target); } catch (Throwable t) { logger.warn("error while process destruction bean with name: {}", name, t); } }
Example 4
Source File: TracingFeignClient.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
TracingFeignClient(HttpTracing httpTracing, Client delegate) { this.currentTraceContext = httpTracing.tracing().currentTraceContext(); this.handler = HttpClientHandler.create(httpTracing); Client delegateTarget = ProxyUtils.getTargetObject(delegate); this.delegate = delegateTarget instanceof TracingFeignClient ? ((TracingFeignClient) delegateTarget).delegate : delegateTarget; }