當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.toString方法代碼示例

本文整理匯總了Java中org.springframework.core.io.Resource.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.toString方法的具體用法?Java Resource.toString怎麽用?Java Resource.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.core.io.Resource的用法示例。


在下文中一共展示了Resource.toString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refresh

import org.springframework.core.io.Resource; //導入方法依賴的package包/類
/**
 * 刷新mapper
 *
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
private void refresh(Resource resource) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
    this.configuration = sqlSessionFactory.getConfiguration();
    boolean isSupper = configuration.getClass().getSuperclass() == Configuration.class;
    try {
        Field loadedResourcesField = isSupper ? configuration.getClass().getSuperclass().getDeclaredField("loadedResources")
                : configuration.getClass().getDeclaredField("loadedResources");
        loadedResourcesField.setAccessible(true);
        Set loadedResourcesSet = ((Set) loadedResourcesField.get(configuration));
        XPathParser xPathParser = new XPathParser(resource.getInputStream(), true, configuration.getVariables(),
                new XMLMapperEntityResolver());
        XNode context = xPathParser.evalNode("/mapper");
        String namespace = context.getStringAttribute("namespace");
        Field field = MapperRegistry.class.getDeclaredField("knownMappers");
        field.setAccessible(true);
        Map mapConfig = (Map) field.get(configuration.getMapperRegistry());
        mapConfig.remove(Resources.classForName(namespace));
        loadedResourcesSet.remove(resource.toString());
        configuration.getCacheNames().remove(namespace);
        cleanParameterMap(context.evalNodes("/mapper/parameterMap"), namespace);
        cleanResultMap(context.evalNodes("/mapper/resultMap"), namespace);
        cleanKeyGenerators(context.evalNodes("insert|update"), namespace);
        cleanSqlElement(context.evalNodes("/mapper/sql"), namespace);
        XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resource.getInputStream(),
                sqlSessionFactory.getConfiguration(), // 注入的sql先不進行處理了
                resource.toString(), sqlSessionFactory.getConfiguration().getSqlFragments());
        xmlMapperBuilder.parse();
        logger.debug("refresh: '" + resource + "', success!");
    } catch (IOException e) {
        logger.error("Refresh IOException :" + e.getMessage());
    } finally {
        ErrorContext.instance().reset();
    }
}
 
開發者ID:Caratacus,項目名稱:mybatis-plus-mini,代碼行數:40,代碼來源:MybatisMapperRefresh.java

示例2: setLocation

import org.springframework.core.io.Resource; //導入方法依賴的package包/類
protected void setLocation() {
	Resource resource = feature.getResource();
	String serializedResource = null == resource ? null : resource.toString();
	serialized.addProperty("location", serializedResource);
}
 
開發者ID:qas-guru,項目名稱:martini-core,代碼行數:6,代碼來源:DefaultFeatureSerializer.java


注:本文中的org.springframework.core.io.Resource.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。