@Override
 public void setApplicationContext(ApplicationContext context) {
   Field field = ReflectionUtils.findField(Context.class, "applicationContext");
   field.setAccessible(true);
   ReflectionUtils.setField(field, this, context);
   Field field2 = ReflectionUtils.findField(Context.class, "coreContext");
   field2.setAccessible(true);
   ReflectionUtils.setField(field2, this, context.getParentBeanFactory());
 }
  /**
   * Invokes all {@link ResourceProcessor} instances registered for the type of the given value and
   * reference type.
   *
   * @param value must not be {@literal null}.
   * @param referenceType must not be {@literal null}.
   * @return
   */
  @SuppressWarnings("unchecked")
  public <T extends ResourceSupport> T invokeProcessorsFor(T value, ResolvableType referenceType) {

    Assert.notNull(value, "Value must not be null!");
    Assert.notNull(referenceType, "Reference type must not be null!");

    // For Resources implementations, process elements first
    if (ResourceProcessorHandlerMethodReturnValueHandler.RESOURCES_TYPE.isAssignableFrom(
        referenceType)) {

      Resources<?> resources = (Resources<?>) value;
      ResolvableType elementTargetType =
          ResolvableType.forClass(Resources.class, referenceType.getRawClass()).getGeneric(0);
      List<Object> result = new ArrayList<Object>(resources.getContent().size());

      for (Object element : resources) {

        ResolvableType elementType = ResolvableType.forClass(element.getClass());

        if (!getRawType(elementTargetType).equals(elementType.getRawClass())) {
          elementTargetType = elementType;
        }

        result.add(invokeProcessorsFor(element, elementTargetType));
      }

      ReflectionUtils.setField(
          ResourceProcessorHandlerMethodReturnValueHandler.CONTENT_FIELD, resources, result);
    }

    return (T) invokeProcessorsFor((Object) value, referenceType);
  }
  public void visit(ASTNode[] nodes, SourceUnit source) {
    List<ClassNode> classes = source.getAST().getClasses();

    AnnotationNode annotation = null;
    for (ClassNode clazz : classes) {
      annotation = findAnnotation(clazz);
      if (annotation != null) {
        break;
      }
    }

    if (annotation == null) {
      return;
    }

    int[] array = extractLineNumberArray(annotation);
    if (array != null) {
      LineNumberVisitor visitor = new LineNumberVisitor(array);
      for (ClassNode clazz : classes) {
        visitor.visitClass(clazz);
      }
    }

    String sourceName = extractSourceName(annotation);
    if (sourceName != null) {
      source.getAST().setDescription(sourceName);
      // source.name = sourceName
      Field field = ReflectionUtils.findField(SourceUnit.class, "name");
      field.setAccessible(true);
      ReflectionUtils.setField(field, source, sourceName);
    }
  }
  public void testDefaultJarSettings() throws Exception {

    Properties defaultSettings = bundleCreator.getSettings();
    Field field =
        ReflectionUtils.findField(
            AbstractConfigurableBundleCreatorTests.class, "jarSettings", Properties.class);
    ReflectionUtils.makeAccessible(field);
    ReflectionUtils.setField(field, null, defaultSettings);
    assertNotNull(defaultSettings);
    assertNotNull(bundleCreator.getRootPath());
    assertNotNull(bundleCreator.getBundleContentPattern());
    assertNotNull(bundleCreator.getManifestLocation());
  }
 private void injectValue(Field field, Object currentBean, String propName, Object propValue) {
   // Set as true for modifications
   ReflectionUtils.makeAccessible(field);
   // Update property
   ReflectionUtils.setField(field, currentBean, propValue);
   logger.debug(
       "Injection of property '"
           + propName
           + "' on "
           + currentBean.getClass().getName()
           + "."
           + field.getName());
 }
 protected final void setDate(Calendar calendar) {
   setField(dateField, persistableFragment.getPersistable(), calendar.getTime());
 }