当前位置: 首页>>代码示例>>Java>>正文


Java PathMatchingResourcePatternResolver.getResources方法代码示例

本文整理汇总了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();
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:17,代码来源:Configs.java

示例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();
}
 
开发者ID:rekit-group,项目名称:rekit-game,代码行数:28,代码来源:LevelManager.java

示例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());

    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:27,代码来源:DroolsLoader.java

示例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());
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:28,代码来源:ResourceLoader.java

示例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());                
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:MessageServiceImplTest.java

示例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;
}
 
开发者ID:csdbianhua,项目名称:telemarket-skittle-alley,代码行数:13,代码来源:CommonConfig.java

示例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;
}
 
开发者ID:moip,项目名称:mockkid,代码行数:15,代码来源:ConfigParser.java

示例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);
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:55,代码来源:ReloadablePropertiesFactoryBeanExt.java

示例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);
	}
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:56,代码来源:DwrServlet.java

示例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;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:48,代码来源:ActionServlet.java


注:本文中的org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。