本文整理匯總了Java中org.springframework.core.io.support.PathMatchingResourcePatternResolver類的典型用法代碼示例。如果您正苦於以下問題:Java PathMatchingResourcePatternResolver類的具體用法?Java PathMatchingResourcePatternResolver怎麽用?Java PathMatchingResourcePatternResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PathMatchingResourcePatternResolver類屬於org.springframework.core.io.support包,在下文中一共展示了PathMatchingResourcePatternResolver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: businessSqlSessionFactory
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Bean
@Primary
public SqlSessionFactory businessSqlSessionFactory(@Qualifier("businessDataSource") DruidDataSource businessDataSource) throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(businessDataSource);
//mybatis分頁
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props);
//添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERXML_LOCATION));
return sqlSessionFactoryBean.getObject();
}
示例2: body
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
private String body(String template, String language, Map<String, String> args) {
final String templateFile = EMAIL_FILE.replace("*", template);
try {
return Files.lines(Paths.get(
new PathMatchingResourcePatternResolver()
.getResource(templateFile)
.getURI()
)).map(line -> text.format(line, language, args))
.collect(joining("\n"));
} catch (final IOException ex) {
throw new IllegalArgumentException(
"Could not find email template '" + templateFile + "'."
);
}
}
示例3: parseLanguageFiles
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
private Map<String, Map<String, String>> parseLanguageFiles() {
try {
return Stream.of(
new PathMatchingResourcePatternResolver()
.getResources(MESSAGES_FILE)
).collect(toMap(
this::parseLanguageName,
this::parseLanguageFile
));
} catch (final IOException ex) {
throw new RuntimeException(
"Error loading resourced by pattern '" +
MESSAGES_FILE + "'.", ex
);
}
}
示例4: getMaps
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
public static List<String> getMaps() {
List<String> maps = new ArrayList<>();
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
Resource[] resources = resolver.getResources("maps/*.yaml");
Arrays.stream(resources).map(Resource::getFilename).map(f -> f.replace(".yaml", ""))
.filter(s -> !s.equals("defaults"))
.forEach(maps::add);
} catch (IOException e) {
e.printStackTrace();
}
File[] localYamls = new File(".").listFiles(
(dir, name) -> name.toLowerCase().endsWith(".yaml")
);
Arrays.stream(localYamls).forEach(f -> maps.add(f.getName().replace(".yaml", "")));
return maps;
}
示例5: sqlSessionFactory
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(roundRobinDataSouceProxy());
sqlSessionFactoryBean.setTypeAliasesPackage(this.typeAliasesPackage);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(this.mapperLocations));
sqlSessionFactoryBean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
return sqlSessionFactoryBean.getObject();
}
示例6: processEngineConfiguration
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Bean
public ProcessEngineConfigurationImpl processEngineConfiguration() throws IOException {
SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
config.setDataSource(dataSource());
config.setTransactionManager(transactionManager());
config.setDatabaseSchemaUpdate("true");
config.setJobExecutorActivate(true);
config.setAuthorizationEnabled(true);
config.setDefaultSerializationFormat("application/json");
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
config.setDeploymentResources(resolver.getResources("classpath:/bpmn/*.bpmn"));
List<ProcessEnginePlugin> processEnginePlugins = new ArrayList<>();
SpinProcessEnginePlugin spinProcessEnginePlugin = new SpinProcessEnginePlugin();
processEnginePlugins.add(spinProcessEnginePlugin);
processEnginePlugins.add(CamundaReactor.plugin());
config.setProcessEnginePlugins(processEnginePlugins);
return config;
}
示例7: validateResource
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
public static void validateResource(String resourcePath,Logger log)
{
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
try {
if (resourceResolver.getResources("classpath*:/GameData" +resourcePath+"*").length==0)
log.error("INEXISTENT RESOURCE "+"/GameData" +resourcePath+"*");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例8: getConfig
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
public Properties getConfig(ConfigurableEnvironment env) throws IOException {
PropertiesFactoryBean config = new PropertiesFactoryBean();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
List<Resource> resouceList = InstanceUtil.newArrayList();
try {
Resource[] resources = resolver.getResources("classpath*:config/*.properties");
for (Resource resource : resources) {
resouceList.add(resource);
}
} catch (Exception e) {
logger.error("", e);
}
config.setLocations(resouceList.toArray(new Resource[]{}));
config.afterPropertiesSet();
return config.getObject();
}
示例9: sqlSessionFactory
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(roundRobinDataSouceProxy());
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));
sqlSessionFactoryBean.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
return sqlSessionFactoryBean.getObject();
}
示例10: loadAllLevels
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
/**
* Load all levels.
*
* @throws IOException
* iff wrong path.
*/
private static void loadAllLevels() throws IOException {
PathMatchingResourcePatternResolver resolv = new PathMatchingResourcePatternResolver(ModManager.SYSLOADER);
Resource[] unknown = resolv.getResources("classpath*:/levels/level*.dat");
Resource[] subdirs = resolv.getResources("classpath*:/levels/*/level*.dat");
Resource[] res = new Resource[unknown.length + subdirs.length];
System.arraycopy(unknown, 0, res, 0, unknown.length);
System.arraycopy(subdirs, 0, res, unknown.length, subdirs.length);
Stream<Resource> numbered = Arrays.stream(res).filter(r -> r.getFilename().matches("level_\\d+\\.dat"));
Stream<Resource> notNumbered = Arrays.stream(res).filter(r -> !r.getFilename().matches("level_\\d+\\.dat"));
numbered.sorted((r1, r2) -> {
String n1 = r1.getFilename().substring("level_".length()).split("\\.")[0];
String n2 = r2.getFilename().substring("level_".length()).split("\\.")[0];
return Integer.compare(Integer.parseInt(n1), Integer.parseInt(n2));
}).forEach(LevelManager::addArcadeLevel);
notNumbered.sorted((r1, r2) -> r1.toString().compareToIgnoreCase(r2.toString())).forEach(LevelManager::addArcadeLevel);
LevelManager.loadInfiniteLevels();
LevelManager.loadCustomLevels();
}
示例11: setUp
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Before
public void setUp() throws Exception
{
moduleService = new ModuleServiceImpl();
Resource simpleMod = new PathMatchingResourcePatternResolver().getResource("classpath:alfresco/module/simplemodule.properties");
assertNotNull(simpleMod);
RegistryService reg = mock(RegistryService.class);
ApplicationContext applicationContext = mock(ApplicationContext.class);
when(reg.getProperty((RegistryKey) anyObject())).thenAnswer(new Answer<Serializable>()
{
public Serializable answer(InvocationOnMock invocation) throws Throwable
{
RegistryKey key = (RegistryKey) invocation.getArguments()[0];
return new ModuleVersionNumber("1.1");
}
});
doReturn(Arrays.asList("fee", "alfresco-simple-module", "fo")).when(reg).getChildElements((RegistryKey) anyObject());
doReturn(new Resource[] {simpleMod}).when(applicationContext).getResources(anyString());
moduleService.setRegistryService(reg);
moduleService.setApplicationContext(applicationContext);
}
示例12: sqlSessionFactory
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Bean public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
//mybatis分頁
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props); //添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/me/caixin/dao/mapping/**/*.xml"));
return sqlSessionFactoryBean.getObject();
}
示例13: findMyTypes
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
protected List<Class<?>> findMyTypes(String basePackage) throws IOException, ClassNotFoundException {
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
List<Class<?>> candidates = new ArrayList<>();
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage)
+ "/" + "**/*.class";
Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
for (Resource resource : resources) {
if (resource.isReadable()) {
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
if (isCandidate(metadataReader)) {
candidates.add(forName(metadataReader.getClassMetadata().getClassName()));
}
}
}
return candidates;
}
示例14: findMangoDaoClasses
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
private List<Class<?>> findMangoDaoClasses(String packages) {
try {
List<Class<?>> daos = new ArrayList<Class<?>>();
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
for (String locationPattern : getLocationPattern(packages)) {
Resource[] rs = resourcePatternResolver.getResources(locationPattern);
for (Resource r : rs) {
MetadataReader reader = metadataReaderFactory.getMetadataReader(r);
AnnotationMetadata annotationMD = reader.getAnnotationMetadata();
if (annotationMD.hasAnnotation(DB.class.getName())) {
ClassMetadata clazzMD = reader.getClassMetadata();
daos.add(Class.forName(clazzMD.getClassName()));
}
}
}
return daos;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例15: sqlSessionFactory
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入依賴的package包/類
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
//mybatis分頁
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "true");
props.setProperty("returnPageInfo", "check");
props.setProperty("params", "count=countSql");
pageHelper.setProperties(props); //添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:org/xxpay/dal/dao/mapper/*.xml"));
return sqlSessionFactoryBean.getObject();
}