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

(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoServicesTest.java (-1 / +1 lines)
Lines 177-183 Link Here
177
    }
177
    }
178
178
179
179
180
    static Bundle findBundle(String bsn) throws Exception {
180
    public static Bundle findBundle(String bsn) throws Exception {
181
        Bundle[] arr = findFramework().getBundleContext().getBundles();
181
        Bundle[] arr = findFramework().getBundleContext().getBundles();
182
        for (Bundle b : arr) {
182
        for (Bundle b : arr) {
183
            if (bsn.equals(b.getSymbolicName())) {
183
            if (bsn.equals(b.getSymbolicName())) {
(-)a/netbinox/nbproject/project.xml (+1 lines)
Lines 45-50 Link Here
45
                        <code-name-base>org.netbeans.core.netigso</code-name-base>
45
                        <code-name-base>org.netbeans.core.netigso</code-name-base>
46
                        <recursive/>
46
                        <recursive/>
47
                        <compile-dependency/>
47
                        <compile-dependency/>
48
                        <test/>
48
                    </test-dependency>
49
                    </test-dependency>
49
                    <test-dependency>
50
                    <test-dependency>
50
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
51
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
(-)a/netbinox/src/org/netbeans/modules/netbinox/JarBundleFile.java (-1 / +24 lines)
Lines 59-64 Link Here
59
import org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile;
59
import org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile;
60
import org.netbeans.core.netigso.spi.BundleContent;
60
import org.netbeans.core.netigso.spi.BundleContent;
61
import org.netbeans.core.netigso.spi.NetigsoArchive;
61
import org.netbeans.core.netigso.spi.NetigsoArchive;
62
import org.openide.modules.ModuleInfo;
63
import org.openide.util.Lookup;
62
64
63
/** This is fake bundle. It is created by the Netbinox infrastructure to 
65
/** This is fake bundle. It is created by the Netbinox infrastructure to 
64
 * use the {@link NetigsoArchive} to get cached data and speed up the start.
66
 * use the {@link NetigsoArchive} to get cached data and speed up the start.
Lines 216-222 Link Here
216
        return arr;
218
        return arr;
217
    }
219
    }
218
220
219
    private BundleEntry findEntry(String why, String name) {
221
    private BundleEntry findEntry(String why, final String name) {
222
        if (!name.equals("META-INF/MANIFEST.MF") && // NOI18N
223
            data != null && 
224
            data.getLocation() != null && 
225
            data.getLocation().startsWith("netigso://") // NOI18N
226
        ) { 
227
            String cnb = data.getLocation().substring(10);
228
            for (ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
229
                if (mi.getCodeNameBase().equals(cnb)) {
230
                    if (!mi.isEnabled()) {
231
                        break;
232
                    }
233
                    final URL url = mi.getClassLoader().getResource(name);
234
                    if (url != null) {
235
                        return new ModuleEntry(url, name);
236
                    } else {
237
                        break;
238
                    }
239
                }
240
            }
241
        }
242
        
220
        BundleEntry u;
243
        BundleEntry u;
221
        for (;;) {
244
        for (;;) {
222
            BundleFile d = delegate(why, name);
245
            BundleFile d = delegate(why, name);
(-)0b9154a59a3b (+92 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 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 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.netbinox;
43
44
import java.io.IOException;
45
import java.io.InputStream;
46
import java.net.URL;
47
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
48
49
/** An entry representing a direct entry inside a NetBeans
50
 * module.
51
 *
52
 * @author Jaroslav Tulach
53
 */
54
final class ModuleEntry extends BundleEntry {
55
    private final URL url;
56
    private final String name;
57
58
    public ModuleEntry(URL url, String name) {
59
        this.url = url;
60
        this.name = name;
61
    }
62
63
    @Override
64
    public InputStream getInputStream() throws IOException {
65
        return url.openStream();
66
    }
67
68
    @Override
69
    public long getSize() {
70
        return -1;
71
    }
72
73
    @Override
74
    public String getName() {
75
        return name;
76
    }
77
78
    @Override
79
    public long getTime() {
80
        return 0L;
81
    }
82
83
    @Override
84
    public URL getLocalURL() {
85
        return url;
86
    }
87
88
    @Override
89
    public URL getFileURL() {
90
        return url;
91
    }
92
}
(-)0b9154a59a3b (+130 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-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
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.netbinox;
46
47
import java.net.URL;
48
import org.netbeans.core.startup.*;
49
import java.io.File;
50
import java.io.IOException;
51
import java.util.Locale;
52
import java.util.concurrent.Callable;
53
import org.netbeans.Module;
54
import org.netbeans.ModuleManager;
55
import org.netbeans.SetupHid;
56
import org.netbeans.core.netigso.NetigsoServicesTest;
57
import org.openide.util.Lookup;
58
import org.openide.util.Mutex.ExceptionAction;
59
import org.osgi.framework.Bundle;
60
61
/**
62
 * Do we correctly handle META-INF/services in bundles?
63
 *
64
 * @author Jaroslav Tulach
65
 */
66
public class BundleGetEntryTest extends SetupHid {
67
    private static Module m1;
68
    private static ModuleManager mgr;
69
    private int cnt;
70
    private File jar;
71
    private File simpleModule;
72
73
    public BundleGetEntryTest(String name) {
74
        super(name);
75
    }
76
77
    protected @Override void setUp() throws Exception {
78
        Locale.setDefault(Locale.US);
79
        clearWorkDir();
80
        File ud = new File(getWorkDir(), "ud");
81
        ud.mkdirs();
82
        System.setProperty("netbeans.user", ud.getPath());
83
        
84
        data = new File(getDataDir(), "jars");
85
        jars = new File(getWorkDir(), "space in path");
86
        jars.mkdirs();
87
        simpleModule = createTestJAR("activate", null);
88
        String mf = "OpenIDE-Module: can.read.metainf\n"
89
                + "OpenIDE-Public-Packages: org.activate\n"
90
                + "\n"
91
                + "\n";
92
       jar = NetigsoHid.changeManifest(getWorkDir(), simpleModule, mf);
93
    }
94
95
    public void testActivation() throws Exception {
96
        ModuleSystem ms = Main.getModuleSystem();
97
        mgr = ms.getManager();
98
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
99
            @Override
100
            public Void run() throws Exception {
101
                Callable<?> fr = Lookup.getDefault().lookup(Callable.class);
102
                assertNull("No registration found yet", fr);
103
104
105
                m1 = mgr.create(jar, null, false, false, false);
106
                mgr.enable(m1);
107
108
                Module m2 = mgr.create(simpleModule, null, false, false, false);
109
                mgr.enable(m2);
110
111
                
112
                Bundle bundle = NetigsoServicesTest.findBundle("can.read.metainf");
113
                assertNotNull("Bundle found", bundle);
114
                URL res = bundle.getEntry("org/activate/entry.txt");
115
                assertNotNull("Entry found", res);
116
                byte[] arr = new byte[1000];
117
                int len = res.openStream().read(arr);
118
                String s = new String(arr, 0, len);
119
                assertEquals("Ahoj", s.substring(0,4));
120
121
                mgr.disable(m1);
122
123
                return null;
124
            }
125
        });
126
    }
127
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
128
        return createTestJAR(data, jars, name, srcdir, classpath);
129
    }
130
}

Return to bug 199784