List of usage examples for org.springframework.util ObjectUtils isEmpty
@SuppressWarnings("rawtypes") public static boolean isEmpty(@Nullable Object obj)
From source file:ch.rasc.wampspring.config.WebMvcWampWebSocketEndpointRegistration.java
@Override public WampWebSocketEndpointRegistration setAllowedOrigins(String... origins) { this.allowedOrigins.clear(); if (!ObjectUtils.isEmpty(origins)) { this.allowedOrigins.addAll(Arrays.asList(origins)); }//ww w.j a v a 2 s . c o m return this; }
From source file:org.eclipse.gemini.blueprint.test.AbstractOptionalDependencyInjectionTests.java
/** * {@inheritDoc}// ww w . j a va 2 s. c o m * * <p/>This implementation will create an empty bundle context in case no * locations are specified. */ protected ConfigurableApplicationContext createApplicationContext(String[] locations) { ConfigurableOsgiBundleApplicationContext context = null; if (ObjectUtils.isEmpty(locations)) context = new EmptyOsgiApplicationContext(); else context = new OsgiBundleXmlApplicationContext(locations); context.setBundleContext(bundleContext); context.refresh(); return context; }
From source file:com.github.persapiens.jsfboot.security.AuthorizeFaceletsTag.java
void setIfNotGranted(String ifNotGranted) { String[] roles = StringUtils.tokenizeToStringArray(ifNotGranted, ","); if (!ObjectUtils.isEmpty(roles)) { String expression = toHasAnyRoleExpression(roles, true); setAccess(getAccess() != null ? getAccess() + AND + expression : expression); }/*from www . ja va 2s . co m*/ }
From source file:com.glaf.activiti.spring.SpringProcessEngineConfigurationBean.java
@Override protected void initSqlSessionFactory() { logger.info("-------------------------------------------"); logger.info("-------------initSqlSessionFactory()-------"); logger.info("sqlSessionFactory:" + sqlSessionFactory); logger.info("transactionFactory:" + transactionFactory); if (sqlSessionFactory == null) { InputStream inputStream = null; try {//from ww w . j a v a2s.com if (configLocation != null) { logger.info("mybatis config:" + this.configLocation.getFile().getAbsolutePath()); inputStream = this.configLocation.getInputStream(); } else { Resource resource = new ClassPathResource("com/glaf/activiti/activiti.mybatis.conf.xml"); inputStream = resource.getInputStream(); } if (!ObjectUtils.isEmpty(this.mapperLocations)) { SAXReader xmlReader = new SAXReader(); EntityResolver entityResolver = new XMLMapperEntityResolver(); xmlReader.setEntityResolver(entityResolver); Document doc = xmlReader.read(inputStream); Element root = doc.getRootElement(); Element mappers = root.element("mappers"); if (mappers != null) { java.util.List<?> list = mappers.elements(); Collection<String> files = new HashSet<String>(); if (list != null && !list.isEmpty()) { Iterator<?> iterator = list.iterator(); while (iterator.hasNext()) { Element elem = (Element) iterator.next(); if (elem.attributeValue("resource") != null) { String file = elem.attributeValue("resource"); files.add(file); } else if (elem.attributeValue("url") != null) { String file = elem.attributeValue("url"); files.add(file); } } } for (Resource mapperLocation : this.mapperLocations) { if (mapperLocation == null) { continue; } String url = mapperLocation.getURL().toString(); // logger.debug("find mapper:" + url); if (!files.contains(url)) { Element element = mappers.addElement("mapper"); element.addAttribute("url", url); } } } IOUtils.closeStream(inputStream); byte[] bytes = Dom4jUtils.getBytesFromPrettyDocument(doc); inputStream = new ByteArrayInputStream(bytes); } // update the jdbc parameters to the configured ones... Environment environment = new Environment("default", transactionFactory, dataSource); Reader reader = new InputStreamReader(inputStream); Properties properties = new Properties(); properties.put("prefix", databaseTablePrefix); if (databaseType != null) { properties.put("limitBefore", DbSqlSessionFactory.databaseSpecificLimitBeforeStatements.get(databaseType)); properties.put("limitAfter", DbSqlSessionFactory.databaseSpecificLimitAfterStatements.get(databaseType)); properties.put("limitBetween", DbSqlSessionFactory.databaseSpecificLimitBetweenStatements.get(databaseType)); properties.put("orderBy", DbSqlSessionFactory.databaseSpecificOrderByStatements.get(databaseType)); } XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler()); configuration = parser.parse(); sqlSessionFactory = new DefaultSqlSessionFactory(configuration); } catch (Exception e) { throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e); } finally { IoUtil.closeSilently(inputStream); } } }
From source file:com.icfcc.cache.annotation.SpringCacheAnnotationParser.java
Collection<CacheOperation> parseCachingAnnotation(AnnotatedElement ae, Caching caching) { Collection<CacheOperation> ops = null; Cacheable[] cacheables = caching.cacheable(); if (!ObjectUtils.isEmpty(cacheables)) { ops = lazyInit(ops);/* ww w .j av a2s .co m*/ for (Cacheable cacheable : cacheables) { ops.add(parseCacheableAnnotation(ae, cacheable)); } } CacheEvict[] evicts = caching.evict(); if (!ObjectUtils.isEmpty(evicts)) { ops = lazyInit(ops); for (CacheEvict evict : evicts) { ops.add(parseEvictAnnotation(ae, evict)); } } CachePut[] updates = caching.put(); if (!ObjectUtils.isEmpty(updates)) { ops = lazyInit(ops); for (CachePut update : updates) { ops.add(parseUpdateAnnotation(ae, update)); } } return ops; }
From source file:example.app.repo.provider.GoogleMapsApiGeocodingRepository.java
@Override public Point geocode(Address address) { String stringAddress = toString(address); try {//from www. ja va2s . c o m GeoApiContext context = newGeoApiContext(); GeocodingResult[] results = GeocodingApi.geocode(context, stringAddress).await(); if (!ObjectUtils.isEmpty(results)) { GeocodingResult result = results[0]; return new Point(result.geometry.location.lat, result.geometry.location.lng); } throw new GoogleMapsApiGeocodingException(String.format( "geographic coordinates (latitude/longitude) for address [%s] not found", stringAddress)); } catch (Exception e) { throw new GoogleMapsApiGeocodingException( String.format("failed to convert address [%s] into geographic coordinates (latitude/longitude)", stringAddress), e); } }
From source file:architecture.ee.jdbc.sqlquery.factory.impl.AbstractSqlQueryFactory.java
protected boolean isEmpty(Object[] array) { return ObjectUtils.isEmpty(array); }
From source file:com.lightning.testplatform.configure.mybatis.MybatisAutoConfiguration.java
@Bean @ConditionalOnMissingBean//from w w w. jav a 2 s . co m 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())); // ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); // factory.setConfigLocation(resolver.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.springmodules.cache.config.CacheSetupStrategyElementBuilder.java
private void appendChildren(Element parent, XmlElementBuilder[] children) { if (!ObjectUtils.isEmpty(children)) { int size = children.length; for (int i = 0; i < size; i++) { parent.appendChild(children[i].toXml()); }/*from w w w .j a v a2s .c om*/ } }
From source file:com.dianwoba.redcliff.blink.config.MybatisConfig2.java
@Bean(name = "bSqlSessionFactory") public SqlSessionFactory sqlSessionFactory(@Qualifier("bDataSource") DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource);//ww w. j a va 2 s. co 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(); }