private void setParamMethods(Class<?> cls) { for (Method m : cls.getMethods()) { if (!m.getName().startsWith("set") || m.getParameterTypes().length != 1) { continue; } for (Annotation a : m.getAnnotations()) { if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) { addParamMethod(m); break; } } } Class<?>[] interfaces = cls.getInterfaces(); for (Class<?> i : interfaces) { setParamMethods(i); } }
@Override public boolean contextsAvailable() { // avoid re-injecting the contexts if the root acts as subresource return super.contextsAvailable() && (isRoot() || parent != null); }
protected BeanResourceInfo(Class<?> resourceClass, Class<?> serviceClass, boolean isRoot, boolean checkContexts, Bus bus) { super(resourceClass, serviceClass, isRoot, checkContexts, bus); if (checkContexts && resourceClass != null) { setParamField(serviceClass); setParamMethods(serviceClass); } }
Message message) { if (bri.isSingleton() && (!bri.getParameterMethods().isEmpty() || !bri.getParameterFields().isEmpty())) { LOG.fine("Injecting request parameters into singleton resource is not thread-safe"); for (Method m : bri.getParameterMethods()) { Parameter p = ResourceUtils.getParameter(0, m.getAnnotations(), m.getParameterTypes()[0]); for (Field f : bri.getParameterFields()) { Parameter p = ResourceUtils.getParameter(0, f.getAnnotations(), f.getType());
public void initBeanParamInfo(ServerProviderFactory factory) { if (factory != null) { Set<OperationResourceInfo> oris = getMethodDispatcher().getOperationResourceInfos(); for (OperationResourceInfo ori : oris) { List<Parameter> params = ori.getParameters(); for (Parameter param : params) { if (param.getType() == ParameterType.BEAN) { Class<?> cls = ori.getMethodToInvoke().getParameterTypes()[param.getIndex()]; BeanParamInfo bpi = new BeanParamInfo(cls, getBus()); factory.addBeanParamInfo(bpi); } } } List<Method> methods = super.getParameterMethods(); for (Method m : methods) { if (m.getAnnotation(BeanParam.class) != null) { BeanParamInfo bpi = new BeanParamInfo(m.getParameterTypes()[0], getBus()); factory.addBeanParamInfo(bpi); } } List<Field> fields = super.getParameterFields(); for (Field f : fields) { if (f.getAnnotation(BeanParam.class) != null) { BeanParamInfo bpi = new BeanParamInfo(f.getType(), getBus()); factory.addBeanParamInfo(bpi); } } } }
private void setParamField(Class<?> cls) { if (Object.class == cls || cls == null) { return; } for (Field f : cls.getDeclaredFields()) { for (Annotation a : f.getAnnotations()) { if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) { if (paramFields == null) { paramFields = new ArrayList<Field>(); } paramsAvailable = true; paramFields.add(f); } } } setParamField(cls.getSuperclass()); }
@Override public void clearThreadLocalProxies() { super.clearThreadLocalProxies(); if (!injectedSubInstances.isEmpty()) { for (ClassResourceInfo sub : subResources.values()) { if (sub != this) { sub.clearThreadLocalProxies(); } } } }
Message message) { if (bri.isSingleton() && (!bri.getParameterMethods().isEmpty() || !bri.getParameterFields().isEmpty())) { LOG.fine("Injecting request parameters into singleton resource is not thread-safe"); for (Method m : bri.getParameterMethods()) { Parameter p = ResourceUtils.getParameter(0, m.getAnnotations(), m.getParameterTypes()[0]); for (Field f : bri.getParameterFields()) { Parameter p = ResourceUtils.getParameter(0, f.getAnnotations(), f.getType());
public void initBeanParamInfo(ProviderFactory factory) { Set<OperationResourceInfo> oris = getMethodDispatcher().getOperationResourceInfos(); for (OperationResourceInfo ori : oris) { List<Parameter> params = ori.getParameters(); for (Parameter param : params) { if (param.getType() == ParameterType.BEAN) { Class<?> cls = ori.getMethodToInvoke().getParameterTypes()[param.getIndex()]; BeanParamInfo bpi = new BeanParamInfo(cls, getBus()); factory.addBeanParamInfo(bpi); } } } List<Method> methods = super.getParameterMethods(); for (Method m : methods) { if (m.getAnnotation(BeanParam.class) != null) { BeanParamInfo bpi = new BeanParamInfo(m.getParameterTypes()[0], getBus()); factory.addBeanParamInfo(bpi); } } List<Field> fields = super.getParameterFields(); for (Field f : fields) { if (f.getAnnotation(BeanParam.class) != null) { BeanParamInfo bpi = new BeanParamInfo(f.getType(), getBus()); factory.addBeanParamInfo(bpi); } } } }
private void setParamField(Class<?> cls) { if (Object.class == cls || cls == null) { return; } for (Field f : ReflectionUtil.getDeclaredFields(cls)) { for (Annotation a : f.getAnnotations()) { if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) { if (paramFields == null) { paramFields = new ArrayList<>(); } paramsAvailable = true; paramFields.add(f); } } } setParamField(cls.getSuperclass()); }
protected BeanResourceInfo(Class<?> resourceClass, Class<?> serviceClass, boolean isRoot, boolean checkContexts, Bus bus) { super(resourceClass, serviceClass, isRoot, checkContexts, bus); if (checkContexts && resourceClass != null) { setParamField(serviceClass); setParamMethods(serviceClass); } }
private void setParamMethods(Class<?> cls) { for (Method m : cls.getMethods()) { if (!m.getName().startsWith("set") || m.getParameterTypes().length != 1) { continue; } for (Annotation a : m.getAnnotations()) { if (AnnotationUtils.isParamAnnotationClass(a.annotationType())) { addParamMethod(m); break; } } } Class<?>[] interfaces = cls.getInterfaces(); for (Class<?> i : interfaces) { setParamMethods(i); } }
@Override public boolean contextsAvailable() { // avoid re-injecting the contexts if the root acts as subresource return super.contextsAvailable() && (isRoot() || parent != null); }