Revision 41073

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/plugins/PluginClassLoader.java
384 384
    /**
385 385
     * Gets the requested resource. If the path is relative, its base directory
386 386
     * will be the one provided in the PluginClassLoader's constructor.
387
     * If the resource is not found, the parent classloader will be invoked
388
     * to try to get it. If it is not found, it will return null.
387
     * If the resource is not found, search in dependents plugins, otherwise 
388
     * the parent classloader will be invoked to try to get it. 
389
     * If it is not found, it will return null.
389 390
     *
390 391
     * @param res An absolute or relative path to the requested resource.
391 392
     *
......
393 394
     */
394 395
    public URL getResource(String res) {
395 396
    	URL ret = null;
396
        try {
397
    	//
398
    	// Primero buscamos en el directorio del plugin.
399
    	try {
397 400
        	logger.debug("Search resource {} in {}", res, this.baseDir.toString());
398 401
            List<String> resource = new ArrayList<String>();
399 402
            StringTokenizer st = new StringTokenizer(res, "\\/");
400

  
401 403
            while (st.hasMoreTokens()) {
402 404
                String token = st.nextToken();
403 405
                resource.add(token);
404 406
            }
405

  
406 407
            ret = getResource(baseDir, resource);
407

  
408 408
            if (ret != null) {
409 409
                return ret;
410 410
            }
......
412 412
        	logger.info("Error getting resource {} in {}'", new Object[] {res,this.baseDir.toString()}, e);
413 413
        }
414 414
        
415
    	// 
416
    	// Luego en los plugins de los que depende 
417
        logger.debug("Searching in depends pluginLoaders");
418
        for (int i = 0; i < this.pluginLoaders.length; i++) {
419
        	PluginClassLoader pluginClassLoader = pluginLoaders[i];
420
    		if (pluginClassLoader != null) {
421
    			try {
422
    				ret = pluginClassLoader.getResource(res);
423
    	            if (ret != null) {
424
    	            	logger.info("Found resource in plugin '"+pluginClassLoader.getPluginName()+"' ("+res+").");
425
    	                return ret;
426
    	            }
427
            	} catch (Exception e) {
428
            		// Ignore, try in next classloader
429
            	}
430
    		}
431
        }
432
        
433
        //
434
        // Por ultimo en el class loader padre, se supone que es el del sistema.
415 435
        try {
416 436
            ret = super.getResource(res);
417 437
        } catch (Exception e) {
418 438
        	logger.info("Error getting resource {} in {}'", new Object[] {res,this.baseDir.toString()}, e);
419 439
        }
440
        
441
        
420 442
        if( ret == null ) {
421 443
        	logger.info("Error getting resource {} in {}'", new Object[] {res,this.baseDir.toString()});
422 444
        }

Also available in: Unified diff