Package org.springframework.core.io.support

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


  public void stop() {
    // no op
  }

  private List<Class> getRemoteObjectJavaBean() {
    ResourcePatternResolver rl = new PathMatchingResourcePatternResolver();
    List<Class> result = new ArrayList();
    try {
      List<String> classNames = ScanClassUtils.scanPackages(packageToScan);
      for(String className : classNames) {
        Class type = Class.forName(className);
View Full Code Here


   */
  private static Class<?>[] getClassesInPackage(Class<?> klass) {
    String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "/" +
        klass.getPackage().getName().replaceAll("\\.", "/") + "/*" + TEST_CLASSNAME_SUFFIX + ".class";
    ArrayList<Class<?>> results = new ArrayList<Class<?>>();
    ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
    try {
      Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
      if (resources != null) {
        for (Resource resource : resources) {
          String unqualifiedClassName = resource.getFilename().replace(".class", "");
          String className = klass.getPackage().getName() + "." + unqualifiedClassName;
          Class<?> candidate = ClassUtils.resolveClassName(className, klass.getClassLoader());
View Full Code Here

*/
public class ParentLastURLClassLoaderTests {
  @Test
  public void test() throws IOException {

    ResourcePatternResolver resourceLoader = new PathMatchingResourcePatternResolver();
    Resource module = resourceLoader.getResource("DefaultModuleOptionsMetadataResolverTests-modules/source/module1/");
    assertTrue(module.exists());

    URLClassLoader classLoader = new ParentLastURLClassLoader(new URL[] {module.getURL()}, getClass().getClassLoader());

    assertNotNull(classLoader.getResource("config/module1.properties"));
View Full Code Here

          + resourceName);

    String collectionPrefix = resourceName.substring(0, index);
    String collectionResourcePath = resourceName.substring(index + 1);

    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

    Map<String, String> resourceMapping = new HashMap<String, String>();

    try {
      org.springframework.core.io.Resource[] resources = resolver.getResources(collectionResourcePath);

      for (org.springframework.core.io.Resource resource : resources) {
        URL url = resource.getURL();
        String name = getLocalUrlAsResourceName(url);
        Resource r = getResourceForPath(name, localeProvider, url);
View Full Code Here

    if (pkg != null) {
      return pkg;
    }
    try {
      // Attempt to find a class in this package
      ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(
          getClass().getClassLoader());
      Resource[] resources = resolver.getResources(ClassUtils
          .convertClassNameToResourcePath(source.toString()) + "/*.class");
      for (Resource resource : resources) {
        String className = StringUtils.stripFilenameExtension(resource
            .getFilename());
        load(Class.forName(source.toString() + "." + className));
View Full Code Here

      throw new IllegalStateException(ex);
    }
  }

  private Resource[] scan(ClassLoader loader, String packageName) throws IOException {
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(loader);
    String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
        + ClassUtils.convertClassNameToResourcePath(packageName) + "/**/*.class";
    Resource[] resources = resolver.getResources(pattern);
    return resources;
  }
View Full Code Here

    protected List<PageConfig> loadPages() throws Exception {
        //
        Map<String, PageConfig> abstractPageConfigMap = new HashMap<String, PageConfig>();
        List<PageConfig> pageConfigList = new ArrayList<PageConfig>();
        //
        ResourcePatternResolver rpr = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
        Resource[] resources = rpr.getResources(prefix + "/**/*" + suffix);
        // parse abstract pages
        for (Resource resource : resources) {
            Document xmlDoc = xmlParser.parseAndValidate(resource);
            Element pagesEle = xmlDoc.getDocumentElement();
            List<Element> pageEles = DomUtils.getChildElementsByTagName(pagesEle, "page");
View Full Code Here

        //
        List<MailConfig> mailConfigHolder = new ArrayList<MailConfig>();
        //
        String locationPattern = String.format("%s/**/*%s", prefix, suffix);
        //
        ResourcePatternResolver rpr = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
        Resource[] resources = rpr.getResources(locationPattern);
        for(Resource resource : resources) {
            //
            Document xmlDoc = xmlParser.parseAndValidate(resource);
            parse(xmlDoc.getDocumentElement(), mailConfigHolder);
        }
View Full Code Here

    int fileCount = 0;
    ClassFileModelBuilder cfmb = new ClassFileModelBuilder();
    String[] paths = getContext().getClassPath().split(File.pathSeparator);
    for (int i = 0; i < paths.length; i++) {
      FileSystemResourceLoader loader = new FileSystemResourceLoader();
      ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(loader);
      String ending = "/"+ ((basePackage.length() > 0) ? basePackage.replace(".", "/") + "/" : "") + pattern;
     
      if (paths[i].startsWith("/")) {
        paths[i] = "file:" + paths[i];
      }
     
      if (paths[i].endsWith(".jar")) {
        paths[i] = "jar:"+ paths[i] + "!";
      }
     
      String packageSearchPath =paths[i]+ending;

      getContext().getLogger().send("Searching: "+packageSearchPath);
      Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);

      for (Resource resource : resources) {
        fileCount++;
        cfmb.visit(resource);
      }
View Full Code Here

   private XMLHelper helper = new XMLHelper();
   
   public List<WorkItem> getItems() {
  FileSystemResourceLoader loader = new FileSystemResourceLoader();
  ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(loader);
  try {
      String packageSearchPath = baseFolder + "/" + pattern;
      Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
      List<WorkItem> out = new ArrayList<WorkItem>(resources.length * 2);

      for (Resource r : resources) {
    getContext().getLogger().send("Scanning: " + r);
    Object o = helper.fromXML(r.getInputStream());
View Full Code Here

TOP

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

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.