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


Java SystemPropertyUtils.resolvePlaceholders方法代码示例

本文整理汇总了Java中org.springframework.util.SystemPropertyUtils.resolvePlaceholders方法的典型用法代码示例。如果您正苦于以下问题:Java SystemPropertyUtils.resolvePlaceholders方法的具体用法?Java SystemPropertyUtils.resolvePlaceholders怎么用?Java SystemPropertyUtils.resolvePlaceholders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.SystemPropertyUtils的用法示例。


在下文中一共展示了SystemPropertyUtils.resolvePlaceholders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initLogging

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
/**
 * Initialize logback from the given file location, with no config file
 * refreshing. Assumes an XML file in case of a ".xml" file extension, and a
 * properties file otherwise.
 *
 * @param location the location of the config file: either a "classpath:"
 *                 location (e.g. "classpath:mylogback.properties"), an absolute
 *                 file URL (e.g.
 *                 "file:C:/logback.properties), or a plain absolute path in the file system (e.g. "
 *                 C:/logback.properties")
 * @throws FileNotFoundException if the location specifies an invalid file path
 */
public static void initLogging(String location)
        throws FileNotFoundException {
    String resolvedLocation = SystemPropertyUtils
            .resolvePlaceholders(location);
    URL url = ResourceUtils.getURL(resolvedLocation);
    if (resolvedLocation.toLowerCase().endsWith(XML_FILE_EXTENSION)) {
        // DOMConfigurator.configure(url);
        configurator.setContext(lc);
        lc.reset();
        try {
            configurator.doConfigure(url);
        } catch (JoranException ex) {
            throw new FileNotFoundException(url.getPath());
        }
        lc.start();
    }
    // else {
    // PropertyConfigurator.configure(url);
    // }
}
 
开发者ID:glameyzhou,项目名称:scaffold,代码行数:33,代码来源:LogbackConfigurer.java

示例2: initLogging

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
/**
 * Initialize logback from the given file.
 *
 * @param location
 *            the location of the config file: either a "classpath:"
 *            location (e.g. "classpath:logback.xml"), an absolute file URL
 *            (e.g. "file:C:/logback.xml), or a plain absolute path in the
 *            file system (e.g. "C:/logback.xml")
 * @throws java.io.FileNotFoundException
 *             if the location specifies an invalid file path
 */
