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 201740
Collapse All | Expand All

(-)a/core.netigso/apichanges.xml (+20 lines)
Lines 49-56 Link Here
49
<apichanges>
49
<apichanges>
50
<apidefs>
50
<apidefs>
51
    <apidef name="spi">Netigso Integration SPI</apidef>
51
    <apidef name="spi">Netigso Integration SPI</apidef>
52
    <apidef name="general">OSGi Related Behavior</apidef>
52
</apidefs>
53
</apidefs>
53
<changes>
54
<changes>
55
    <change id="no.friends">
56
      <api name="general"/>
57
      <summary>Friend API is no longer accessible</summary>
58
      <version major="1" minor="11"/>
59
      <date day="14" month="9" year="2011"/>
60
      <author login="jtulach"/>
61
      <compatibility addition="yes" binary="compatible" source="compatible" semantic="incompatible">
62
          In previous version OSGi bundles could access NetBeans APIs which
63
          enumerated list of "friends" without any restrictions. This has been
64
          restricted. If you need a friend access, consider writing real 
65
          NetBeans module.
66
      </compatibility>
67
      <description>
68
          Only NetBeans modules with public API can be accessed from OSGi bundles.
69
          One can specify direct value for
70
          <a href="@TOP@/architecture-summary.html#property-Netigso-Export-Package">Netigso-Export-Package</a>
71
          to export also non-public APIs.
72
     </description>
73
    </change>
54
    <change id="archive">
74
    <change id="archive">
55
      <api name="spi"/>
75
      <api name="spi"/>
56
      <summary>Netigso grants access to archives</summary>
76
      <summary>Netigso grants access to archives</summary>
(-)a/core.netigso/arch.xml (-1 / +5 lines)
Lines 620-626 Link Here
620
-->
620
-->
621
 <answer id="exec-property">
621
 <answer id="exec-property">
622
  <p>
622
  <p>
623
   XXX no answer for exec-property
623
   <api name="Netigso-Export-Package" category="stable" group="property" type="export">
624
   If a NetBeans module's manifest contains tag <code>Netigso-Export-Package</code>,
625
   then it is used as a value of <code>Export-Package</code> OSGi tag, when
626
   re-exporting the module as OSGi bundle.
627
   </api>
624
  </p>
628
  </p>
625
 </answer>
629
 </answer>
626
630
(-)a/core.netigso/manifest.mf (-1 / +1 lines)
Lines 2-8 Link Here
2
OpenIDE-Module: org.netbeans.core.netigso
2
OpenIDE-Module: org.netbeans.core.netigso
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/netigso/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/netigso/Bundle.properties
4
OpenIDE-Module-Provides: org.netbeans.NetigsoFramework
4
OpenIDE-Module-Provides: org.netbeans.NetigsoFramework
5
OpenIDE-Module-Specification-Version: 1.10
5
OpenIDE-Module-Specification-Version: 1.11
6
OpenIDE-Module-Needs: org.osgi.framework.launch.FrameworkFactory
6
OpenIDE-Module-Needs: org.osgi.framework.launch.FrameworkFactory
7
AutoUpdate-Essential-Module: true
7
AutoUpdate-Essential-Module: true
8
8
(-)a/core.netigso/nbproject/project.xml (-1 / +1 lines)
Lines 55-61 Link Here
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
57
                        <release-version>1</release-version>
58
                        <specification-version>2.37</specification-version>
58
                        <specification-version>2.41</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
