本文整理匯總了Java中org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources方法的典型用法代碼示例。如果您正苦於以下問題:Java PathMatchingResourcePatternResolver.getResources方法的具體用法?Java PathMatchingResourcePatternResolver.getResources怎麽用?Java PathMatchingResourcePatternResolver.getResources使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.core.io.support.PathMatchingResourcePatternResolver
的用法示例。
在下文中一共展示了PathMatchingResourcePatternResolver.getResources方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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();
}
示例3: loadDrools
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
/**
* loads all the Xml files with xml file name in the manager from all the jars
* where package contains META-INF/*
*/
@PostConstruct
public void loadDrools() {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
manager.clearDroolsDirectory();
Resource[] resources = resolver.getResources("classpath*:META-INF/rules/**/*.drl");
if (resources != null) {
for (Resource resource : resources) {
if (resource == null) {
continue;
}
manager.registerDrool(resource, ContextHelper.getVariationSalience(resource.getURI().toString()));
}
}
manager.createAgents();
}catch(Exception w){
w.printStackTrace();
throw new RuntimeException(w.getCause());
}
}
示例4: loadXmls
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
/**
* loads all the Xml files with xml file name in the manager from all the jars
* where package contains META-INF/*
*/
@PostConstruct
public void loadXmls() {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
Resource[] resources = resolver.getResources("classpath*:META-INF/" + manager.getResourceFileName());
if (resources != null) {
for (Resource resource : resources) {
if (resource == null) {
continue;
}
try {
manager.registerResource(resource, ContextHelper.getContextSalience(resource.getURI().toString()),
ContextHelper.getVariationSalience(resource.getURI().toString()));
managerRepositoryService.add(manager.getClass().getSimpleName(), manager);
} catch (Exception e) {
logger.error("Exception occurred while registering XML " + resource.getURI().toString() + " exception " + e);
}
}
}
}catch(Exception w){
throw new RuntimeException(w.getCause());
}
}
示例5: setupRepo
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
private void setupRepo() throws Exception
{
AuthenticationUtil.clearCurrentSecurityContext();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
// Create a test workspace
this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
// Get a reference to the root node
NodeRef rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
// Create and authenticate the user
if(!authenticationService.authenticationExists(AuthenticationUtil.getAdminUserName()))
{
authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), PWD.toCharArray());
}
// Authenticate - as admin
authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), PWD.toCharArray());
// Store test messages in repo
String pattern = "classpath*:" + BASE_RESOURCE_CLASSPATH + BASE_BUNDLE_NAME + "*";
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources(pattern);
if (resources != null)
{
for (int i = 0; i < resources.length; i++)
{
String filename = resources[i].getFilename();
addMessageResource(rootNodeRef, filename, resources[i].getInputStream());
}
}
}
示例6: yamlPropertiesFactoryBean
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
@Bean
public static YamlPropertiesFactoryBean yamlPropertiesFactoryBean() {
YamlPropertiesFactoryBean propertiesFactoryBean = new YamlPropertiesFactoryBean();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
try {
Resource[] resources = resolver.getResources("/**/*.yml");
propertiesFactoryBean.setResources(resources);
} catch (IOException e) {
throw new IllegalStateException(e);
}
return propertiesFactoryBean;
}
示例7: openConfigurations
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
private Configurations openConfigurations() {
Configurations configurations = new Configurations();
try {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources(configurationPath);
extractConfigsFromResources(configurations, resources);
} catch (IOException ioe) {
logger.error("Something nasty has happened while trying to read configuration files!", ioe);
throw new IllegalStateException(ioe);
}
printConfigurations(configurations);
return configurations;
}
示例8: setLocations
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
/**
*/
public void setLocations(List<String> fileNames) {
List<String> fileNameList = new ArrayList<String>();
if(this.globalShareEnable && DisClientConfigExt.GLOBAL_SHARE_ENABLE) {
log.info("global share enable");
//獲取global配置項獲取global文件列表
String[] fileList = loadGlobalItem();
if(fileList != null && fileList.length > 0) {
fileNameList.addAll(Arrays.asList(fileList));
}
} else {
log.info("global share disable");
}
fileNameList.addAll(fileNames);
List<Resource> resources = new ArrayList<Resource>();
for (String filename : fileNameList) {
// trim
filename = filename.trim();
String realFileName = getFileName(filename);
//
// register to disconf
//
DisconfMgrExt.getInstance().reloadableScan(realFileName);
//
// only properties will reload
//
String ext = FilenameUtils.getExtension(filename);
if (ext.equals("properties")) {
PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver =
new PathMatchingResourcePatternResolver();
try {
Resource[] resourceList = pathMatchingResourcePatternResolver.getResources(filename);
for (Resource resource : resourceList) {
resources.add(resource);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
this.locations = resources.toArray(new Resource[resources.size()]);
lastModified = new long[locations.length];
super.setLocations(locations);
}
示例9: init
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
@Override
public void init(ServletConfig servletConfig) throws javax.servlet.ServletException {
super.init(servletConfig);
if (log.isDebugEnabled()) {
log.debug("initializing DwrServlet Extension");
}
try {
Enumeration en = servletConfig.getInitParameterNames();
boolean skipDefaultConfig = false;
while (en.hasMoreElements()) {
String paramName = (String) en.nextElement();
String paramValue = servletConfig.getInitParameter(paramName);
// meta-config
if (paramName.startsWith("meta-config") && paramValue != null && !"".equals(paramValue.trim())) {
PathMatchingResourcePatternResolver resolver = OrderedPathMatchingResourcePatternResolver.getInstance();
resources = resolver.getResources(paramValue);
}
// skipDefaultConfig
if (paramName.startsWith("skipDefaultConfig") && paramValue != null && !"".equals(paramValue.trim())) {
skipDefaultConfig = Boolean.parseBoolean(paramValue);
}
}
/*
* Nothing will get loaded into dwr container, since no resources
* found in classpath and default config got skipped.
*/
if ((resources == null || resources.length == 0) && skipDefaultConfig) {
throw new IOException(Messages.getString("DwrXmlConfigurator.MissingConfigFile",new String[] { "jar!META-INF/dwr.xml" }));
}
/*
* When there is no resources found under meta-inf and the
* skipDefaultConfig set to false then the validation handled for
* default config and the default config will get load into
* container by super class.
*/
if (resources == null && !skipDefaultConfig) {
return;
}
org.jaffa.dwr.util.ContainerUtil.configureFromResource(getContainer(), servletConfig, resources);
ContainerUtil.publishContainer(getContainer(), servletConfig);
} catch (IOException | ParserConfigurationException | SAXException e) {
throw new ServletException(e);
}
}
示例10: initModuleConfig
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; //導入方法依賴的package包/類
protected ModuleConfig initModuleConfig(String prefix, String paths) throws ServletException {
if (log.isDebugEnabled()) {
log.debug("Initializing module path '" + prefix + "' configuration from '" + paths + "'");
}
//to support default behaviour.
if(!"classpath*:/META-INF/struts-config.xml".equals(paths)){
return super.initModuleConfig(prefix, paths);
}
ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
ModuleConfig config = factoryObject.createModuleConfig(prefix);
Digester digester = initConfigDigester();
PathMatchingResourcePatternResolver resolver = OrderedPathMatchingResourcePatternResolver.getInstance();
try {
Resource[] resources = resolver.getResources(paths);
if (resources != null && resources.length > 0) {
for (Resource resource : resources) {
digester.push(config);
if (resource == null) {
continue;
}
parseModuleConfigFile(digester, resource);
}
} else {
String msg = internal.getMessage("configMissing", paths);
log.error(msg);
throw new UnavailableException(msg);
}
getServletContext().setAttribute("org.apache.struts.action.MODULE" + config.getPrefix(), config);
FormBeanConfig[] fbs = config.findFormBeanConfigs();
for (int i = 0; i < fbs.length; i++) {
if (fbs[i].getDynamic()) {
fbs[i].getDynaActionFormClass();
}
}
} catch (IOException ie) {
throw new ServletException(ie);
}
return config;
}