Package org.springframework.core.io

Examples of org.springframework.core.io.Resource


    public static IEmailService createPartiallyMockedEmailService(String templateDir) {
        try {
            GaeEmailUtils gaeEmailUtils = mock(GaeEmailUtils.class);
            GaeVelocityUtils gaeVelocityUtils = GaeVelocityUtils.getInstance();

            Resource templateDirResource = mock(Resource.class, RETURNS_DEEP_STUBS);
            when(templateDirResource.exists()).thenReturn(true);
            when(templateDirResource.getFile().getPath()).thenReturn(templateDir);

            GaeVelocityTemplateService templateService = new GaeVelocityTemplateService();
            templateService.setGaeVelocityUtils(gaeVelocityUtils);
            templateService.setTemplateDirResource(templateDirResource);
            templateService.afterPropertiesSet();
View Full Code Here


     * @param entitiesPath  Path to the entities configuration file on disk
     * @return DaoObjectifyService created based on the contents of the entities file.
     */
    public static DaoObjectifyService createDaoObjectifyService(String entitiesPath) {
        String contents = FilesystemUtils.getFileContentsAsString(entitiesPath);
        Resource entities = TestUtils.createMockedResource(contents);
        return createDaoObjectifyService(entities);
    }
View Full Code Here

        for (Class clazz : classes) {
            contents.append(clazz.getCanonicalName());
            contents.append("\n");
        }

        Resource entities = TestUtils.createMockedResource(contents.toString());
        return createDaoObjectifyService(entities);
    }
View Full Code Here

        this.schema = schema;
    }

    public InputSource getInputSource() throws IOException {
        if (inputSource == null) {
            Resource resource = getSchemaResource();
            if (resource == null) {
                throw new IllegalArgumentException("No schemaResource or inputSource specified");
            } else {
                InputStream inputStream = resource.getInputStream();
                if (inputStream == null) {
                    throw new IllegalArgumentException("No inputStream available for: " + resource);
                }
                inputSource = new InputSource(inputStream);
            }
View Full Code Here

* @version $Revision: 1.1 $
*/
public class JingComponent extends ResourceBasedComponent {
    protected Endpoint<Exchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
        JingValidator validator = new JingValidator();
        Resource resource = resolveMandatoryResource(remaining);
        validator.setSchemaResource(resource);
        if (LOG.isDebugEnabled()) {
            LOG.debug(this + " using schema resource: " + resource);
        }
        configureValidator(validator, uri, remaining, parameters);
View Full Code Here

    public void setResourceLoader(ResourceLoader resourceLoader) {
        this.resourceLoader = resourceLoader;
    }

    protected Resource resolveMandatoryResource(String uri) {
        Resource resource = getResourceLoader().getResource(uri);
        if (resource == null) {
            throw new IllegalArgumentException("Could not find resource for URI: " + uri + " using: " + getResourceLoader());
        } else {
            return resource;
        }
View Full Code Here

*/
public class ValidatorComponent extends ResourceBasedComponent {

    protected Endpoint<Exchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
        SpringValidator validator = new SpringValidator();
        Resource resource = resolveMandatoryResource(remaining);
        validator.setSchemaResource(resource);
        if (LOG.isDebugEnabled()) {
            LOG.debug(this + " using schema resource: " + resource);
        }
        configureValidator(validator, uri, remaining, parameters);
View Full Code Here

        }
        applicationContext = new GenericApplicationContext();
        resourceLoader = new DefaultResourceLoader(configContextClass.getClassLoader());
        for (String beanDefinitionPath : getConfigLocations()) {
            XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(applicationContext);
            Resource resource = resourceLoader.getResource(beanDefinitionPath);
            reader.loadBeanDefinitions(resource);
        }
        additionalSpringConfiguration(applicationContext);
        applicationContext.refresh();
        super.setUpBus();
View Full Code Here

    public BusApplicationContextResourceResolver() {
    }
   

    public InputStream getAsStream(String name) {
        Resource r = context.getResource(name);
        if (r != null && r.exists()) {
            try {
                return r.getInputStream();
            } catch (IOException e) {
                //ignore and return null
            }
        }
        return null;
View Full Code Here

        }
        try {
            if (ClassLoader.class.isAssignableFrom(resourceType)) {
                return resourceType.cast(context.getClassLoader());
            } else if (URL.class.isAssignableFrom(resourceType)) {
                Resource r = context.getResource(resourceName);
                if (r != null && r.exists()) {
                    return resourceType.cast(r.getURL());
                }
            }
        } catch (IOException e) {
            //ignore
        }
View Full Code Here

TOP

Related Classes of org.springframework.core.io.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.