Package org.springframework.core.io.support

Examples of org.springframework.core.io.support.PathMatchingResourcePatternResolver


        catch (Throwable t) {
            // restrictive classloading environment, use the original
            parentOnlyResourceLoader = originalResourceLoader;
        }

        final PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(parentOnlyResourceLoader) {
            @Override
            protected Resource[] findAllClassPathResources(String location) throws IOException {
                Set<Resource> result = new LinkedHashSet<Resource>(16);

                if(BuildSettings.CLASSES_DIR != null) {
                    @SuppressWarnings("unused")
                    URL classesDir = BuildSettings.CLASSES_DIR.toURI().toURL();

                    // only scan classes from project classes directory
                    String path = location;
                    if (path.startsWith("/")) {
                        path = path.substring(1);
                    }
                    Enumeration<URL> resourceUrls = getClassLoader().getResources(path);
                    while (resourceUrls.hasMoreElements()) {
                        URL url = resourceUrls.nextElement();
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("Scanning URL " + url.toExternalForm() + " while searching for '" + location + "'");
                        }
                    /*
                    if (!warDeployed && classesDir!= null && url.equals(classesDir)) {
                        result.add(convertClassLoaderURL(url));
                    }
                    else if (warDeployed) {
                        result.add(convertClassLoaderURL(url));
                    }
                    */
                        result.add(convertClassLoaderURL(url));
                    }
                }
                return result.toArray(new Resource[result.size()]);
            }
        };
        resourceResolver.setPathMatcher(new AntPathMatcher() {
            @Override
            public boolean match(String pattern, String path) {
                if (path.endsWith(".class")) {
                    String filename = GrailsStringUtils.getFileBasename(path);
                    if (filename.contains("$")) return false;


    public void setResourceLoader(ResourceLoader resourceLoader) {
        super.setResourceLoader(resourceLoader);

        this.localResourceLoader = resourceLoader;
        if (resourceResolver == null) {
            resourceResolver = new PathMatchingResourcePatternResolver(localResourceLoader);
        }
    }

    protected MockApplicationContext createMockApplicationContext() {
        return new MockApplicationContext();
    }

    protected Resource[] getResources(String pattern) throws IOException {
        return new PathMatchingResourcePatternResolver().getResources(pattern);
    }

    protected GrailsPluginManager pluginManager;
    protected boolean warDeployed = Environment.isWarDeployed();

    public void setSearchLocation(String searchLocation) {
        ResourceLoader resourceLoader = getDefaultResourceLoader();
        patchMatchingResolver = new PathMatchingResourcePatternResolver(resourceLoader);
        initializeForSearchLocation(searchLocation);
    }

    protected ResourceLoader getDefaultResourceLoader() {
        return defaultResourceLoader;
    }

    public void setSearchLocations(Collection<String> searchLocations) {
        patchMatchingResolver = new PathMatchingResourcePatternResolver(getDefaultResourceLoader());
        for (String searchLocation : searchLocations) {
            initializeForSearchLocation(searchLocation);
        }
    }

    public DefaultGrailsPlugin(Class<?> pluginClass, Resource resource, GrailsApplication application) {
        super(pluginClass, application);
        // create properties
        dependencies = Collections.emptyMap();
        pluginDescriptor = resource;
        resolver = new PathMatchingResourcePatternResolver();

        initialisePlugin(pluginClass);
    }

        foundPluginClasses.add(plugin);
    }

    public void setParentApplicationContext(ApplicationContext parent) {
        if (parent != null) {
            resolver = new PathMatchingResourcePatternResolver(parent);
        }
    }

    public DefaultGrailsPluginManager(String resourcePath, GrailsApplication application) {
        super(application);
        Assert.notNull(application, "Argument [application] cannot be null!");

        resolver = new PathMatchingResourcePatternResolver();
        try {
            pluginResources = resolver.getResources(resourcePath);
        }
        catch (IOException ioe) {
            LOG.debug("Unable to load plugins for resource path " + resourcePath, ioe);

        setPluginFilter();
    }

    public DefaultGrailsPluginManager(String[] pluginResources, GrailsApplication application) {
        super(application);
        resolver = new PathMatchingResourcePatternResolver();

        List<Resource> resourceList = new ArrayList<Resource>();
        for (String resourcePath : pluginResources) {
            try {
                resourceList.addAll(Arrays.asList(resolver.getResources(resourcePath)));

    }

    public DefaultGrailsPluginManager(Class<?>[] plugins, GrailsApplication application) {
        super(application);
        pluginClasses = plugins;
        resolver = new PathMatchingResourcePatternResolver();
        //this.corePlugins = new PathMatchingResourcePatternResolver().getResources("classpath:org/codehaus/groovy/grails/**/plugins/**GrailsPlugin.groovy");
        this.application = application;
        setPluginFilter();
    }

TOP

Related Classes of org.springframework.core.io.support.PathMatchingResourcePatternResolver

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.