@Test public void testGetIncrementer_CacheByDataSource() throws Exception { DataFieldMaxValueIncrementer incrementer1 = MaxValueIncrementerFactory.getIncrementer(mysql, "MY_SEQUENCE"); DataFieldMaxValueIncrementer incrementer2 = MaxValueIncrementerFactory.getIncrementer(oracle, "MY_SEQUENCE"); assertNotSame(incrementer1, incrementer2); }
public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) { if (dataSource == null) { throw new IllegalArgumentException("DataSource must not be null"); } if (StringUtils.isBlank(incrementerName)) { throw new IllegalArgumentException("Incrementer name must not be null or blank"); } ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource); if (incrementerCache == null) { cache.put(dataSource, new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1)); if (incrementerCache == null) { incrementerCache = cache.get(dataSource); } } DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase()); if (incrementer == null) { incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource, incrementerName)); if (incrementer == null) { incrementer = incrementerCache.get(incrementerName.toUpperCase()); } } return incrementer; }
MaxValueIncrementerFactory { public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) { if (dataSource == null) { throw new IllegalArgumentException("DataSource must not be null"); } if (StringUtils.isBlank(incrementerName)) { throw new IllegalArgumentException("Incrementer name must not be null or blank"); } ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource); if (incrementerCache == null) { cache.put(dataSource, new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1)); if (incrementerCache == null) { incrementerCache = cache.get(dataSource); } } DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase()); if (incrementer == null) { incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource, incrementerName)); if (incrementer == null) { incrementer = incrementerCache.get(incrementerName.toUpperCase()); } } return incrementer; } }
MaxValueIncrementerFactory { public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) { if (dataSource == null) { throw new IllegalArgumentException("DataSource must not be null"); } if (StringUtils.isBlank(incrementerName)) { throw new IllegalArgumentException("Incrementer name must not be null or blank"); } ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource); if (incrementerCache == null) { cache.put(dataSource, new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1)); if (incrementerCache == null) { incrementerCache = cache.get(dataSource); } } DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase()); if (incrementer == null) { incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource, incrementerName)); if (incrementer == null) { incrementer = incrementerCache.get(incrementerName.toUpperCase()); } } return incrementer; } private  MaxValueIncrementerFactory(); }
MaxValueIncrementerFactory { public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) { if (dataSource == null) { throw new IllegalArgumentException("DataSource must not be null"); } if (StringUtils.isBlank(incrementerName)) { throw new IllegalArgumentException("Incrementer name must not be null or blank"); } ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource); if (incrementerCache == null) { cache.put(dataSource, new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1)); if (incrementerCache == null) { incrementerCache = cache.get(dataSource); } } DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase()); if (incrementer == null) { incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource, incrementerName)); if (incrementer == null) { incrementer = incrementerCache.get(incrementerName.toUpperCase()); } } return incrementer; } private  MaxValueIncrementerFactory(); static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName); }
MaxValueIncrementerFactory { public static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName) { if (dataSource == null) { throw new IllegalArgumentException("DataSource must not be null"); } if (StringUtils.isBlank(incrementerName)) { throw new IllegalArgumentException("Incrementer name must not be null or blank"); } ConcurrentMap<String, DataFieldMaxValueIncrementer> incrementerCache = cache.get(dataSource); if (incrementerCache == null) { cache.put(dataSource, new ConcurrentHashMap<String, DataFieldMaxValueIncrementer>(8, 0.9f, 1)); if (incrementerCache == null) { incrementerCache = cache.get(dataSource); } } DataFieldMaxValueIncrementer incrementer = incrementerCache.get(incrementerName.toUpperCase()); if (incrementer == null) { incrementer = incrementerCache.putIfAbsent(incrementerName.toUpperCase(), createIncrementer(dataSource, incrementerName)); if (incrementer == null) { incrementer = incrementerCache.get(incrementerName.toUpperCase()); } } return incrementer; } private  MaxValueIncrementerFactory(); static DataFieldMaxValueIncrementer getIncrementer(DataSource dataSource, String incrementerName); static final String PLATFORM_INCREMENTER_PREFIX; }