use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project jaffa-framework by jaffa-projects.
the class TransactionManager method unregisterXML.
/**
* unregisters all the transactions and typeInfo in the xml from the repository
* @param uri for the xml location
*/
public void unregisterXML(String uri, String context, String variation) throws JAXBException, SAXException, IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Config config = JAXBHelper.unmarshalConfigFile(Config.class, resolver.getResource(uri), CONFIGURATION_SCHEMA_FILE);
if (config.getTransactionOrType() != null) {
for (final Object o : config.getTransactionOrType()) {
if (o.getClass() == TransactionInfo.class) {
final TransactionInfo transactionInfo = (TransactionInfo) o;
ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), uri, variation, context);
unregisterTransactionInfo(contextKey);
} else if (o.getClass() == TypeInfo.class) {
final TypeInfo typeInfo = (TypeInfo) o;
ContextKey contextKey = new ContextKey(typeInfo.getName(), uri, variation, context);
unregisterTypeInfo(contextKey);
}
}
}
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project web3sdk by FISCO-BCOS.
the class PEMManager method load.
public void load() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, NoSuchProviderException, InvalidKeySpecException {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource pemResources = resolver.getResource(pemFile);
load(pemResources.getInputStream());
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project dq-easy-cloud by dq-open-cloud.
the class EcDataSourceConfig method sqlSessionFactory.
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSourece) throws Exception {
// 添加XML目录
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSourece);
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
sessionFactory.setMapperLocations(resolver.getResources(mapperLocations));
return sessionFactory.getObject();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project littlefisher-system by littlefishercoder.
the class PackageUtil method scanTypePackage.
/**
* 扫描获取指定包路径所有类
*
* @param typePackage 扫描类包路径
* @return Set<Class>
*/
public static Set<Class> scanTypePackage(String typePackage) {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
String pkg = ClassUtils.convertClassNameToResourcePath(typePackage) + ".class";
/*
* 将加载多个绝对匹配的所有Resource
* 将首先通过ClassLoader.getResource("META-INF")加载非模式路径部分,然后进行遍历模式匹配,排除重复包路径
*/
try {
Set<Class> set = Sets.newHashSet();
Resource[] resources = resolver.getResources(pkg);
if (ArrayUtils.isNotEmpty(resources)) {
MetadataReader metadataReader;
for (Resource resource : resources) {
if (resource.isReadable()) {
metadataReader = metadataReaderFactory.getMetadataReader(resource);
set.add(Class.forName(metadataReader.getClassMetadata().getClassName()));
}
}
}
return set;
} catch (Exception e) {
throw new BaseAppException("CORE-000007", null, e);
}
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project entando-core by entando.
the class WidgetType method existsJsp.
public static boolean existsJsp(ServletContext srvCtx, String code, String pluginCode) throws IOException {
String jspPath = getJspPath(code, pluginCode);
String folderPath = srvCtx.getRealPath("/");
boolean existsJsp = (new File(folderPath + jspPath)).exists();
if (existsJsp) {
return true;
}
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources("file:**" + jspPath);
for (int i = 0; i < resources.length; i++) {
Resource resource = resources[i];
if (resource.exists()) {
return true;
}
}
return false;
}
Aggregations