protected BeanDefinition addDependsOn(BeanDefinition beanDefinition, String... beanNames) { return SpringUtils.addDependsOn(beanDefinition, beanNames); }
public static String defaultIfEmpty(String value, String defaultValue) { return defaultIfEmpty(value, () -> defaultValue); }
public static <T> T defaultIfNull(T value, T defaultValue) { return defaultIfNull(value, () -> defaultValue); }
public static <T> T safeGetValue(Supplier<T> valueSupplier) { return safeGetValue(valueSupplier, (T) null); }
String resolveDereferencedId(Element element) { return SpringUtils.dereferenceBean(resolveId(element)); }
/** * Registers all the provided names for given Spring {@link BeanFactory}. * * @param names {@link Set} of names and aliases to associate with the Spring {@link BeanFactory}. * @param beanFactory reference to the Spring {@link BeanFactory}. * @see org.springframework.beans.factory.BeanFactory * @throws IllegalArgumentException if {@link BeanFactory} is {@literal null}. * @throws IllegalStateException if one of the provided names is already associated with * an existing, other than given, Spring {@link BeanFactory}. * @see org.springframework.beans.factory.BeanFactory */ protected static synchronized void registerAliases(Set<String> names, BeanFactory beanFactory) { Set<String> safeNames = nullSafeSet(names); Assert.isTrue(safeNames.isEmpty() || beanFactory != null, "BeanFactory must not be null when aliases are specified"); for (String name : safeNames) { BeanFactory existingBeanFactory = BEAN_FACTORIES.putIfAbsent(name, beanFactory); Assert.isTrue(nullOrEquals(existingBeanFactory, beanFactory), String.format("BeanFactory reference already exists for key [%s]", name)); } }
@Bean BeanFactoryPostProcessor regionCompressionBeanFactoryPostProcessor() { String resolvedCompressorBeanName = resolveCompressorBeanName(); return beanFactory -> stream(nullSafeArray(beanFactory.getBeanDefinitionNames(), String.class)).forEach(beanName -> Optional.of(beanFactory.getBeanDefinition(beanName)) .filter(beanDefinition -> isTargetedRegionBean(beanName, beanDefinition, beanFactory)) .ifPresent(beanDefinition -> SpringUtils.setPropertyReference( beanDefinition, "compressor", resolvedCompressorBeanName))); }
private void assertFunctionExecutionInterfaceIsValid(String annotationType) { boolean valid = this.functionExecutionInterface != null && this.functionExecutionInterface.isInterface(); Assert.isTrue(valid, String.format("The annotation [%1$s] only applies to an interface; It is not valid for type [%2$s]", annotationType, SpringUtils.nullSafeName(this.functionExecutionInterface))); }
protected Optional<Object> getPropertyValue(BeanDefinition beanDefinition, String propertyName) { return SpringUtils.getPropertyValue(beanDefinition, propertyName); }
public static <T> T safeGetValue(Supplier<T> valueSupplier, T defaultValue) { return safeGetValue(valueSupplier, (Supplier<T>) () -> defaultValue); }
String resolveDereferencedId(Element element) { return SpringUtils.dereferenceBean(resolveId(element)); }
/** * Registers all the provided names for given Spring {@link BeanFactory}. * * @param names {@link Set} of names and aliases to associate with the Spring {@link BeanFactory}. * @param beanFactory reference to the Spring {@link BeanFactory}. * @see org.springframework.beans.factory.BeanFactory * @throws IllegalArgumentException if {@link BeanFactory} is {@literal null}. * @throws IllegalStateException if one of the provided names is already associated with * an existing, other than given, Spring {@link BeanFactory}. * @see org.springframework.beans.factory.BeanFactory */ protected static synchronized void registerAliases(Set<String> names, BeanFactory beanFactory) { Set<String> safeNames = nullSafeSet(names); Assert.isTrue(safeNames.isEmpty() || beanFactory != null, "BeanFactory must not be null when aliases are specified"); for (String name : safeNames) { BeanFactory existingBeanFactory = BEAN_FACTORIES.putIfAbsent(name, beanFactory); Assert.isTrue(nullOrEquals(existingBeanFactory, beanFactory), String.format("BeanFactory reference already exists for key [%s]", name)); } }
@Bean BeanFactoryPostProcessor regionCompressionBeanFactoryPostProcessor() { String resolvedCompressorBeanName = resolveCompressorBeanName(); return beanFactory -> stream(nullSafeArray(beanFactory.getBeanDefinitionNames(), String.class)).forEach(beanName -> Optional.of(beanFactory.getBeanDefinition(beanName)) .filter(beanDefinition -> isTargetedRegionBean(beanName, beanDefinition, beanFactory)) .ifPresent(beanDefinition -> SpringUtils.setPropertyReference( beanDefinition, "compressor", resolvedCompressorBeanName))); }
private void assertFunctionExecutionInterfaceIsValid(String annotationType) { boolean valid = this.functionExecutionInterface != null && this.functionExecutionInterface.isInterface(); Assert.isTrue(valid, String.format("The annotation [%1$s] only applies to an interface; It is not valid for type [%2$s]", annotationType, SpringUtils.nullSafeName(this.functionExecutionInterface))); }
protected Optional<Object> getPropertyValue(BeanDefinition beanDefinition, String propertyName) { return SpringUtils.getPropertyValue(beanDefinition, propertyName); }
public static <T> T safeGetValue(Supplier<T> valueSupplier) { return safeGetValue(valueSupplier, (T) null); }
public static String defaultIfEmpty(String value, String defaultValue) { return defaultIfEmpty(value, () -> defaultValue); }
protected BeanDefinition addDependsOn(BeanDefinition beanDefinition, String... beanNames) { return SpringUtils.addDependsOn(beanDefinition, beanNames); }
public static <T> T defaultIfNull(T value, T defaultValue) { return defaultIfNull(value, () -> defaultValue); }
/** * Resolves the {@link Pool} used to configure the {@link ClientCache}, {@literal DEFAULT} {@link Pool}. * * @return the resolved {@link Pool} used to configure the {@link ClientCache}, {@literal DEFAULT} {@link Pool}. * @see org.apache.geode.cache.client.PoolManager#find(String) * @see org.apache.geode.cache.client.Pool * @see #getPoolName() * @see #getPool() * @see #findPool(String) * @see #isPoolNameResolvable(String) */ Pool resolvePool() { Pool pool = getPool(); if (pool == null) { String poolName = resolvePoolName(); pool = findPool(poolName); if (pool == null && isPoolNameResolvable(poolName)) { String dereferencedPoolName = SpringUtils.dereferenceBean(poolName); PoolFactoryBean poolFactoryBean = getBeanFactory().getBean(dereferencedPoolName, PoolFactoryBean.class); return poolFactoryBean.getPool(); } } return pool; }