(-)a/core.netigso/src/org/netbeans/core/netigso/Netigso.java (-3 / +11 lines)
Lines 268-273 Link Here
268
            try {
268
            try {
269
                LOG.log(Level.FINE, "Starting bundle {0}", m.getCodeNameBase());
269
                LOG.log(Level.FINE, "Starting bundle {0}", m.getCodeNameBase());
270
                b.start();
270
                b.start();
271
                if (b.getState() == Bundle.INSTALLED && isRealBundle(b)) {
272
                    throw new IOException("Cannot start " + m.getCodeName() + " state remains INSTALLED after start()"); // NOI18N
273
                }
271
            } catch (BundleException possible) {
274
            } catch (BundleException possible) {
272
                if (isRealBundle(b)) {
275
                if (isRealBundle(b)) {
273
                    throw possible;
276
                    throw possible;
Lines 423-431 Link Here
423
     *   make sense to represent this module as bundle
426
     *   make sense to represent this module as bundle
424
     */
427
     */
425
    private static InputStream fakeBundle(ModuleInfo m) throws IOException {
428
    private static InputStream fakeBundle(ModuleInfo m) throws IOException {
429
        String netigsoExp = (String) m.getAttribute("Netigso-Export-Package"); // NOI18N
426
        String exp = (String) m.getAttribute("OpenIDE-Module-Public-Packages"); // NOI18N
430
        String exp = (String) m.getAttribute("OpenIDE-Module-Public-Packages"); // NOI18N
427
        if ("-".equals(exp)) { // NOI18N
431
        if (netigsoExp == null) {
428
            return null;
432
            if ("-".equals(exp) || m.getAttribute("OpenIDE-Module-Friends") != null) { // NOI18N
433
                return null;
434
            }
429
        }
435
        }
430
        ByteArrayOutputStream os = new ByteArrayOutputStream();
436
        ByteArrayOutputStream os = new ByteArrayOutputStream();
431
        Manifest man = new Manifest();
437
        Manifest man = new Manifest();
Lines 437-443 Link Here
437
            String spec = threeDotsWithMajor(m.getSpecificationVersion().toString(), m.getCodeName());
443
            String spec = threeDotsWithMajor(m.getSpecificationVersion().toString(), m.getCodeName());
438
            man.getMainAttributes().putValue("Bundle-Version", spec.toString()); // NOI18N
444
            man.getMainAttributes().putValue("Bundle-Version", spec.toString()); // NOI18N
439
        }
445
        }
440
        if (exp != null) {
446
        if (netigsoExp != null) {
447
            man.getMainAttributes().putValue("Export-Package", netigsoExp); // NOI18N
448
        } else if (exp != null) {
441
            man.getMainAttributes().putValue("Export-Package", exp.replaceAll("\\.\\*", "")); // NOI18N
449
            man.getMainAttributes().putValue("Export-Package", exp.replaceAll("\\.\\*", "")); // NOI18N
442
        } else {
450
        } else {
443
            man.getMainAttributes().putValue("Export-Package", m.getCodeNameBase()); // NOI18N
451
            man.getMainAttributes().putValue("Export-Package", m.getCodeNameBase()); // NOI18N
(-)0ce49db65c29 (+97 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.core.netigso;
43
44
import java.io.File;
45
import java.util.Arrays;
46
import java.util.HashSet;
47
import org.netbeans.MockEvents;
48
import org.netbeans.MockModuleInstaller;
49
import org.netbeans.Module;
50
import org.netbeans.ModuleManager;
51
52
public class NetigsoExportPackageTest extends NetigsoHid {
53
54
    public NetigsoExportPackageTest(String name) {
55
        super(name);
56
    }
57
    
58
    
59
    public void testNetigsoExportPackage() throws Exception {
60
        MockModuleInstaller installer = new MockModuleInstaller();
61
        MockEvents ev = new MockEvents();
62
        ModuleManager mgr = new ModuleManager(installer, ev);
63
        mgr.mutexPrivileged().enterWriteAccess();
64
        HashSet<Module> b = null;
65
        boolean ok = false;
66
        try {
67
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
68
                "Bundle-Version: 1.1.0\n" +
69
                "Bundle-ManifestVersion: 2\n" +
70
                "Import-Package: org.foo\n" +
71
                "\n\n";
72
73
            String mfSimple = "OpenIDE-Module: org.foo/1\n"
74
                    + "OpenIDE-Module-Specification-Version: 1.2\n"
75
                    + "OpenIDE-Module-Public-Packages: org.wrong.foo.*\n"
76
                    + "OpenIDE-Module-Friends: few.unknown\n"
77
                    + "Netigso-Export-Package: org.foo\n"
78
                    + "\n\n";
79
80
            
81
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mfSimple);
82
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
83
            Module m1 = mgr.create(j1, null, false, false, false);
84
            Module m2 = mgr.create(j2, null, false, false, false);
85
            b = new HashSet<Module>(Arrays.asList(m1, m2));
86
            mgr.enable(b);
87
            ok = true;
88
            assertTrue("Enabled OK", m2.isEnabled());
89
        } finally {
90
            if (ok) {
91
                mgr.disable(b);
92
            }
93
            mgr.mutexPrivileged().exitWriteAccess();
94
        }
95
    }
96
    
97
}
(-)0ce49db65c29 (+90 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.core.netigso;
44
45
import java.io.File;
46
import java.util.Arrays;
47
import java.util.HashSet;
48
import org.netbeans.*;
49
50
public class NetigsoOSGiIsNotFriendTest extends NetigsoHid {
51
    public NetigsoOSGiIsNotFriendTest(String name) {
52
        super(name);
53
    }
54
55
    public void testOSGiBundleAreNotImplicitFriendsOfNetBeansModules() throws Exception {
56
        MockModuleInstaller installer = new MockModuleInstaller();
57
        MockEvents ev = new MockEvents();
58
        ModuleManager mgr = new ModuleManager(installer, ev);
59
        mgr.mutexPrivileged().enterWriteAccess();
60
        try {
61
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
62
                "Bundle-Version: 1.1.0\n" +
63
                "Bundle-ManifestVersion: 2\n" +
64
                "Require-Bundle: org.foo\n" +
65
                "\n\n";
66
67
            String mfSimple = "OpenIDE-Module: org.foo/1\n"
68
                    + "OpenIDE-Module-Specification-Version: 1.2\n"
69
                    + "OpenIDE-Module-Public-Packages: org.foo.*\n"
70
                    + "OpenIDE-Module-Friends: few.unknown\n"
71
                    + "\n\n";
72
73
            
74
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mfSimple);
75
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
76
            Module m1 = mgr.create(j1, null, false, false, false);
77
            Module m2 = mgr.create(j2, null, false, false, false);
78
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
79
            try {
80
                mgr.enable(b);
81
                fail("InvalidException should be raised!");
82
            } catch (InvalidException ex) {
83
                // OK
84
            }
85
            assertFalse("We should not be able to enable org.bar bundle!", m2.isEnabled());
86
        } finally {
87
            mgr.mutexPrivileged().exitWriteAccess();
88
        }
89
    }
90
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoSelfQueryTest.java (-1 / +3 lines)
Lines 453-458 Link Here
453
        private final String url;
453
        private final String url;
454
        private final MockFramework f;
454
        private final MockFramework f;
455
        private final NetigsoArchive archive;
455
        private final NetigsoArchive archive;
456
        private transient int state = Bundle.INSTALLED;
456
457
457
        public MockBundle(String url, MockFramework f) {
458
        public MockBundle(String url, MockFramework f) {
458
            this.url = url;
459
            this.url = url;
Lines 464-470 Link Here
464
465
465
        @Override
466
        @Override
466
        public int getState() {
467
        public int getState() {
467
            throw new UnsupportedOperationException("Not supported yet.");
468
            return state;
468
        }
469
        }
469
470
470
        @Override
471
        @Override
Lines 474-479 Link Here
474
475
475
        @Override
476
        @Override
476
        public void start() throws BundleException {
477
        public void start() throws BundleException {
478
            state = Bundle.ACTIVE;
477
        }
479
        }
478
480
479
        @Override
481
        @Override
(-)0ce49db65c29 (+91 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.netbinox;
44
45
import java.io.File;
46
import java.util.Arrays;
47
import java.util.HashSet;
48
import org.netbeans.*;
49
50
public class NetigsoOSGiIsNotFriendTest extends NetigsoHid {
51
    public NetigsoOSGiIsNotFriendTest(String name) {
52
        super(name);
53
    }
54
55
    public void testOSGiBundleAreNotImplicitFriendsOfNetBeansModules() throws Exception {
56
        MockModuleInstaller installer = new MockModuleInstaller();
57
        MockEvents ev = new MockEvents();
58
        ModuleManager mgr = new ModuleManager(installer, ev);
59
        mgr.mutexPrivileged().enterWriteAccess();
60
        try {
61
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
62
                "Bundle-Version: 1.1.0\n" +
63
                "Bundle-ManifestVersion: 2\n" +
64
                "Require-Bundle: org.foo\n" +
65
                "\n\n";
66
67
            String mfSimple = "OpenIDE-Module: org.foo/1\n"
68
                    + "OpenIDE-Module-Specification-Version: 1.2\n"
69
                    + "OpenIDE-Module-Public-Packages: org.foo.*\n"
70
                    + "OpenIDE-Module-Friends: few.unknown\n"
71
                    + "\n\n";
72
73
            
74
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mfSimple);
75
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
76
            Module m1 = mgr.create(j1, null, false, false, false);
77
            Module m2 = mgr.create(j2, null, false, false, false);
78
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
79
            try {
80
                mgr.enable(b);
81
                fail("InvalidException should be raised!");
82
            } catch (InvalidException ex) {
83
                // OK
84
            }
85
            assertFalse("We should not be able to enable org.bar bundle!", m2.isEnabled());
86
        } finally {
87
            mgr.mutexPrivileged().exitWriteAccess();
88
        }
89
    }
90
91
}
(-)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.41
3
OpenIDE-Module-Specification-Version: 2.42
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/src/org/netbeans/NetigsoFramework.java (-4 / +14 lines)
Lines 51-57 Link Here
51
import java.util.List;
51
import java.util.List;
52
import java.util.Set;
52
import java.util.Set;
53
import org.openide.modules.ModuleInfo;
53
import org.openide.modules.ModuleInfo;
54
import org.openide.util.Exceptions;
55
import org.openide.util.Lookup;
54
import org.openide.util.Lookup;
56
import org.openide.util.lookup.Lookups;
55
import org.openide.util.lookup.Lookups;
57
56
Lines 151-157 Link Here
151
        toEnable.addAll(newlyEnabling);
150
        toEnable.addAll(newlyEnabling);
152
    }
151
    }
153
152
154
    static Set<Module> turnOn(ClassLoader findNetigsoFrameworkIn, Collection<Module> allModules) {
153
    static Set<Module> turnOn(ClassLoader findNetigsoFrameworkIn, Collection<Module> allModules) throws InvalidException {
155
        boolean found = false;
154
        boolean found = false;
156
        if (framework == null) {
155
        if (framework == null) {
157
            for (Module m : toEnable) {
156
            for (Module m : toEnable) {
Lines 189-195 Link Here
189
        return additional;
188
        return additional;
190
    }
189
    }
191
190
192
    private static boolean delayedInit() {
191
    private static boolean delayedInit() throws InvalidException {
193
        List<NetigsoModule> init;
192
        List<NetigsoModule> init;
194
        synchronized (NetigsoFramework.class) {
193
        synchronized (NetigsoFramework.class) {
195
            init = toInit;
194
            init = toInit;
Lines 198-210 Link Here
198
                return true;
197
                return true;
199
            }
198
            }
200
        }
199
        }
200
        InvalidException thrw = null;
201
        for (NetigsoModule nm : init) {
201
        for (NetigsoModule nm : init) {
202
            try {
202
            try {
203
                nm.start();
203
                nm.start();
204
            } catch (IOException ex) {
204
            } catch (IOException ex) {
205
                Exceptions.printStackTrace(ex);
205
                nm.setEnabled(false);
206
                InvalidException invalid = new InvalidException(nm, ex.getMessage());
207
                if (thrw == null) {
208
                    invalid.initCause(ex);
209
                } else {
210
                    invalid.initCause(thrw);
211
                }
212
                thrw = invalid;
206
            }
213
            }
207
        }
214
        }
215
        if (thrw != null) {
216
            throw thrw;
217
        }
208
        return false;
218
        return false;
209
    }
219
    }
210
220

Return to bug 201740