/** * Computes the target classloader to place the proxy in based on the used dependencies. * * @throws InvalidProxyDescriptionException * if no fitting classloader can be located */ private void computeTargetClassLoader() throws InvalidProxyDescriptionException { // Collect all dependencies of the proxy class HashSet<ClassLoader> dependencies = new HashSet<ClassLoader>(); dependencies.add(getSuperClass().getClassLoader()); for (Class<?> interf : getImplementedInterfaces()) { dependencies.add(interf.getClassLoader()); } for (MethodBuildPlanImpl meth : getMethods()) { dependencies.add(meth.getReturnType().getClassLoader()); for (Class<?> type : meth.getParameterTypes()) { dependencies.add(type.getClassLoader()); } } targetClassLoader = getLowestClassLoader(dependencies); }
/** * Check for method overwriting. Returns true if every of the following condition holds: a) * the names of the methods are equal b) both methods take the same number of arguments c) * the arguemnt types match exactly d) the return type of the method represented by this * build plan is assignable to the return type of the given other method * * @param otherMethod * the method to check * @return true if the method described in this plan overrides the given method */ private boolean checkMethodOverriding(Method otherMethod) { if (!otherMethod.getReturnType().isAssignableFrom(this.returnType)) { return false; } Class<?>[] parameterTypes = otherMethod.getParameterTypes(); return isSignatureEqual(otherMethod.getName(), Arrays.asList(parameterTypes)); }
MethodBuildPlanImpl methodPlan = new MethodBuildPlanImpl(); try { methodPlan.targetMethod = method;
MethodBuildPlanImpl methodPlan = MethodBuildPlanImpl.create(method, context); if (methodPlan != null) { plan.methods.add(methodPlan);
MethodBuildPlanImpl first = methods.get(i); MethodBuildPlanImpl second = methods.get(j); if (first.isSignatureEqual(second.getMethodName(), second.getParameterTypes())) { InvalidProxyDescriptionException.throwException("The method %s%s occurs multiple times!", second.getMethodName(), second.getParameterTypes().toArray(new Class<?>[0]));