Examples of PathMatchingResourcePatternResolver


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

   *
   * @param resourcePattern
   * @throws IOException When the path cannot be matched
   */
  public void loadBeans(String resourcePattern) throws IOException {
    loadBeans(new PathMatchingResourcePatternResolver().getResources(resourcePattern));
  }

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

        // Import any ldif files
        Resource[] ldifs;

        if (ctxt == null) {
            // Not running within an app context
            ldifs = new PathMatchingResourcePatternResolver().getResources(ldifResources);
        } else {
            ldifs = ctxt.getResources(ldifResources);
        }

        // Note that we can't just import using the ServerContext returned

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

        PythonInterpreter python = new PythonInterpreter();
        python.set("authentication", authentication);
        python.set("args", createArgumentMap(mi));
        python.set("method", mi.getMethod().getName());
        Resource scriptResource = new PathMatchingResourcePatternResolver().getResource(script);

        try {
            python.execfile(scriptResource.getInputStream());
        } catch (IOException e) {
            throw new IllegalArgumentException("Couldn't run python script, " + script, e);

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

 
        List<Resource> resources = new ArrayList<Resource>();
      
        if (includeDefaults) {
            try {
                PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(Thread
                    .currentThread().getContextClassLoader());
               
                Collections.addAll(resources, resolver.getResources(DEFAULT_CXF_CFG_FILE));

                Resource[] exts = resolver.getResources(DEFAULT_CXF_EXT_CFG_FILE);
                for (Resource r : exts) {
                    InputStream is = r.getInputStream();
                    BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                    String line = rd.readLine();
                    while (line != null) {
                        if (!"".equals(line)) {
                            resources.add(resolver.getResource(line));
                        }
                        line = rd.readLine();
                    }
                    is.close();
                }

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

    protected Map< Class< ? extends Annotation >, Collection< Class< ? > > > findClassesInternal(
        Collection< String > basePackages, List<Class< ? extends Annotation > > annotations)
        throws IOException, ClassNotFoundException {
   
        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        MetadataReaderFactory factory = new CachingMetadataReaderFactory(resolver);
       
        final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
            new HashMap< Class< ? extends Annotation >, Collection< Class< ? > > >();
        final Map< Class< ? extends Annotation >, Collection< String > > matchingInterfaces =
            new HashMap< Class< ? extends Annotation >, Collection< String > >();
        final Map<String, String[]> nonMatchingClasses = new HashMap<String, String[]>();
       
        for (Class< ? extends Annotation > annotation: annotations) {
            classes.put(annotation, new HashSet< Class < ? > >());
            matchingInterfaces.put(annotation, new HashSet< String >());
        }
       
        if (basePackages == null || basePackages.isEmpty()) {
            return classes;
        }
       
        for (final String basePackage: basePackages) {
            final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
           
            final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
                + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(basePackage))
                + ALL_CLASS_FILES;
           
            final Resource[] resources = resolver.getResources(packageSearchPath);   
           
           
            for (final Resource resource: resources) {
                final MetadataReader reader = factory.getMetadataReader(resource);
                final AnnotationMetadata metadata = reader.getAnnotationMetadata();

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

        throws IOException {
        final List<URL> resourceURLs = new ArrayList<URL>();
        if (basePackages == null || basePackages.isEmpty()) {
            return resourceURLs;
        }
        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
       
       
       
        for (final String basePackage: basePackages) {
            final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
           
            String theBasePackage = basePackage;
            if (theBasePackage.startsWith(CLASSPATH_URL_SCHEME)) {
                theBasePackage = theBasePackage.substring(CLASSPATH_URL_SCHEME.length());
            }
           
            final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
                + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(theBasePackage))
                + ALL_FILES + "." + extension;
           
            final Resource[] resources = resolver.getResources(packageSearchPath);                       
            for (final Resource resource: resources) {
                resourceURLs.add(resource.getURL());
            }                       
        }
       

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

      throws IOException {
    String lastPart = StringUtils.hasText(fileName) ? fileName : "*";
    String pattern = "file:" + yarnCluster.getYarnWorkDir().getAbsolutePath()
        + "/*logDir*/" + applicationId.toString()
        + "/**/" + lastPart;
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    ArrayList<Resource> ret = new ArrayList<Resource>();
    for (Resource r : resolver.getResources(pattern)) {
      if (r.getFile().isFile()) {
        ret.add(r);
      }
    }
    return ret;

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

  }

  public void setResourceLoader(ResourceLoader resourceLoader) {
    this.resourcePatternResolver = (resourceLoader != null ?
        ResourcePatternUtils.getResourcePatternResolver(resourceLoader) :
        new PathMatchingResourcePatternResolver());
  }

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

*/
public class PersistenceXmlParsingTests extends TestCase {

  public void testExample1() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-example1.xml";
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertNotNull(info);
    assertEquals(1, info.length);

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

    assertEquals("OrderManagement", info[0].getPersistenceUnitName());
  }

  public void testExample2() throws Exception {
    PersistenceUnitReader reader = new PersistenceUnitReader(
        new PathMatchingResourcePatternResolver(), new JndiDataSourceLookup());
    String resource = "/org/springframework/orm/jpa/persistence-example2.xml";
    PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);

    assertNotNull(info);
    assertEquals(1, info.length);
TOP
Copyright © 2018 www.massapi.com. 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.