Package org.springframework.beans

Examples of org.springframework.beans.DirectFieldAccessor


  @Test
  public void testParser() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/xd/integration/hadoop/config/DatasetOutboundChannelAdapterParserTests.xml");
    EventDrivenConsumer adapter = context.getBean("adapter", EventDrivenConsumer.class);
    HdfsWritingMessageHandler handler = (HdfsWritingMessageHandler) new DirectFieldAccessor(adapter).getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    assertEquals(false, handlerAccessor.getPropertyValue("autoStartup"));
    DatasetWriterFactory writerFactory = (DatasetWriterFactory) handlerAccessor.getPropertyValue("hdfsWriterFactory");
    DatasetOperations datasetOperations = (DatasetOperations) new DirectFieldAccessor(writerFactory).getPropertyValue("datasetOperations");
    assertEquals(context.getBean("datasetOperations"), datasetOperations);
    context.close();
  }
View Full Code Here


  @Test
  public void test() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/xd/integration/hadoop/config/HdfsOutboundChannelAdapterParserTests.xml");
    EventDrivenConsumer adapter = context.getBean("adapter", EventDrivenConsumer.class);
    HdfsStoreMessageHandler handler = (HdfsStoreMessageHandler) new DirectFieldAccessor(adapter).getPropertyValue("handler");
    DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
    assertEquals(false, handlerAccessor.getPropertyValue("autoStartup"));

    TextFileWriter storeWriter = (TextFileWriter) handlerAccessor.getPropertyValue("storeWriter");
    assertNotNull(storeWriter);

    Configuration configuration = (Configuration) new DirectFieldAccessor(storeWriter).getPropertyValue("configuration");
    assertEquals(context.getBean("hadoopConfiguration"), configuration);

    context.close();
  }
View Full Code Here

    }
    return Collections.EMPTY_LIST;
  }

  private Collection<?> getBindingsFromMsgBus(MessageBus messageBus) {
    DirectFieldAccessor accessor = new DirectFieldAccessor(messageBus);
    return (List<?>) accessor.getPropertyValue("bindings");
  }
View Full Code Here

    }
  }

  private ClientHttpRequestFactory getRequestFactory() {
    // InterceptingClientHttpRequestFactory doesn't let us access the underlying object
    DirectFieldAccessor f = new DirectFieldAccessor(twitter.getRestTemplate().getRequestFactory());
    Object requestFactory = f.getPropertyValue("requestFactory");
    return (ClientHttpRequestFactory) requestFactory;
  }
View Full Code Here

    return resource.getFile().getAbsolutePath()
        .contains("target" + File.separator + "test-classes");
  }

  private boolean isPublic(MethodMetadata methodMetadata) {
    int access = (Integer) new DirectFieldAccessor(methodMetadata)
        .getPropertyValue("access");

    return (access & Opcodes.ACC_PUBLIC) != 0;
  }
View Full Code Here

      return null;
    }
  }

  private HikariPool getHikariPool() {
    return (HikariPool) new DirectFieldAccessor(getDataSource())
        .getPropertyValue("pool");
  }
View Full Code Here

    this.context.register(CustomJmxDomainConfiguration.class,
        JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
    this.context.refresh();
    IntegrationMBeanExporter mbeanExporter = this.context
        .getBean(IntegrationMBeanExporter.class);
    DirectFieldAccessor dfa = new DirectFieldAccessor(mbeanExporter);
    assertEquals("foo.my", dfa.getPropertyValue("domain"));
  }
View Full Code Here

    assertCharacterEncodingFilter(filter, "US-ASCII", false);
  }

  private void assertCharacterEncodingFilter(CharacterEncodingFilter actual,
      String encoding, boolean forceEncoding) {
    DirectFieldAccessor accessor = new DirectFieldAccessor(actual);
    assertEquals("Wrong encoding", encoding, accessor.getPropertyValue("encoding"));
    assertEquals("Wrong forceEncoding flag", forceEncoding,
        accessor.getPropertyValue("forceEncoding"));
  }
View Full Code Here

    map.put(IllegalStateException.class, true);
    map.put(BarException.class, false);
    BinaryExceptionClassifier binaryExceptionClassifier = new BinaryExceptionClassifier(map, true);
    binaryExceptionClassifier.setTraverseCauses(true);
    assertTrue(binaryExceptionClassifier.classify(new RuntimeException(new FooException("Foo", new BarException()))));
    assertTrue(((Map<?, ?>) new DirectFieldAccessor(binaryExceptionClassifier).getPropertyValue("classified"))
        .containsKey(FooException.class));
  }
View Full Code Here

   * @param propertyPath The path.
   * @return The field.
   */
  public static Object getPropertyValue(Object root, String propertyPath) {
    Object value = null;
    DirectFieldAccessor accessor = new DirectFieldAccessor(root);
    String[] tokens = propertyPath.split("\\.");
    for (int i = 0; i < tokens.length; i++) {
      value = accessor.getPropertyValue(tokens[i]);
      if (value != null) {
        accessor = new DirectFieldAccessor(value);
      }
      else if (i == tokens.length - 1) {
        return null;
      }
      else {
View Full Code Here

TOP

Related Classes of org.springframework.beans.DirectFieldAccessor

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.