org.springframework.util.SystemPropertyUtils Java Examples

The following examples show how to use org.springframework.util.SystemPropertyUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassScaner.java    From oim-fx with MIT License 6 votes vote down vote up
public Set<Class<?>> doScan(String basePackage) {
	Set<Class<?>> classes = new HashSet<Class<?>>();
	try {
		String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + org.springframework.util.ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(basePackage)) + "/**/*.class";
		Resource[] resources = this.resourcePatternResolver.getResources(packageSearchPath);

		for (int i = 0; i < resources.length; i++) {
			Resource resource = resources[i];
			if (resource.isReadable()) {
				MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(resource);
				if ((includeFilters.size() == 0 && excludeFilters.size() == 0) || matches(metadataReader)) {
					try {
						classes.add(Class.forName(metadataReader.getClassMetadata().getClassName()));
					} catch (ClassNotFoundException e) {
						e.printStackTrace();
					}

				}
			}
		}
	} catch (IOException ex) {
		throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex);
	}
	return classes;
}
 
Example #2
Source File: TestUtils.java    From chassis with Apache License 2.0 6 votes vote down vote up
public static OutputStream createFile(String path) {
    try {
        Path p = Paths.get(SystemPropertyUtils.resolvePlaceholders(path));
        if (Files.exists(p)) {
            Files.delete(p);
        }
        File file = new File(path);
        if (!file.getParentFile().exists()) {
            if (!file.getParentFile().mkdirs()) {
                throw new RuntimeException("Unable to create parent file(s) " + file.getParent());
            }
        }
        return Files.newOutputStream(p);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #3
Source File: CustomTagAnnotations.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Finds all the classes which have a BeanTag or BeanTags annotation
 *
 * @param basePackage the package to start in
 * @return classes which have BeanTag or BeanTags annotation
 * @throws IOException
 * @throws ClassNotFoundException
 */
protected static List<Class<?>> findTagClasses(String basePackage) throws IOException, ClassNotFoundException {
    ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);

    List<Class<?>> classes = new ArrayList<Class<?>>();

    String resolvedBasePackage = ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(
            basePackage));
    String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
            resolvedBasePackage + "/" + "**/*.class";

    Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
    for (Resource resource : resources) {
        if (resource.isReadable()) {
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            if (metadataReader != null && isBeanTag(metadataReader)) {
                classes.add(Class.forName(metadataReader.getClassMetadata().getClassName()));
            }
        }
    }

    return classes;
}
 
Example #4
Source File: ConfigurationBuilder.java    From chassis with Apache License 2.0 6 votes vote down vote up
private void initModuleConfiguration() {
    if (!scanModuleConfigurations) {
        this.moduleDefaultConfiguration = new ConcurrentMapConfiguration();
        return;
    }
    HashMap<String, Object> base = new HashMap<>();
    Set<Class<?>> types = reflections
            .getTypesAnnotatedWith(PropertySource.class);
    for (Class<?> type : types) {
        PropertySource propertySource = type
                .getAnnotation(PropertySource.class);
        String[] propertiesFiles = propertySource.value();
        for (String propertyFile : propertiesFiles) {
            Properties properties = new Properties();
            try (InputStream is = resourceLoader.getResource(SystemPropertyUtils.resolvePlaceholders(propertyFile))
                    .getInputStream()) {
                properties.load(is);
                LOGGER.debug("Initializing module properties from path " + propertyFile);
            } catch (Exception e) {
                BootstrapException.resourceLoadingFailed(propertyFile, e);
            }
            join(base, properties, propertyFile, propertiesFiles);
        }
    }
    this.moduleDefaultConfiguration = new ConcurrentMapConfiguration(base);
}
 
