Package com.sun.jersey.spi.inject

Examples of com.sun.jersey.spi.inject.Injectable


       
        ComponentContext ic = new AnnotatedContext(p.getAnnotations());
       
        if (s == ComponentScope.PerRequest) {
            // Find a per request injectable with Parameter
            Injectable i = getInjectable(p.getAnnotation().annotationType(), ic, p.getAnnotation(),
                    p, ComponentScope.PerRequest);
            if (i != null) return i;

            // Find a per request, undefined or singleton injectable with parameter Type
            return getInjectable(
View Full Code Here


                if (getFieldValue(t, f) != null) continue;

                aoc.setAccesibleObject(f);
                final Annotation[] as = f.getAnnotations();
                for (Annotation a : as) {
                    Injectable i = ipc.getInjectable(
                            a.annotationType(), aoc, a, f.getGenericType(),
                            ComponentScope.UNDEFINED_SINGLETON);
                    if (i != null) {
                        setFieldValue(t, f, i.getValue());
                    }
                }

            }
            oClass = oClass.getSuperclass();
        }

        MethodList ml = new MethodList(c.getMethods());
        for (AnnotatedMethod m : ml.
                hasNotMetaAnnotation(HttpMethod.class).
                hasNotAnnotation(Path.class).
                hasNumParams(1).
                hasReturnType(void.class).
                nameStartsWith("set")) {
            final Annotation[] as = m.getAnnotations();
            aoc.setAccesibleObject(m.getMethod(), as);
            final Type gpt = m.getGenericParameterTypes()[0];
            for (Annotation a : as) {
                Injectable i = ipc.getInjectable(
                        a.annotationType(), aoc, a, gpt,
                        ComponentScope.UNDEFINED_SINGLETON);
                if (i != null) {
                    setMethodValue(t, m, i.getValue());
                }
            }
        }
    }
View Full Code Here

            int ps = con.getParameterTypes().length;
            for (int p = 0; p < ps; p++) {
                Type pgtype = con.getGenericParameterTypes()[p];
                Annotation[] as = con.getParameterAnnotations()[p];
                aoc.setAnnotations(as);
                Injectable i = null;
                for (Annotation a : as) {
                    i = ipc.getInjectable(
                            a.annotationType(), aoc, a, pgtype,
                            ComponentScope.UNDEFINED_SINGLETON);
                }
View Full Code Here

            }
           
            public Injectable getInjectable(ComponentContext ic, Context a, Type c) {
                final Object o = m.get(c);
                if (o != null) {
                    return new Injectable() {
                        public Object getValue() {
                            return o;
                        }
                    };
                } else
View Full Code Here

                if (e == null)
                    return null;
                is.add(new FormParamInjectable(e, !p.isEncoded()));
               
            } else {
                Injectable injectable = sipc.getInjectable(p, ComponentScope.PerRequest);
                if (injectable == null)
                    return null;
                is.add(injectable);
            }
        }
View Full Code Here

                return null;

            // Otherwise create the entity injectable
            for (int i = 0; i < is.size(); i++) {
                if (is.get(i) == null) {
                    Injectable ij = processEntityParameter(method,
                        method.getParameters().get(i),
                        method.getMethod().getParameterAnnotations()[i],
                        requireNoEntityParameter);
                    is.set(i, ij);
                    break;
View Full Code Here

                    is.add(new DispositionParamInjectable(p));
                } else {
                    is.add(new MultipartFormParamInjectable(mbws, p));
                }
            } else {
                Injectable injectable = sipc.getInjectable(p, ComponentScope.PerRequest);
                is.add(injectable);
            }
        }
        return is;
    }   
View Full Code Here

                    is.add(new FormEntityInjectable(p.getParameterClass(),
                            p.getParameterType(), p.getAnnotations()));
                } else
                    is.add(null);
            } else {
                Injectable injectable = getInjectableProviderContext().
                        getInjectable(p, ComponentScope.PerRequest);
                is.add(injectable);
            }
        }
        return is;
View Full Code Here

        if (Collections.frequency(is, null) == 1) {
            final int i = is.lastIndexOf(null);
            final Parameter parameter = method.getParameters().get(i);
            if (Parameter.Source.UNKNOWN == parameter.getSource()) {
                final Injectable ij = processEntityParameter(
                    parameter,
                    method.getMethod().getParameterAnnotations()[i]);
                is.set(i, ij);
            }
        }
View Full Code Here

                aoc.setAccesibleObject(f);
                final Annotation[] as = f.getAnnotations();
                boolean missingDependency = false;
                for (Annotation a : as) {
                    Injectable i = ipc.getInjectable(
                            a.annotationType(), aoc, a, f.getGenericType(),
                            ComponentScope.UNDEFINED_SINGLETON);
                    if (i != null) {
                        missingDependency = false;
                        setFieldValue(t, f, i.getValue());
                        break;
                    } else if (ipc.isAnnotationRegistered(a.annotationType(), f.getGenericType().getClass())) {
                        missingDependency = true;
                    }
                }

                if (missingDependency) {
                    Errors.missingDependency(f);
                }

            }
            oClass = oClass.getSuperclass();
        }

        MethodList ml = new MethodList(c.getMethods());
        int methodIndex = 0;
        for (AnnotatedMethod m : ml.
                hasNotMetaAnnotation(HttpMethod.class).
                hasNotAnnotation(Path.class).
                hasNumParams(1).
                hasReturnType(void.class).
                nameStartsWith("set")) {
            final Annotation[] as = m.getAnnotations();
            aoc.setAccesibleObject(m.getMethod(), as);
            final Type gpt = m.getGenericParameterTypes()[0];

            boolean missingDependency = false;
            for (Annotation a : as) {
                Injectable i = ipc.getInjectable(
                        a.annotationType(), aoc, a, gpt,
                        ComponentScope.UNDEFINED_SINGLETON);
                if (i != null) {
                    missingDependency = false;
                    setMethodValue(t, m, i.getValue());
                    break;
                } else if (ipc.isAnnotationRegistered(a.annotationType(), gpt.getClass())) {
                    missingDependency = true;
                }
            }
View Full Code Here

TOP

Related Classes of com.sun.jersey.spi.inject.Injectable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.