private void validateDuplicateInterceptors(InterceptionType interceptionType, List<InterceptorMetadata<I>> interceptorsList, InterceptorMetadata<I>... interceptors) { for (InterceptorMetadata interceptor : interceptors) { if (interceptorsList.contains(interceptor)) { if (interceptionType != null) { throw new InterceptorException("Duplicate interceptor class definition when binding" + interceptor + " on " + interceptionType.name()); } } } }
public Object createFor(InterceptorReference<ClassMetadata<?>> clazz) { try { return clazz.getInterceptor().getJavaClass().newInstance(); } catch (InstantiationException e) { throw new InterceptorException(e); } catch (IllegalAccessException e) { throw new InterceptorException(e); } } }
public Object proceed() throws Exception { try { return interceptionChain.invokeNextInterceptor(this); } catch (Exception e) { throw e; } catch (Throwable t) { throw new InterceptorException(t); } }
public static void executePostConstruct(Object proxy, Callable callback) { if (proxy instanceof LifecycleMixin) { LifecycleMixin lifecycleMixin = (LifecycleMixin) proxy; lifecycleMixin.lifecycle_mixin_$$_postConstruct(); } if (callback != null) { try { callback.call(); } catch (Exception e) { throw new InterceptorException(e); } } }
public static void executePredestroy(Object proxy, Callable callback) { if (proxy instanceof LifecycleMixin) { LifecycleMixin lifecycleMixin = (LifecycleMixin) proxy; lifecycleMixin.lifecycle_mixin_$$_preDestroy(); } if (callback != null) { try { callback.call(); } catch (Exception e) { throw new InterceptorException(e); } } }
public <T> T createAdvisedSubclassInstance(ClassMetadata<T> proxifiedClass, Class<?>[] constructorParameterTypes, Object[] constructorArguments) { try { Class<T> clazz = InterceptionUtils.createProxyClass(((Class<T>) proxifiedClass.getJavaClass()), true); Constructor<T> constructor = clazz.getConstructor(constructorParameterTypes); return constructor.newInstance(constructorArguments); } catch (Exception e) { throw new InterceptorException(e); } }
throw new InterceptorException(e); throw new InterceptorException("Cannot found a constructor for the proxy class: " + proxyClass + ". " + "No no-arg constructor is available, and sun.reflect.ReflectionFactory is not accessible"); try throw new InterceptorException(e);
private Object readResolve() { try { Class<?>[] parameterTypes = null; if (parameterClassNames != null) { parameterTypes = new Class<?>[parameterClassNames.length]; for (int i = 0; i<parameterClassNames.length; i++) { parameterTypes[i] = ReflectionUtils.classForName(parameterClassNames[i]); } } Class<?> declaringClass = null; if (className != null) { declaringClass = ReflectionUtils.classForName(className); } return new MethodReference(methodName, parameterTypes, declaringClass); } catch (ClassNotFoundException e) { throw new InterceptorException("Error while deserializing intercepted instance", e); } } }