Package org.dozer.config

Examples of org.dozer.config.GlobalSettings


      }

      log.info("Initializing Dozer. Version: {}, Thread Name: {}",
              DozerConstants.CURRENT_VERSION, Thread.currentThread().getName());

      GlobalSettings globalSettings = GlobalSettings.getInstance();
      initialize(globalSettings);

      isInitialized = true;
    }
  }
View Full Code Here


    log.info("Initializing a new instance of dozer bean mapper.");

    // initialize any bean mapper caches. These caches are only visible to the bean mapper instance and
    // are not shared across the VM.
    GlobalSettings globalSettings = GlobalSettings.getInstance();
    cacheManager.addCache(DozerCacheType.CONVERTER_BY_DEST_TYPE.name(), globalSettings.getConverterByDestTypeCacheMaxSize());
    cacheManager.addCache(DozerCacheType.SUPER_TYPE_CHECK.name(), globalSettings.getSuperTypesCacheMaxSize());

    // stats
    statsMgr.increment(StatisticType.MAPPER_INSTANCES_COUNT);
  }
View Full Code Here

    assertFalse(instance.isInitialized());
  }

  @Test(expected=MappingException.class)
  public void testBeanisMissing() {
    GlobalSettings settings = mock(GlobalSettings.class);
    when(settings.getClassLoaderName()).thenReturn(DozerConstants.DEFAULT_CLASS_LOADER_BEAN);
    when(settings.getProxyResolverName()).thenReturn("no.such.class.Found");

    instance.initialize(settings);
    fail();
  }
View Full Code Here

    fail();
  }

  @Test(expected=MappingException.class)
  public void testBeanIsNotAssignable() {
    GlobalSettings settings = mock(GlobalSettings.class);
    when(settings.getClassLoaderName()).thenReturn("java.lang.String");
    when(settings.getProxyResolverName()).thenReturn(DozerConstants.DEFAULT_PROXY_RESOLVER_BEAN);

    instance.initialize(settings);
    fail();
  }
View Full Code Here

*/
public class GlobalSettingsTest extends AbstractDozerTest {

  @Test
  public void testLoadDefaultPropFile_Default() {
    GlobalSettings globalSettings = GlobalSettings.createNew();
    assertNotNull("loaded by name should not be null", globalSettings.getLoadedByFileName());
    assertEquals("invalid loaded by file name", DozerConstants.DEFAULT_CONFIG_FILE, globalSettings.getLoadedByFileName());
  }
View Full Code Here

  @Test
  public void testLoadDefaultPropFile_NotFound() {
    String propFileName = String.valueOf(System.currentTimeMillis());
    System.setProperty(DozerConstants.CONFIG_FILE_SYS_PROP, propFileName);
    GlobalSettings globalSettings = GlobalSettings.createNew();

    // assert all global settings equal the default values
    assertNull("loaded by file name should be null", globalSettings.getLoadedByFileName());
    assertEquals("invalid stats enabled value", DozerConstants.DEFAULT_STATISTICS_ENABLED, globalSettings.isStatisticsEnabled());
    assertEquals("invalid converter cache max size value", DozerConstants.DEFAULT_CONVERTER_BY_DEST_TYPE_CACHE_MAX_SIZE,
        globalSettings.getConverterByDestTypeCacheMaxSize());
    assertEquals("invalid super type cache max size value", DozerConstants.DEFAULT_SUPER_TYPE_CHECK_CACHE_MAX_SIZE, globalSettings
        .getSuperTypesCacheMaxSize());
    assertEquals("invalid autoregister jmx beans", DozerConstants.DEFAULT_AUTOREGISTER_JMX_BEANS, globalSettings
        .isAutoregisterJMXBeans());
    assertEquals(DozerConstants.DEFAULT_PROXY_RESOLVER_BEAN, globalSettings.getProxyResolverName());
    assertEquals(DozerConstants.DEFAULT_CLASS_LOADER_BEAN, globalSettings.getClassLoaderName());
    assertEquals(DozerConstants.DEFAULT_EL_ENABLED, globalSettings.isElEnabled());
  }
View Full Code Here

  @Test
  public void testLoadPropFile_SpecifiedViaSysProp() {
    String propFileName = "samplecustomdozer.properties";
    System.setProperty(DozerConstants.CONFIG_FILE_SYS_PROP, propFileName);

    GlobalSettings globalSettings = GlobalSettings.createNew();

    assertNotNull("loaded by name should not be null", globalSettings.getLoadedByFileName());
    assertEquals("invalid load by file name", propFileName, globalSettings.getLoadedByFileName());
    assertEquals("invalid stats enabled value", true, globalSettings.isStatisticsEnabled());
    assertEquals("invalid converter cache max size value", 25000, globalSettings.getConverterByDestTypeCacheMaxSize());
    assertEquals("invalid super type cache max size value", 10000, globalSettings.getSuperTypesCacheMaxSize());
    assertEquals("invalid autoregister jmx beans", false, globalSettings.isAutoregisterJMXBeans());
    assertEquals("org.dozer.CustomLoader", globalSettings.getClassLoaderName());
    assertEquals("org.dozer.CustomResolver", globalSettings.getProxyResolverName());
    assertEquals(true, globalSettings.isElEnabled());
  }
View Full Code Here

     *                     {@link DozerTypeConverter} in
     *
     * @param configuration dozer mapping bean configuration.
     */
    public DozerTypeConverterLoader(CamelContext camelContext, DozerBeanMapperConfiguration configuration) {
        GlobalSettings settings = GlobalSettings.getInstance();
        try {
            log.info("Configuring GlobalSettings to use Camel classloader: {}", CamelToDozerClassResolverAdapter.class.getName());
            Field field = settings.getClass().getDeclaredField("classLoaderBeanName");
            ReflectionHelper.setField(field, settings, CamelToDozerClassResolverAdapter.class.getName());
        } catch (Exception e) {
            throw new IllegalStateException("Cannot configure Dozer GlobalSettings to use CamelToDozerClassResolverAdapter as classloader due " + e.getMessage(), e);
        }

View Full Code Here

     *                     {@link DozerTypeConverter} in
     *
     * @param configuration dozer mapping bean configuration.
     */
    public DozerTypeConverterLoader(CamelContext camelContext, DozerBeanMapperConfiguration configuration) {
        GlobalSettings settings = GlobalSettings.getInstance();
        try {
            log.info("Configuring GlobalSettings to use Camel classloader: {}", CamelToDozerClassResolverAdapter.class.getName());
            Field field = settings.getClass().getDeclaredField("classLoaderBeanName");
            ReflectionHelper.setField(field, settings, CamelToDozerClassResolverAdapter.class.getName());
        } catch (Exception e) {
            throw new IllegalStateException("Cannot configure Dozer GlobalSettings to use CamelToDozerClassResolverAdapter as classloader due " + e.getMessage(), e);
        }

View Full Code Here

      }

      InitLogger.log(log, "Initializing Dozer.  Version: " + DozerConstants.CURRENT_VERSION + ", Thread Name:"
          + Thread.currentThread().getName());

      GlobalSettings globalSettings = GlobalSettings.getInstance();
      initialize(globalSettings);

      isInitialized = true;
    }
  }
View Full Code Here

TOP

Related Classes of org.dozer.config.GlobalSettings

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.