Java Code Examples for org.springframework.aop.framework.AopProxyUtils#getSingletonTarget()
The following examples show how to use
org.springframework.aop.framework.AopProxyUtils#getSingletonTarget() .
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: BeanValidationPostProcessor.java From spring-analysis-note with MIT License | 6 votes |
/** * Perform validation of the given bean. * @param bean the bean instance to validate * @see javax.validation.Validator#validate */ protected void doValidate(Object bean) { Assert.state(this.validator != null, "No Validator set"); Object objectToValidate = AopProxyUtils.getSingletonTarget(bean); if (objectToValidate == null) { objectToValidate = bean; } Set<ConstraintViolation<Object>> result = this.validator.validate(objectToValidate); if (!result.isEmpty()) { StringBuilder sb = new StringBuilder("Bean state is invalid: "); for (Iterator<ConstraintViolation<Object>> it = result.iterator(); it.hasNext();) { ConstraintViolation<Object> violation = it.next(); sb.append(violation.getPropertyPath()).append(" - ").append(violation.getMessage()); if (it.hasNext()) { sb.append("; "); } } throw new BeanInitializationException(sb.toString()); } }
Example 2
Source File: BeanValidationPostProcessor.java From java-technology-stack with MIT License | 6 votes |
/** * Perform validation of the given bean. * @param bean the bean instance to validate * @see javax.validation.Validator#validate */ protected void doValidate(Object bean) { Assert.state(this.validator != null, "No Validator set"); Object objectToValidate = AopProxyUtils.getSingletonTarget(bean); if (objectToValidate == null) { objectToValidate = bean; } Set<ConstraintViolation<Object>> result = this.validator.validate(objectToValidate); if (!result.isEmpty()) { StringBuilder sb = new StringBuilder("Bean state is invalid: "); for (Iterator<ConstraintViolation<Object>> it = result.iterator(); it.hasNext();) { ConstraintViolation<Object> violation = it.next(); sb.append(violation.getPropertyPath()).append(" - ").append(violation.getMessage()); if (it.hasNext()) { sb.append("; "); } } throw new BeanInitializationException(sb.toString()); } }
Example 3
Source File: AbstractApplicationEventMulticaster.java From spring-analysis-note with MIT License | 5 votes |
@Override public void addApplicationListener(ApplicationListener<?> listener) { synchronized (this.retrievalMutex) { // Explicitly remove target for a proxy, if registered already, // in order to avoid double invocations of the same listener. Object singletonTarget = AopProxyUtils.getSingletonTarget(listener); if (singletonTarget instanceof ApplicationListener) { this.defaultRetriever.applicationListeners.remove(singletonTarget); } this.defaultRetriever.applicationListeners.add(listener); this.retrieverCache.clear(); } }
Example 4
Source File: ApiRequestHandlerProvider.java From swagger-more with Apache License 2.0 | 5 votes |
private BiFunction<List<HandlerMethod>, ? super ServiceBean, List<HandlerMethod>> toMappingEntries() { return (list, bean) -> { Object object = AopUtils.isAopProxy(bean.getRef()) ? AopProxyUtils.getSingletonTarget(bean.getRef()) : bean.getRef(); list.addAll(Arrays.stream(bean.getInterfaceClass().getDeclaredMethods()) .filter(method -> !Modifier.isStatic(method.getModifiers())) .filter(method -> AnnotatedElementUtils.hasAnnotation(method, ApiMethod.class)) .map(method -> new HandlerMethod(object, method)) .collect(Collectors.toList())); return list; }; }
Example 5
Source File: AbstractApplicationEventMulticaster.java From java-technology-stack with MIT License | 5 votes |
@Override public void addApplicationListener(ApplicationListener<?> listener) { synchronized (this.retrievalMutex) { // Explicitly remove target for a proxy, if registered already, // in order to avoid double invocations of the same listener. Object singletonTarget = AopProxyUtils.getSingletonTarget(listener); if (singletonTarget instanceof ApplicationListener) { this.defaultRetriever.applicationListeners.remove(singletonTarget); } this.defaultRetriever.applicationListeners.add(listener); this.retrieverCache.clear(); } }
Example 6
Source File: AbstractApplicationEventMulticaster.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void addApplicationListener(ApplicationListener<?> listener) { synchronized (this.retrievalMutex) { // Explicitly remove target for a proxy, if registered already, // in order to avoid double invocations of the same listener. Object singletonTarget = AopProxyUtils.getSingletonTarget(listener); if (singletonTarget instanceof ApplicationListener) { this.defaultRetriever.applicationListeners.remove(singletonTarget); } this.defaultRetriever.applicationListeners.add(listener); this.retrieverCache.clear(); } }