Search in sources :

Example 6 with ProjectStage

use of org.apache.deltaspike.core.api.projectstage.ProjectStage in project deltaspike by apache.

the class PropertyLoader method loadAllProperties.

private static List<Properties> loadAllProperties(String propertyFileName) throws IOException {
    ClassLoader cl = ClassUtils.getClassLoader(null);
    List<Properties> properties = new ArrayList<Properties>();
    // read the normal property file names
    Enumeration<URL> propertyUrls = cl.getResources(propertyFileName + FILE_EXTENSION);
    while (propertyUrls != null && propertyUrls.hasMoreElements()) {
        URL propertyUrl = propertyUrls.nextElement();
        fillProperties(properties, propertyUrl);
    }
    // and also read the ones post-fixed with the projectStage
    ProjectStage ps = ProjectStageProducer.getInstance().getProjectStage();
    propertyUrls = cl.getResources(propertyFileName + "-" + ps + FILE_EXTENSION);
    while (propertyUrls != null && propertyUrls.hasMoreElements()) {
        URL propertyUrl = propertyUrls.nextElement();
        fillProperties(properties, propertyUrl);
    }
    if (properties.isEmpty()) {
        if (LOG.isLoggable(Level.INFO)) {
            LOG.info("could not find any property files with name " + propertyFileName);
        }
        return null;
    }
    return properties;
}
Also used : ProjectStage(org.apache.deltaspike.core.api.projectstage.ProjectStage) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URL(java.net.URL)

Aggregations

ProjectStage (org.apache.deltaspike.core.api.projectstage.ProjectStage)6 Test (org.junit.Test)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Exclude (org.apache.deltaspike.core.api.exclude.Exclude)1 Deactivatable (org.apache.deltaspike.core.spi.activation.Deactivatable)1 ProjectStageProducer (org.apache.deltaspike.core.util.ProjectStageProducer)1