View | Details | Raw Unified | Return to bug 56771
Collapse All | Expand All

(-)java/org/apache/naming/resources/BaseDirContext.java (-20 / +37 lines)
Lines 425-436 Link Here
425
425
426
        if (path != null)
426
        if (path != null)
427
            return path;
427
            return path;
428
        
428
429
        String resourceName = "/META-INF/resources" + name;
429
        // Check the alternate locations
430
        // Check the alternate locations
430
        for (DirContext altDirContext : altDirContexts) {
431
        for (DirContext altDirContext : altDirContexts) {
431
            if (altDirContext instanceof BaseDirContext){
432
            if (altDirContext instanceof BaseDirContext){
432
                path = ((BaseDirContext) altDirContext).getRealPath(
433
                path = ((BaseDirContext) altDirContext).getRealPath(resourceName);
433
                        "/META-INF/resources" + name);
434
                if (path != null)
434
                if (path != null)
435
                    return path;
435
                    return path;
436
            }
436
            }
Lines 470-475 Link Here
470
    @Override
470
    @Override
471
    public final Object lookup(String name) throws NamingException {
471
    public final Object lookup(String name) throws NamingException {
472
        // First check for aliases
472
        // First check for aliases
473
        Object obj = doLookupWithoutNFE(name);
474
        if (obj != null) {
475
            return obj;
476
        }
477
478
        // Really not found
479
        throw new NameNotFoundException(
480
                sm.getString("resources.notFound", name));
481
    }
482
483
    protected Object doLookupWithoutNFE(String name) throws NamingException {
473
        if (!aliases.isEmpty()) {
484
        if (!aliases.isEmpty()) {
474
            AliasResult result = findAlias(name);
485
            AliasResult result = findAlias(name);
475
            if (result.dirContext != null) {
486
            if (result.dirContext != null) {
Lines 484-502 Link Here
484
            return obj;
495
            return obj;
485
        
496
        
486
        // Check the alternate locations
497
        // Check the alternate locations
498
        String resourceName = "/META-INF/resources" + name;
487
        for (DirContext altDirContext : altDirContexts) {
499
        for (DirContext altDirContext : altDirContexts) {
488
            try {
500
            if (altDirContext instanceof BaseDirContext) {
489
                obj = altDirContext.lookup("/META-INF/resources" + name);
501
                obj = ((BaseDirContext)altDirContext).doLookupWithoutNFE(resourceName);
490
                if (obj != null)
502
            }
491
                    return obj;
503
            else {
492
            } catch ( NamingException ex) {
504
                try {
493
                // ignore
505
                    obj = altDirContext.lookup(resourceName);
506
                } catch ( NamingException ex) {
507
                    // ignore
508
                }
509
            }
510
            if (obj != null) {
511
                return obj;
494
            }
512
            }
495
        }
513
        }
496
        
514
        
497
        // Really not found
515
        //Return null instead
498
        throw new NameNotFoundException(
516
        return null;
499
                sm.getString("resources.notFound", name));
500
    }
517
    }
501
518
502
    /**
519
    /**
Lines 689-698 Link Here
689
        // Check the alternate locations
706
        // Check the alternate locations
690
        List<NamingEntry> altBindings = null;
707
        List<NamingEntry> altBindings = null;
691
708
709
        String resourceName = "/META-INF/resources" + name;
692
        for (DirContext altDirContext : altDirContexts) {
710
        for (DirContext altDirContext : altDirContexts) {
693
            if (altDirContext instanceof BaseDirContext) {
711
            if (altDirContext instanceof BaseDirContext) {
694
                altBindings = ((BaseDirContext) altDirContext).doListBindings(
712
                altBindings = ((BaseDirContext) altDirContext).doListBindings(resourceName);
695
                        "/META-INF/resources" + name);
696
            }
713
            }
697
            if (altBindings != null) {
714
            if (altBindings != null) {
698
                if (bindings == null) {
715
                if (bindings == null) {
Lines 758-767 Link Here
758
        // Check the alternate locations
775
        // Check the alternate locations
759
        List<NamingEntry> altBindings = null;
776
        List<NamingEntry> altBindings = null;
760
777
778
        String resourceName = "/META-INF/resources" + name;
761
        for (DirContext altDirContext : altDirContexts) {
779
        for (DirContext altDirContext : altDirContexts) {
762
            if (altDirContext instanceof BaseDirContext) {
780
            if (altDirContext instanceof BaseDirContext) {
763
                altBindings = ((BaseDirContext) altDirContext).doListBindings(
781
                altBindings = ((BaseDirContext) altDirContext).doListBindings(resourceName);
764
                        "/META-INF/resources" + name);
765
            }
782
            }
766
            if (altBindings != null) {
783
            if (altBindings != null) {
767
                if (bindings == null) {
784
                if (bindings == null) {
Lines 791-797 Link Here
791
     * This method is idempotent. It succeeds even if the terminal atomic 
808
     * This method is idempotent. It succeeds even if the terminal atomic 
792
     * name is not bound in the target context, but throws 
809
     * name is not bound in the target context, but throws 
793
     * NameNotFoundException if any of the intermediate contexts do not exist. 
810
     * NameNotFoundException if any of the intermediate contexts do not exist. 
794
     * 
811
     *
795
     * In a federated naming system, a context from one naming system may be 
812
     * In a federated naming system, a context from one naming system may be 
796
     * bound to a name in another. One can subsequently look up and perform 
813
     * bound to a name in another. One can subsequently look up and perform 
797
     * operations on the foreign context using a composite name. However, an 
814
     * operations on the foreign context using a composite name. However, an 
Lines 1138-1149 Link Here
1138
1155
1139
        if (attrs != null)
1156
        if (attrs != null)
1140
            return attrs;
1157
            return attrs;
1141
        
1158
1159
        String resourceName = "/META-INF/resources" + name;
1142
        // Check the alternate locations
1160
        // Check the alternate locations
1143
        for (DirContext altDirContext : altDirContexts) {
1161
        for (DirContext altDirContext : altDirContexts) {
1144
            if (altDirContext instanceof BaseDirContext)
1162
            if (altDirContext instanceof BaseDirContext)
1145
                attrs = ((BaseDirContext) altDirContext).doGetAttributes(
1163
                attrs = ((BaseDirContext) altDirContext).doGetAttributes(resourceName, attrIds);
1146
                        "/META-INF/resources" + name, attrIds);
1147
            else {
1164
            else {
1148
                try {
1165
                try {
1149
                    attrs = altDirContext.getAttributes(name, attrIds);
1166
                    attrs = altDirContext.getAttributes(name, attrIds);

Return to bug 56771