@Override public Injectable getInjectable(AccessibleObject ao, Parameter p, ComponentScope s) { InjectableScopePair isp = getInjectableiWithScope(ao, p, s); if (isp == null) return null; return isp.i; }
@Override public Object[] getInjectableValues(HttpContext context) { processForm(context); return super.getInjectableValues(context); } }
@Override public List<Injectable> getInjectable(List<Parameter> ps, ComponentScope s) { return getInjectable(null, ps, s); }
Parameter p = sm.getParameters().get(0); InjectableScopePair isp = ipc.getInjectableiWithScope(sm.getMethod(), p, s); if (isp != null) { if (s == ComponentScope.PerRequest && isp.cs != ComponentScope.Singleton) { singletons.put(sm.getMethod(), isp.i); } else if (ipc.isParameterTypeRegistered(p)) { for (Map.Entry<Method, Injectable<?>> e : perRequest.entrySet()) { perRequestSetters[i] = e.getKey(); perRequestSetterInjectables[i++] = AbstractHttpContextInjectable.transform(e.getValue());
Injectable i = getInjectable( p.getAnnotation().annotationType(), ic, return getInjectableWithScope( p.getAnnotation().annotationType(), ic, } else { return getInjectableWithScope( p.getAnnotation().annotationType(), ic,
private Object _construct(HttpContext httpContext) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (injectables == null) { return constructor != null ? constructor.newInstance() : nonPublicConstructor != null ? nonPublicConstructor.newInstance() : clazz.newInstance(); } else { Object[] params = new Object[injectables.size()]; int i = 0; for (AbstractHttpContextInjectable injectable : injectables) { params[i++] = (injectable != null) ? injectable.getValue(httpContext) : null; } return constructor.newInstance(params); } }
/** * Create a new instance given a list of injectable. * * @param is the list of injectable. */ public InjectableValuesProvider(List<Injectable> is) { this.is = AbstractHttpContextInjectable.transform(is); }
@Override protected InjectableValuesProvider getInjectableValuesProvider(AbstractResourceMethod abstractResourceMethod) { return new InjectableValuesProvider(processParameters(abstractResourceMethod)); }
@Override public boolean isParameterTypeRegistered(Parameter p) { if (p.getAnnotation() == null) return false; if (isAnnotationRegistered(p.getAnnotation().annotationType(), p.getClass())) return true; return isAnnotationRegistered(p.getAnnotation().annotationType(), p.getParameterType().getClass()); }
@Override public Injectable getInjectable(Parameter p, ComponentScope s) { return getInjectable(null, p, s); }
/** * Get the injectable values. * * @param context the http contest. * @return the injectable values. Each element in the object array * is a value obtained from the injectable at the list index * that is the element index. */ public Object[] getInjectableValues(HttpContext context) { final Object[] params = new Object[is.size()]; try { int index = 0; for (AbstractHttpContextInjectable i : is) { params[index++] = i.getValue(context); } return params; } catch (WebApplicationException e) { throw e; } catch (ContainerException e) { throw e; } catch (RuntimeException e) { throw new ContainerException("Exception obtaining parameters", e); } } }
final Object[] getParams(HttpContext context) { return pp.getInjectableValues(context); } }
/** * Transform a list of {@link Injectable} into a list of this class. * * @param l the list of injectable. * @return the list of this class. */ public static List<AbstractHttpContextInjectable> transform(List<Injectable> l) { List<AbstractHttpContextInjectable> al = new ArrayList<AbstractHttpContextInjectable>(l.size()); for (Injectable i : l) { al.add(transform(i)); } return al; }
@Override public InjectableScopePair getInjectableiWithScope(Parameter p, ComponentScope s) { return getInjectableiWithScope(null, p, s); }
@Override public List<Injectable> getInjectable(AccessibleObject ao, List<Parameter> ps, ComponentScope s) { List<Injectable> is = new ArrayList<Injectable>(); for (Parameter p : ps) is.add(getInjectable(ao, p, s)); return is; } }
for (Field f : perRequestFields) { try { f.set(o, perRequestFieldInjectables[i++].getValue(c)); } catch (IllegalAccessException ex) { throw new ContainerException(ex); for (Method m : perRequestSetters) { try { m.invoke(o, perRequestSetterInjectables[i++].getValue(c)); } catch (Exception ex) { throw new ContainerException(ex);
public SubLocatorRule(UriTemplate template, List<Injectable> is, List<ContainerRequestFilter> requestFilters, List<ContainerResponseFilter> responseFilters, DispatchingListener dispatchingListener, AbstractSubResourceLocator locator) { super(template); this.is = AbstractHttpContextInjectable.transform(is); this.requestFilters = requestFilters; this.responseFilters = responseFilters; this.dispatchingListener = dispatchingListener; this.locator = locator; this.m = locator.getMethod(); }
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Inject a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Context a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, InjectParam a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });