This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

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

(-)a/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListTest.java (-1 / +2 lines)
Lines 71-76 Link Here
71
import org.openide.filesystems.FileUtil;
71
import org.openide.filesystems.FileUtil;
72
import org.openide.filesystems.LocalFileSystem;
72
import org.openide.filesystems.LocalFileSystem;
73
import org.openide.modules.InstalledFileLocator;
73
import org.openide.modules.InstalledFileLocator;
74
import org.openide.modules.ModuleInfo;
74
import org.openide.modules.Places;
75
import org.openide.modules.Places;
75
import org.openide.modules.api.PlacesTestUtils;
76
import org.openide.modules.api.PlacesTestUtils;
76
import org.openide.util.test.MockLookup;
77
import org.openide.util.test.MockLookup;
Lines 184-190 Link Here
184
        assertFile(new File(data, "org-bar_disabled.xml"), FileUtil.toFile(bar));
185
        assertFile(new File(data, "org-bar_disabled.xml"), FileUtil.toFile(bar));
185
        // Check that changes in disk are parsed and applied (#13921)
186
        // Check that changes in disk are parsed and applied (#13921)
186
        LoggedPCListener listener2 = new LoggedPCListener();
187
        LoggedPCListener listener2 = new LoggedPCListener();
187
        Module m1 = mgr.get("org.foo");
188
        ModuleInfo m1 = mgr.findCodeNameBase("org.foo");
188
        m1.addPropertyChangeListener(listener2);
189
        m1.addPropertyChangeListener(listener2);
189
        copy(new File(data, "org-foo.xml"), foo);
190
        copy(new File(data, "org-foo.xml"), foo);
190
        /* Does not seem to refresh reliably enough:
191
        /* Does not seem to refresh reliably enough:
(-)a/o.n.bootstrap/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.bootstrap/1
2
OpenIDE-Module: org.netbeans.bootstrap/1
3
OpenIDE-Module-Specification-Version: 2.57
3
OpenIDE-Module-Specification-Version: 2.58
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
6
6
(-)a/o.n.bootstrap/nbproject/project.xml (-1 / +1 lines)
Lines 54-60 Link Here
54
                    <build-prerequisite/>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <specification-version>7.30</specification-version>
57
                        <specification-version>7.37</specification-version>
58
                    </run-dependency>
58
                    </run-dependency>
59
                </dependency>
59
                </dependency>
60
                <dependency>
60
                <dependency>
(-)a/o.n.bootstrap/src/org/netbeans/ModuleManager.java (-3 / +5 lines)
Lines 77-87 Link Here
77
import java.util.TreeSet;
77
import java.util.TreeSet;
78
import java.util.concurrent.ExecutionException;
78
import java.util.concurrent.ExecutionException;
79
import java.util.concurrent.Future;
79
import java.util.concurrent.Future;
80
import java.util.concurrent.TimeUnit;
81
import java.util.concurrent.TimeoutException;
82
import java.util.jar.Manifest;
80
import java.util.jar.Manifest;
83
import java.util.logging.Level;
81
import java.util.logging.Level;
84
import org.openide.LifecycleManager;
85
import org.openide.modules.Dependency;
82
import org.openide.modules.Dependency;
86
import org.openide.modules.ModuleInfo;
83
import org.openide.modules.ModuleInfo;
87
import org.openide.modules.Modules;
84
import org.openide.modules.Modules;
Lines 353-358 Link Here
353
        return modulesByName.get(codeNameBase);
350
        return modulesByName.get(codeNameBase);
354
    }
351
    }
355
352
353
    @Override
354
    public ModuleInfo findCodeNameBase(String cnb) {
355
        return get(cnb);
356
    }
357
356
    public @Override ModuleInfo ownerOf(Class<?> clazz) {
358
    public @Override ModuleInfo ownerOf(Class<?> clazz) {
357
        ClassLoader cl = clazz.getClassLoader();
359
        ClassLoader cl = clazz.getClassLoader();
358
        if (cl instanceof Util.ModuleProvider) {
360
        if (cl instanceof Util.ModuleProvider) {
(-)a/openide.modules/apichanges.xml (+18 lines)
Lines 50-55 Link Here
50
  	<apidef name="modules">Modules API</apidef>
50
  	<apidef name="modules">Modules API</apidef>
51
  </apidefs>
51
  </apidefs>
52
<changes>
52
<changes>
53
    <change id="find.by.cnb">
54
        <api name="modules"/>
55
        <summary>Find ModuleInfo by code name base easily</summary>
56
        <version major="7" minor="37"/>
57
        <date day="12" month="2" year="2013"/>
58
        <author login="jtulach"/>
59
        <compatibility addition="yes" binary="compatible" semantic="compatible" source="compatible">
60
        </compatibility>
61
        <description>
62
            <p>
63
                New <code>findCodeNameBase(String)</code> method returning
64
                <a href="@TOP@/org/openide/modules/ModuleInfo.html">ModuleInfo</a>
65
                or <code>null</code>.
66
            </p>
67
        </description>
68
        <class package="org.openide.modules" name="Modules"/>
69
        <issue number="225582"/>
70
    </change>
53
    <change id="allow.numbers">
71
    <change id="allow.numbers">
54
        <api name="modules"/>
72
        <api name="modules"/>
55
        <summary>Less restrictive check of code names of modules and OSGi bundles</summary>
73
        <summary>Less restrictive check of code names of modules and OSGi bundles</summary>
(-)a/openide.modules/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.modules
2
OpenIDE-Module: org.openide.modules
3
OpenIDE-Module-Localizing-Bundle: org/openide/modules/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/modules/Bundle.properties
4
OpenIDE-Module-Specification-Version: 7.36
4
OpenIDE-Module-Specification-Version: 7.37
5
5
(-)a/openide.modules/src/org/openide/modules/Modules.java (-17 / +24 lines)
Lines 48-54 Link Here
48
 * Information about the set of available {@linkplain ModuleInfo modules}.
48
 * Information about the set of available {@linkplain ModuleInfo modules}.
49
 * @since org.openide.modules 7.19
49
 * @since org.openide.modules 7.19
50
 */
