/** {@inheritDoc} */ @Override public void inject(GridResourceMethod mtd, Object target, Class<?> depCls, GridDeployment dep) throws GridException { assert dep != null; GridUserResource ann = (GridUserResource)mtd.getAnnotation(); if (mtd.getMethod().getParameterTypes().length != 1) throw new GridException("Method injection setter must have only one parameter: " + mtd.getMethod()); Class<?> rsrcCls = !ann.resourceClass().equals(Void.class) ? ann.resourceClass() : mtd.getMethod().getParameterTypes()[0]; String rsrcName = ann.resourceName(); GridResourceUtils.inject(mtd.getMethod(), target, getResource(dep, depCls, rsrcCls, rsrcName)); }
/** {@inheritDoc} */ @Override public void inject(GridResourceField field, Object target, Class<?> depCls, GridDeployment dep) throws GridException { assert dep != null; GridUserResource ann = (GridUserResource)field.getAnnotation(); assert ann != null; if (!Modifier.isTransient(field.getField().getModifiers())) { throw new GridException("@GridUserResource must only be used with 'transient' fields: " + field.getField()); } Class<?> rsrcCls = !ann.resourceClass().equals(Void.class) ? ann.resourceClass() : field.getField().getType(); String rsrcName = ann.resourceName(); GridResourceUtils.inject(field.getField(), target, getResource(dep, depCls, rsrcCls, rsrcName)); }