Example #5
Source File: MyBatisXmlParser.java    From jstarcraft-core with Apache License 2.0 6 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #6
Source File: BaseStreamCompilerAutoConfiguration.java    From spring-cloud-cli with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: TestUtils.java    From chassis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void writePropertiesToFile(String path, Set<Path> filesCreated, SimpleEntry<String, String>... entries) {
    Properties properties = new Properties();
    for (SimpleEntry<String, String> entry : entries) {
        properties.put(entry.getKey(), entry.getValue());
    }
    Path p = Paths.get(SystemPropertyUtils.resolvePlaceholders(path));
    try (OutputStream os = createFile(p.toString())) {
        properties.store(os, "test properties");
        filesCreated.add(p);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #8
Source File: ConfigurationBuilder.java    From chassis with Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example #9
Source File: BuildConfig.java    From hasor with Apache License 2.0 5 votes vote down vote up
public Hasor build(Object parentObject, ApplicationContext applicationContext) throws IOException {
    Hasor hasorBuild = (parentObject == null) ? Hasor.create() : Hasor.create(parentObject);
    hasorBuild.parentClassLoaderWith(applicationContext.getClassLoader());
    //
    // make sure mainConfig
    String config = this.mainConfig;
    if (!StringUtils.isBlank(config)) {
        config = SystemPropertyUtils.resolvePlaceholders(config);
        Resource resource = StringUtils.isNotBlank(config) ? applicationContext.getResource(config) : null;
        if (resource != null) {
            hasorBuild.mainSettingWith(resource.getURI());
        }
    }
    //
    // merge Properties
    if (this.envProperties != null) {
        this.envProperties.forEach((k, v) -> {
            hasorBuild.addVariable(k.toString(), v.toString());
        });
    }
    if (this.refProperties != null) {
        this.refProperties.forEach((k, v) -> {
            hasorBuild.addVariable(k.toString(), v.toString());
        });
    }
    if (this.customProperties != null) {
        this.customProperties.forEach((k, v) -> {
            hasorBuild.addVariable(k.toString(), v.toString());
        });
    }
    //
    // import Properties to Settings
    if (this.useProperties) {
        hasorBuild.importVariablesToSettings();
    }
    //
    return hasorBuild.addModules(this.loadModules);
}
 
Example #10
Source File: ModelClassFinder.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * Finds all the model classes and the model error class.
 *
 * @throws MojoExecutionException if a class couldn't be instantiated or an I/O error occurred.
 */
private void findModelClasses() throws MojoExecutionException
{
    try
    {
        log.debug("Finding model classes.");

        // Get the model classes as resources.
        modelClasses = new HashSet<>();

        // Loop through each model resource and add each one to the set of model classes.
        for (Resource resource : ResourceUtils.getResources(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
            ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(modelJavaPackage)) +
            "/**/*.class"))
        {
            if (resource.isReadable())
            {
                MetadataReader metadataReader = new CachingMetadataReaderFactory(new PathMatchingResourcePatternResolver()).getMetadataReader(resource);
                Class<?> clazz = Class.forName(metadataReader.getClassMetadata().getClassName());
                modelClasses.add(clazz);
                log.debug("Found model class \"" + clazz.getName() + "\".");

                // If the model error class name is configured and matches this class, then hold onto it.
                if (clazz.getSimpleName().equals(modelErrorClassName))
                {
                    log.debug("Found model error class \"" + clazz.getName() + "\".");
                    modelErrorClass = clazz;
                }
            }
        }
    }
    catch (IOException | ClassNotFoundException e)
    {
        throw new MojoExecutionException("Error finding model classes. Reason: " + e.getMessage(), e);
    }
}
 
Example #11
Source File: JaxbElementWrapper.java    From eclair with Apache License 2.0 5 votes vote down vote up
private Resource[] pathToResources(String path) {
    String resourcePath = ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(path));
    String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resourcePath + "/*.class";
    try {
        return resourcePatternResolver.getResources(packageSearchPath);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example #12
Source File: CommunicationXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = CommunicationModule.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(name)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new CommunicationConfigurationException(message, exception);
    }
}
 
Example #13
Source File: CodecXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
/**
 * 获取指定包下的静态资源对象
 * 
 * @param packageName 包名
 * @return
 * @throws IOException
 */
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = this.resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = ProtocolConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(resource);
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (annotationMetadata.hasAnnotation(name)) {
                names.add(classMetadata.getClassName());
            } else {
                String[] interfaceNames = classMetadata.getInterfaceNames();
                for (String interfaceName : interfaceNames) {
                    metadataReader = this.metadataReaderFactory.getMetadataReader(interfaceName);
                    annotationMetadata = metadataReader.getAnnotationMetadata();
                    if (annotationMetadata.hasAnnotation(name)) {
                        names.add(classMetadata.getClassName());
                        break;
                    }
                }
            }
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        throw new RuntimeException(exception);
    }
}
 
Example #14
Source File: CacheXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = CacheConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(name)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new CacheConfigurationException(message, exception);
    }
}
 
Example #15
Source File: LuceneXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String document = LuceneConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(document)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #16
Source File: BerkeleyXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String entity = Entity.class.getName();
        String persistent = Persistent.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(entity) && !annotationMetadata.hasAnnotation(persistent)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #17