50
 */
51
public abstract class Modules {
51
public class Modules {
52
    /**
53
     * Constructor for subclasses.
54
     */
55
    protected Modules() {}
52
    
56
    
53
    /**
57
    /**
54
     * Gets the singleton set of modules.
58
     * Gets the singleton set of modules.
Lines 59-73 Link Here
59
    public static Modules getDefault() {
63
    public static Modules getDefault() {
60
        Modules impl = Lookup.getDefault().lookup(Modules.class);
64
        Modules impl = Lookup.getDefault().lookup(Modules.class);
61
        if (impl == null) {
65
        if (impl == null) {
62
            impl = new Trivial();
66
            impl = new Modules();
63
        }
67
        }
64
        return impl;
68
        return impl;
65
    }
69
    }
66
70
67
    /**
71
    /* Finds a module with given code name base.
68
     * Constructor for subclasses.
72
     * @param cnb the {@link ModuleInfo#getCodeNameBase() code name base} of a module
73
     * @return the found module or <code>null</code>, if such module is not known
74
     *   to the system
75
     * @since 7.37
69
     */
76
     */
70
    protected Modules() {}
77
    public ModuleInfo findCodeNameBase(String cnb) {
78
        for (ModuleInfo module : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
79
            if (cnb.equals(module.getCodeNameBase())) {
80
                return module;
81
            }
82
        }
83
        return null;
84
    }
71
    
85
    
72
    /**
86
    /**
73
     * Finds the module which loaded a class.
87
     * Finds the module which loaded a class.
Lines 75-93 Link Here
75
     * @return the owner of the class, or null if it is not owned by any module
89
     * @return the owner of the class, or null if it is not owned by any module
76
     * @see ModuleInfo#owns
90
     * @see ModuleInfo#owns
77
     */
91
     */
78
    public abstract ModuleInfo ownerOf(Class<?> clazz);
92
    public ModuleInfo ownerOf(Class<?> clazz) {
79
    
93
        for (ModuleInfo module : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
80
    private static class Trivial extends Modules {
94
            if (module.owns(clazz)) {
81
        
95
                return module;
82
        public @Override ModuleInfo ownerOf(Class<?> clazz) {
83
            for (ModuleInfo module : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
84
                if (module.owns(clazz)) {
85
                    return module;
86
                }
87
            }
96
            }
88
            return null;
89
        }
97
        }
90
        
98
        return null;
91
    }
99
    }
92
    
93
}
100
}

Return to bug 225582