private Collection<Method> getAnnotatedMethods(Class<? extends Annotation> acls) { Collection<Method> methods = new LinkedList<Method>(); addAnnotatedMethods(acls, getTarget().getClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTarget().getClass()), methods); if (getTargetClass() != getTarget().getClass()) { addAnnotatedMethods(acls, getTargetClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTargetClass()), methods); } return methods; }
private void invokeSetter(Method method, Object resource) { try { ReflectionUtil.setAccessible(method); if (method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) { method.invoke(getTarget(), resource); } else { // deal with the proxy setter method Method targetMethod = getTarget().getClass().getMethod(method.getName(), method.getParameterTypes()); targetMethod.invoke(getTarget(), resource); } } catch (IllegalAccessException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_NOT_VISIBLE", method); } catch (InvocationTargetException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (SecurityException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (NoSuchMethodException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", new Object[] {method.getName()}); } }
private Collection<Method> getAnnotatedMethods(Class<? extends Annotation> acls) { Collection<Method> methods = new LinkedList<Method>(); addAnnotatedMethods(acls, getTarget().getClass().getMethods(), methods); addAnnotatedMethods(acls, getTarget().getClass().getDeclaredMethods(), methods); if (getTargetClass() != getTarget().getClass()) { addAnnotatedMethods(acls, getTargetClass().getMethods(), methods); addAnnotatedMethods(acls, getTargetClass().getDeclaredMethods(), methods); } return methods; }
private void invokeSetter(Method method, Object resource) { try { ReflectionUtil.setAccessible(method); if (method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) { method.invoke(getTarget(), resource); } else { // deal with the proxy setter method Method targetMethod = getTarget().getClass().getMethod(method.getName(), method.getParameterTypes()); targetMethod.invoke(getTarget(), resource); } } catch (IllegalAccessException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_NOT_VISIBLE", method); } catch (InvocationTargetException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (SecurityException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (NoSuchMethodException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", new Object[] {method.getName()}); } }
private Collection<Method> getAnnotatedMethods(Class<? extends Annotation> acls) { Collection<Method> methods = new LinkedList<>(); addAnnotatedMethods(acls, getTarget().getClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTarget().getClass()), methods); if (getTargetClass() != getTarget().getClass()) { addAnnotatedMethods(acls, getTargetClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTargetClass()), methods); } return methods; }
private void invokeSetter(Method method, Object resource) { try { ReflectionUtil.setAccessible(method); if (method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) { method.invoke(getTarget(), resource); } else { // deal with the proxy setter method Method targetMethod = getTarget().getClass().getMethod(method.getName(), method.getParameterTypes()); targetMethod.invoke(getTarget(), resource); } } catch (IllegalAccessException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_NOT_VISIBLE", method); } catch (InvocationTargetException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (SecurityException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (NoSuchMethodException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", new Object[] {method.getName()}); } }
private Collection<Method> getAnnotatedMethods(Class<? extends Annotation> acls) { Collection<Method> methods = new LinkedList<>(); addAnnotatedMethods(acls, getTarget().getClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTarget().getClass()), methods); if (getTargetClass() != getTarget().getClass()) { addAnnotatedMethods(acls, getTargetClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTargetClass()), methods); } return methods; }
private void invokeSetter(Method method, Object resource) { try { ReflectionUtil.setAccessible(method); if (method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) { method.invoke(getTarget(), resource); } else { // deal with the proxy setter method Method targetMethod = getTarget().getClass().getMethod(method.getName(), method.getParameterTypes()); targetMethod.invoke(getTarget(), resource); } } catch (IllegalAccessException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_NOT_VISIBLE", method); } catch (InvocationTargetException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (SecurityException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (NoSuchMethodException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", new Object[] {method.getName()}); } }
private Collection<Method> getAnnotatedMethods(Class<? extends Annotation> acls) { Collection<Method> methods = new LinkedList<Method>(); addAnnotatedMethods(acls, getTarget().getClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTarget().getClass()), methods); if (getTargetClass() != getTarget().getClass()) { addAnnotatedMethods(acls, getTargetClass().getMethods(), methods); addAnnotatedMethods(acls, ReflectionUtil.getDeclaredMethods(getTargetClass()), methods); } return methods; }
private Method findSetterForResource(Resource res) { assert target != null; String setterName = resourceNameToSetter(res.name()); Method setterMethod = null; for (Method method : getTarget().getClass().getMethods()) { if (setterName.equals(method.getName())) { setterMethod = method; break; } } if (setterMethod != null && setterMethod.getParameterTypes().length != 1) { LOG.log(Level.WARNING, "SETTER_INJECTION_WITH_INCORRECT_TYPE", setterMethod); } return setterMethod; }
private void invokeSetter(Method method, Object resource) { try { ReflectionUtil.setAccessible(method); if (method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) { method.invoke(getTarget(), resource); } else { // deal with the proxy setter method Method targetMethod = getTarget().getClass().getMethod(method.getName(), method.getParameterTypes()); targetMethod.invoke(getTarget(), resource); } } catch (IllegalAccessException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_NOT_VISIBLE", method); } catch (InvocationTargetException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (SecurityException e) { LogUtils.log(LOG, Level.SEVERE, "INJECTION_SETTER_RAISED_EXCEPTION", e, method); } catch (NoSuchMethodException e) { LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", new Object[] {method.getName()}); } }
private Method findSetterForResource(Resource res) { assert target != null; String setterName = resourceNameToSetter(res.name()); Method setterMethod = null; for (Method method : getTarget().getClass().getMethods()) { if (setterName.equals(method.getName())) { setterMethod = method; break; } } if (setterMethod != null && setterMethod.getParameterTypes().length != 1) { LOG.log(Level.WARNING, "SETTER_INJECTION_WITH_INCORRECT_TYPE", setterMethod); } return setterMethod; }
private Method findSetterForResource(Resource res) { assert target != null; String setterName = resourceNameToSetter(res.name()); Method setterMethod = null; for (Method method : getTarget().getClass().getMethods()) { if (setterName.equals(method.getName())) { setterMethod = method; break; } } if (setterMethod != null && setterMethod.getParameterTypes().length != 1) { LOG.log(Level.WARNING, "SETTER_INJECTION_WITH_INCORRECT_TYPE", setterMethod); } return setterMethod; }
private Method findSetterForResource(Resource res) { assert target != null; String setterName = resourceNameToSetter(res.name()); Method setterMethod = null; for (Method method : getTarget().getClass().getMethods()) { if (setterName.equals(method.getName())) { setterMethod = method; break; } } if (setterMethod != null && setterMethod.getParameterTypes().length != 1) { LOG.log(Level.WARNING, "SETTER_INJECTION_WITH_INCORRECT_TYPE", setterMethod); } return setterMethod; }
private Method findSetterForResource(Resource res) { assert target != null; String setterName = resourceNameToSetter(res.name()); Method setterMethod = null; for (Method method : getTarget().getClass().getMethods()) { if (setterName.equals(method.getName())) { setterMethod = method; break; } } if (setterMethod != null && setterMethod.getParameterTypes().length != 1) { LOG.log(Level.WARNING, "SETTER_INJECTION_WITH_INCORRECT_TYPE", setterMethod); } return setterMethod; }
private void injectField(Field field, Object resource) { assert field != null; assert resource != null; boolean accessible = field.isAccessible(); try { if (field.getType().isAssignableFrom(resource.getClass())) { ReflectionUtil.setAccessible(field); field.set(ClassHelper.getRealObject(getTarget()), resource); } } catch (IllegalAccessException e) { e.printStackTrace(); LOG.severe("FAILED_TO_INJECT_FIELD"); } finally { ReflectionUtil.setAccessible(field, accessible); } }
private void injectField(Field field, Object resource) { assert field != null; assert resource != null; boolean accessible = field.isAccessible(); try { if (field.getType().isAssignableFrom(resource.getClass())) { ReflectionUtil.setAccessible(field); field.set(ClassHelper.getRealObject(getTarget()), resource); } } catch (IllegalAccessException e) { e.printStackTrace(); LOG.severe("FAILED_TO_INJECT_FIELD"); } finally { ReflectionUtil.setAccessible(field, accessible); } }
private void injectField(Field field, Object resource) { assert field != null; assert resource != null; boolean accessible = field.isAccessible(); try { if (field.getType().isAssignableFrom(resource.getClass())) { ReflectionUtil.setAccessible(field); field.set(ClassHelper.getRealObject(getTarget()), resource); } } catch (IllegalAccessException e) { e.printStackTrace(); LOG.severe("FAILED_TO_INJECT_FIELD"); } finally { ReflectionUtil.setAccessible(field, accessible); } }
private void injectField(Field field, Object resource) { assert field != null; assert resource != null; boolean accessible = field.isAccessible(); try { if (field.getType().isAssignableFrom(resource.getClass())) { ReflectionUtil.setAccessible(field); field.set(ClassHelper.getRealObject(getTarget()), resource); } } catch (IllegalAccessException e) { e.printStackTrace(); LOG.severe("FAILED_TO_INJECT_FIELD"); } finally { ReflectionUtil.setAccessible(field, accessible); } }
private void injectField(Field field, Object resource) { assert field != null; assert resource != null; boolean accessible = field.isAccessible(); try { if (field.getType().isAssignableFrom(resource.getClass())) { ReflectionUtil.setAccessible(field); field.set(ClassHelper.getRealObject(getTarget()), resource); } } catch (IllegalAccessException e) { e.printStackTrace(); LOG.severe("FAILED_TO_INJECT_FIELD"); } finally { ReflectionUtil.setAccessible(field, accessible); } }