Example usage for org.springframework.core.io DefaultResourceLoader DefaultResourceLoader

List of usage examples for org.springframework.core.io DefaultResourceLoader DefaultResourceLoader

Introduction

In this page you can find the example usage for org.springframework.core.io DefaultResourceLoader DefaultResourceLoader.

Prototype

public DefaultResourceLoader() 

Source Link

Document

Create a new DefaultResourceLoader.

Usage

From source file:com.github.mjeanroy.springmvc.view.mustache.MustacheView_Handlebars_Test.java

@Before
public void setUp() throws Exception {
    this.model = new HashMap<String, Object>();
    this.model.put("name", "foo");
    this.model.put("zero", 0);
    this.model.put("emptyString", "");

    writer = new StringWriter();
    when(response.getWriter()).thenReturn(new PrintWriter(writer));

    ResourceLoader resourceLoader = new DefaultResourceLoader();
    templateLoader = new DefaultTemplateLoader(resourceLoader);

    Handlebars handlebars = new Handlebars();
    MustacheCompiler mustacheCompiler = new HandlebarsCompiler(handlebars, templateLoader);
    mustacheView = new MustacheView();
    mustacheView.setCompiler(mustacheCompiler);
}

From source file:com.github.mjeanroy.springmvc.view.mustache.MustacheView_JMustache_Test.java

@Before
public void setUp() throws Exception {
    this.model = new HashMap<String, Object>();
    this.model.put("name", "foo");
    this.model.put("zero", 0);
    this.model.put("emptyString", "");

    writer = new StringWriter();
    when(response.getWriter()).thenReturn(new PrintWriter(writer));

    ResourceLoader resourceLoader = new DefaultResourceLoader();
    templateLoader = new DefaultTemplateLoader(resourceLoader);
    Compiler compiler = Mustache.compiler().zeroIsFalse(true).emptyStringIsFalse(true);

    MustacheCompiler mustacheCompiler = new JMustacheCompiler(compiler, templateLoader);
    mustacheView = new MustacheView();
    mustacheView.setCompiler(mustacheCompiler);
}

From source file:org.paxml.util.PaxmlUtils.java

/**
 * Get resource from path./*  www .  ja  v  a2 s. co  m*/
 * 
 * @param path
 *            if path has prefix, the path will be directly used; if not,
 *            the path will be treated as a relative path based on the
 *            "base" resource parameter.
 * @param base
 *            the base resource when path has no prefix. If null given and
 *            base resource has no prefix, then the path is assumed to be a
 *            file system resource if it exists, and if it doesn't exist, it
 *            will be assumed as a classpath resource.
 * @return the Spring resource.
 */
public static Resource getResource(String path, Resource base) {
    final String filePrefix = "file:";
    final String classpathPrefix = "classpath:";

    if (!path.startsWith(filePrefix) && !path.startsWith(classpathPrefix)) {
        if (base == null) {
            File file = getFile(path);
            if (file.isFile()) {
                path = filePrefix + file.getAbsolutePath();
            } else {
                // assume to be a file
                path = classpathPrefix + path;
            }
        } else {
            try {
                path = base.createRelative(path).getURI().toString();
            } catch (IOException e) {
                throw new PaxmlParseException("Cannot create relative path '" + path + "' from base resource: "
                        + base + ", because: " + e.getMessage());
            }
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("Taking resource from computed path: " + path);
    }
    return new DefaultResourceLoader().getResource(path);

}

From source file:org.obiba.mica.micaConfig.service.EntityConfigService.java

private String getResourceAsString(String path, String defaultValue) {

    if (StringUtils.isEmpty(path))
        return defaultValue;

    Resource resource = new DefaultResourceLoader().getResource(path);
    try (Scanner s = new Scanner(resource.getInputStream())) {
        return s.useDelimiter("\\A").hasNext() ? s.next() : "";
    } catch (IOException e) {
        return defaultValue;
    }/*from www  .j a  v  a  2s.c  o  m*/
}

From source file:com.edgenius.wiki.service.impl.SystemPropertyPlaceholderConfigurer.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    Properties props = loadProperties();

    DefaultResourceLoader loader = new DefaultResourceLoader();
    Resource globalConf = loader.getResource(props.get(DataRoot.rootKey) + Global.FILE);
    initGlobal(globalConf);//www  .  j ava2s . c  o m

    super.postProcessBeanFactory(beanFactory);
}

From source file:org.obiba.mica.micaConfig.service.DataAccessFormService.java

private Resource getDefaultDataAccessFormResource(String name) {
    return new DefaultResourceLoader().getResource("classpath:config/data-access-form/" + name);
}

From source file:eu.eidas.node.utils.PluginPropertyLoader.java

private void updatePropLocation() {
    if (locationProp != null && locationNames != null && locationNames.length > 0) {
        List<Resource> loadedLocations = new ArrayList<Resource>();
        DefaultResourceLoader drl = new DefaultResourceLoader();
        String locationPropValue = PropertiesUtil.getProperty(locationProp);
        for (int i = 0; i < locationNames.length && locationPropValue != null; i++) {
            String currentLocation = locationPropValue + locationNames[i];
            loadedLocations.add(drl.getResource("file:" + currentLocation.replace(File.separatorChar, '/')));
        }// w  ww  .  ja  va2s.c o  m
        locations = new Resource[loadedLocations.size()];
        loadedLocations.toArray(locations);
        if (isLocationReadable(locationPropValue) && locations.length > 0) {
            setLocations(locations);
        }
    }
}

From source file:com.hesine.manager.generate.Generate.java

public static void main(String[] args) throws Exception {
    File projectPath = new DefaultResourceLoader().getResource("").getFile();
    //        Generate.execute(projectPath);

    // /*from  w w w. ja v a  2  s. c o  m*/
    String packageName = "com.hesine.manager";
    String moduleName = "";

    // ?
    List<Map<String, String>> list = DBOperator.getTables("tb_");
    for (Map<String, String> a : list) {
        System.out.println(a.toString());
        if (a.get("tableName").equals("tb_userinfo")) {
            List<Map<String, String>> listTC = DBOperator.getTableColumns(a.get("tableName"));
            // ?
            for (Map<String, String> b : listTC) {
                System.out.println(b.toString());
                for (String key : b.keySet()) {
                    System.out.println(key + " : " + b.get(key));
                }

            }
            Generate.execute(projectPath, packageName, moduleName, a, listTC);
            break;
        }
    }

}

From source file:com.netflix.genie.client.JobClientIntegrationTests.java

/**
 * Setup for tests.//from   w w w  .  ja  v a 2s .c  o m
 *
 * @throws Exception If there is an error.
 */
@Before
public void setup() throws Exception {
    this.resourceLoader = new DefaultResourceLoader();
    clusterClient = new ClusterClient(getBaseUrl(), null, null);
    commandClient = new CommandClient(getBaseUrl(), null, null);
    //applicationClient = new ApplicationClient(getBaseUrl());
    final GenieNetworkConfiguration genieNetworkConfiguration = new GenieNetworkConfiguration();
    genieNetworkConfiguration.setReadTimeout(20000);
    jobClient = new JobClient(getBaseUrl(), null, genieNetworkConfiguration);
}