@Bean public Interceptor interceptor() { // This will barf at runtime if the weaver isn't working (probably a // good thing) return Aspects.aspectOf(Interceptor.class); }
private static Method getPerObjectAspectOf(Class<?> aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(ASPECTOF, PEROBJECT_CLASS_ARRAY); return checkAspectOf(method, aspectClass); }
private static Method getSingletonOrThreadHasAspect(Class aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(HASASPECT, EMPTY_CLASS_ARRAY); return checkHasAspect(method, aspectClass); }
/** * Return the values of the attributes * * @param executable * an instance of a class annotated by {@link Program} or by * {@link Executable} * @return the values of the attributes or an empty map if the parameter is * <code>null</code> or if the class is not annotated by * {@link Program} or by {@link Executable} */ public static Map<String, String> attributes(Object executable) { if (executable == null || !Aspects.hasAspect(PerExecutable.class, executable.getClass())) { return empty; } PerExecutable perExecutable = Aspects.aspectOf(PerExecutable.class, executable.getClass()); if (perExecutable.executable != null) { return perExecutable.executable.values(executable); } else { return empty; } }
/** * Returns true if the perthis / pertarget aspect is bound * @param aspectClass * @param perObject * @return * @throws NoAspectBoundException if not bound */ public static boolean hasAspect(Class<?> aspectClass, Object perObject) throws NoAspectBoundException { try { return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); } catch (Exception e) { return false; } }
/** * Returns true if the pertypewithin aspect is bound * @param aspectClass * @param perTypeWithin class * @return * @throws NoAspectBoundException if not bound */ public static boolean hasAspect(Class<?> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException { try { return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); } catch (Exception e) { return false; } }
/** * Returns the pertypewithin aspect * @param aspectClass * @param perTypeWithin class * @return * @throws NoAspectBoundException if no such aspect, or no aspect bound */ public static <T> T aspectOf(Class<T> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException { try { return (T) getPerTypeWithinAspectOf(aspectClass).invoke(null, new Object[]{perTypeWithin}); } catch (InvocationTargetException e) { // FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); } catch (Exception e) { throw new NoAspectBoundException(aspectClass.getName(), e); } }
/** * Returns the perthis / pertarget aspect * @param aspectClass * @param perObject * @return * @throws NoAspectBoundException if no such aspect, or no aspect bound */ public static <T> T aspectOf(Class<T> aspectClass, Object perObject) throws NoAspectBoundException { try { return (T) getPerObjectAspectOf(aspectClass).invoke(null, new Object[]{perObject}); } catch (InvocationTargetException e) { //FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); } catch (Exception e) { throw new NoAspectBoundException(aspectClass.getName(), e); } }
/** * Returns true if the perthis / pertarget aspect is bound * @param aspectClass * @param perObject * @return * @throws NoAspectBoundException if not bound */ public static boolean hasAspect(Class<?> aspectClass, Object perObject) throws NoAspectBoundException { try { return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); } catch (Exception e) { return false; } }
/** * Returns true if the pertypewithin aspect is bound * @param aspectClass * @param perTypeWithin class * @return * @throws NoAspectBoundException if not bound */ public static boolean hasAspect(Class<?> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException { try { return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); } catch (Exception e) { return false; } }
/** * Returns the pertypewithin aspect * @param aspectClass * @param perTypeWithin class * @return * @throws NoAspectBoundException if no such aspect, or no aspect bound */ public static <T> T aspectOf(Class<T> aspectClass, Class<?> perTypeWithin) throws NoAspectBoundException { try { return (T) getPerTypeWithinAspectOf(aspectClass).invoke(null, new Object[]{perTypeWithin}); } catch (InvocationTargetException e) { // FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); } catch (Exception e) { throw new NoAspectBoundException(aspectClass.getName(), e); } }
/** * Returns the perthis / pertarget aspect * @param aspectClass * @param perObject * @return * @throws NoAspectBoundException if no such aspect, or no aspect bound */ public static <T> T aspectOf(Class<T> aspectClass, Object perObject) throws NoAspectBoundException { try { return (T) getPerObjectAspectOf(aspectClass).invoke(null, new Object[]{perObject}); } catch (InvocationTargetException e) { //FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); } catch (Exception e) { throw new NoAspectBoundException(aspectClass.getName(), e); } }
@Bean public Interceptor interceptor() { // This will barf at runtime if the weaver isn't working (probably a // good thing) return Aspects.aspectOf(Interceptor.class); }
private static Method getPerTypeWithinAspectOf(Class<?> aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(ASPECTOF, PERTYPEWITHIN_CLASS_ARRAY); return checkAspectOf(method, aspectClass); }
private static Method getPerTypeWithinHasAspect(Class aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(HASASPECT, PERTYPEWITHIN_CLASS_ARRAY); return checkHasAspect(method, aspectClass); }
@Bean public Interceptor interceptor() { // This will barf at runtime if the weaver isn't working (probably a // good thing) return Aspects.aspectOf(Interceptor.class); }
private static Method getSingletonOrThreadAspectOf(Class<?> aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(ASPECTOF, EMPTY_CLASS_ARRAY); return checkAspectOf(method, aspectClass); }
private static Method getPerObjectHasAspect(Class aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(HASASPECT, PEROBJECT_CLASS_ARRAY); return checkHasAspect(method, aspectClass); }
@Bean public Interceptor interceptor() { // This will barf at runtime if the weaver isn't working (probably a // good thing) return Aspects.aspectOf(Interceptor.class); }
private static Method getPerTypeWithinAspectOf(Class<?> aspectClass) throws NoSuchMethodException { Method method = aspectClass.getDeclaredMethod(ASPECTOF, PERTYPEWITHIN_CLASS_ARRAY); return checkAspectOf(method, aspectClass); }