public static void initLogging(final String location)
		throws FileNotFoundException {
	String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
	URL url = ResourceUtils.getURL(resolvedLocation);
	LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

	try {
		JoranConfigurator configurator = new JoranConfigurator();
		configurator.setContext(loggerContext);
		// the context was probably already configured by default
		// configuration
		// rules
		loggerContext.reset();
		configurator.doConfigure(url);
	} catch (JoranException je) {
		// StatusPrinter will handle this
	}
	StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:31,代码来源:LogbackConfigurer.java

示例3: main

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
public static void main(String[] args)
{
  ClassPathXmlApplicationContext ctx = Util.initContext("simple-res.xml");
  System.out.println("res loaderd");
  ctx.close();
  try
  {
    String s1 ="D:/tmp/gemlite/data/prod*";
    String s2 ="classpath:prod*";
    String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(s2);
    URL url = ResourceUtils.getURL(resolvedLocation);
    System.out.println(resolvedLocation+" "+url);
    
  }
  catch (Exception e)
  {
    e.printStackTrace();
  }
  
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:21,代码来源:TestResource.java

示例4: initLogging

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
/**
 * 加载logback配置
 * @param location 文件路径
 * @throws FileNotFoundException 文件不存在异常
 */
public static void initLogging(String location) throws FileNotFoundException {
    if (LoggerFactory.getILoggerFactory() instanceof LoggerContext) {
        String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
        URL url = ResourceUtils.getURL(resolvedLocation);
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        try {
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(loggerContext);
            loggerContext.reset();
            configurator.doConfigure(url);
        } catch (Throwable e) {
            BasicConfigurator.configureDefaultContext();
            Logger log = LoggerFactory.getLogger(MODULE);
            log.warn("Logback configure fail!", e);
        }
    }
}
 
开发者ID:tryndamere,项目名称:bpm-adapter,代码行数:23,代码来源:LogbackConfigurer.java

示例5: expandEnvironmentVars

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
public static String expandEnvironmentVars(String text) {
    if (text == null) {
        return text;
    }
    return SystemPropertyUtils.resolvePlaceholders(text);
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:7,代码来源:StringUtils.java

示例6: initLogging

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
/**
 * Initialize logback, including setting the web app root system property.
 *
 * @param servletContext the current ServletContext
 * @see WebUtils#setWebAppRootSystemProperty
 */
public static void initLogging(ServletContext servletContext) {
    // Expose the web app root system property.
    if (exposeWebAppRoot(servletContext)) {
        WebUtils.setWebAppRootSystemProperty(servletContext);
    }

    // Only perform custom logback initialization in case of a config file.
    String location = servletContext
            .getInitParameter(CONFIG_LOCATION_PARAM);
    if (location != null) {
        // Perform actual logback initialization; else rely on logback's
        // default initialization.
        try {
            // Return a URL (e.g. "classpath:" or "file:") as-is;
            // consider a plain file path as relative to the web application
            // root directory.
            if (!ResourceUtils.isUrl(location)) {
                // Resolve system property placeholders before resolving
                // real path.
                location = SystemPropertyUtils
                        .resolvePlaceholders(location);
                location = WebUtils.getRealPath(servletContext, location);
            }

            // Write log message to server log.
            servletContext.log("Initializing logback from [" + location
                    + "]");

            // Initialize without refresh check, i.e. without logback's
            // watchdog thread.
            LogbackConfigurer.initLogging(location);

        } catch (FileNotFoundException ex) {
            throw new IllegalArgumentException(
                    "Invalid 'logbackConfigLocation' parameter: "
                            + ex.getMessage());
        }
    }
}
 
开发者ID:glameyzhou,项目名称:scaffold,代码行数:46,代码来源:LogbackWebConfigurer.java

示例7: getClassSearchPattern

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
private static String getClassSearchPattern(String packageName) {
    String resolvedPackageName = SystemPropertyUtils.resolvePlaceholders(packageName);
    String resourcePath = ClassUtils.convertClassNameToResourcePath(resolvedPackageName);

    if (StringUtils.isEmpty(resourcePath)) {
        return ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "??/" + CLASS_RESOURCE_PATTERN;
    }

    return ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resourcePath + "/" + CLASS_RESOURCE_PATTERN;
}
 
开发者ID:Indoqa,项目名称:indoqa-spring,代码行数:11,代码来源:ClassPathScanner.java

示例8: initLog4j

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
public static void initLog4j(String configFile)
{
  configFile = "log4j2-server.xml";
  if (getProperty(ITEMS.NODE_TYPE.name()) == null)
    setProperty("NODE_TYPE", "");
  if (getProperty(ITEMS.NODE_NAME.name()) == null)
    setProperty("NODE_NAME", "");
  String resolvedLocation = SystemPropertyUtils.resolvePlaceholders("log4j2-server.xml");
  
  URL url;
  try
  {
    url = ServerConfigHelper.class.getClassLoader().getResource(configFile);
    LoggerContext context = (LoggerContext) LogManager.getContext(false);
    context.setConfigLocation(url.toURI());
    LogUtil.init();
  }
  catch (URISyntaxException e)
  {
    e.printStackTrace();
  }
  
  // System.setProperty("log4j.configurationFile", configFile);
  
  // try
  // {
  // if (!configFile.startsWith("classpath"))
  // configFile = "classpath:" + configFile;
  // Log4jConfigurer.initLogging(configFile);
  // }
  // catch (FileNotFoundException e)
  // {
  // System.err.println("File " + configFile + " not exists!");
  // }
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:36,代码来源:ServerConfigHelper.java

示例9: initApplicationFileConfiguration

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
private void initApplicationFileConfiguration() {
    if (applicationPropertiesPath == null) {
        LOGGER.debug("No client application properties to configure. Skipping...");
        applicationFileConfiguration = new ConcurrentMapConfiguration();
        return;
    }

    this.applicationFileConfiguration = new ConcurrentCompositeConfiguration();

    String path = SystemPropertyUtils.resolvePlaceholders(applicationPropertiesPath);
    LOGGER.debug("Configuring client application properties from path " + applicationPropertiesPath);

    Map applicationProperties = new Properties();

    if (SystemUtils.IS_OS_WINDOWS) {
        if (path.startsWith("file://")) {
            if (!path.startsWith("file:///")) {
                path = path.replaceFirst(Pattern.quote("file://"), "file:///");
            }
        }
    }

    try (InputStream is = resourceLoader.getResource(path).getInputStream()) {
        ((Properties) applicationProperties).load(is);
    } catch (Exception e) {
        BootstrapException.resourceLoadingFailed(path, applicationPropertiesPath, e);
    }

    Map environmentApplicationProperties = getEnvironmentSpecificProperties(path);
    if (environmentApplicationProperties != null) {
        ((ConcurrentCompositeConfiguration) this.applicationFileConfiguration).addConfiguration(new ConcurrentMapConfiguration(environmentApplicationProperties));
    }
    ((ConcurrentCompositeConfiguration) this.applicationFileConfiguration).addConfiguration(new ConcurrentMapConfiguration(applicationProperties));

    if (applicationFileConfiguration.containsKey(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName())) {
        this.publishDefaults = applicationFileConfiguration.getBoolean(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName());
    }
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:40,代码来源:ConfigurationBuilder.java

示例10: isTransport

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
static boolean isTransport(ClassNode node, String type) {
	for (AnnotationNode annotationNode : node.getAnnotations()) {
		String annotation = "EnableBinding";
		if (PatternMatchUtils.simpleMatch(annotation,
				annotationNode.getClassNode().getName())) {
			Expression expression = annotationNode.getMembers().get("transport");
			String transport = expression == null ? "rabbit" : expression.getText();
			if (transport != null) {
				transport = SystemPropertyUtils.resolvePlaceholders(transport);
			}
			return transport.equals(type);
		}
	}
	return false;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-cli,代码行数:16,代码来源:BaseStreamCompilerAutoConfiguration.java

示例11: initializeWithSpecificConfig

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
private void initializeWithSpecificConfig(
		LoggingInitializationContext initializationContext, String configLocation,
		LogFile logFile) {
	configLocation = SystemPropertyUtils.resolvePlaceholders(configLocation);
	loadConfiguration(initializationContext, configLocation, logFile);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:AbstractLoggingSystem.java

示例12: getDefaultLibDirectory

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
private File getDefaultLibDirectory() {
	String home = SystemPropertyUtils
			.resolvePlaceholders("${spring.home:${SPRING_HOME:.}}");
	return new File(home, "lib");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:Installer.java

示例13: getFileSearchPattern

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
private static String getFileSearchPattern(String path) {
    String resolvedPath = SystemPropertyUtils.resolvePlaceholders(path);
    return ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolvedPath;
}
 
开发者ID:Indoqa,项目名称:indoqa-spring,代码行数:5,代码来源:ClassPathScanner.java

示例14: initLogging

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
/**
 * Initialize Logback, including setting the web app root system property.
 *
 * @param servletContext
 *            the current ServletContext
 * @see org.springframework.web.util.WebUtils#setWebAppRootSystemProperty
 */
public static void initLogging(final ServletContext servletContext) {
	// Expose the web app root system property.
	if (exposeWebAppRoot(servletContext)) {
		WebUtils.setWebAppRootSystemProperty(servletContext);
	}

	// Only perform custom Logback initialization in case of a config file.
	String locationParameter = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
	String[] locations = null;
	if(locationParameter.indexOf(",") != -1) {
		locations = locationParameter.split(",");
	} else {
		locations = new String[] {locationParameter};
	}
	if (locations.length > 0) {
		for (String location : locations) {
			// Perform actual Logback initialization; else rely on Logback's
			// default initialization.
			try {
				// Return a URL (e.g. "classpath:" or "file:") as-is;
				// consider a plain file path as relative to the web
				// application
				// root directory.
				if (!ResourceUtils.isUrl(location)) {
					// Resolve system property placeholders before resolving
					// real path.
					location = SystemPropertyUtils.resolvePlaceholders(location);
					location = WebUtils.getRealPath(servletContext,	location);
				}

				// Write log message to server log.
				servletContext.log("Initializing Logback from [" + location	+ "]");

				// Initialize
				LogbackConfigurer.initLogging(location);
				break;
			} catch (FileNotFoundException ex) {
				servletContext.log("Invalid 'logbackConfigLocation' parameter: " +  ex.getMessage());
			}
		}
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:50,代码来源:LogbackWebConfigurer.java

示例15: resolveBasePackage

import org.springframework.util.SystemPropertyUtils; //导入方法依赖的package包/类
/**
 * 将包名转换成目录名(com.my9yu-->com/my9yu)
 * @param basePackage 包名
 * @return
 */
private static String resolveBasePackage(String basePackage) {
	String placeHolderReplace = SystemPropertyUtils.resolvePlaceholders(basePackage);//${classpath}替换掉placeholder 引用的变量值
	return ClassUtils.convertClassNameToResourcePath(placeHolderReplace);
}
 
开发者ID:Jakegogo,项目名称:concurrent,代码行数:10,代码来源:PackageScanner.java


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