public static T proxy()

in fractions/cdi-extensions/cdi-jaxrsapi/src/main/java/org/wildfly/swarm/cdi/jaxrsapi/deployment/ProxyBuilder.java [44:86]


    public static <T> T proxy(final Class<T> iface, WebTarget base, final ProxyConfig config) {
        if (iface.isAnnotationPresent(Path.class)) {
            Path path = iface.getAnnotation(Path.class);
            if (!path.value().equals("") && !path.value().equals("/")) {
                base = base.path(path.value());
            }
        }
        HashMap<Method, MethodInvoker> methodMap = new HashMap<Method, MethodInvoker>();
        for (Method method : iface.getMethods()) {
            // ignore the as method to allow declaration in client interfaces
            if ("as".equals(method.getName()) && Arrays.equals(method.getParameterTypes(), cClassArgArray)) {
                continue;
            }

            // Added by Ken Finnigan
            // Ignore default methods
            if (method.isDefault()) {
                continue;
            }

            MethodInvoker invoker;
            Set<String> httpMethods = IsHttpMethod.getHttpMethods(method);
            if ((httpMethods == null || httpMethods.size() == 0) && method.isAnnotationPresent(Path.class) && method.getReturnType().isInterface()) {
                invoker = new SubResourceInvoker((ResteasyWebTarget) base, method, config);
            } else {
                invoker = createClientInvoker(iface, method, (ResteasyWebTarget) base, config);
            }
            methodMap.put(method, invoker);
        }

        Class<?>[] intfs =
                {
                        iface, ResteasyClientProxy.class
                };

        ClientProxy clientProxy = new ClientProxy(methodMap, base, config);
        // this is done so that equals and hashCode work ok. Adding the proxy to a
        // Collection will cause equals and hashCode to be invoked. The Spring
        // infrastructure had some problems without this.
        clientProxy.setClazz(iface);

        return (T) Proxy.newProxyInstance(config.getLoader(), intfs, clientProxy);
    }