Source File: MongoXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String document = Document.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(document)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        LOGGER.error(message, exception);
        throw new StorageConfigurationException(message, exception);
    }
}
 
Example #18
Source File: ResourceXmlParser.java    From jstarcraft-core with Apache License 2.0 5 votes vote down vote up
private String[] getResources(String packageName) {
    try {
        // 搜索资源
        String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(packageName)) + "/" + DEFAULT_RESOURCE_PATTERN;
        Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
        // 提取资源
        Set<String> names = new HashSet<String>();
        String name = ResourceConfiguration.class.getName();
        for (Resource resource : resources) {
            if (!resource.isReadable()) {
                continue;
            }
            // 判断是否静态资源
            MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
            AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
            if (!annotationMetadata.hasAnnotation(name)) {
                continue;
            }
            ClassMetadata classMetadata = metadataReader.getClassMetadata();
            names.add(classMetadata.getClassName());
        }
        return names.toArray(new String[0]);
    } catch (IOException exception) {
        String message = "无法获取资源";
        logger.error(message, exception);
        throw new StorageException(message, exception);
    }
}
 
Example #19
Source File: PropertySourcesPlaceholdersResolver.java    From spring-cloud-gray with Apache License 2.0 5 votes vote down vote up
public PropertySourcesPlaceholdersResolver(Iterable<PropertySource<?>> sources,
                                           PropertyPlaceholderHelper helper) {
    this.sources = sources;
    this.helper = (helper != null) ? helper
            : new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
            SystemPropertyUtils.PLACEHOLDER_SUFFIX,
            SystemPropertyUtils.VALUE_SEPARATOR, true);
}
 
Example #20
Source File: StringUtils.java    From rug-cli with GNU General Public License v3.0 4 votes vote down vote up
public static String expandEnvironmentVars(String text) {
    if (text == null) {
        return text;
    }
    return SystemPropertyUtils.resolvePlaceholders(text);
}
 
Example #21
Source File: JFishResourcesScanner.java    From onetwo with Apache License 2.0 4 votes vote down vote up
protected String resolveBasePackage(String basePackage) {
	return ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(basePackage));
}
 
Example #22
Source File: ClassScanner.java    From kaif with Apache License 2.0 4 votes vote down vote up
private static String resolveBasePackage(String basePackage) {
  return ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(
      basePackage));
}
 
Example #23
Source File: AutomaticJobRegistrarConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 4 votes vote down vote up
private String resolveBasePackage(String basePackage) {
	return ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(basePackage));
}
 
Example #24
Source File: CsvReportEntitiesMapping.java    From aw-reporting with Apache License 2.0 2 votes vote down vote up
/**
 * Resolve the package name to a canonical path, in case there any place holders.
 *
 * @param basePackage the base package to be scanned.
 * @return the canonical version of the package name.
 */
private static String resolveBasePackage(String basePackage) {
  return ClassUtils.convertClassNameToResourcePath(
      SystemPropertyUtils.resolvePlaceholders(basePackage));
}
 
Example #25
Source File: ContextUtil.java    From BlogManagePlatform with Apache License 2.0 2 votes vote down vote up
/**
 * 转换成包名,ant风格
 * @author Frodez
 * @date 2019-12-14
 */
public static String getPackagePath(String pattern) {
	String packagePath = ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(pattern));
	return StrUtil.concat(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX, packagePath, DefStr.CLASS_SUFFIX);
}
 
Example #26
Source File: ClassPathScanningCandidateComponentProvider.java    From thinking-in-spring-boot-samples with Apache License 2.0 2 votes vote down vote up
/**
 * Resolve the specified base package into a pattern specification for
 * the package search path.
 * <p>The default implementation resolves placeholders against system properties,
 * and converts a "."-based package path to a "/"-based resource path.
 * @param basePackage the base package as specified by the user
 * @return the pattern specification to be used for package searching
 */
protected String resolveBasePackage(String basePackage) {
    return ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(basePackage));
}
 
Example #27
Source File: ClassPathScanningCandidateComponentProvider.java    From thinking-in-spring-boot-samples with Apache License 2.0 2 votes vote down vote up
/**
 * Resolve the specified base package into a pattern specification for
 * the package search path.
 * <p>The default implementation resolves placeholders against system properties,
 * and converts a "."-based package path to a "/"-based resource path.
 * @param basePackage the base package as specified by the user
 * @return the pattern specification to be used for package searching
 */
protected String resolveBasePackage(String basePackage) {
    return ClassUtils.convertClassNameToResourcePath(SystemPropertyUtils.resolvePlaceholders(basePackage));
}