List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:com.dianwoba.redcliff.blink.config.MybatisConfig.java
@Bean(name = "aSqlSessionFactory") public SqlSessionFactory sqlSessionFactory(@Qualifier("aDataSource") DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource);//from ww w . j a va 2 s .c o m factory.setVfs(SpringBootVFS.class); if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } factory.setConfiguration(properties.getConfiguration()); if (!ObjectUtils.isEmpty(this.interceptors)) { factory.setPlugins(this.interceptors); } if (this.databaseIdProvider != null) { factory.setDatabaseIdProvider(this.databaseIdProvider); } if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); } if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) { factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); } if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { factory.setMapperLocations(this.properties.resolveMapperLocations()); } return factory.getObject(); }
From source file:org.synyx.hades.dao.config.DaoContext.java
@Override protected String getDaoImplPostfix() { String daoImplPostfix = getElement().getAttribute(DAO_IMPL_POSTFIX); return StringUtils.hasLength(daoImplPostfix) ? daoImplPostfix : parent.getDaoImplPostfix(); }
From source file:com.github.springtestdbunit.SingleTransactionTestExecutionListener.java
@SuppressWarnings("serial") @Override/* www . ja v a 2s .co m*/ public void beforeTestClass(TestContext testContext) throws Exception { super.prepareTestInstance(testContext); final Class<?> testClass = testContext.getTestClass(); TransactionAttribute transactionAttribute = annotationParser.parseTransactionAnnotation(testClass); TransactionDefinition transactionDefinition = null; if (transactionAttribute != null) { transactionDefinition = new DelegatingTransactionAttribute(transactionAttribute) { public String getName() { return testClass.getName(); } }; } if (transactionDefinition != null) { if (logger.isDebugEnabled()) { logger.debug("Explicit transaction definition [" + transactionDefinition + "] found for test context [" + testContext + "]"); } String qualifier = transactionAttribute.getQualifier(); PlatformTransactionManager tm; if (StringUtils.hasLength(qualifier)) { // Use autowire-capable factory in order to support extended qualifier matching // (only exposed on the internal BeanFactory, not on the ApplicationContext). BeanFactory bf = testContext.getApplicationContext().getAutowireCapableBeanFactory(); tm = TransactionAspectUtils.getTransactionManager(bf, qualifier); } else { tm = getTransactionManager(testContext); } transactionContext = new TransactionContext(tm, transactionDefinition); startNewTransaction(testContext, transactionContext); logger.debug("Started transaction. Setting up database"); runner.beforeTestMethod(new DbUnitTestContextAdapter(testContext)); } }
From source file:io.syndesis.inspector.DataMapperClassInspector.java
private String prependPrefix(String prefix, String name) { return StringUtils.hasLength(prefix) ? prefix + DEFAULT_SEPARATOR + name : name; }
From source file:com.github.yuxiaobin.mybatis.gm.GeneralSqlSessionFactoryBean.java
private void injectSql(GeneralMapperSqlInjector generalSqlInjector) { if (configuration instanceof GeneralConfiguration) { typeAliasesPackage = ((GeneralConfiguration) configuration).getTypeAliasesPackage(); }/*from w w w. j a v a 2 s.co m*/ if (StringUtils.hasLength(typeAliasesPackage)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("injectSql(): typeAliasesPackage=" + typeAliasesPackage); } String[] typeAliasPackageArray = MybatisGeneralEntityProcessor .parseTypeAliasPackage(this.typeAliasesPackage); if (typeAliasPackageArray != null) { MybatisGeneralEntityProcessor.typeAliasPackageArray = typeAliasPackageArray; for (String packageToScan : typeAliasPackageArray) { configuration.getTypeAliasRegistry().registerAliases(packageToScan, Object.class); } } } for (Map.Entry<String, Class<?>> type : configuration.getTypeAliasRegistry().getTypeAliases().entrySet()) { if (checkValidateClassTypes(type.getValue())) { MapperBuilderAssistant assistant = new MapperBuilderAssistant(configuration, type.getValue().getPackage().getName()); assistant.setCurrentNamespace(MybatisGeneralEntityProcessor.generateNamespace(type.getValue())); generalSqlInjector.inject(configuration, assistant, GeneralMapper.class, type.getValue(), null); } } }
From source file:com.googlecode.ehcache.annotations.resolver.DefaultCacheResolverFactory.java
public CacheableCacheResolver getCacheResolver(Cacheable cacheable, Method method) { final String cacheName = cacheable.cacheName(); Ehcache cache = this.getCache(cacheName); ThreadLocal<MethodInvocation> entryFactory = null; final DecoratedCacheType decoratedCacheType = DecoratedCacheType.getDecoratedCacheType(cacheable, method); if (decoratedCacheType == DecoratedCacheType.SELF_POPULATING_CACHE || decoratedCacheType == DecoratedCacheType.REFRESHING_SELF_POPULATING_CACHE) { if (this.badSelfPopulatingCache) { logger.error(/*from ww w . j a v a 2s. co m*/ "SelfPopulatingCache in Ehcache 2.3.0 & 2.3.1 has a bug which can result in unexpected behavior, see EHC-828. {} may not behave as expected", cacheName); } final int selfPopulatingTimeout = cacheable.selfPopulatingTimeout(); final long refreshInterval = cacheable.refreshInterval(); final SelfPopulatingCacheTracker selfPopulatingCacheTracker = this.createSelfPopulatingCacheInternal( cache, selfPopulatingTimeout, decoratedCacheType, refreshInterval); cache = selfPopulatingCacheTracker.selfPopulatingCache; entryFactory = selfPopulatingCacheTracker.cacheEntryFactory; } final String exceptionCacheName = cacheable.exceptionCacheName(); if (StringUtils.hasLength(exceptionCacheName)) { final Ehcache exceptionCache = this.getCache(exceptionCacheName); return new SingletonCacheableCacheResolver(cache, entryFactory, exceptionCache); } return new SingletonCacheableCacheResolver(cache, entryFactory); }
From source file:org.jasig.jpa.OpenEntityManagerAspect.java
/** * Look up the EntityManagerFactory that this filter should use. * <p>The default implementation looks for a bean with the specified name * in Spring's root application context. * @return the EntityManagerFactory to use * @see #getEntityManagerFactoryBeanName *//*from ww w . j a v a 2 s . c o m*/ protected EntityManagerFactory lookupEntityManagerFactory(OpenEntityManager openEntityManager) { String emfBeanName = openEntityManager.name(); String puName = openEntityManager.unitName(); if (StringUtils.hasLength(emfBeanName)) { return this.applicationContext.getBean(emfBeanName, EntityManagerFactory.class); } else if (!StringUtils.hasLength(puName) && this.applicationContext .containsBean(OpenEntityManagerInViewFilter.DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME)) { return this.applicationContext.getBean( OpenEntityManagerInViewFilter.DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME, EntityManagerFactory.class); } else { // Includes fallback search for single EntityManagerFactory bean by type. return EntityManagerFactoryUtils.findEntityManagerFactory(this.applicationContext, puName); } }
From source file:com.github.mybatis.repository.autoconfig.MybatisAutoConfiguration.java
@Bean @ConditionalOnMissingBean//from w w w . j a v a 2s .c om public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource); factory.setVfs(SpringBootVFS.class); if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } factory.setConfiguration(properties.getConfiguration()); if (!ObjectUtils.isEmpty(this.interceptors)) { factory.setPlugins(this.interceptors); } if (this.databaseIdProvider != null) { factory.setDatabaseIdProvider(this.databaseIdProvider); } if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); } if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) { factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); } if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { factory.setMapperLocations(this.properties.resolveMapperLocations()); } return factory.getObject(); }
From source file:com.starit.diamond.server.service.DiskService.java
public void removeConfigInfo(String dataId, String group) throws IOException { if (!StringUtils.hasLength(dataId) || StringUtils.containsWhitespace(dataId)) throw new IllegalArgumentException("dataId"); if (!StringUtils.hasLength(group) || StringUtils.containsWhitespace(group)) throw new IllegalArgumentException("group"); final String basePath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR); createDirIfNessary(basePath);/* w w w .j a v a2s.com*/ final String groupPath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR + "/" + group); final File groupDir = new File(groupPath); if (!groupDir.exists()) { return; } // group?groupdataId??? String fnDataId = SystemConfig.encodeDataIdForFNIfUnderWin(dataId); final String dataPath = WebUtils.getRealPath(servletContext, Constants.BASE_DIR + "/" + group + "/" + fnDataId); File dataFile = new File(dataPath); if (!dataFile.exists()) { return; } String cacheKey = generateCacheKey(group, dataId); // if (this.modifyMarkCache.putIfAbsent(cacheKey, true) == null) { try { if (!dataFile.delete()) throw new ConfigServiceException("?"); } finally { this.modifyMarkCache.remove(cacheKey); } } else throw new ConfigServiceException("?"); }
From source file:org.jenkinsci.plugins.reverse_proxy_auth.auth.ReverseProxyAuthenticationProvider.java
@Override protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (!StringUtils.hasLength(username)) { throw new BadCredentialsException( messages.getMessage("ReverseProxyAuthenticationProvider.emptyUsername", "Empty Username")); }/* ww w . j a v a 2 s . c om*/ if (logger.isDebugEnabled()) { logger.debug("Retrieving user " + username); } String password = (String) authentication.getCredentials(); // We do not need this when doing Reverse Proxy Auth //Assert.notNull(password, "Null password was supplied in authentication token"); // if (password.length() == 0) { // logger.debug("Rejecting empty password for user " + username); // throw new BadCredentialsException(messages.getMessage("LdapAuthenticationProvider.emptyPassword", // "Empty Password")); //} try { ReverseProxyUserDetails revProxyU = getAuthenticator().authenticate(username, password); return createUserDetails(revProxyU, username, password); } catch (DataAccessException ldapAccessFailure) { throw new AuthenticationServiceException(ldapAccessFailure.getMessage(), ldapAccessFailure); } }