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

(-)a/j2ee.common/nbproject/project.xml (-1 / +1 lines)
Lines 193-199 Link Here
193
                    <compile-dependency/>
193
                    <compile-dependency/>
194
                    <run-dependency>
194
                    <run-dependency>
195
                        <release-version>4</release-version>
195
                        <release-version>4</release-version>
196
                        <specification-version>1.58</specification-version>
196
                        <specification-version>1.68</specification-version>
197
                    </run-dependency>
197
                    </run-dependency>
198
                </dependency>
198
                </dependency>
199
                <dependency>
199
                <dependency>
(-)a/j2ee.common/src/org/netbeans/modules/j2ee/common/Util.java (-1 / +16 lines)
Lines 63-68 Link Here
63
import org.netbeans.api.j2ee.core.Profile;
63
import org.netbeans.api.j2ee.core.Profile;
64
import org.netbeans.api.java.classpath.ClassPath;
64
import org.netbeans.api.java.classpath.ClassPath;
65
import org.netbeans.api.project.Project;
65
import org.netbeans.api.project.Project;
66
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
66
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
67
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
67
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
68
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
68
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
69
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
Lines 75-80 Link Here
75
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileUtil;
77
import org.openide.filesystems.FileUtil;
77
import org.openide.filesystems.URLMapper;
78
import org.openide.filesystems.URLMapper;
79
import org.openide.util.Exceptions;
78
import org.openide.util.NbBundle;
80
import org.openide.util.NbBundle;
79
import org.openide.util.Parameters;
81
import org.openide.util.Parameters;
80
import org.w3c.dom.Element;
82
import org.w3c.dom.Element;
Lines 298-304 Link Here
298
            if (j2eeModuleProvider != null) {
300
            if (j2eeModuleProvider != null) {
299
                J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(j2eeModuleProvider.getServerInstanceID());
301
                J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(j2eeModuleProvider.getServerInstanceID());
300
                if (j2eePlatform != null) {
302
                if (j2eePlatform != null) {
301
                    return j2eePlatform.getClasspathEntries();
303
                    File[] platformClasspath = j2eePlatform.getClasspathEntries();
304
                    File[] libraryClasspath = null;
305
                    try {
306
                        libraryClasspath = j2eePlatform.getClasspathEntries(j2eeModuleProvider.getConfigSupport().getLibraries());
307
                    } catch (ConfigurationException ex) {
308
                        // noop
309
                    }
310
                    if (libraryClasspath == null) {
311
                        return platformClasspath;
312
                    }
313
                    File[] result = new File[platformClasspath.length + libraryClasspath.length];
314
                    System.arraycopy(platformClasspath, 0, result, 0, platformClasspath.length);
315
                    System.arraycopy(libraryClasspath, 0, result, platformClasspath.length, libraryClasspath.length);
316
                    return result;
302
                }
317
                }
303
            }
318
            }
304
        }
319
        }
(-)a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/J2EEProjectProperties.java (-7 / +16 lines)
Lines 53-58 Link Here
53
import java.util.logging.Logger;
53
import java.util.logging.Logger;
54
import org.netbeans.api.j2ee.core.Profile;
54
import org.netbeans.api.j2ee.core.Profile;
55
import org.netbeans.api.project.Project;
55
import org.netbeans.api.project.Project;
56
import org.netbeans.modules.j2ee.common.Util;
56
import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
58
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
58
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
59
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
Lines 129-138 Link Here
129
                (items !=null && !getServerLibraries(items).isEmpty());
130
                (items !=null && !getServerLibraries(items).isEmpty());
130
    }
131
    }
131
132
133
    public static void setServerProperties(EditableProperties ep, EditableProperties epPriv,
134
            String serverLibraryName, ClassPathSupport cs, Iterable<ClassPathSupport.Item> items,
135
            String serverInstanceID, Profile j2eeProfile, J2eeModule.Type moduleType) {
136
        setServerProperties(null, ep, epPriv, serverLibraryName, cs, items, serverInstanceID, j2eeProfile, moduleType);
137
    }
138
132
    /**
139
    /**
133
     * Sets all server related properties.
140
     * Sets all server related properties.
134
     */
141
     */
135
    public static void setServerProperties(EditableProperties ep, EditableProperties epPriv, 
142
    public static void setServerProperties(Project project, EditableProperties ep, EditableProperties epPriv,
136
            String serverLibraryName, ClassPathSupport cs, Iterable<ClassPathSupport.Item> items,
143
            String serverLibraryName, ClassPathSupport cs, Iterable<ClassPathSupport.Item> items,
137
            String serverInstanceID, Profile j2eeProfile, J2eeModule.Type moduleType) {
144
            String serverInstanceID, Profile j2eeProfile, J2eeModule.Type moduleType) {
138
        Deployment deployment = Deployment.getDefault();
145
        Deployment deployment = Deployment.getDefault();
Lines 163-172 Link Here
163
            String root = extractPlatformLibrariesRoot(j2eePlatform);
170
            String root = extractPlatformLibrariesRoot(j2eePlatform);
164
            if (root != null) {
171
            if (root != null) {
165
                // path will be relative and therefore stored in project.properties:
172
                // path will be relative and therefore stored in project.properties:
166
                setLocalServerProperties(epPriv, ep, j2eePlatform, root);
173
                setLocalServerProperties(project, epPriv, ep, j2eePlatform, root);
167
            } else {
174
            } else {
168
                // store absolute paths in private.properties:
175
                // store absolute paths in private.properties:
169
                setLocalServerProperties(ep, epPriv, j2eePlatform, null);
176
                setLocalServerProperties(project, ep, epPriv, j2eePlatform, null);
170
            }
177
            }
171
        }
178
        }
172
179
Lines 238-244 Link Here
238
        }
245
        }
239
        callback.registerJ2eePlatformListener(j2eePlatform);
246
        callback.registerJ2eePlatformListener(j2eePlatform);
240
247
241
        setServerProperties(projectProps, privateProps, null, cs, items, newServInstID, profile, moduleType);
248
        setServerProperties(proj, projectProps, privateProps, null, cs, items, newServInstID, profile, moduleType);
242
249
243
        // ant deployment support
250
        // ant deployment support
244
        createDeploymentScript(proj.getProjectDirectory(), projectProps, privateProps, newServInstID, moduleType);
251
        createDeploymentScript(proj.getProjectDirectory(), projectProps, privateProps, newServInstID, moduleType);
Lines 323-335 Link Here
323
        ep.remove(J2EE_PLATFORM_WSIT_CLASSPATH);
330
        ep.remove(J2EE_PLATFORM_WSIT_CLASSPATH);
324
        ep.remove(J2EE_PLATFORM_JWSDP_CLASSPATH);
331
        ep.remove(J2EE_PLATFORM_JWSDP_CLASSPATH);
325
        ep.remove(J2EE_SERVER_HOME);
332
        ep.remove(J2EE_SERVER_HOME);
326
    }
333
    }    
327
334
328
    private static void setLocalServerProperties(EditableProperties epToClean, EditableProperties epTarget, J2eePlatform j2eePlatform, String root) {
335
    private static void setLocalServerProperties(Project project, EditableProperties epToClean, EditableProperties epTarget, J2eePlatform j2eePlatform, String root) {
329
        // remove all props first:
336
        // remove all props first:
330
        removeServerClasspathProperties(epTarget);
337
        removeServerClasspathProperties(epTarget);
331
338
332
        String classpath = toClasspathString(j2eePlatform.getClasspathEntries(), root);
339
        String classpath = project == null
340
                ? toClasspathString(j2eePlatform.getClasspathEntries(), root)
341
                : toClasspathString(Util.getJ2eePlatformClasspathEntries(project), root);
333
        epTarget.setProperty(J2EE_PLATFORM_CLASSPATH, classpath);
342
        epTarget.setProperty(J2EE_PLATFORM_CLASSPATH, classpath);
334
343
335
        // set j2ee.platform.embeddableejb.classpath
344
        // set j2ee.platform.embeddableejb.classpath
(-)a/j2ee.common/src/org/netbeans/modules/j2ee/common/project/ui/J2eePlatformNode.java (-9 / +32 lines)
Lines 45-50 Link Here
45
package org.netbeans.modules.j2ee.common.project.ui;
45
package org.netbeans.modules.j2ee.common.project.ui;
46
46
47
47
48
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
48
import org.netbeans.modules.java.api.common.project.ui.LibrariesNode;
49
import org.netbeans.modules.java.api.common.project.ui.LibrariesNode;
49
import java.awt.Image;
50
import java.awt.Image;
50
import java.beans.PropertyChangeEvent;
51
import java.beans.PropertyChangeEvent;
Lines 53-58 Link Here
53
import java.util.ArrayList;
54
import java.util.ArrayList;
54
import java.util.Collections;
55
import java.util.Collections;
55
import java.util.List;
56
import java.util.List;
57
import java.util.logging.Level;
58
import java.util.logging.Logger;
56
import javax.swing.Action;
59
import javax.swing.Action;
57
import javax.swing.Icon;
60
import javax.swing.Icon;
58
import javax.swing.ImageIcon;
61
import javax.swing.ImageIcon;
Lines 61-66 Link Here
61
import org.openide.nodes.Children;
64
import org.openide.nodes.Children;
62
import org.openide.nodes.AbstractNode;
65
import org.openide.nodes.AbstractNode;
63
import org.openide.nodes.Node;
66
import org.openide.nodes.Node;
67
import org.openide.util.Exceptions;
64
import org.openide.util.ImageUtilities;
68
import org.openide.util.ImageUtilities;
65
import org.openide.util.WeakListeners;
69
import org.openide.util.WeakListeners;
66
import org.netbeans.api.project.SourceGroup;
70
import org.netbeans.api.project.SourceGroup;
Lines 86-91 Link Here
86
 */
90
 */
87
class J2eePlatformNode extends AbstractNode implements PropertyChangeListener, InstanceListener {
91
class J2eePlatformNode extends AbstractNode implements PropertyChangeListener, InstanceListener {
88
92
93
    private static final Logger LOGGER = Logger.getLogger(J2eePlatformNode.class.getName());
94
89
    private static final String ARCHIVE_ICON = "org/netbeans/modules/j2ee/common/project/ui/resources/jar.gif"; //NOI18N
95
    private static final String ARCHIVE_ICON = "org/netbeans/modules/j2ee/common/project/ui/resources/jar.gif"; //NOI18N
90
    private static final String DEFAULT_ICON = "org/netbeans/modules/j2ee/common/project/ui/resources/j2eeServer.gif"; //NOI18N
96
    private static final String DEFAULT_ICON = "org/netbeans/modules/j2ee/common/project/ui/resources/j2eeServer.gif"; //NOI18N
91
    private static final String BROKEN_PROJECT_BADGE = "org/netbeans/modules/j2ee/common/project/ui/resources/brokenProjectBadge.gif"; //NOI18N
97
    private static final String BROKEN_PROJECT_BADGE = "org/netbeans/modules/j2ee/common/project/ui/resources/brokenProjectBadge.gif"; //NOI18N
Lines 115-121 Link Here
115
    private PropertyChangeListener weakPlatformListener;
121
    private PropertyChangeListener weakPlatformListener;
116
122
117
    private J2eePlatformNode(Project project, PropertyEvaluator evaluator, String platformPropName, ClassPathSupport cs) {
123
    private J2eePlatformNode(Project project, PropertyEvaluator evaluator, String platformPropName, ClassPathSupport cs) {
118
        super(new PlatformContentChildren(cs));
124
        super(new PlatformContentChildren(project, cs));
119
        this.evaluator = evaluator;
125
        this.evaluator = evaluator;
120
        this.platformPropName = platformPropName;
126
        this.platformPropName = platformPropName;
121
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
127
        evaluator.addPropertyChangeListener(WeakListeners.propertyChange(this, evaluator));
Lines 234-240 Link Here
234
240
235
    private static class PlatformContentChildren extends Children.Keys<SourceGroup> {
241
    private static class PlatformContentChildren extends Children.Keys<SourceGroup> {
236
242
237
        PlatformContentChildren (ClassPathSupport cs) {
243
        private final J2eeModuleProvider j2eeModuleProvider;
244
245
        PlatformContentChildren(Project project, ClassPathSupport cs) {
246
            j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class);
238
        }
247
        }
239
248
240
        @Override
249
        @Override
Lines 258-270 Link Here
258
            if (j2eePlatform != null) {
267
            if (j2eePlatform != null) {
259
                File[] classpathEntries = j2eePlatform.getClasspathEntries();
268
                File[] classpathEntries = j2eePlatform.getClasspathEntries();
260
                result = new ArrayList<SourceGroup>(classpathEntries.length);
269
                result = new ArrayList<SourceGroup>(classpathEntries.length);
261
                for (int i = 0; i < classpathEntries.length; i++) {
270
                addToSourceGroups(classpathEntries, result);
262
                    FileObject file = FileUtil.toFileObject(classpathEntries[i]);
271
                if (j2eeModuleProvider != null) {
263
                    if (file != null) {
272
                    try {
264
                        FileObject archiveFile = FileUtil.getArchiveRoot(file);
273
                        classpathEntries = j2eePlatform.getClasspathEntries(j2eeModuleProvider.getConfigSupport().getLibraries());
265
                        if (archiveFile != null) {
274
                        addToSourceGroups(classpathEntries, result);
266
                            result.add(ProjectUISupport.createLibrariesSourceGroup(archiveFile, file.getNameExt(), icon, icon));
275
                    } catch (ConfigurationException ex) {
267
                        }
276
                        // noop
277
                        LOGGER.log(Level.INFO, null, ex);
268
                    }
278
                    }
269
                }
279
                }
270
            } else {
280
            } else {
Lines 273-277 Link Here
273
            
283
            
274
            return result;
284
            return result;
275
        }
285
        }
286
287
        private void addToSourceGroups(File[] classpathEntries, List<SourceGroup> sourceGroups) {
288
            for (int i = 0; i < classpathEntries.length; i++) {
289
                FileObject file = FileUtil.toFileObject(classpathEntries[i]);
290
                if (file != null) {
291
                    FileObject archiveFile = FileUtil.getArchiveRoot(file);
292
                    if (archiveFile != null) {
293
                        sourceGroups.add(ProjectUISupport.createLibrariesSourceGroup(archiveFile, file.getNameExt(), icon, icon));
294
                    }
295
                }
296
            }
297
        }
276
    }
298
    }
299
277
}
300
}
(-)a/j2ee.weblogic9/nbproject/project.xml (-1 / +1 lines)
Lines 140-146 Link Here
140
                    <compile-dependency/>
140
                    <compile-dependency/>
141
                    <run-dependency>
141
                    <run-dependency>
142
                        <release-version>4</release-version>
142
                        <release-version>4</release-version>
143
                        <specification-version>1.66</specification-version>
143
                        <specification-version>1.68</specification-version>
144
                    </run-dependency>
144
                    </run-dependency>
145
                </dependency>
145
                </dependency>
146
                <dependency>
146
                <dependency>
(-)5eda48228ef2 (+79 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.weblogic9;
41
42
import java.util.concurrent.CountDownLatch;
43
import java.util.concurrent.TimeUnit;
44
import javax.enterprise.deploy.spi.status.ProgressEvent;
45
import javax.enterprise.deploy.spi.status.ProgressListener;
46
import javax.enterprise.deploy.spi.status.ProgressObject;
47
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
48
49
/**
50
 *
51
 * @author Petr Hejl
52
 */
53
public final class ProgressObjectSupport {
54
55
    private ProgressObjectSupport() {
56
        super();
57
    }
58
59
    public static void waitFor(ProgressObject obj) {
60
        final CountDownLatch latch = new CountDownLatch(1);
61
        obj.addProgressListener(new ProgressListener() {
62
63
            @Override
64
            public void handleProgressEvent(ProgressEvent pe) {
65
                if (pe.getDeploymentStatus().isCompleted() || pe.getDeploymentStatus().isFailed()) {
66
                    latch.countDown();
67
                }
68
            }
69
        });
70
        if (obj.getDeploymentStatus().isCompleted() || obj.getDeploymentStatus().isFailed()) {
71
            return;
72
        }
73
        try {
74
            latch.await(WLDeploymentManager.MANAGER_TIMEOUT, TimeUnit.MILLISECONDS);
75
        } catch (InterruptedException ex) {
76
            Thread.currentThread().interrupt();
77
        }
78
    }
79
}
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/WLPluginProperties.java (-159 / +4 lines)
Lines 55-60 Link Here
55
import java.util.logging.Level;
55
import java.util.logging.Level;
56
import java.util.logging.Logger;
56
import java.util.logging.Logger;
57
import org.netbeans.api.annotations.common.CheckForNull;
57
import org.netbeans.api.annotations.common.CheckForNull;
58
import org.netbeans.modules.j2ee.deployment.common.api.Version;
58
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
59
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
59
import org.openide.filesystems.FileLock;
60
import org.openide.filesystems.FileLock;
60
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileObject;
Lines 227-233 Link Here
227
     * Checks whether the server root contains weblogic.jar of version 9 or 10.
228
     * Checks whether the server root contains weblogic.jar of version 9 or 10.
228
     */
229
     */
229
    public static boolean isSupportedVersion(Version version) {
230
    public static boolean isSupportedVersion(Version version) {
230
        return version != null && ("9".equals(version.getMajorNumber()) || "10".equals(version.getMajorNumber())); // NOI18N
231
        return version != null && (Integer.valueOf(9).equals(version.getMajor())
232
                    || Integer.valueOf(10).equals(version.getMajor()));
231
    }
233
    }
232
234
233
    public static Version getVersion(File serverRoot) {
235
    public static Version getVersion(File serverRoot) {
Lines 247-253 Link Here
247
                }
249
                }
248
                if (implementationVersion != null) { // NOI18N
250
                if (implementationVersion != null) { // NOI18N
249
                    implementationVersion = implementationVersion.trim();
251
                    implementationVersion = implementationVersion.trim();
250
                    return new Version(implementationVersion);
252
                    return Version.fromJsr277NotationWithFallback(implementationVersion);
251
                }
253
                }
252
            } finally {
254
            } finally {
253
                try {
255
                try {
Lines 321-481 Link Here
321
        return this.installLocation;
323
        return this.installLocation;
322
    }
324
    }
323
325
324
    /**
325
     * Class representing the WebLogic version.
326
     * <p>
327
     * <i>Immutable</i>
328
     *
329
     * @author Petr Hejl
330
     */
331
    public static final class Version implements Comparable<Version> {
332
333
        private String majorNumber = "0";
334
335
        private String minorNumber = "0";
336
337
        private String microNumber = "0";
338
339
        private String update = "";
340
341
        /**
342
         * Constructs the version from the spec version string.
343
         * Expected format is <code>MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE]]]</code>.
344
         *
345
         * @param version spec version string with the following format:
346
         *             <code>MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE]]]</code>
347
         */
348
        public Version(String version) {
349
            assert version != null : "Version can't be null"; // NOI18N
350
351
            String[] tokens = version.split("\\.");
352
353
            if (tokens.length >= 4) {
354
                update = tokens[3];
355
            }
356
            if (tokens.length >= 3) {
357
                microNumber = tokens[2];
358
            }
359
            if (tokens.length >= 2) {
360
                minorNumber = tokens[1];
361
            }
362
            majorNumber = tokens[0];
363
        }
364
365
        /**
366
         * Returns the major number.
367
         *
368
         * @return the major number. Never returns <code>null</code>.
369
         */
370
        public String getMajorNumber() {
371
            return majorNumber;
372
        }
373
374
        /**
375
         * Returns the minor number.
376
         *
377
         * @return the minor number. Never returns <code>null</code>.
378
         */
379
        public String getMinorNumber() {
380
            return minorNumber;
381
        }
382
383
        /**
384
         * Returns the micro number.
385
         *
386
         * @return the micro number. Never returns <code>null</code>.
387
         */
388
        public String getMicroNumber() {
389
            return microNumber;
390
        }
391
392
        /**
393
         * Returns the update.
394
         *
395
         * @return the update. Never returns <code>null</code>.
396
         */
397
        public String getUpdate() {
398
            return update;
399
        }
400
401
        /**
402
         * {@inheritDoc}<p>
403
         * Two versions are equal if and only if they have same major, minor,
404
         * micro number and update.
405
         */
406
        @Override
407
        public boolean equals(Object obj) {
408
            if (obj == null) {
409
                return false;
410
            }
411
            if (getClass() != obj.getClass()) {
412
                return false;
413
            }
414
            final Version other = (Version) obj;
415
            if (this.majorNumber != other.majorNumber
416
                    && (this.majorNumber == null || !this.majorNumber.equals(other.majorNumber))) {
417
                return false;
418
            }
419
            if (this.minorNumber != other.minorNumber
420
                    && (this.minorNumber == null || !this.minorNumber.equals(other.minorNumber))) {
421
                return false;
422
            }
423
            if (this.microNumber != other.microNumber
424
                    && (this.microNumber == null || !this.microNumber.equals(other.microNumber))) {
425
                return false;
426
            }
427
            if (this.update != other.update
428
                    && (this.update == null || !this.update.equals(other.update))) {
429
                return false;
430
            }
431
            return true;
432
        }
433
434
        /**
435
         * {@inheritDoc}<p>
436
         * The implementation consistent with {@link #equals(Object)}.
437
         */
438
        @Override
439
        public int hashCode() {
440
            int hash = 7;
441
            hash = 17 * hash + (this.majorNumber != null ? this.majorNumber.hashCode() : 0);
442
            hash = 17 * hash + (this.minorNumber != null ? this.minorNumber.hashCode() : 0);
443
            hash = 17 * hash + (this.microNumber != null ? this.microNumber.hashCode() : 0);
444
            hash = 17 * hash + (this.update != null ? this.update.hashCode() : 0);
445
            return hash;
446
        }
447
448
        /**
449
         * {@inheritDoc}<p>
450
         * Compares the versions based on its major, minor, micro and update.
451
         * Major number is the most significant. Implementation is consistent
452
         * with {@link #equals(Object)}.
453
         */
454
        public int compareTo(Version o) {
455
            int comparison = compareToIgnoreUpdate(o);
456
            if (comparison != 0) {
457
                return comparison;
458
            }
459
            return update.compareTo(o.update);
460
        }
461
462
        /**
463
         * Compares the versions based on its major, minor, micro. Update field
464
         * is ignored. Major number is the most significant.
465
         *
466
         * @param o version to compare with
467
         */
468
        public int compareToIgnoreUpdate(Version o) {
469
            int comparison = majorNumber.compareTo(o.majorNumber);
470
            if (comparison != 0) {
471
                return comparison;
472
            }
473
            comparison = minorNumber.compareTo(o.minorNumber);
474
            if (comparison != 0) {
475
                return comparison;
476
            }
477
            return microNumber.compareTo(o.microNumber);
478
        }
479
480
    }
481
}
326
}
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/Bundle.properties (-1 / +5 lines)
Lines 68-71 Link Here
68
have write access to this file.
68
have write access to this file.
69
MSG_FailedToCreateConfigFolder=The {0} folder could not be created.
69
MSG_FailedToCreateConfigFolder=The {0} folder could not be created.
70
70
71
MSG_FailedToDeployDatasource=One or more datasources could not be deployed. Check project configuration.
71
MSG_FailedToDeployDatasource=One or more datasources could not be deployed. Check project configuration.
72
MSG_FailedToDeployLibrary=One or more libraries could not be deployed. Check project configuration.
73
74
MSG_CannotReaderServerLibraries=Cannot read the server libraries value since the {0} file is not parseable.
75
MSG_DidNotFindServerLibraries=Some server libraries could not be find on server or deployed.
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WLDatasourceManager.java (-23 / +2 lines)
Lines 49-65 Link Here
49
import java.util.LinkedList;
49
import java.util.LinkedList;
50
import java.util.Map;
50
import java.util.Map;
51
import java.util.Set;
51
import java.util.Set;
52
import java.util.concurrent.CountDownLatch;
53
import java.util.concurrent.TimeUnit;
54
import java.util.logging.Level;
52
import java.util.logging.Level;
55
import java.util.logging.Logger;
53
import java.util.logging.Logger;
56
import javax.enterprise.deploy.spi.status.ProgressEvent;
57
import javax.enterprise.deploy.spi.status.ProgressListener;
58
import javax.enterprise.deploy.spi.status.ProgressObject;
54
import javax.enterprise.deploy.spi.status.ProgressObject;
59
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
55
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
60
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
56
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
61
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
57
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
62
import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager;
58
import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager;
59
import org.netbeans.modules.j2ee.weblogic9.ProgressObjectSupport;
63
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
60
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
64
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
61
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
65
import org.netbeans.modules.j2ee.weblogic9.deploy.WLCommandDeployer;
62
import org.netbeans.modules.j2ee.weblogic9.deploy.WLCommandDeployer;
Lines 131-137 Link Here
131
        WLCommandDeployer deployer = new WLCommandDeployer(WLDeploymentFactory.getInstance(),
128
        WLCommandDeployer deployer = new WLCommandDeployer(WLDeploymentFactory.getInstance(),
132
                manager.getInstanceProperties());
129
                manager.getInstanceProperties());
133
        ProgressObject po = deployer.deployDatasource(toDeploy.values());
130
        ProgressObject po = deployer.deployDatasource(toDeploy.values());
134
        waitFor(po);
131
        ProgressObjectSupport.waitFor(po);
135
        if (po.getDeploymentStatus().isFailed()) {
132
        if (po.getDeploymentStatus().isFailed()) {
136
            String msg = NbBundle.getMessage(WLDatasourceManager.class, "MSG_FailedToDeployDatasource");
133
            String msg = NbBundle.getMessage(WLDatasourceManager.class, "MSG_FailedToDeployDatasource");
137
            throw new ConfigurationException(msg);
134
            throw new ConfigurationException(msg);
Lines 162-183 Link Here
162
        }
159
        }
163
        return map;
160
        return map;
164
    }
161
    }
165
166
    private void waitFor(ProgressObject obj) {
167
        final CountDownLatch latch = new CountDownLatch(1);
168
        obj.addProgressListener(new ProgressListener() {
169
170
            @Override
171
            public void handleProgressEvent(ProgressEvent pe) {
172
                if (pe.getDeploymentStatus().isCompleted() || pe.getDeploymentStatus().isFailed()) {
173
                    latch.countDown();
174
                }
175
            }
176
        });
177
        try {
178
            latch.await(WLDeploymentManager.MANAGER_TIMEOUT, TimeUnit.MILLISECONDS);
179
        } catch (InterruptedException ex) {
180
            Thread.currentThread().interrupt();
181
        }
182
    }
183
}
162
}
(-)5eda48228ef2 (+141 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.weblogic9.config;
41
42
import java.io.File;
43
import java.util.HashSet;
44
import java.util.Iterator;
45
import java.util.Map;
46
import java.util.Set;
47
import java.util.logging.Logger;
48
import javax.enterprise.deploy.spi.status.ProgressObject;
49
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
50
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
51
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
52
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryFactory;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
54
import org.netbeans.modules.j2ee.weblogic9.ProgressObjectSupport;
55
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
56
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
57
import org.netbeans.modules.j2ee.weblogic9.deploy.WLCommandDeployer;
58
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
59
import org.openide.util.NbBundle;
60
61
/**
62
 *
63
 * @author Petr Hejl
64
 */
65
public class WLServerLibraryManager implements ServerLibraryManager {
66
67
    private static final Logger LOGGER = Logger.getLogger(WLServerLibraryManager.class.getName());
68
69
    private final WLDeploymentManager manager;
70
71
    private final WLServerLibrarySupport support;
72
73
    public WLServerLibraryManager(WLDeploymentManager manager) {
74
        this.manager = manager;
75
        String domainDir = manager.getInstanceProperties().getProperty(WLPluginProperties.DOMAIN_ROOT_ATTR);
76
        assert domainDir != null;
77
        String serverDir = manager.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR);
78
        assert serverDir != null;
79
        this.support = new WLServerLibrarySupport(new File(serverDir), new File(domainDir));
80
    }
81
82
    @Override
83
    public void deployLibraries(Set<ServerLibraryDependency> libraries) throws ConfigurationException {
84
        Set<ServerLibraryDependency> notHandled = new HashSet<ServerLibraryDependency>(libraries);
85
        Set<ServerLibrary> deployed = getDeployedLibraries();
86
87
        for (ServerLibraryDependency range : libraries) {
88
            for (ServerLibrary lib : deployed) {
89
                if (range.versionMatches(lib)) {
90
                    notHandled.remove(range);
91
                    break;
92
                }
93
            }
94
        }
95
96
        Set<File> toDeploy = new HashSet<File>();
97
        Map<ServerLibrary, File> deployable = support.getDeployableFiles();
98
        for (Iterator<ServerLibraryDependency> it = notHandled.iterator(); it.hasNext(); ) {
99
            ServerLibraryDependency range = it.next();
100
            for (Map.Entry<ServerLibrary, File> entry : deployable.entrySet()) {
101
                if (range.versionMatches(entry.getKey())) {
102
                    it.remove();
103
                    toDeploy.add(entry.getValue());
104
                    break;
105
                }
106
            }
107
        }
108
109
        if (!notHandled.isEmpty()) {
110
            throw new ConfigurationException(NbBundle.getMessage(WLServerLibraryManager.class, "MSG_DidNotFindServerLibraries"));
111
        }
112
113
        deployFiles(toDeploy);
114
    }
115
116
    // this handles only archives
117
    @Override
118
    public Set<ServerLibrary> getDeployableLibraries() {
119
        return support.getDeployableFiles().keySet();
120
    }
121
122
    @Override
123
    public Set<ServerLibrary> getDeployedLibraries() {
124
        Set<ServerLibrary> result = new HashSet<ServerLibrary>();
125
        for (WLServerLibrarySupport.WLServerLibrary lib : support.getDeployedLibraries()) {
126
            result.add(ServerLibraryFactory.createServerLibrary(lib));
127
        }
128
        return result;
129
    }
130
131
    private void deployFiles(Set<File> libraries) throws ConfigurationException {
132
        WLCommandDeployer deployer = new WLCommandDeployer(WLDeploymentFactory.getInstance(),
133
                manager.getInstanceProperties());
134
        ProgressObject po = deployer.deployLibraries(libraries);
135
        ProgressObjectSupport.waitFor(po);
136
        if (po.getDeploymentStatus().isFailed()) {
137
            String msg = NbBundle.getMessage(WLDatasourceManager.class, "MSG_FailedToDeployLibrary");
138
            throw new ConfigurationException(msg);
139
        }
140
    }
141
}
(-)5eda48228ef2 (+502 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.weblogic9.config;
41
42
import java.beans.PropertyVetoException;
43
import java.io.BufferedInputStream;
44
import java.io.File;
45
import java.io.FileInputStream;
46
import java.io.FilenameFilter;
47
import java.io.IOException;
48
import java.io.InputStream;
49
import java.util.ArrayList;
50
import java.util.Arrays;
51
import java.util.Collections;
52
import java.util.HashMap;
53
import java.util.HashSet;
54
import java.util.List;
55
import java.util.Map;
56
import java.util.Set;
57
import java.util.jar.Attributes;
58
import java.util.jar.Manifest;
59
import java.util.logging.Level;
60
import java.util.logging.Logger;
61
import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
62
import javax.xml.parsers.ParserConfigurationException;
63
import javax.xml.parsers.SAXParser;
64
import javax.xml.parsers.SAXParserFactory;
65
import org.netbeans.api.annotations.common.CheckForNull;
66
import org.netbeans.modules.j2ee.deployment.common.api.Version;
67
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
68
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
69
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryFactory;
70
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryImplementation;
71
import org.openide.filesystems.FileObject;
72
import org.openide.filesystems.FileUtil;
73
import org.openide.filesystems.JarFileSystem;
74
import org.xml.sax.SAXException;
75
import org.xml.sax.helpers.DefaultHandler;
76
77
/**
78
 *
79
 * @author Petr Hejl
80
 */
81
public class WLServerLibrarySupport {
82
83
    private static final Logger LOGGER = Logger.getLogger(WLServerLibrarySupport.class.getName());
84
85
    private static final FilenameFilter LIBRARY_FILTER = new FilenameFilter() {
86
87
        @Override
88
        public boolean accept(File dir, String name) {
89
            return name.endsWith(".jar") // NOI18N
90
                        || name.endsWith(".war") // NOI18N
91
                        || name.endsWith(".ear"); // NOI18N
92
        }
93
    };
94
95
    private static final FilenameFilter JAR_FILTER = new FilenameFilter() {
96
97
        @Override
98
        public boolean accept(File dir, String name) {
99
            return name.endsWith(".jar"); // NOI18N
100
        }
101
    };
102
103
    private final File domainPath;
104
105
    private final File serverRoot;
106
107
    public WLServerLibrarySupport(File serverRoot, File domainPath) {
108
        this.domainPath = domainPath;
109
        this.serverRoot = serverRoot;
110
    }
111
112
    public File[] getClasspathEntries(Set<ServerLibraryDependency> libraries) throws ConfigurationException {
113
        Set<WLServerLibrary> deployed = getDeployedLibraries();
114
        Set<WLServerLibrary> classpath = new HashSet<WLServerLibrary>();
115
116
        for (ServerLibraryDependency range : libraries) {
117
            for (WLServerLibrary lib : deployed) {
118
                // optimize
119
                if (range.versionMatches(ServerLibraryFactory.createServerLibrary(lib))) {
120
                    classpath.add((WLServerLibrary) lib);
121
                    break;
122
                }
123
            }
124
        }
125
126
        // TODO deployable files
127
128
        List<File> result = new ArrayList<File>();
129
        // XXX optimize collection of libs on same server and/or same name
130
        for (WLServerLibrary lib : classpath) {
131
            String server = lib.getServer();
132
            // XXX is this path always the same ??
133
            File tmpPath = new File(domainPath, "servers" + File.separator + server + File.separator + "tmp" // NOI18N
134
                   + File.separator + "_WL_user" + File.separator + lib.getName()); // NOI18N
135
            if (tmpPath.exists() && tmpPath.isDirectory()) {
136
                File[] subDirs = tmpPath.listFiles();
137
                if (subDirs != null) {
138
                    for (File subdir : subDirs) {
139
                        WLServerLibrary parsed = readFromFile(subdir);
140
                        if (parsed != null) {
141
                            if (sameLibraries(lib, parsed)) {
142
                                // FIXME other libs ?
143
                                File webInfLib = new File(subdir, "WEB-INF" + File.separator + "lib"); // NOI18N
144
                                if (webInfLib.exists() && webInfLib.isDirectory()) {
145
                                    File[] children = webInfLib.listFiles(JAR_FILTER);
146
                                    if (children != null) {
147
                                        result.addAll(Arrays.asList(children));
148
                                    }
149
                                }
150
                            }
151
                        }
152
                    }
153
                }
154
            }
155
        }
156
157
        return result.toArray(new File[result.size()]);
158
    }
159
160
    Set<WLServerLibrary> getDeployedLibraries() {
161
        FileObject domain = FileUtil.toFileObject(domainPath);
162
        FileObject domainConfig = null;
163
        if (domain != null) {
164
            domainConfig = domain.getFileObject("config/config.xml"); // NOI18N
165
        }
166
        if (domainConfig == null) {
167
            return Collections.emptySet();
168
        }
169
170
        try {
171
            SAXParserFactory factory = SAXParserFactory.newInstance();
172
            SAXParser parser = factory.newSAXParser();
173
            LibraryHandler handler = new LibraryHandler(domainPath);
174
            parser.parse(new BufferedInputStream(domainConfig.getInputStream()), handler);
175
176
            Set<WLServerLibrary> libs = new HashSet<WLServerLibrary>();
177
            for (Library library : handler.getLibraries()) {
178
                File file = library.resolveFile();
179
                WLServerLibrary parsed = readFromFile(file);
180
                if (parsed != null) {
181
                    // checking the version - maybe we can avoid it
182
                    if (parsed.getSpecificationVersion() != library.getSpecificationVersion()
183
                        && (parsed.getSpecificationVersion() == null
184
                                || !parsed.getSpecificationVersion().equals(library.getSpecificationVersion()))) {
185
                        LOGGER.log(Level.INFO, "Inconsistent specification version for {0}", library.getName());
186
                    } else if (parsed.getImplementationVersion() != library.getImplementationVersion()
187
                        && (parsed.getImplementationVersion() == null
188
                                || !parsed.getImplementationVersion().equals(library.getImplementationVersion()))) {
189
                        LOGGER.log(Level.INFO, "Inconsistent implementation version for {0}", library.getName());
190
                    } else {
191
                        libs.add(new WLServerLibrary(
192
                                parsed.getSpecificationTitle(), parsed.getSpecificationVersion(),
193
                                parsed.getImplementationTitle(), parsed.getImplementationVersion(),
194
                                library.getTarget(), library.getName()));
195
                    }
196
                } else {
197
                    LOGGER.log(Level.INFO, "Source path does not exists for {0}", library.getName());
198
                    // XXX we use name as spec title
199
                    libs.add(new WLServerLibrary(
200
                            null, library.getSpecificationVersion(),
201
                            null, library.getImplementationVersion(), library.getTarget(), library.getName()));
202
                }
203
            }
204
205
            return libs;
206
        } catch (IOException ex) {
207
            return Collections.emptySet();
208
        } catch (ParserConfigurationException ex) {
209
            return Collections.emptySet();
210
        } catch (SAXException ex) {
211
            return Collections.emptySet();
212
        }
213
    }
214
215
    Map<ServerLibrary, File> getDeployableFiles() {
216
        File libPath = FileUtil.normalizeFile(new File(serverRoot,
217
                "common" + File.separator + "deployable-libraries")); // NOI18N
218
        if (!libPath.exists() || !libPath.isDirectory()) {
219
            return Collections.emptyMap();
220
        }
221
222
        Map<ServerLibrary, File> res = new HashMap<ServerLibrary, File>();
223
        for (File file : libPath.listFiles(LIBRARY_FILTER)) {
224
            WLServerLibrary lib = readFromFile(file);
225
            if (lib != null) {
226
                res.put(ServerLibraryFactory.createServerLibrary(lib), file);
227
            }
228
        }
229
        return res;
230
    }
231
232
    // consider implementation of equals in WLServerLibrary
233
    private static boolean sameLibraries(WLServerLibrary first, WLServerLibrary second) {
234
        if ((first.specTitle == null) ? (second.specTitle != null) : !first.specTitle.equals(second.specTitle)) {
235
            return false;
236
        }
237
        if (first.specVersion != second.specVersion
238
                && (first.specVersion == null || !first.specVersion.equals(second.specVersion))) {
239
            return false;
240
        }
241
        if ((first.implTitle == null) ? (second.implTitle != null) : !first.implTitle.equals(second.implTitle)) {
242
            return false;
243
        }
244
        if (first.implVersion != second.implVersion
245
                && (first.implVersion == null || !first.implVersion.equals(second.implVersion))) {
246
            return false;
247
        }
248
        if ((first.name == null) ? (second.name != null) : !first.name.equals(second.name)) {
249
            return false;
250
        }
251
        return true;
252
    }
253
254
    private static WLServerLibrary readFromFile(File file) {
255
        if (file == null || !file.exists() || !file.canRead()) {
256
            return null;
257
        }
258
259
        Attributes attributes = null;
260
261
        if (file.isDirectory()) {
262
            File manifestFile = new File(file, "META-INF" + File.separator + "MANIFEST.MF");
263
            if (manifestFile.exists() && manifestFile.isFile()) {
264
                Manifest manifest = new Manifest();
265
                try {
266
                    InputStream is = new BufferedInputStream(new FileInputStream(manifestFile));
267
                    try {
268
                        manifest.read(is);
269
                        attributes = manifest.getMainAttributes();
270
                    } finally {
271
                        is.close();
272
                    }
273
                } catch (IOException ex) {
274
                    LOGGER.log(Level.INFO, null, ex);
275
                }
276
            }
277
        } else {
278
            try {
279
                JarFileSystem jar = new JarFileSystem();
280
                jar.setJarFile(file);
281
                attributes = jar.getManifest().getMainAttributes();
282
            } catch (IOException ex) {
283
                LOGGER.log(Level.INFO, null, ex);
284
            } catch (PropertyVetoException ex) {
285
                LOGGER.log(Level.INFO, null, ex);
286
            }
287
        }
288
289
        if (attributes == null) {
290
            return null;
291
        }
292
293
        String specVersionValue = attributes.getValue("Specification-Version"); // NOI18N
294
        String implVersionValue = attributes.getValue("Implementation-Version"); // NOI18N
295
        String specTitle = attributes.getValue("Specification-Title"); // NOI18N
296
        String implTitle = attributes.getValue("Implementation-Title"); // NOI18N
297
        String name = attributes.getValue("Extension-Name"); // NOI18N
298
299
        Version specVersion = specVersionValue == null
300
                ? null
301
                : Version.fromJsr277NotationWithFallback(specVersionValue);
302
        Version implVersion = implVersionValue == null
303
                ? null
304
                : Version.fromJsr277NotationWithFallback(implVersionValue);
305
306
        return new WLServerLibrary(specTitle, specVersion, implTitle, implVersion, null, name);
307
    }
308
309
    static class WLServerLibrary implements ServerLibraryImplementation {
310
311
        private final String specTitle;
312
313
        private final Version specVersion;
314
315
        private final String implTitle;
316
317
        private final Version implVersion;
318
319
        private final String server;
320
321
        private final String name;
322
323
        public WLServerLibrary(String specTitle, Version specVersion,
324
                String implTitle, Version implVersion, String server, String name) {
325
            this.specTitle = specTitle;
326
            this.specVersion = specVersion;
327
            this.implTitle = implTitle;
328
            this.implVersion = implVersion;
329
            this.server = server;
330
            this.name = name;
331
        }
332
333
        @Override
334
        public String getSpecificationTitle() {
335
            return specTitle;
336
        }
337
338
        @Override
339
        public Version getSpecificationVersion() {
340
            return specVersion;
341
        }
342
343
        @Override
344
        public String getImplementationTitle() {
345
            return implTitle;
346
        }
347
348
        @Override
349
        public Version getImplementationVersion() {
350
            return implVersion;
351
        }
352
353
        @Override
354
        public String getName() {
355
            return name;
356
        }
357
358
        public String getServer() {
359
            return server;
360
        }
361
    }
362
363
    private static class LibraryHandler extends DefaultHandler {
364
365
        private final List<Library> libraries = new ArrayList<Library>();
366
367
        private final File domainDir;
368
369
        private Library library;
370
371
        private String value;
372
373
        public LibraryHandler(File domainDir) {
374
            this.domainDir = domainDir;
375
        }
376
377
        @Override
378
        public void startElement(String uri, String localName, String qName, org.xml.sax.Attributes attributes) throws SAXException {
379
            value = null;
380
            if ("library".equals(qName)) { // NOI18N
381
                library = new Library(domainDir);
382
            }
383
        }
384
385
        @Override
386
        public void endElement(String uri, String localName, String qName) {
387
            if (library == null) {
388
                return;
389
            }
390
391
            if ("library".equals(qName)) { // NOI18N
392
                libraries.add(library);
393
                library = null;
394
            } else if("name".equals(qName)) { // NOI18N
395
                String[] splitted = value.split("#"); // NOI18N
396
                if (splitted.length > 1) {
397
                    library.setName(splitted[0]);
398
                    splitted = splitted[1].split("@"); // NOI18N
399
                    library.setSpecificationVersion(Version.fromJsr277NotationWithFallback(splitted[0]));
400
                    if (splitted.length > 1) {
401
                        library.setImplementationVersion(Version.fromJsr277NotationWithFallback(splitted[1]));
402
                    }
403
                } else {
404
                    library.setName(value);
405
                }
406
            } else if ("target".equals(qName)) { // NOI18N
407
                library.setTarget(value);
408
            } else if ("source-path".equals(qName)) { // NOI18N
409
                library.setFile(value);
410
            }
411
        }
412
413
        @Override
414
        public void characters(char[] ch, int start, int length) {
415
            value = new String(ch, start, length);
416
        }
417
418
        public List<Library> getLibraries() {
419
            return libraries;
420
        }
421
    }
422
423
    private static class Library {
424
425
        private final File baseFile;
426
427
        private String name;
428
429
        private Version specVersion;
430
431
        private Version implVersion;
432
433
        private String file;
434
435
        private String target;
436
437
        public Library(File baseFile) {
438
            this.baseFile = baseFile;
439
        }
440
441
        @CheckForNull
442
        public File resolveFile() {
443
            if (file == null) {
444
                return null;
445
            }
446
447
            File config = new File(file);
448
            if (!config.isAbsolute()) {
449
                if (baseFile != null) {
450
                    config = new File(baseFile, file);
451
                } else {
452
                    return null;
453
                }
454
            }
455
            if (config.exists() && config.isFile() && config.canRead()) {
456
                return config;
457
            }
458
            return null;
459
        }
460
461
        public String getName() {
462
            return name;
463
        }
464
465
        public void setName(String name) {
466
            this.name = name;
467
        }
468
469
        public Version getSpecificationVersion() {
470
            return specVersion;
471
        }
472
473
        public void setSpecificationVersion(Version specVersion) {
474
            this.specVersion = specVersion;
475
        }
476
477
        public Version getImplementationVersion() {
478
            return implVersion;
479
        }
480
481
        public void setImplementationVersion(Version implVersion) {
482
            this.implVersion = implVersion;
483
        }
484
485
        public String getTarget() {
486
            return target;
487
        }
488
489
        public void setTarget(String target) {
490
            this.target = target;
491
        }
492
493
        public String getFile() {
494
            return file;
495
        }
496
497
        public void setFile(String file) {
498
            this.file = file;
499
        }
500
501
    }
502
}
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WarDeploymentConfiguration.java (-7 / +192 lines)
Lines 51-63 Link Here
51
import java.io.File;
51
import java.io.File;
52
import java.io.IOException;
52
import java.io.IOException;
53
import java.io.OutputStream;
53
import java.io.OutputStream;
54
import java.util.Collections;
55
import java.util.HashSet;
56
import java.util.Set;
57
import javax.swing.event.ChangeListener;
54
import javax.swing.text.BadLocationException;
58
import javax.swing.text.BadLocationException;
55
import javax.swing.text.StyledDocument;
59
import javax.swing.text.StyledDocument;
60
import org.netbeans.api.annotations.common.NonNull;
56
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
61
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
62
import org.netbeans.modules.j2ee.deployment.common.api.Version;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
63
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
64
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
58
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
65
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
59
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
66
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
60
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
67
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
68
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration;
69
import org.netbeans.modules.j2ee.weblogic9.config.gen.LibraryRefType;
61
import org.netbeans.modules.j2ee.weblogic9.config.gen.WeblogicWebApp;
70
import org.netbeans.modules.j2ee.weblogic9.config.gen.WeblogicWebApp;
62
import org.netbeans.modules.schema2beans.AttrProp;
71
import org.netbeans.modules.schema2beans.AttrProp;
63
import org.netbeans.modules.schema2beans.BaseBean;
72
import org.netbeans.modules.schema2beans.BaseBean;
Lines 65-77 Link Here
65
import org.openide.NotifyDescriptor;
74
import org.openide.NotifyDescriptor;
66
import org.openide.cookies.EditorCookie;
75
import org.openide.cookies.EditorCookie;
67
import org.openide.cookies.SaveCookie;
76
import org.openide.cookies.SaveCookie;
77
import org.openide.filesystems.FileAttributeEvent;
78
import org.openide.filesystems.FileChangeListener;
79
import org.openide.filesystems.FileEvent;
80
import org.openide.filesystems.FileRenameEvent;
68
import org.openide.filesystems.FileUtil;
81
import org.openide.filesystems.FileUtil;
69
import org.openide.loaders.DataObject;
82
import org.openide.loaders.DataObject;
70
import org.openide.loaders.DataObjectNotFoundException;
83
import org.openide.loaders.DataObjectNotFoundException;
71
import org.openide.text.NbDocument;
84
import org.openide.text.NbDocument;
85
import org.openide.util.ChangeSupport;
72
import org.openide.util.Exceptions;
86
import org.openide.util.Exceptions;
73
import org.openide.util.Lookup;
87
import org.openide.util.Lookup;
74
import org.openide.util.NbBundle;
88
import org.openide.util.NbBundle;
89
import org.openide.util.Parameters;
75
import org.openide.util.lookup.Lookups;
90
import org.openide.util.lookup.Lookups;
76
91
77
/**
92
/**
Lines 81-92 Link Here
81
 * @author sherold
96
 * @author sherold
82
 */
97
 */
83
public class WarDeploymentConfiguration extends WLDeploymentConfiguration
98
public class WarDeploymentConfiguration extends WLDeploymentConfiguration
84
        implements ModuleConfiguration, ContextRootConfiguration, DeploymentPlanConfiguration, PropertyChangeListener {
99
        implements ServerLibraryConfiguration, ModuleConfiguration,
85
    
100
        ContextRootConfiguration, DeploymentPlanConfiguration, PropertyChangeListener {
101
102
103
    private final ChangeSupport serverLibraryChangeSupport = new ChangeSupport(this);
104
86
    private final File file;
105
    private final File file;
106
87
    private final J2eeModule j2eeModule;
107
    private final J2eeModule j2eeModule;
108
88
    private final DataObject dataObject;
109
    private final DataObject dataObject;
110
111
    private final FileChangeListener weblogicXmlListener = new WeblogicXmlListener();
112
89
    private WeblogicWebApp webLogicWebApp;
113
    private WeblogicWebApp webLogicWebApp;
114
115
    private Set<ServerLibraryDependency> originalDeps;
90
    
116
    
91
    /**
117
    /**
92
     * Creates a new instance of WarDeploymentConfiguration 
118
     * Creates a new instance of WarDeploymentConfiguration 
Lines 95-100 Link Here
95
        super(j2eeModule);
121
        super(j2eeModule);
96
        this.j2eeModule = j2eeModule;
122
        this.j2eeModule = j2eeModule;
97
        file = j2eeModule.getDeploymentConfigurationFile("WEB-INF/weblogic.xml"); // NOI18N
123
        file = j2eeModule.getDeploymentConfigurationFile("WEB-INF/weblogic.xml"); // NOI18N
124
        FileUtil.addFileChangeListener(weblogicXmlListener, file);
125
98
        getWeblogicWebApp();
126
        getWeblogicWebApp();
99
        DataObject dataObject = null;
127
        DataObject dataObject = null;
100
        try {
128
        try {
Lines 106-112 Link Here
106
        this.dataObject = dataObject;
134
        this.dataObject = dataObject;
107
    }
135
    }
108
    
136
    
109
110
    public Lookup getLookup() {
137
    public Lookup getLookup() {
111
        return Lookups.fixed(this);
138
        return Lookups.fixed(this);
112
    }
139
    }
Lines 141-147 Link Here
141
     *
168
     *
142
     * @return WeblogicWebApp graph or null if the weblogic.xml file is not parseable.
169
     * @return WeblogicWebApp graph or null if the weblogic.xml file is not parseable.
143
     */
170
     */
144
    public synchronized WeblogicWebApp getWeblogicWebApp() {
171
    public final synchronized WeblogicWebApp getWeblogicWebApp() {
145
        if (webLogicWebApp == null) {
172
        if (webLogicWebApp == null) {
146
            try {
173
            try {
147
                if (file.exists()) {
174
                if (file.exists()) {
Lines 328-337 Link Here
328
            }
355
            }
329
        });
356
        });
330
    }
357
    }
331
    
358
332
    
359
    @Override
360
    public void configureLibrary(@NonNull final ServerLibraryDependency library) throws ConfigurationException {
361
        assert library != null;
362
363
        modifyWeblogicWebApp(new WeblogicWebAppModifier() {
364
            public void modify(WeblogicWebApp webLogicWebApp) {
365
                for (LibraryRefType libRef : webLogicWebApp.getLibraryRef()) {
366
                    ServerLibraryDependency lib = getServerLibraryRange(libRef);
367
                    if (library.equals(lib)) {
368
                        return;
369
                    }
370
                }
371
372
                setServerLibraryRange(webLogicWebApp, library);
373
            }
374
        });
375
    }
376
377
    @Override
378
    public Set<ServerLibraryDependency> getLibraries() throws ConfigurationException {
379
        WeblogicWebApp webLogicWebApp = getWeblogicWebApp();
380
        if (webLogicWebApp == null) { // graph not parseable
381
            String msg = NbBundle.getMessage(WarDeploymentConfiguration.class, "MSG_CannotReadServerLibraries", file.getPath());
382
            throw new ConfigurationException(msg);
383
        }
384
385
        Set<ServerLibraryDependency> ranges = new HashSet<ServerLibraryDependency>();
386
        for (LibraryRefType libRef : webLogicWebApp.getLibraryRef()) {
387
            ranges.add(getServerLibraryRange(libRef));
388
        }
389
390
        return ranges;
391
    }
392
393
    @Override
394
    public void addLibraryChangeListener(@NonNull ChangeListener listener) {
395
        Parameters.notNull("listener", listener);
396
397
        boolean load = false;
398
        synchronized (this) {
399
            load = originalDeps == null;
400
        }
401
        if (load) {
402
            Set<ServerLibraryDependency> deps = null;
403
            try {
404
                deps = getLibraries();
405
            } catch(ConfigurationException ex) {
406
                deps = Collections.emptySet();
407
            }
408
            synchronized (this) {
409
                if (originalDeps == null) {
410
                    originalDeps = deps;
411
                }
412
            }
413
        }
414
415
        serverLibraryChangeSupport.addChangeListener(listener);
416
    }
417
418
    @Override
419
    public void removeLibraryChangeListener(@NonNull ChangeListener listener) {
420
        Parameters.notNull("listener", listener);
421
        serverLibraryChangeSupport.removeChangeListener(listener);
422
    }
423
424
    private void fireChange() {
425
        Set<ServerLibraryDependency> oldDeps = null;
426
        synchronized (this) {
427
            if (originalDeps == null) {
428
                // nobody is listening
429
                return;
430
            }
431
            oldDeps = new HashSet<ServerLibraryDependency>(originalDeps);
432
        }
433
434
        Set<ServerLibraryDependency> deps = new HashSet<ServerLibraryDependency>();
435
        try {
436
            deps.addAll(getLibraries());
437
        } catch (ConfigurationException ex) {
438
            // noop - empty set
439
        }
440
        boolean fire = false;
441
        for (ServerLibraryDependency old : oldDeps) {
442
            if (!deps.remove(old)) {
443
                fire = true;
444
                break;
445
            }
446
        }
447
        if (!deps.isEmpty()) {
448
            fire = true;
449
        }
450
        if (fire) {
451
            serverLibraryChangeSupport.fireChange();
452
        }
453
    }
454
455
    private ServerLibraryDependency getServerLibraryRange(LibraryRefType libRef) {
456
        String name = libRef.getLibraryName();
457
        String specVersionString = libRef.getSpecificationVersion();
458
        String implVersionString = libRef.getImplementationVersion();
459
        boolean exactMatch = libRef.isExactMatch();
460
461
        Version spec = specVersionString == null ? null : Version.fromJsr277NotationWithFallback(specVersionString);
462
        Version impl = implVersionString == null ? null : Version.fromJsr277NotationWithFallback(implVersionString);
463
        if (exactMatch) {
464
            return ServerLibraryDependency.exactVersion(name, spec, impl);
465
        } else {
466
            return ServerLibraryDependency.minimalVersion(name, spec, impl);
467
        }
468
    }
469
470
    private void setServerLibraryRange(WeblogicWebApp webApp, ServerLibraryDependency library) {
471
        LibraryRefType libRef = new LibraryRefType();
472
        libRef.setLibraryName(library.getName());
473
        if (library.isExactMatch()) {
474
            libRef.setExactMatch(true);
475
        }
476
        if (library.getSpecificationVersion() != null) {
477
            libRef.setSpecificationVersion(library.getSpecificationVersion().toString());
478
        }
479
        if (library.getImplementationVersion() != null) {
480
            libRef.setImplementationVersion(library.getImplementationVersion().toString());
481
        }
482
        webApp.setLibraryRef(new LibraryRefType[] {libRef});
483
    }
484
333
    // private helper interface -----------------------------------------------
485
    // private helper interface -----------------------------------------------
334
     
486
487
    private class WeblogicXmlListener implements FileChangeListener {
488
489
        @Override
490
        public void fileFolderCreated(FileEvent fe) {
491
            // noop
492
        }
493
494
        @Override
495
        public void fileDataCreated(FileEvent fe) {
496
            fireChange();
497
        }
498
499
        @Override
500
        public void fileChanged(FileEvent fe) {
501
            fireChange();
502
        }
503
504
        @Override
505
        public void fileDeleted(FileEvent fe) {
506
            fireChange();
507
        }
508
509
        @Override
510
        public void fileRenamed(FileRenameEvent fe) {
511
            fireChange();
512
        }
513
514
        @Override
515
        public void fileAttributeChanged(FileAttributeEvent fe) {
516
            // noop
517
        }
518
    }
519
335
    private interface WeblogicWebAppModifier {
520
    private interface WeblogicWebAppModifier {
336
        void modify(WeblogicWebApp context);
521
        void modify(WeblogicWebApp context);
337
    }
522
    }
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/deploy/Bundle.properties (+7 lines)
Lines 89-91 Link Here
89
MSG_Datasource_Failed_Interrupted=Datasource deployment failed. The deployment was interrupted.
89
MSG_Datasource_Failed_Interrupted=Datasource deployment failed. The deployment was interrupted.
90
MSG_Datasource_Failed=Datasource deployment failed. Check the configured credentials.
90
MSG_Datasource_Failed=Datasource deployment failed. Check the configured credentials.
91
MSG_Datasource_Completed=Datasource deployment completed.
91
MSG_Datasource_Completed=Datasource deployment completed.
92
93
MSG_Library_Started=Library deployment started.
94
MSG_Library_Failed=Library deployment failed. Check the configured credentials.
95
MSG_Library_Completed=Library deployment completed.
96
MSG_Library_Failed_With_Message=Library deployment failed. Message was: {0}
97
MSG_Library_Failed_Timeout=Library deployment failed. The timeout expired.
98
MSG_Library_Failed_Interrupted=Library deployment failed. The deployment was interrupted.
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/deploy/WLCommandDeployer.java (+63 lines)
Lines 51-56 Link Here
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.Collection;
52
import java.util.Collection;
53
import java.util.List;
53
import java.util.List;
54
import java.util.Set;
54
import java.util.concurrent.ExecutionException;
55
import java.util.concurrent.ExecutionException;
55
import java.util.concurrent.Future;
56
import java.util.concurrent.Future;
56
import java.util.concurrent.TimeUnit;
57
import java.util.concurrent.TimeUnit;
Lines 81-86 Link Here
81
import org.netbeans.modules.j2ee.dd.api.application.DDProvider;
82
import org.netbeans.modules.j2ee.dd.api.application.DDProvider;
82
import org.netbeans.modules.j2ee.dd.api.application.Module;
83
import org.netbeans.modules.j2ee.dd.api.application.Module;
83
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
84
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
85
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
84
import org.netbeans.modules.j2ee.weblogic9.URLWait;
86
import org.netbeans.modules.j2ee.weblogic9.URLWait;
85
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
87
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
86
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
88
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
Lines 442-447 Link Here
442
        return progress;
444
        return progress;
443
    }
445
    }
444
446
447
    public ProgressObject deployLibraries(final Set<File> libraries) {
448
        final WLProgressObject progress = new WLProgressObject(new TargetModuleID[0]);
449
450
        progress.fireProgressEvent(null, new WLDeploymentStatus(
451
                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.RUNNING,
452
                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Started")));
453
454
        factory.getExecutorService().submit(new Runnable() {
455
456
            @Override
457
            public void run() {
458
                boolean failed = false;
459
                for (File library : libraries) {
460
                    ExecutionService service = createService("-deploy", null,
461
                            "-library" , library.getAbsolutePath()); // NOI18N
462
                    Future<Integer> result = service.run();
463
                    try {
464
                        Integer value = result.get(TIMEOUT, TimeUnit.MILLISECONDS);
465
                        if (value.intValue() != 0) {
466
                            failed = true;
467
                            progress.fireProgressEvent(null, new WLDeploymentStatus(
468
                                    ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
469
                                    NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed")));
470
                            break;
471
                        } else {
472
                            continue;
473
                        }
474
                    } catch (InterruptedException ex) {
475
                        failed = true;
476
                        progress.fireProgressEvent(null, new WLDeploymentStatus(
477
                                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
478
                                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed_Interrupted")));
479
                        result.cancel(true);
480
                        Thread.currentThread().interrupt();
481
                        break;
482
                    } catch (TimeoutException ex) {
483
                        failed = true;
484
                        progress.fireProgressEvent(null, new WLDeploymentStatus(
485
                                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
486
                                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed_Timeout")));
487
                        result.cancel(true);
488
                        break;
489
                    } catch (ExecutionException ex) {
490
                        failed = true;
491
                        progress.fireProgressEvent(null, new WLDeploymentStatus(
492
                                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
493
                                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed_With_Message")));
494
                        break;
495
                    }
496
                }
497
                if (!failed) {
498
                    progress.fireProgressEvent(null, new WLDeploymentStatus(
499
                            ActionType.EXECUTE, CommandType.START, StateType.COMPLETED,
500
                            NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Completed")));
501
                }
502
            }
503
        });
504
505
        return progress;
506
    }
507
445
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) {
508
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) {
446
509
447
        assert !SwingUtilities.isEventDispatchThread() : "Should not be executed in EDT";
510
        assert !SwingUtilities.isEventDispatchThread() : "Should not be executed in EDT";
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/j2ee/WLJ2eePlatformFactory.java (-6 / +30 lines)
Lines 60-67 Link Here
60
import java.util.logging.Level;
60
import java.util.logging.Level;
61
import java.util.logging.Logger;
61
import java.util.logging.Logger;
62
import javax.enterprise.deploy.spi.DeploymentManager;
62
import javax.enterprise.deploy.spi.DeploymentManager;
63
import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
63
import org.netbeans.api.j2ee.core.Profile;
64
import org.netbeans.api.j2ee.core.Profile;
64
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule.Type;
65
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule.Type;
66
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
65
import org.netbeans.modules.j2ee.deployment.plugins.spi.support.LookupProviderSupport;
67
import org.netbeans.modules.j2ee.deployment.plugins.spi.support.LookupProviderSupport;
66
import org.openide.modules.InstalledFileLocator;
68
import org.openide.modules.InstalledFileLocator;
67
import org.netbeans.api.java.platform.JavaPlatform;
69
import org.netbeans.api.java.platform.JavaPlatform;
Lines 72-78 Link Here
72
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
74
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
73
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
75
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
74
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
76
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
75
import org.netbeans.modules.j2ee.weblogic9.WLProductProperties;
77
import org.netbeans.modules.j2ee.weblogic9.config.WLServerLibrarySupport;
76
import org.netbeans.spi.project.libraries.LibraryImplementation;
78
import org.netbeans.spi.project.libraries.LibraryImplementation;
77
import org.openide.filesystems.FileObject;
79
import org.openide.filesystems.FileObject;
78
import org.openide.filesystems.FileUtil;
80
import org.openide.filesystems.FileUtil;
Lines 108-115 Link Here
108
        }
110
        }
109
111
110
        private final Set<Profile> PROFILES = new HashSet<Profile>();
112
        private final Set<Profile> PROFILES = new HashSet<Profile>();
111
        
113
112
//        private String platformRoot = WLPluginProperties.getInstance().getInstallLocation();
113
        private String platformRoot;
114
        private String platformRoot;
114
        
115
        
115
        private LibraryImplementation[] libraries = null;
116
        private LibraryImplementation[] libraries = null;
Lines 183-189 Link Here
183
        }
184
        }
184
        
185
        
185
        public java.io.File[] getPlatformRoots() {
186
        public java.io.File[] getPlatformRoots() {
186
            return new File[]{new File(getPlatformRoot())};
187
            File server = new File(getPlatformRoot());
188
            File domain = new File(dm.getInstanceProperties().getProperty(
189
                    WLPluginProperties.DOMAIN_ROOT_ATTR));
190
191
            assert server.isAbsolute();
192
            assert domain.isAbsolute();
193
            
194
            return new File[] {server, domain};
187
        }
195
        }
188
        
196
        
189
        public LibraryImplementation[] getLibraries() {
197
        public LibraryImplementation[] getLibraries() {
Lines 192-197 Link Here
192
            }
200
            }
193
            return libraries;
201
            return libraries;
194
        }
202
        }
203
204
        @Override
205
        public File[] getClasspathEntries(Set<ServerLibraryDependency> libraries) {
206
            String domainDir = dm.getInstanceProperties().getProperty(WLPluginProperties.DOMAIN_ROOT_ATTR);
207
            assert domainDir != null;
208
            String serverDir = dm.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR);
209
            assert serverDir != null;
210
            WLServerLibrarySupport support = new WLServerLibrarySupport(new File(serverDir), new File(domainDir));
211
212
            try {
213
                return support.getClasspathEntries(libraries);
214
            } catch (ConfigurationException ex) {
215
                LOGGER.log(Level.INFO, null, ex);
216
                return new File[] {};
217
            }
218
        }
195
        
219
        
196
        private void initLibraries() {
220
        private void initLibraries() {
197
            
221
            
Lines 345-353 Link Here
345
        }
369
        }
346
        
370
        
347
        private String getPlatformRoot() {
371
        private String getPlatformRoot() {
348
            if (platformRoot == null)
372
            if (platformRoot == null) {
349
                platformRoot = dm.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR);
373
                platformRoot = dm.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR);
350
            
374
            }
351
            return platformRoot;
375
            return platformRoot;
352
        }
376
        }
353
377
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLOptionalDeploymentManagerFactory.java (+7 lines)
Lines 51-59 Link Here
51
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer;
51
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer;
52
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory;
52
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
54
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
54
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
55
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
55
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
56
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
56
import org.netbeans.modules.j2ee.weblogic9.config.WLDatasourceManager;
57
import org.netbeans.modules.j2ee.weblogic9.config.WLDatasourceManager;
58
import org.netbeans.modules.j2ee.weblogic9.config.WLServerLibraryManager;
57
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
59
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
58
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDriverDeployer;
60
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDriverDeployer;
59
import org.netbeans.modules.j2ee.weblogic9.ui.wizard.WLInstantiatingIterator;
61
import org.netbeans.modules.j2ee.weblogic9.ui.wizard.WLInstantiatingIterator;
Lines 138-143 Link Here
138
        return new WLServerInstanceDescriptor((WLDeploymentManager) dm);
140
        return new WLServerInstanceDescriptor((WLDeploymentManager) dm);
139
    }
141
    }
140
142
143
    @Override
144
    public ServerLibraryManager getServerLibraryManager(DeploymentManager dm) {
145
        return new WLServerLibraryManager((WLDeploymentManager) dm);
146
    }
147
141
    private static class WLServerInstanceDescriptor implements ServerInstanceDescriptor {
148
    private static class WLServerInstanceDescriptor implements ServerInstanceDescriptor {
142
149
143
        private final String host;
150
        private final String host;
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/ui/wizard/ServerLocationVisual.java (-1 / +2 lines)
Lines 61-66 Link Here
61
import javax.swing.event.ChangeEvent;
61
import javax.swing.event.ChangeEvent;
62
import javax.swing.event.ChangeListener;
62
import javax.swing.event.ChangeListener;
63
import javax.swing.filechooser.FileFilter;
63
import javax.swing.filechooser.FileFilter;
64
import org.netbeans.modules.j2ee.deployment.common.api.Version;
64
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
65
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
65
import org.openide.WizardDescriptor;
66
import org.openide.WizardDescriptor;
66
import org.openide.util.NbBundle;
67
import org.openide.util.NbBundle;
Lines 107-113 Link Here
107
        }
108
        }
108
        
109
        
109
        File serverRoot = new File(location);
110
        File serverRoot = new File(location);
110
        WLPluginProperties.Version version = WLPluginProperties.getVersion(serverRoot);
111
        Version version = WLPluginProperties.getVersion(serverRoot);
111
112
112
        if (!WLPluginProperties.isSupportedVersion(version)) {
113
        if (!WLPluginProperties.isSupportedVersion(version)) {
113
            String msg = NbBundle.getMessage(ServerLocationVisual.class, "ERR_INVALID_SERVER_VERSION");  // NOI18N
114
            String msg = NbBundle.getMessage(ServerLocationVisual.class, "ERR_INVALID_SERVER_VERSION");  // NOI18N
(-)a/j2eeserver/apichanges.xml (+28 lines)
Lines 116-121 Link Here
116
    <!-- ACTUAL CHANGES BEGIN HERE: -->
116
    <!-- ACTUAL CHANGES BEGIN HERE: -->
117
117
118
    <changes>
118
    <changes>
119
        <change id="serverLibraries">
120
	    <summary>
121
                Implemented support for handling the server libraries.
122
	    </summary>
123
	    <version major="1" minor="68"/>
124
	    <date day="9" month="6" year="2010"/>
125
	    <author login="phejl"/>
126
	    <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
127
	    <description>
128
                <p>
129
                Implemented both SPI and API to provide support for server
130
                libraries management.
131
                </p>
132
	    </description>
133
            <class package="org.netbeans.modules.j2ee.deployment.common.api" name="Version"/>
134
            <class package="org.netbeans.modules.j2ee.deployment.devmodules.api" name="ServerInstance"/>
135
            <class package="org.netbeans.modules.j2ee.deployment.devmodules.spi" name="J2eeModuleProvider"/>
136
            <class package="org.netbeans.modules.j2ee.deployment.plugins.api" name="ServerLibrary"/>
137
            <class package="org.netbeans.modules.j2ee.deployment.plugins.api" name="ServerLibraryRange"/>
138
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi" name="OptionalDeploymentManagerFactory"/>
139
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi" name="ServerLibraryFactory"/>
140
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi" name="ServerLibraryImplementation"/>
141
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi" name="ServerLibraryManager"/>
142
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi.config" name="ServerLibraryConfiguration"/>
143
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi.support" name="ProxyOptionalFactory"/>
144
            <issue number="182282"/>
145
	 </change>
146
119
        <change id="optionalFactoryProxy">
147
        <change id="optionalFactoryProxy">
120
	    <api name="support"/>
148
	    <api name="support"/>
121
	    <summary>
149
	    <summary>
(-)a/j2eeserver/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
is.autoload=true
43
is.autoload=true
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.67.0
45
spec.version.base=1.68.0
46
46
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)5eda48228ef2 (+299 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.deployment.common.api;
41
42
import java.util.regex.Matcher;
43
import java.util.regex.Pattern;
44
import org.netbeans.api.annotations.common.CheckForNull;
45
import org.netbeans.api.annotations.common.NonNull;
46
import org.openide.util.Parameters;
47
48
/**
49
 * Represents the generic version. Useful for libraries, products etc.
50
 * <p>
51
 * This class is <i>Immutable</i>.
52
 *
53
 * @author Petr Hejl
54
 * @since 1.68
55
 */
56
// TODO add JBoss notation parsing MAJOR.MINOR.MICRO.QUALIFIER
57
public final class Version {
58
59
    private static final Pattern JSR277_PATTERN = Pattern.compile(
60
            "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.(\\d+))?)?)?(-((\\w|-)+))?");
61
62
    private final String version;
63
64
    private final Integer majorNumber;
65
66
    private final Integer minorNumber;
67
68
    private final Integer microNumber;
69
70
    private final Integer updateNumber;
71
72
    private final String qualifier;
73
74
    private Version(String version, Integer majorNumber, Integer minorNumber,
75
            Integer microNumber, Integer updateNumber, String qualifier) {
76
        this.version = version;
77
        this.majorNumber = majorNumber;
78
        this.minorNumber = minorNumber;
79
        this.microNumber = microNumber;
80
        this.updateNumber = updateNumber;
81
        this.qualifier = qualifier;
82
    }
83
84
    /**
85
     * Creates the version from the spec version string.
86
     * Expected format is <code>MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE_NUMBER]]][-QUALIFIER]</code>
87
     * or <code>GENERIC_VERSION_STRING</code>.
88
     *
89
     * @param version spec version string with the following format:
90
     *             <code>MAJOR_NUMBER[.MINOR_NUMBER[.MICRO_NUMBER[.UPDATE_NUMBER]]][-QUALIFIER]</code>
91
     *             or <code>GENERIC_VERSION_STRING</code>
92
     */
93
    public static @NonNull Version fromJsr277NotationWithFallback(@NonNull String version) {
94
        Parameters.notNull("version", version);
95
96
        Matcher matcher = JSR277_PATTERN.matcher(version);
97
        if (matcher.matches()) {
98
            String fragment = matcher.group(1);
99
            Integer majorNumber = fragment != null ? Integer.valueOf(fragment) : null;
100
            fragment = matcher.group(3);
101
            Integer minorNumber = fragment != null ? Integer.valueOf(fragment) : null;
102
            fragment = matcher.group(5);
103
            Integer microNumber = fragment != null ? Integer.valueOf(fragment) : null;
104
            fragment = matcher.group(7);
105
            Integer updateNumber = fragment != null ? Integer.valueOf(fragment) : null;
106
            String qualifier = matcher.group(9);
107
108
            return new Version(version, majorNumber, minorNumber,
109
                    microNumber, updateNumber, qualifier);
110
        } else {
111
            return new Version(version, null, null, null, null, null);
112
        }
113
    }
114
115
    /**
116
     * Returns the major number. May return <code>null</code>.
117
     *
118
     * @return the major number; may return <code>null</code>
119
     */
120
    @CheckForNull
121
    public Integer getMajor() {
122
        return majorNumber;
123
    }
124
125
    /**
126
     * Returns the minor number. May return <code>null</code>.
127
     *
128
     * @return the minor number; may return <code>null</code>
129
     */
130
    @CheckForNull
131
    public Integer getMinor() {
132
        return minorNumber;
133
    }
134
135
    /**
136
     * Returns the micro number. May return <code>null</code>.
137
     *
138
     * @return the micro number; may return <code>null</code>
139
     */
140
    @CheckForNull
141
    public Integer getMicro() {
142
        return microNumber;
143
    }
144
145
    /**
146
     * Returns the update. May return <code>null</code>.
147
     *
148
     * @return the update; may return <code>null</code>
149
     */
150
    @CheckForNull
151
    public Integer getUpdate() {
152
        return updateNumber;
153
    }
154
155
    /**
156
     * Returns the qualifier. May return <code>null</code>.
157
     *
158
     * @return the qualifier; may return <code>null</code>
159
     */
160
    @CheckForNull
161
    public String getQualifier() {
162
        return qualifier;
163
    }
164
165
    /**
166
     * {@inheritDoc}
167
     * <p>
168
     * Two versions are equal if and only if they have same major, minor,
169
     * micro, update number and qualifier. If the version does not conform to
170
     * notation the versions are equal only if the version strings exactly
171
     * matches.
172
     */
173
    @Override
174
    public boolean equals(Object obj) {
175
        if (obj == null) {
176
            return false;
177
        }
178
        if (getClass() != obj.getClass()) {
179
            return false;
180
        }
181
        final Version other = (Version) obj;
182
        
183
        // non conform
184
        if ((this.majorNumber == null && other.majorNumber != null)
185
                || (this.majorNumber != null && other.majorNumber == null)) {
186
            return false;
187
        } else if (this.majorNumber == null && other.majorNumber == null) {
188
            return this.version.equals(other.version);
189
        }
190
191
        // standard
192
        if (this.majorNumber != other.majorNumber && (this.majorNumber == null || !this.majorNumber.equals(other.majorNumber))) {
193
            return false;
194
        }
195
        if (this.minorNumber != other.minorNumber && (this.minorNumber == null || !this.minorNumber.equals(other.minorNumber))) {
196
            return false;
197
        }
198
        if (this.microNumber != other.microNumber && (this.microNumber == null || !this.microNumber.equals(other.microNumber))) {
199
            return false;
200
        }
201
        if (this.updateNumber != other.updateNumber && (this.updateNumber == null || !this.updateNumber.equals(other.updateNumber))) {
202
            return false;
203
        }
204
        if ((this.qualifier == null) ? (other.qualifier != null) : !this.qualifier.equals(other.qualifier)) {
205
            return false;
206
        }
207
        return true;
208
    }
209
210
    /**
211
     * {@inheritDoc}
212
     * <p>
213
     * The implementation consistent with {@link #equals(Object)}.
214
     */
215
    @Override
216
    public int hashCode() {
217
        // non conform
218
        if (this.majorNumber == null) {
219
            return this.version.hashCode();
220
        }
221
222
        // standard
223
        int hash = 7;
224
        hash = 97 * hash + (this.majorNumber != null ? this.majorNumber.hashCode() : 0);
225
        hash = 97 * hash + (this.minorNumber != null ? this.minorNumber.hashCode() : 0);
226
        hash = 97 * hash + (this.microNumber != null ? this.microNumber.hashCode() : 0);
227
        hash = 97 * hash + (this.updateNumber != null ? this.updateNumber.hashCode() : 0);
228
        hash = 97 * hash + (this.qualifier != null ? this.qualifier.hashCode() : 0);
229
        return hash;
230
    }
231
232
    public boolean isAboveOrEqual(Version other) {
233
        if (this.majorNumber == null || other.majorNumber == null) {
234
            return this.equals(other);
235
        }
236
237
        return compareTo(other) >= 0;
238
    }
239
240
    public boolean isBelowOrEqual(Version other) {
241
        if (this.majorNumber == null || other.majorNumber == null) {
242
            return this.equals(other);
243
        }
244
245
        return compareTo(other) <= 0;
246
    }
247
248
    @Override
249
    public String toString() {
250
        return version;
251
    }
252
253
    private int compareTo(Version o) {
254
        int comparison = compare(majorNumber, o.majorNumber);
255
        if (comparison != 0) {
256
            return comparison;
257
        }
258
        comparison = compare(minorNumber, o.minorNumber);
259
        if (comparison != 0) {
260
            return comparison;
261
        }
262
        comparison = compare(microNumber, o.microNumber);
263
        if (comparison != 0) {
264
            return comparison;
265
        }
266
        comparison = compare(updateNumber, o.updateNumber);
267
        if (comparison != 0) {
268
            return comparison;
269
        }
270
        return compare(qualifier, o.qualifier);
271
    }
272
273
    private static int compare(Integer o1, Integer o2) {
274
        if (o1 == null && o2 == null) {
275
            return 0;
276
        }
277
        if (o1 == null) {
278
            return Integer.valueOf(0).compareTo(o2);
279
        }
280
        if (o2 == null) {
281
            return o1.compareTo(Integer.valueOf(0));
282
        }
283
        return o1.compareTo(o2);
284
    }
285
286
    private static int compare(String o1, String o2) {
287
        if (o1 == null && o2 == null) {
288
            return 0;
289
        }
290
        if (o1 == null) {
291
            return "".compareTo(o2);
292
        }
293
        if (o2 == null) {
294
            return o1.compareTo("");
295
        }
296
        return o1.compareTo(o2);
297
    }
298
299
}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/config/ConfigSupportImpl.java (-1 / +52 lines)
Lines 56-61 Link Here
56
import java.util.Set;
56
import java.util.Set;
57
import java.util.logging.Level;
57
import java.util.logging.Level;
58
import java.util.logging.Logger;
58
import java.util.logging.Logger;
59
import javax.swing.event.ChangeListener;
60
import org.netbeans.api.annotations.common.CheckForNull;
61
import org.netbeans.api.annotations.common.NonNull;
59
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
62
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
60
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
63
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
61
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
64
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
Lines 66-71 Link Here
66
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
69
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
67
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
70
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
68
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
71
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
72
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
69
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
73
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
70
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration;
74
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration;
71
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
75
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
Lines 84-89 Link Here
84
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
88
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
85
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
89
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
86
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration;
90
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration;
91
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration;
87
import org.openide.util.Mutex.Action;
92
import org.openide.util.Mutex.Action;
88
import org.openide.util.Parameters;
93
import org.openide.util.Parameters;
89
94
Lines 334-340 Link Here
334
            mappingConfiguration.setCMPResource(ejbName, jndiName);
339
            mappingConfiguration.setCMPResource(ejbName, jndiName);
335
        }
340
        }
336
    }
341
    }
337
    
342
343
    @Override
344
    public void configureLibrary(@NonNull ServerLibraryDependency library) throws ConfigurationException {
345
        ServerLibraryConfiguration libraryConfiguration = getServerLibraryConfiguration();
346
        if (libraryConfiguration != null) {
347
            libraryConfiguration.configureLibrary(library);
348
        }
349
    }
350
351
    @Override
352
    public Set<ServerLibraryDependency> getLibraries() throws ConfigurationException {
353
        Set<ServerLibraryDependency> libs = Collections.emptySet();
354
355
        ServerLibraryConfiguration libraryConfiguration = getServerLibraryConfiguration();
356
        if (libraryConfiguration != null) {
357
            libs = libraryConfiguration.getLibraries();
358
        }
359
        return libs;
360
    }
361
362
    @Override
363
    public void addLibraryChangeListener(ChangeListener listener) {
364
        ServerLibraryConfiguration libraryConfiguration = getServerLibraryConfiguration();
365
        if (libraryConfiguration != null) {
366
            libraryConfiguration.addLibraryChangeListener(listener);
367
        }
368
    }
369
370
    @Override
371
    public void removeLibraryChangeListener(ChangeListener listener) {
372
        ServerLibraryConfiguration libraryConfiguration = getServerLibraryConfiguration();
373
        if (libraryConfiguration != null) {
374
            libraryConfiguration.removeLibraryChangeListener(listener);
375
        }
376
    }
377
338
    public Set<Datasource> getDatasources() throws ConfigurationException {
378
    public Set<Datasource> getDatasources() throws ConfigurationException {
339
        
379
        
340
        Set<Datasource> projectDS = Collections.<Datasource>emptySet();
380
        Set<Datasource> projectDS = Collections.<Datasource>emptySet();
Lines 761-766 Link Here
761
    
801
    
762
    // private helpers --------------------------------------------------------
802
    // private helpers --------------------------------------------------------
763
    
803
    
804
    @CheckForNull
805
    private ServerLibraryConfiguration getServerLibraryConfiguration() {
806
        if (server != null) {
807
            ModuleConfiguration config = getModuleConfiguration();
808
            if (config != null) {
809
                return config.getLookup().lookup(ServerLibraryConfiguration.class);
810
            }
811
        }
812
        return null;
813
    }
814
764
    /**
815
    /**
765
     * Return list of server specific configuration files.
816
     * Return list of server specific configuration files.
766
     */
817
     */
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/Deployment.java (+1 lines)
Lines 166-171 Link Here
166
                server.getServerInstance().start(progress);
166
                server.getServerInstance().start(progress);
167
            }
167
            }
168
168
169
            DeploymentHelper.deployServerLibraries(jmp);
169
            DeploymentHelper.deployDatasources(jmp);
170
            DeploymentHelper.deployDatasources(jmp);
170
            DeploymentHelper.deployMessageDestinations(jmp);
171
            DeploymentHelper.deployMessageDestinations(jmp);
171
172
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/J2eePlatform.java (-1 / +7 lines)
Lines 71-76 Link Here
71
import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider;
71
import org.netbeans.modules.j2ee.deployment.common.api.J2eeLibraryTypeProvider;
72
import org.netbeans.modules.j2ee.deployment.config.J2eeModuleAccessor;
72
import org.netbeans.modules.j2ee.deployment.config.J2eeModuleAccessor;
73
import org.netbeans.modules.j2ee.deployment.impl.sharability.ServerLibraryTypeProvider;
73
import org.netbeans.modules.j2ee.deployment.impl.sharability.ServerLibraryTypeProvider;
74
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
75
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
74
import org.netbeans.spi.project.libraries.LibraryImplementation;
76
import org.netbeans.spi.project.libraries.LibraryImplementation;
75
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
77
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
76
import org.openide.filesystems.FileObject;
78
import org.openide.filesystems.FileObject;
Lines 311-316 Link Here
311
        return classpathCache;
313
        return classpathCache;
312
    }
314
    }
313
315
316
    public File[] getClasspathEntries(Set<ServerLibraryDependency> libraries) {
317
        return impl.getClasspathEntries(libraries);
318
    }
319
314
    /**
320
    /**
315
     * Return classpath for the specified tool. Use the tool constants declared
321
     * Return classpath for the specified tool. Use the tool constants declared
316
     * in this class.
322
     * in this class.
Lines 817-823 Link Here
817
823
818
    private String getClasspathAsString() {
824
    private String getClasspathAsString() {
819
        File[] classpathEntr = getClasspathEntries();
825
        File[] classpathEntr = getClasspathEntries();
820
        StringBuffer classpath = new StringBuffer();
826
        StringBuilder classpath = new StringBuilder();
821
        final String PATH_SEPARATOR = System.getProperty("path.separator"); // NOI18N
827
        final String PATH_SEPARATOR = System.getProperty("path.separator"); // NOI18N
822
        for (int i = 0; i < classpathEntr.length; i++) {
828
        for (int i = 0; i < classpathEntr.length; i++) {
823
            classpath.append(classpathEntr[i].getAbsolutePath());
829
            classpath.append(classpathEntr[i].getAbsolutePath());
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/ServerInstance.java (-2 / +52 lines)
Lines 42-50 Link Here
42
42
43
package org.netbeans.modules.j2ee.deployment.devmodules.api;
43
package org.netbeans.modules.j2ee.deployment.devmodules.api;
44
44
45
import java.io.IOException;
45
import java.util.Set;
46
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
47
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
47
import org.netbeans.modules.j2ee.deployment.impl.TargetServer;
48
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
48
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment;
49
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment;
49
50
50
/**
51
/**
Lines 200-205 Link Here
200
        return null;
201
        return null;
201
    }
202
    }
202
203
204
    /**
205
     * Returns manager providing the access to server libraries. May
206
     * return <code>null</code> if the server does not support this.
207
     *
208
     * @return manager providing the access to server libraries or <code>null</code>
209
     * @throws InstanceRemovedException if the instance is not available anymore
210
     * @since 1.68
211
     */
212
    public LibraryManager getLibraryManager() throws InstanceRemovedException {
213
        final ServerRegistry registry = ServerRegistry.getInstance();
214
        // see comment at the beginning of the class
215
        synchronized (registry) {
216
            org.netbeans.modules.j2ee.deployment.impl.ServerInstance inst = getInstanceFromRegistry(registry);
217
            if (inst.isServerLibraryManagementSupported()) {
218
                return new LibraryManager();
219
            }
220
        }
221
        return null;
222
    }
223
203
    private org.netbeans.modules.j2ee.deployment.impl.ServerInstance getInstanceFromRegistry(ServerRegistry registry)
224
    private org.netbeans.modules.j2ee.deployment.impl.ServerInstance getInstanceFromRegistry(ServerRegistry registry)
204
            throws InstanceRemovedException {
225
            throws InstanceRemovedException {
205
226
Lines 251-254 Link Here
251
            return getInstanceFromRegistry(ServerRegistry.getInstance()).getServerInstanceDescriptor().isLocal();
272
            return getInstanceFromRegistry(ServerRegistry.getInstance()).getServerInstanceDescriptor().isLocal();
252
        }
273
        }
253
    }
274
    }
275
276
    /**
277
     * The manager providing the access to server libraries.
278
     *
279
     * @since 1.68
280
     */
281
    public final class LibraryManager {
282
283
        /**
284
         * Returns the set of libraries the server has access to and can be deployed
285
         * on request (by call to {@link #deployRequiredLibraries(java.util.Set)}.
286
         *
287
         * @return the set of libraries which can be deployed on server
288
         */
289
        @NonNull
290
        public Set<ServerLibrary> getDeployableLibraries() throws InstanceRemovedException {
291
            return getInstanceFromRegistry(ServerRegistry.getInstance()).getDeployableLibraries();
292
        }
293
294
        /**
295
         * Returns the set of libraries already deployed to the server.
296
         *
297
         * @return the set of libraries already deployed to the server
298
         */
299
        @NonNull
300
        public Set<ServerLibrary> getDeployedLibraries() throws InstanceRemovedException {
301
            return getInstanceFromRegistry(ServerRegistry.getInstance()).getDeployedLibraries();
302
        }
303
    }
254
}
304
}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/spi/J2eeModuleProvider.java (-1 / +36 lines)
Lines 75-83 Link Here
75
import java.util.List;
75
import java.util.List;
76
import java.util.logging.Level;
76
import java.util.logging.Level;
77
import java.util.logging.Logger;
77
import java.util.logging.Logger;
78
import javax.swing.event.ChangeListener;
78
import org.netbeans.api.annotations.common.CheckForNull;
79
import org.netbeans.api.annotations.common.CheckForNull;
80
import org.netbeans.api.annotations.common.NonNull;
79
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
81
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
80
import org.netbeans.modules.j2ee.deployment.impl.projects.J2eeModuleProviderAccessor;
82
import org.netbeans.modules.j2ee.deployment.impl.projects.J2eeModuleProviderAccessor;
83
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
81
84
82
/** This object must be implemented by J2EE module support and an instance 
85
/** This object must be implemented by J2EE module support and an instance 
83
 * added into project lookup.
86
 * added into project lookup.
Lines 181-187 Link Here
181
        }
184
        }
182
        return si.getStartServer().getDebugInfo(target);
185
        return si.getStartServer().getDebugInfo(target);
183
    }
186
    }
184
    
187
185
    /**
188
    /**
186
     * Gets the data sources deployed on the target server instance.
189
     * Gets the data sources deployed on the target server instance.
187
     *
190
     *
Lines 300-305 Link Here
300
     * The setters and getters work with server specific data on the server returned by
303
     * The setters and getters work with server specific data on the server returned by
301
     * {@link #getServerID} method.
304
     * {@link #getServerID} method.
302
     */
305
     */
306
    // FIXME replace this with final class - this is not deigned to be implemented by anybody
303
    public static interface ConfigSupport {
307
    public static interface ConfigSupport {
304
        /**
308
        /**
305
         * Create an initial fresh configuration for the current module.  Do nothing if configuration already exists.
309
         * Create an initial fresh configuration for the current module.  Do nothing if configuration already exists.
Lines 485-490 Link Here
485
        public Datasource findDatasource(String jndiName) throws ConfigurationException;
489
        public Datasource findDatasource(String jndiName) throws ConfigurationException;
486
490
487
        /**
491
        /**
492
         * Configure the library (dependency) the enterprise module needs in order
493
         * to work properly.
494
         * <p>
495
         * Once library is configured it should be present in the result
496
         * of the {@link #getRequiredLibraries()} call.
497
         *
498
         * @param library the library the enterprise module needs in order to work
499
         *             properly
500
         * @throws ConfigurationException if there was a problem writing
501
         *             configuration
502
         * @since 1.68
503
         */
504
        public void configureLibrary(@NonNull ServerLibraryDependency library) throws ConfigurationException;
505
506
        /**
507
         * Returns the server library dependencies the enterprise module needs
508
         * to work properly.
509
         *
510
         * @return the server library dependencies
511
         * @throws ConfigurationException if there was a problem reading
512
         *             configuration
513
         * @since 1.68
514
         */
515
        @NonNull
516
        public Set<ServerLibraryDependency> getLibraries() throws ConfigurationException;
517
518
        void addLibraryChangeListener(@NonNull ChangeListener listener);
519
520
        void removeLibraryChangeListener(@NonNull ChangeListener listener);
521
        
522
        /**
488
         * Retrieves message destinations stored in the module.
523
         * Retrieves message destinations stored in the module.
489
         * 
524
         * 
490
         * @return set of message destinations
525
         * @return set of message destinations
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java (+1 lines)
Lines 392-397 Link Here
392
                        "MSG_DeployOnSave", provider.getDeploymentName()), false);
392
                        "MSG_DeployOnSave", provider.getDeploymentName()), false);
393
                ui.start(Integer.valueOf(PROGRESS_DELAY));
393
                ui.start(Integer.valueOf(PROGRESS_DELAY));
394
                try {
394
                try {
395
                    DeploymentHelper.deployServerLibraries(provider);
395
                    DeploymentHelper.deployDatasources(provider);
396
                    DeploymentHelper.deployDatasources(provider);
396
                    DeploymentHelper.deployMessageDestinations(provider);
397
                    DeploymentHelper.deployMessageDestinations(provider);
397
398
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeploymentHelper.java (+12 lines)
Lines 52-57 Link Here
52
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
52
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
53
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
53
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
54
import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI;
54
import org.netbeans.modules.j2ee.deployment.impl.ui.ProgressUI;
55
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
55
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer;
56
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer;
56
57
57
/**
58
/**
Lines 114-117 Link Here
114
                    "The data sources cannot be deployed because the server instance cannot be found.");
115
                    "The data sources cannot be deployed because the server instance cannot be found.");
115
        }
116
        }
116
    }
117
    }
118
119
    public static void deployServerLibraries(J2eeModuleProvider jmp) throws ConfigurationException {
120
        ServerInstance si = ServerRegistry.getInstance ().getServerInstance (jmp.getServerInstanceID ());
121
        if (si != null) {
122
            Set<ServerLibraryDependency> libraries = jmp.getConfigSupport().getLibraries();
123
            si.deployLibraries(libraries);
124
        } else {
125
            LOGGER.log(Level.WARNING,
126
                    "The libraries cannot be deployed because the server instance cannot be found.");
127
        }
128
    }
117
}
129
}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/ServerInstance.java (-2 / +67 lines)
Lines 47-52 Link Here
47
47
48
import java.beans.PropertyChangeEvent;
48
import java.beans.PropertyChangeEvent;
49
import java.beans.PropertyChangeListener;
49
import java.beans.PropertyChangeListener;
50
import java.io.File;
50
import java.net.InetAddress;
51
import java.net.InetAddress;
51
import java.net.NetworkInterface;
52
import java.net.NetworkInterface;
52
import java.net.SocketException;
53
import java.net.SocketException;
Lines 78-83 Link Here
78
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
79
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
79
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
80
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
80
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
81
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
82
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
83
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
81
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
84
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
82
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
85
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
83
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
86
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
Lines 88-93 Link Here
88
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory;
91
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory;
89
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
92
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
90
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
93
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
94
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
91
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
95
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
92
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
96
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
93
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
97
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
Lines 145-150 Link Here
145
    private J2eePlatformImpl j2eePlatformImpl;
149
    private J2eePlatformImpl j2eePlatformImpl;
146
    private StartServer startServer;
150
    private StartServer startServer;
147
    private FindJSPServlet findJSPServlet;
151
    private FindJSPServlet findJSPServlet;
152
    private ServerLibraryManager libraryManager;
153
    private ServerLibraryManager disconnectedLibraryManager;
148
    private DatasourceManager dsMgr;
154
    private DatasourceManager dsMgr;
149
    private DatasourceManager ddsMgr;
155
    private DatasourceManager ddsMgr;
150
    private MessageDestinationDeployment msgDestDeploymentConnected;
156
    private MessageDestinationDeployment msgDestDeploymentConnected;
Lines 685-691 Link Here
685
            return ddsMgr;
691
            return ddsMgr;
686
        }
692
        }
687
    }
693
    }
688
    
694
695
    private ServerLibraryManager getServerLibraryManager() {
696
        DeploymentManager dm = getDeploymentManager();
697
        synchronized (this) {
698
            if (libraryManager == null) {
699
                libraryManager = server.getOptionalFactory().getServerLibraryManager(dm);
700
            }
701
            return libraryManager;
702
        }
703
    }
704
705
    private ServerLibraryManager getDisconnectedServerLibraryManager() {
706
        DeploymentManager dm = null;
707
        try {
708
            dm = getDisconnectedDeploymentManager();
709
        }  catch (DeploymentManagerCreationException dmce) {
710
            throw new RuntimeException(dmce);
711
        }
712
        synchronized (this) {
713
            if (disconnectedLibraryManager == null) {
714
                disconnectedLibraryManager = server.getOptionalFactory().getServerLibraryManager(dm);
715
            }
716
            return disconnectedLibraryManager;
717
        }
718
    }
719
689
    /**
720
    /**
690
     * Gets the data sources deployed on the this server instance.
721
     * Gets the data sources deployed on the this server instance.
691
     *
722
     *
Lines 716-722 Link Here
716
        if (dsMgr != null) 
747
        if (dsMgr != null) 
717
            dsMgr.deployDatasources(datasources);
748
            dsMgr.deployDatasources(datasources);
718
    }
749
    }
719
    
750
751
    public boolean isServerLibraryManagementSupported() {
752
        return getDisconnectedServerLibraryManager() != null;
753
    }
754
755
    public Set<ServerLibrary> getDeployableLibraries() {
756
        ServerLibraryManager libraryManager = getDisconnectedServerLibraryManager();
757
758
        Set<ServerLibrary> libraries = Collections.emptySet();
759
        if (libraryManager != null) {
760
            libraries = libraryManager.getDeployableLibraries();
761
        }
762
763
        return libraries;
764
    }
765
766
    public Set<ServerLibrary> getDeployedLibraries() {
767
        ServerLibraryManager libraryManager = getDisconnectedServerLibraryManager();
768
769
        Set<ServerLibrary> libraries = Collections.emptySet();
770
        if (libraryManager != null) {
771
            libraries = libraryManager.getDeployedLibraries();
772
        }
773
774
        return libraries;
775
    }
776
777
    public void deployLibraries(Set<ServerLibraryDependency> libraries) throws ConfigurationException {
778
        ServerLibraryManager libraryManager = getServerLibraryManager();
779
780
        if (libraryManager != null) {
781
            libraryManager.deployLibraries(libraries);
782
        }
783
    }
784
720
    private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() {
785
    private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() {
721
        if (msgDestDeploymentConnected == null) {
786
        if (msgDestDeploymentConnected == null) {
722
            msgDestDeploymentConnected = server.getOptionalFactory().
787
            msgDestDeploymentConnected = server.getOptionalFactory().
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/TargetServer.java (+3 lines)
Lines 784-790 Link Here
784
            }
784
            }
785
785
786
            try {
786
            try {
787
                // FIXME libraries stored in server specific descriptor
788
                // do not match server resources
787
                if (serverResources) {
789
                if (serverResources) {
790
                    DeploymentHelper.deployServerLibraries(provider);
788
                    DeploymentHelper.deployDatasources(provider);
791
                    DeploymentHelper.deployDatasources(provider);
789
                    DeploymentHelper.deployMessageDestinations(provider);
792
                    DeploymentHelper.deployMessageDestinations(provider);
790
                }
793
                }
(-)5eda48228ef2 (+138 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.deployment.plugins.api;
41
42
import java.io.File;
43
import org.netbeans.api.annotations.common.CheckForNull;
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.modules.j2ee.deployment.common.api.Version;
46
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryFactory;
47
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryImplementation;
48
49
/**
50
 * The representation of the server library. This means the library server
51
 * manages not the jars deployed along with the application.
52
 * 
53
 * @since 1.68
54
 * @author Petr Hejl
55
 */
56
public final class ServerLibrary {
57
58
    static {
59
        ServerLibraryFactory.Accessor.DEFAULT = new ServerLibraryFactory.Accessor() {
60
61
            @Override
62
            public ServerLibrary createServerLibrary(ServerLibraryImplementation impl) {
63
                return new ServerLibrary(impl);
64
            }
65
        };
66
    }
67
68
    private final ServerLibraryImplementation impl;
69
70
    private ServerLibrary(@NonNull ServerLibraryImplementation impl) {
71
        this.impl = impl;
72
    }
73
74
    /**
75
     * Returns the specification title of the library. May return
76
     * <code>null</code>.
77
     * <p>
78
     * <div class="nonnormative">
79
     * For example specification title for JSF would be JavaServer Faces.
80
     * </div>
81
     *
82
     * @return the specification title of the library; may return <code>null</code>
83
     */
84
    @CheckForNull
85
    public String getSpecificationTitle() {
86
        return impl.getSpecificationTitle();
87
    }
88
89
    /**
90
     * Returns the specification version of the library. May return
91
     * <code>null</code>.
92
     *
93
     * @return the specification version of the library; may return <code>null</code>
94
     */
95
    @CheckForNull
96
    public Version getSpecificationVersion() {
97
        return impl.getSpecificationVersion();
98
    }
99
100
    /**
101
     * Returns the implementation title of the library. May return
102
     * <code>null</code>.
103
     * <p>
104
     * <div class="nonnormative">
105
     * For example specification title for MyFaces implementation of JSF
106
     * this would be something like MyFaces.
107
     * </div>
108
     *
109
     * @return the implementation title of the library; may return <code>null</code>
110
     */
111
    @CheckForNull
112
    public String getImplementationTitle() {
113
        return impl.getImplementationTitle();
114
    }
115
116
    /**
117
     * Returns the implementation version of the library. May return
118
     * <code>null</code>.
119
     *
120
     * @return the implementation version of the library; may return <code>null</code>
121
     */
122
    @CheckForNull
123
    public Version getImplementationVersion() {
124
        return impl.getImplementationVersion();
125
    }
126
127
    /**
128
     * Returns the library name. May return <code>null</code>.
129
     *
130
     * @return the library name; may return <code>null</code>
131
     */
132
    @CheckForNull
133
    public String getName() {
134
        return impl.getName();
135
    }
136
137
    // TODO should we implement equals and hashCode ?
138
}
(-)5eda48228ef2 (+232 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.deployment.plugins.api;
41
42
import org.netbeans.api.annotations.common.CheckForNull;
43
import org.netbeans.api.annotations.common.NonNull;
44
import org.netbeans.api.annotations.common.NullAllowed;
45
import org.netbeans.modules.j2ee.deployment.common.api.Version;
46
import org.openide.util.Parameters;
47
48
/**
49
 * Represents the library dependency. For example library version required by
50
 * the enterprise module.
51
 *
52
 * @since 1.68
53
 * @author Petr Hejl
54
 */
55
public final class ServerLibraryDependency {
56
57
    private final String name;
58
59
    private final Version specificationVersion;
60
61
    private final Version implementationVersion;
62
63
    private boolean exactMatch;
64
65
    private ServerLibraryDependency(String name, Version specificationVersion,
66
            Version implementationVersion, boolean exactMatch) {
67
        this.name = name;
68
        this.specificationVersion = specificationVersion;
69
        this.implementationVersion = implementationVersion;
70
        this.exactMatch = exactMatch;
71
    }
72
73
    /**
74
     * Creates the library dependency which specifies the minimal specification
75
     * and implementation version.
76
     * <p>
77
     * When both specification and implementation version is <code>null</code>
78
     * it has the meaning of any version.
79
     *
80
     * @param name name of the library
81
     * @param specificationVersion the minimal specification version, may be <code>null</code>
82
     * @param implementationVersion the minimal implementation version, may be <code>null</code>
83
     * @return the library dependency which specifies the minimal specification
84
     *             and implementation version
85
     */
86
    public static ServerLibraryDependency minimalVersion(@NonNull String name,
87
            @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) {
88
89
        Parameters.notNull("name", name);
90
91
        return new ServerLibraryDependency(name, specificationVersion, implementationVersion, false);
92
    }
93
94
    /**
95
     * Creates the library dependency which specifies the exact specification and
96
     * implementation version.
97
     *
98
     * @param name name of the library
99
     * @param specificationVersion the minimal specification version, may be <code>null</code>
100
     * @param implementationVersion the minimal implementation version, may be <code>null</code>
101
     * @return the library dependency which specifies the exact specification
102
     *             and implementation version
103
     */
104
    public static ServerLibraryDependency exactVersion(@NonNull String name,
105
            @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) {
106
107
        Parameters.notNull("name", name);
108
        Parameters.notNull("specificationVersion", name);
109
110
        return new ServerLibraryDependency(name, specificationVersion, implementationVersion, true);
111
    }
112
113
    /**
114
     * Returns <code>true</code> if the given library matches the dependency.
115
     * <p>
116
     * The library matches the dependency if the dependency specify the minimal
117
     * versions (specification and/or implementation) and corresponding versions
118
     * of the library are equal or greater. If the dependency specify the exact
119
     * version the corresponding versions of library must be the same as those
120
     * specified for dependency.
121
     *
122
     * @param library the library to check
123
     * @return <code>true</code> if the given library matches the dependency
124
     * @see Version#isAboveOrEqual(org.netbeans.modules.j2ee.deployment.common.api.Version)
125
     * @see Version#isBelowOrEqual(org.netbeans.modules.j2ee.deployment.common.api.Version)
126
     */
127
    public boolean versionMatches(@NonNull ServerLibrary library) {
128
        Parameters.notNull("library", library);
129
130
        if (exactMatch) {
131
            return (library.getName() != null && library.getName().equals(name))
132
                    && (specificationVersion == null
133
                            || specificationVersion.equals(library.getSpecificationVersion()))
134
                    && (implementationVersion == null
135
                            || implementationVersion.equals(library.getImplementationVersion()));
136
        }
137
138
        return (library.getName() != null && library.getName().equals(name))
139
                && (specificationVersion == null
140
                        || (library.getSpecificationVersion() != null && specificationVersion.isBelowOrEqual(library.getSpecificationVersion())))
141
                && (implementationVersion == null
142
                        || (library.getImplementationVersion() != null && implementationVersion.isBelowOrEqual(library.getImplementationVersion())));
143
    }
144
145
    /**
146
     * Returns the name of the required library.
147
     *
148
     * @return the name of the required library
149
     */
150
    @NonNull
151
    public String getName() {
152
        return name;
153
    }
154
155
    /**
156
     * Returns the specification version. May be <code>null</code>.
157
     *
158
     * @return the specification version; may be <code>null</code>
159
     */
160
    @CheckForNull
161
    public Version getSpecificationVersion() {
162
        return specificationVersion;
163
    }
164
165
    /**
166
     * Returns the implementation version. May be <code>null</code>.
167
     *
168
     * @return the implementation version; may be <code>null</code>
169
     */
170
    @CheckForNull
171
    public Version getImplementationVersion() {
172
        return implementationVersion;
173
    }
174
175
    /**
176
     * Returns <code>true</code> if the exactly the same version are required
177
     * by the dependency to match the library.
178
     *
179
     * @return <code>true</code> if the exactly the same version are required
180
     *             by the dependency to match the library
181
     */
182
    public boolean isExactMatch() {
183
        return exactMatch;
184
    }
185
186
    /**
187
     * @{@inheritDoc}
188
     *
189
     * Dependencies are equal if they have the same name, specification version,
190
     * implementation version and exact match flag.
191
     */
192
    @Override
193
    public boolean equals(Object obj) {
194
        if (obj == null) {
195
            return false;
196
        }
197
        if (getClass() != obj.getClass()) {
198
            return false;
199
        }
200
        final ServerLibraryDependency other = (ServerLibraryDependency) obj;
201
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
202
            return false;
203
        }
204
        if (this.specificationVersion != other.specificationVersion && (this.specificationVersion == null || !this.specificationVersion.equals(other.specificationVersion))) {
205
            return false;
206
        }
207
        if (this.implementationVersion != other.implementationVersion && (this.implementationVersion == null || !this.implementationVersion.equals(other.implementationVersion))) {
208
            return false;
209
        }
210
        if (this.exactMatch != other.exactMatch) {
211
            return false;
212
        }
213
        return true;
214
    }
215
216
    /**
217
     * @{@inheritDoc}
218
     * <p>
219
     * Implementation consistent with {@link #equals(java.lang.Object)}.
220
     * @see #equals(java.lang.Object)
221
     */
222
    @Override
223
    public int hashCode() {
224
        int hash = 5;
225
        hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
226
        hash = 53 * hash + (this.specificationVersion != null ? this.specificationVersion.hashCode() : 0);
227
        hash = 53 * hash + (this.implementationVersion != null ? this.implementationVersion.hashCode() : 0);
228
        hash = 53 * hash + (this.exactMatch ? 1 : 0);
229
        return hash;
230
    }
231
232
}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/J2eePlatformImpl.java (-1 / +6 lines)
Lines 56-61 Link Here
56
import org.netbeans.modules.j2ee.deployment.config.J2eeModuleAccessor;
56
import org.netbeans.modules.j2ee.deployment.config.J2eeModuleAccessor;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
58
import org.netbeans.api.j2ee.core.Profile;
58
import org.netbeans.api.j2ee.core.Profile;
59
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
59
import org.netbeans.spi.project.libraries.LibraryImplementation;
60
import org.netbeans.spi.project.libraries.LibraryImplementation;
60
import org.openide.util.Lookup;
61
import org.openide.util.Lookup;
61
62
Lines 84-90 Link Here
84
     * @return platform's libraries.
85
     * @return platform's libraries.
85
     */
86
     */
86
    public abstract LibraryImplementation[] getLibraries();
87
    public abstract LibraryImplementation[] getLibraries();
87
    
88
89
    public File[] getClasspathEntries(Set<ServerLibraryDependency> libraries) {
90
        return new File[] {};
91
    }
92
88
    /**
93
    /**
89
     * Return platform's display name.
94
     * Return platform's display name.
90
     *
95
     *
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java (+14 lines)
Lines 46-51 Link Here
46
package org.netbeans.modules.j2ee.deployment.plugins.spi;
46
package org.netbeans.modules.j2ee.deployment.plugins.spi;
47
47
48
import javax.enterprise.deploy.spi.DeploymentManager;
48
import javax.enterprise.deploy.spi.DeploymentManager;
49
import org.netbeans.api.annotations.common.CheckForNull;
49
import org.openide.WizardDescriptor;
50
import org.openide.WizardDescriptor;
50
51
51
/**
52
/**
Lines 179-182 Link Here
179
    public void finishServerInitialization() throws ServerInitializationException {
180
    public void finishServerInitialization() throws ServerInitializationException {
180
    }
181
    }
181
182
183
    /**
184
     * Return the manager handling the server libraries. May return
185
     * <code>null</code> if the functionality is not supported by the plugin.
186
     *
187
     * @param dm the deployment manager
188
     * @return the manager handling the server libraries
189
     * @since 1.68
190
     * @see ServerLibraryManager
191
     */
192
    @CheckForNull
193
    public ServerLibraryManager getServerLibraryManager(DeploymentManager dm) {
194
        return null;
195
    }
182
}
196
}
(-)5eda48228ef2 (+97 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
 * 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 2008 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.j2ee.deployment.plugins.spi;
44
45
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
46
47
/**
48
 * Factory creating the API representation of the library provided in SPI.
49
 *
50
 * @since 1.68
51
 * @author Petr Hejl
52
 */
53
public final class ServerLibraryFactory {
54
55
    private ServerLibraryFactory() {
56
        super();
57
    }
58
    
59
    /**
60
     * Creates the API representation of the provided SPI instance.
61
     * 
62
     * @param impl the SPI instance
63
     * @return the API server instance representation
64
     */
65
    public static ServerLibrary createServerLibrary(ServerLibraryImplementation impl) {
66
        return Accessor.DEFAULT.createServerLibrary(impl);
67
    }
68
    
69
    /**
70
     * The accessor pattern class.
71
     */
72
    public abstract static class Accessor {
73
74
        /** The default accessor. */
75
        public static Accessor DEFAULT;
76
77
        static {
78
            // invokes static initializer of ServerLibrary.class
79
            // that will assign value to the DEFAULT field above
80
            Class c = ServerLibrary.class;
81
            try {
82
                Class.forName(c.getName(), true, c.getClassLoader());
83
            } catch (ClassNotFoundException ex) {
84
                assert false : ex;
85
            }
86
        }
87
88
        /**
89
         * Creates the API instance.
90
         *
91
         * @param impl the SPI instance
92
         * @return the API instance
93
         */
94
        public abstract ServerLibrary createServerLibrary(ServerLibraryImplementation impl);
95
96
    }
97
}
(-)5eda48228ef2 (+107 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.deployment.plugins.spi;
41
42
import java.io.File;
43
import org.netbeans.api.annotations.common.CheckForNull;
44
import org.netbeans.modules.j2ee.deployment.common.api.Version;
45
46
/**
47
 * The representation of the server library. This means the library server
48
 * manages not the jars deployed along with the application.
49
 *
50
 * @since 1.68
51
 * @author Petr Hejl
52
 */
53
public interface ServerLibraryImplementation {
54
55
    /**
56
     * Returns the specification title of the library. May return
57
     * <code>null</code>.
58
     * <p>
59
     * <div class="nonnormative">
60
     * For example specification title for JSF would be JavaServer Faces.
61
     * </div>
62
     *
63
     * @return the specification title of the library; may return <code>null</code>
64
     */
65
    @CheckForNull
66
    String getSpecificationTitle();
67
68
    /**
69
     * Returns the implementation title of the library. May return
70
     * <code>null</code>.
71
     * <p>
72
     * <div class="nonnormative">
73
     * For example specification title for MyFaces implementation of JSF
74
     * this would be something like MyFaces.
75
     * </div>
76
     *
77
     * @return the implementation title of the library; may return <code>null</code>
78
     */
79
    @CheckForNull
80
    String getImplementationTitle();
81
82
    /**
83
     * Returns the specification version of the library. May return
84
     * <code>null</code>.
85
     * 
86
     * @return the specification version of the library; may return <code>null</code>
87
     */
88
    @CheckForNull
89
    Version getSpecificationVersion();
90
91
    /**
92
     * Returns the implementation version of the library. May return
93
     * <code>null</code>.
94
     *
95
     * @return the implementation version of the library; may return <code>null</code>
96
     */
97
    @CheckForNull
98
    Version getImplementationVersion();
99
100
    /**
101
     * Returns the library name. May return <code>null</code>.
102
     * 
103
     * @return the library name; may return <code>null</code>
104
     */
105
    @CheckForNull
106
    String getName();
107
}
(-)5eda48228ef2 (+87 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.deployment.plugins.spi;
41
42
import java.io.File;
43
import java.util.Set;
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
46
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
47
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
48
49
/**
50
 * The interface that should serverplugin should implement in order to
51
 * support the server library management.
52
 *
53
 * @since 1.68
54
 * @author Petr Hejl
55
 * @see org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration
56
 */
57
public interface ServerLibraryManager {
58
59
    /**
60
     * Returns the set of libraries the server has access to and can be deployed
61
     * on request (by call to {@link #deployRequiredLibraries(java.util.Set)}.
62
     *
63
     * @return the set of libraries which can be deployed on server
64
     */
65
    @NonNull
66
    Set<ServerLibrary> getDeployableLibraries();
67
68
    /**
69
     * Returns the set of libraries already deployed to the server.
70
     *
71
     * @return the set of libraries already deployed to the server
72
     */
73
    @NonNull
74
    Set<ServerLibrary> getDeployedLibraries();
75
76
    /**
77
     * Deploys all the required libraries passed to the method. The libraries
78
     * passed to the method may be already deployed and it is up to implementor
79
     * to handle such case.
80
     *
81
     * @param libraries the libraries to deploy
82
     * @throws ConfigurationException if there was a problem during
83
     *             the deployment
84
     */
85
    void deployLibraries(@NonNull Set<ServerLibraryDependency> libraries) throws ConfigurationException;
86
87
}
(-)5eda48228ef2 (+89 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.j2ee.deployment.plugins.spi.config;
41
42
import java.util.Set;
43
import javax.swing.event.ChangeListener;
44
import org.netbeans.api.annotations.common.NonNull;
45
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
46
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
47
48
/**
49
 * The interface defining the methods that can handle the server libraries in
50
 * scope of enterprise module.
51
 * <p>
52
 * This interface is typically looked up in {@link ModuleConfiguration}'s
53
 * lookup.
54
 *
55
 * @since 1.68
56
 * @author Petr Hejl
57
 */
58
public interface ServerLibraryConfiguration {
59
60
    /**
61
     * Configure the library (dependency) the enterprise module needs in order
62
     * to work properly.
63
     * <p>
64
     * Once library is configured it should be present in the result
65
     * of the {@link #getRequiredLibraries()} call.
66
     *
67
     * @param library the library the enterprise module needs in order to work
68
     *             properly
69
     * @throws ConfigurationException if there was a problem writing
70
     *             configuration
71
     */
72
    void configureLibrary(@NonNull ServerLibraryDependency library) throws ConfigurationException;
73
74
    /**
75
     * Returns the server library dependencies the enterprise module needs
76
     * to work properly.
77
     *
78
     * @return the server library dependencies
79
     * @throws ConfigurationException if there was a problem reading
80
     *             configuration
81
     */
82
    @NonNull
83
    Set<ServerLibraryDependency> getLibraries() throws ConfigurationException;
84
85
    void addLibraryChangeListener(@NonNull ChangeListener listener);
86
87
    void removeLibraryChangeListener(@NonNull ChangeListener listener);
88
89
}
(-)a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/support/ProxyOptionalFactory.java (+6 lines)
Lines 53-58 Link Here
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory;
53
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory;
54
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInitializationException;
54
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInitializationException;
55
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
55
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
56
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
56
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
57
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
57
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
58
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
58
import org.openide.WizardDescriptor.InstantiatingIterator;
59
import org.openide.WizardDescriptor.InstantiatingIterator;
Lines 151-156 Link Here
151
        }
152
        }
152
    }
153
    }
153
154
155
    @Override
156
    public ServerLibraryManager getServerLibraryManager(DeploymentManager dm) {
157
        return getDelegate().getServerLibraryManager(dm);
158
    }
159
154
    private OptionalDeploymentManagerFactory getDelegate() {
160
    private OptionalDeploymentManagerFactory getDelegate() {
155
        synchronized (this) {
161
        synchronized (this) {
156
            if (delegate != null) {
162
            if (delegate != null) {
(-)a/web.jsf/nbproject/project.xml (-1 / +1 lines)
Lines 309-315 Link Here
309
                    <compile-dependency/>
309
                    <compile-dependency/>
310
                    <run-dependency>
310
                    <run-dependency>
311
                        <release-version>4</release-version>
311
                        <release-version>4</release-version>
312
                        <specification-version>1.21</specification-version>
312
                        <specification-version>1.68</specification-version>
313
                    </run-dependency>
313
                    </run-dependency>
314
                </dependency>
314
                </dependency>
315
                <dependency>
315
                <dependency>
(-)a/web.jsf/src/org/netbeans/modules/web/jsf/JSFFrameworkProvider.java (-4 / +35 lines)
Lines 83-89 Link Here
83
import org.netbeans.modules.j2ee.common.Util;
83
import org.netbeans.modules.j2ee.common.Util;
84
import org.netbeans.modules.j2ee.common.dd.DDHelper;
84
import org.netbeans.modules.j2ee.common.dd.DDHelper;
85
import org.netbeans.modules.j2ee.dd.api.common.InitParam;
85
import org.netbeans.modules.j2ee.dd.api.common.InitParam;
86
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
87
import org.netbeans.modules.j2ee.deployment.common.api.Version;
86
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
88
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
89
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
90
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
91
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryDependency;
87
import org.netbeans.modules.web.api.webmodule.ExtenderController;
92
import org.netbeans.modules.web.api.webmodule.ExtenderController;
88
import org.netbeans.modules.web.spi.webmodule.WebFrameworkProvider;
93
import org.netbeans.modules.web.spi.webmodule.WebFrameworkProvider;
89
import org.netbeans.modules.web.api.webmodule.WebModule;
94
import org.netbeans.modules.web.api.webmodule.WebModule;
Lines 200-205 Link Here
200
                webInf = FileUtil.createFolder(webModule.getDocumentBase(), "WEB-INF"); //NOI18N
205
                webInf = FileUtil.createFolder(webModule.getDocumentBase(), "WEB-INF"); //NOI18N
201
            }
206
            }
202
            assert webInf != null;
207
            assert webInf != null;
208
209
            // configure server library
210
            ServerLibrary serverLibrary = panel.getServerLibrary();
211
            if (serverLibrary != null) {
212
                String implementationTitle = serverLibrary.getImplementationTitle();
213
                isMyFaces = implementationTitle != null && implementationTitle.contains("MyFaces"); // NOI18N
214
                Project prj = FileOwnerQuery.getOwner(webInf);
215
                if (prj != null) {
216
                    J2eeModuleProvider provider = prj.getLookup().lookup(J2eeModuleProvider.class);
217
                    if (provider != null) {
218
                        provider.getConfigSupport().configureLibrary(
219
                                ServerLibraryDependency.minimalVersion(serverLibrary.getName(),
220
                                    serverLibrary.getSpecificationVersion(),
221
                                    serverLibrary.getImplementationVersion()));
222
                    }
223
                }
224
            }
225
203
            FileSystem fileSystem = webInf.getFileSystem();
226
            FileSystem fileSystem = webInf.getFileSystem();
204
            fileSystem.runAtomicAction(new CreateFacesConfig(webModule, isMyFaces));
227
            fileSystem.runAtomicAction(new CreateFacesConfig(webModule, isMyFaces));
205
228
Lines 208-214 Link Here
208
            if (welcomeFile != null) {
231
            if (welcomeFile != null) {
209
                result.add(welcomeFile);
232
                result.add(welcomeFile);
210
            }
233
            }
211
        }  catch (IOException exception) {   
234
        } catch (IOException exception) {   
235
           LOGGER.log(Level.WARNING, "Exception during extending an web project", exception); //NOI18N
236
        } catch (ConfigurationException exception) {
212
           LOGGER.log(Level.WARNING, "Exception during extending an web project", exception); //NOI18N
237
           LOGGER.log(Level.WARNING, "Exception during extending an web project", exception); //NOI18N
213
        }
238
        }
214
        createWelcome = true;
239
        createWelcome = true;
Lines 373-384 Link Here
373
                jsfLibrary = LibraryManager.getDefault().getLibrary(panel.getNewLibraryName());
398
                jsfLibrary = LibraryManager.getDefault().getLibrary(panel.getNewLibraryName());
374
            }
399
            }
375
400
376
            if (jsfLibrary !=null) {
401
            if (jsfLibrary != null) {
377
                List<URL> content = jsfLibrary.getContent("classpath"); //NOI18N
402
                List<URL> content = jsfLibrary.getContent("classpath"); //NOI18N
378
                isJSF20 = Util.containsClass(content, JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
403
                isJSF20 = Util.containsClass(content, JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
379
            } else {
404
            } else {
380
                ClassPath classpath = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE);
405
                if (panel.getLibraryType() == JSFConfigurationPanel.LibraryType.SERVER && panel.getServerLibrary() != null) {
381
                isJSF20 = classpath.findResource(JSFUtils.JSF_2_0__API_SPECIFIC_CLASS.replace('.', '/')+".class")!=null; //NOI18N
406
                    isJSF20 = Version.fromJsr277NotationWithFallback("2.0").isBelowOrEqual(
407
                            panel.getServerLibrary().getSpecificationVersion());
408
                } else {
409
                    ClassPath classpath = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE);
410
                    isJSF20 = classpath.findResource(JSFUtils.JSF_2_0__API_SPECIFIC_CLASS.replace('.', '/')+".class")!=null; //NOI18N
411
                }
382
            }
412
            }
383
413
384
            WebApp ddRoot = DDProvider.getDefault().getDDRoot(dd);
414
            WebApp ddRoot = DDProvider.getDefault().getDDRoot(dd);
Lines 549-554 Link Here
549
                                application.addViewHandler(viewHandler);
579
                                application.addViewHandler(viewHandler);
550
                            }
580
                            }
551
                            ClassPath cp = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE);
581
                            ClassPath cp = ClassPath.getClassPath(webModule.getDocumentBase(), ClassPath.COMPILE);
582
                            // FIXME icefaces on server
552
                            if (panel.getLibrary()!=null && panel.getLibrary().getName().indexOf("facelets-icefaces") != -1 //NOI18N
583
                            if (panel.getLibrary()!=null && panel.getLibrary().getName().indexOf("facelets-icefaces") != -1 //NOI18N
553
                                    && cp != null && cp.findResource("com/icesoft/faces/facelets/D2DFaceletViewHandler.class") != null){    //NOI18N
584
                                    && cp != null && cp.findResource("com/icesoft/faces/facelets/D2DFaceletViewHandler.class") != null){    //NOI18N
554
                                ViewHandler iceViewHandler = model.getFactory().createViewHandler();
585
                                ViewHandler iceViewHandler = model.getFactory().createViewHandler();
(-)a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/Bundle.properties (-2 / +1 lines)
Lines 175-181 Link Here
175
MSG_CreatingLibraries=When you finish this wizard, JSF Library will be added to the IDE's Library Manager. \n\\nThis library will contain the appropriate JARs from the JSF folder.
175
MSG_CreatingLibraries=When you finish this wizard, JSF Library will be added to the IDE's Library Manager. \n\\nThis library will contain the appropriate JARs from the JSF folder.
176
HINT_Version=Write the JSF version (e.g. "1.1")
176
HINT_Version=Write the JSF version (e.g. "1.1")
177
LBL_INSTALL_DIR=JSF Folder\:
177
LBL_INSTALL_DIR=JSF Folder\:
178
LBL_Any_Library=Use default library which comes with Server ({0}).
178
LBL_Any_Library=Server Library:
179
HINT_JSF_Directory=Choose JSF folder.
179
HINT_JSF_Directory=Choose JSF folder.
180
180
181
LBL_TAB_Configuration=Configuration
181
LBL_TAB_Configuration=Configuration
Lines 298-301 Link Here
298
298
299
MSG_From=from
299
MSG_From=from
300
300
301
LBL_Weblogic_Warning=<html>Make sure JSF shared server library is deployed on the server.</html>
(-)a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanel.java (-1 / +12 lines)
Lines 55-60 Link Here
55
import org.netbeans.api.project.Project;
55
import org.netbeans.api.project.Project;
56
import org.netbeans.api.project.ProjectUtils;
56
import org.netbeans.api.project.ProjectUtils;
57
import org.netbeans.api.project.libraries.Library;
57
import org.netbeans.api.project.libraries.Library;
58
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
58
import org.netbeans.modules.web.api.webmodule.ExtenderController;
59
import org.netbeans.modules.web.api.webmodule.ExtenderController;
59
import org.netbeans.modules.web.api.webmodule.WebModule;
60
import org.netbeans.modules.web.api.webmodule.WebModule;
60
import org.netbeans.modules.web.jsf.JSFFrameworkProvider;
61
import org.netbeans.modules.web.jsf.JSFFrameworkProvider;
Lines 75-83 Link Here
75
76
76
    private Preferences preferences;
77
    private Preferences preferences;
77
78
78
    public enum LibraryType {USED, NEW, NONE};
79
    public enum LibraryType {USED, NEW, SERVER};
79
    private LibraryType libraryType;
80
    private LibraryType libraryType;
80
    private Library jsfCoreLibrary;
81
    private Library jsfCoreLibrary;
82
    private ServerLibrary serverLibrary;
81
    private String newLibraryName;
83
    private String newLibraryName;
82
    private File installedFolder;
84
    private File installedFolder;
83
85
Lines 323-328 Link Here
323
        fireChangeEvent();
325
        fireChangeEvent();
324
    }
326
    }
325
327
328
    public ServerLibrary getServerLibrary() {
329
        return serverLibrary;
330
    }
331
332
    protected void setServerLibrary(ServerLibrary library){
333
        this.serverLibrary = library;
334
        fireChangeEvent();
335
    }
336
326
    protected static class PreferredLanguage {
337
    protected static class PreferredLanguage {
327
        private String name;
338
        private String name;
328
339
(-)a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.form (-21 / +32 lines)
Lines 1-4 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.1" encoding="UTF-8" ?>
2
2
3
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <NonVisualComponents>
4
  <NonVisualComponents>
Lines 61-88 Link Here
61
                  <Group type="102" attributes="0">
61
                  <Group type="102" attributes="0">
62
                      <EmptySpace max="-2" attributes="0"/>
62
                      <EmptySpace max="-2" attributes="0"/>
63
                      <Group type="103" groupAlignment="0" attributes="0">
63
                      <Group type="103" groupAlignment="0" attributes="0">
64
                          <Component id="rbNoneLibrary" pref="463" max="32767" attributes="0"/>
64
                          <Component id="rbNewLibrary" alignment="1" pref="466" max="32767" attributes="0"/>
65
                          <Group type="102" alignment="0" attributes="0">
65
                          <Group type="102" alignment="0" attributes="0">
66
                              <Component id="rbRegisteredLibrary" min="-2" max="-2" attributes="0"/>
66
                              <EmptySpace min="22" pref="22" max="22" attributes="0"/>
67
                              <Group type="103" groupAlignment="0" attributes="0">
68
                                  <Component id="lVersion" alignment="1" pref="444" max="32767" attributes="0"/>
69
                                  <Component id="lDirectory" alignment="0" pref="444" max="32767" attributes="0"/>
70
                              </Group>
71
                          </Group>
72
                          <Group type="102" alignment="0" attributes="0">
73
                              <Group type="103" groupAlignment="1" max="-2" attributes="0">
74
                                  <Component id="rbServerLibrary" alignment="0" max="32767" attributes="1"/>
75
                                  <Component id="rbRegisteredLibrary" alignment="0" max="32767" attributes="1"/>
76
                              </Group>
67
                              <EmptySpace type="unrelated" max="-2" attributes="0"/>
77
                              <EmptySpace type="unrelated" max="-2" attributes="0"/>
68
                              <Group type="103" groupAlignment="0" attributes="0">
78
                              <Group type="103" groupAlignment="0" attributes="0">
69
                                  <Component id="cbLibraries" pref="295" max="32767" attributes="0"/>
79
                                  <Component id="cbLibraries" pref="283" max="32767" attributes="0"/>
70
                                  <Group type="102" alignment="1" attributes="0">
80
                                  <Group type="102" alignment="1" attributes="0">
71
                                      <Group type="103" groupAlignment="1" attributes="0">
81
                                      <Group type="103" groupAlignment="1" attributes="0">
72
                                          <Component id="jtNewLibraryName" alignment="1" pref="221" max="32767" attributes="1"/>
82
                                          <Component id="jtNewLibraryName" alignment="1" pref="175" max="32767" attributes="1"/>
73
                                          <Component id="jtFolder" alignment="1" pref="221" max="32767" attributes="1"/>
83
                                          <Component id="jtFolder" alignment="1" pref="175" max="32767" attributes="1"/>
74
                                      </Group>
84
                                      </Group>
75
                                      <EmptySpace max="-2" attributes="0"/>
85
                                      <EmptySpace max="-2" attributes="0"/>
76
                                      <Component id="jbBrowse" min="-2" max="-2" attributes="0"/>
86
                                      <Component id="jbBrowse" min="-2" max="-2" attributes="0"/>
77
                                  </Group>
87
                                  </Group>
78
                              </Group>
88
                                  <Component id="serverLibraries" alignment="0" pref="283" max="32767" attributes="0"/>
79
                          </Group>
80
                          <Component id="rbNewLibrary" alignment="1" pref="463" max="32767" attributes="0"/>
81
                          <Group type="102" alignment="0" attributes="0">
82
                              <EmptySpace min="22" pref="22" max="22" attributes="0"/>
83
                              <Group type="103" groupAlignment="0" attributes="0">
84
                                  <Component id="lVersion" alignment="1" pref="441" max="32767" attributes="0"/>
85
                                  <Component id="lDirectory" alignment="0" pref="441" max="32767" attributes="0"/>
86
                              </Group>
89
                              </Group>
87
                          </Group>
90
                          </Group>
88
                      </Group>
91
                      </Group>
Lines 93-101 Link Here
93
            <DimensionLayout dim="1">
96
            <DimensionLayout dim="1">
94
              <Group type="103" groupAlignment="0" attributes="0">
97
              <Group type="103" groupAlignment="0" attributes="0">
95
                  <Group type="102" alignment="1" attributes="0">
98
                  <Group type="102" alignment="1" attributes="0">
96
                      <EmptySpace min="-2" max="-2" attributes="0"/>
99
                      <EmptySpace max="-2" attributes="0"/>
97
                      <Component id="rbNoneLibrary" min="-2" max="-2" attributes="0"/>
100
                      <Group type="103" groupAlignment="3" attributes="0">
98
                      <EmptySpace min="-2" max="-2" attributes="0"/>
101
                          <Component id="rbServerLibrary" alignment="3" min="-2" max="-2" attributes="0"/>
102
                          <Component id="serverLibraries" alignment="3" min="-2" max="-2" attributes="0"/>
103
                      </Group>
104
                      <EmptySpace max="-2" attributes="0"/>
99
                      <Group type="103" groupAlignment="3" attributes="0">
105
                      <Group type="103" groupAlignment="3" attributes="0">
100
                          <Component id="rbRegisteredLibrary" alignment="3" min="-2" max="-2" attributes="0"/>
106
                          <Component id="rbRegisteredLibrary" alignment="3" min="-2" max="-2" attributes="0"/>
101
                          <Component id="cbLibraries" alignment="3" min="-2" max="-2" attributes="0"/>
107
                          <Component id="cbLibraries" alignment="3" min="-2" max="-2" attributes="0"/>
Lines 111-123 Link Here
111
                          <Component id="jtNewLibraryName" alignment="3" min="-2" max="-2" attributes="0"/>
117
                          <Component id="jtNewLibraryName" alignment="3" min="-2" max="-2" attributes="0"/>
112
                          <Component id="lVersion" alignment="3" min="-2" max="-2" attributes="0"/>
118
                          <Component id="lVersion" alignment="3" min="-2" max="-2" attributes="0"/>
113
                      </Group>
119
                      </Group>
114
                      <EmptySpace pref="45" max="32767" attributes="0"/>
120
                      <EmptySpace pref="59" max="32767" attributes="0"/>
115
                  </Group>
121
                  </Group>
116
              </Group>
122
              </Group>
117
            </DimensionLayout>
123
            </DimensionLayout>
118
          </Layout>
124
          </Layout>
119
          <SubComponents>
125
          <SubComponents>
120
            <Component class="javax.swing.JRadioButton" name="rbNoneLibrary">
126
            <Component class="javax.swing.JRadioButton" name="rbServerLibrary">
121
              <Properties>
127
              <Properties>
122
                <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
128
                <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
123
                  <ComponentRef name="buttonGroup1"/>
129
                  <ComponentRef name="buttonGroup1"/>
Lines 130-136 Link Here
130
                </Property>
136
                </Property>
131
              </Properties>
137
              </Properties>
132
              <Events>
138
              <Events>
133
                <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="rbNoneLibraryItemStateChanged"/>
139
                <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="rbServerLibraryItemStateChanged"/>
134
              </Events>
140
              </Events>
135
            </Component>
141
            </Component>
136
            <Component class="javax.swing.JRadioButton" name="rbRegisteredLibrary">
142
            <Component class="javax.swing.JRadioButton" name="rbRegisteredLibrary">
Lines 246-251 Link Here
246
                <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jtNewLibraryNameKeyReleased"/>
252
                <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jtNewLibraryNameKeyReleased"/>
247
              </Events>
253
              </Events>
248
            </Component>
254
            </Component>
255
            <Component class="javax.swing.JComboBox" name="serverLibraries">
256
              <Events>
257
                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="serverLibrariesActionPerformed"/>
258
              </Events>
259
            </Component>
249
          </SubComponents>
260
          </SubComponents>
250
        </Container>
261
        </Container>
251
        <Container class="javax.swing.JPanel" name="confPanel">
262
        <Container class="javax.swing.JPanel" name="confPanel">
Lines 268-274 Link Here
268
                          <Group type="102" alignment="0" attributes="0">
279
                          <Group type="102" alignment="0" attributes="0">
269
                              <Component id="lURLPattern" min="-2" max="-2" attributes="0"/>
280
                              <Component id="lURLPattern" min="-2" max="-2" attributes="0"/>
270
                              <EmptySpace max="-2" attributes="0"/>
281
                              <EmptySpace max="-2" attributes="0"/>
271
                              <Component id="tURLPattern" pref="295" max="32767" attributes="0"/>
282
                              <Component id="tURLPattern" pref="280" max="32767" attributes="0"/>
272
                          </Group>
283
                          </Group>
273
                          <Group type="102" alignment="0" attributes="0">
284
                          <Group type="102" alignment="0" attributes="0">
274
                              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
285
                              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
(-)a/web.jsf/src/org/netbeans/modules/web/jsf/wizards/JSFConfigurationPanelVisual.java (-108 / +342 lines)
Lines 50-70 Link Here
50
import java.net.URL;
50
import java.net.URL;
51
import java.util.ArrayList;
51
import java.util.ArrayList;
52
import java.util.Arrays;
52
import java.util.Arrays;
53
import java.util.Collection;
54
import java.util.HashSet;
53
import java.util.List;
55
import java.util.List;
56
import java.util.Set;
57
import java.util.SortedSet;
58
import java.util.TreeSet;
54
import java.util.Vector;
59
import java.util.Vector;
55
import java.util.logging.Level;
60
import java.util.logging.Level;
56
import java.util.logging.Logger;
61
import java.util.logging.Logger;
57
import java.util.regex.Pattern;
62
import java.util.regex.Pattern;
58
import javax.swing.DefaultComboBoxModel;
63
import javax.swing.DefaultComboBoxModel;
59
import javax.swing.JFileChooser;
64
import javax.swing.JFileChooser;
65
import javax.swing.SwingUtilities;
60
import javax.swing.event.DocumentListener;
66
import javax.swing.event.DocumentListener;
61
import org.netbeans.api.j2ee.core.Profile;
67
import org.netbeans.api.j2ee.core.Profile;
62
import org.netbeans.api.project.libraries.Library;
68
import org.netbeans.api.project.libraries.Library;
63
import org.netbeans.api.project.libraries.LibraryManager;
69
import org.netbeans.api.project.libraries.LibraryManager;
64
import org.netbeans.modules.j2ee.common.Util;
70
import org.netbeans.modules.j2ee.common.Util;
71
import org.netbeans.modules.j2ee.deployment.common.api.Version;
65
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
72
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
66
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
73
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
67
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
74
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform;
75
import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
76
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
68
import org.netbeans.modules.web.api.webmodule.ExtenderController;
77
import org.netbeans.modules.web.api.webmodule.ExtenderController;
69
import org.netbeans.modules.web.api.webmodule.ExtenderController.Properties;
78
import org.netbeans.modules.web.api.webmodule.ExtenderController.Properties;
70
import org.netbeans.modules.web.jsf.JSFUtils;
79
import org.netbeans.modules.web.jsf.JSFUtils;
Lines 89-94 Link Here
89
    private boolean customizer;
98
    private boolean customizer;
90
    
99
    
91
    private final List<LibraryItem> jsfLibraries = new ArrayList<LibraryItem>();
100
    private final List<LibraryItem> jsfLibraries = new ArrayList<LibraryItem>();
101
    private final Set<ServerLibraryItem> serverJsfLibraries = new TreeSet<ServerLibraryItem>();
92
    private boolean libsInitialized;
102
    private boolean libsInitialized;
93
    private String serverInstanceID;
103
    private String serverInstanceID;
94
    private final List<String> preferredLanguages = new ArrayList<String>();
104
    private final List<String> preferredLanguages = new ArrayList<String>();
Lines 124-131 Link Here
124
            return;
134
            return;
125
        }
135
        }
126
136
127
        final Vector <String> items = new Vector <String>();
137
        // init server libraries first
138
        initServerLibraries();
139
140
        final Vector<String> registeredItems = new Vector<String>();
128
        jsfLibraries.clear();
141
        jsfLibraries.clear();
142
129
        final Runnable libraryFinder = new Runnable() {
143
        final Runnable libraryFinder = new Runnable() {
130
144
131
            @Override
145
            @Override
Lines 140-146 Link Here
140
                        if (library.getName().startsWith("facelets-") && !library.getName().endsWith("el-api")    //NOI18N
154
                        if (library.getName().startsWith("facelets-") && !library.getName().endsWith("el-api")    //NOI18N
141
                        && !library.getName().endsWith("jsf-ri") && !library.getName().endsWith("myfaces")){                                            //NOI18N
155
                        && !library.getName().endsWith("jsf-ri") && !library.getName().endsWith("myfaces")){                                            //NOI18N
142
                            String displayName = library.getDisplayName();
156
                            String displayName = library.getDisplayName();
143
                            items.add(displayName);
157
                            registeredItems.add(displayName);
144
                            //TODO XX Add correct version
158
                            //TODO XX Add correct version
145
                            jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_1_2));
159
                            jsfLibraries.add(new LibraryItem(library, JSFVersion.JSF_1_2));
146
                        }
160
                        }
Lines 148-154 Link Here
148
                        content = library.getContent("classpath"); //NOI18N
162
                        content = library.getContent("classpath"); //NOI18N
149
                        try {
163
                        try {
150
                            if (Util.containsClass(content, JSFUtils.FACES_EXCEPTION) && !excludeLibs.contains(library.getName())) {
164
                            if (Util.containsClass(content, JSFUtils.FACES_EXCEPTION) && !excludeLibs.contains(library.getName())) {
151
                                items.add(library.getDisplayName());
165
                                registeredItems.add(library.getDisplayName());
152
                                boolean isJSF12 = Util.containsClass(content, JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
166
                                boolean isJSF12 = Util.containsClass(content, JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
153
                                boolean isJSF20 = Util.containsClass(content, JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
167
                                boolean isJSF20 = Util.containsClass(content, JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
154
                                if (isJSF12 && !isJSF20) {
168
                                if (isJSF12 && !isJSF20) {
Lines 163-170 Link Here
163
                            Exceptions.printStackTrace(exception);
177
                            Exceptions.printStackTrace(exception);
164
                        }
178
                        }
165
                    }
179
                    }
166
                    setLibraryModel(items);
180
                    
167
                    updatePreferredLanguages();
181
                    SwingUtilities.invokeLater(new Runnable() {
182
                        @Override
183
                        public void run() {
184
                            setRegisteredLibraryModel(registeredItems);
185
                            updatePreferredLanguages();
186
                        }
187
                    });
168
                    LOG.finest("Time spent in initLibraries in Runnable = "+(System.currentTimeMillis()-time) +" ms");  //NOI18N
188
                    LOG.finest("Time spent in initLibraries in Runnable = "+(System.currentTimeMillis()-time) +" ms");  //NOI18N
169
                }
189
                }
170
            }
190
            }
Lines 176-189 Link Here
176
        LOG.finest("Time spent in "+this.getClass().getName() +" initLibraries = "+(System.currentTimeMillis()-time) +" ms");   //NOI18N
196
        LOG.finest("Time spent in "+this.getClass().getName() +" initLibraries = "+(System.currentTimeMillis()-time) +" ms");   //NOI18N
177
    }
197
    }
178
198
179
    private void setLibraryModel(Vector<String> items) {
199
    private void initServerLibraries() {
200
        serverJsfLibraries.clear();
201
202
//        final Runnable libraryFinder = new Runnable() {
203
//
204
//            @Override
205
//            public void run() {
206
                synchronized (this) {
207
                    boolean serverLib = false;
208
                    if (serverInstanceID != null && !"".equals(serverInstanceID)) {
209
                        try {
210
                            ServerInstance.LibraryManager libManager = Deployment.getDefault().getServerInstance(serverInstanceID).getLibraryManager();
211
                            if (libManager != null) {
212
                                serverLib = true;
213
                                Set<ServerLibrary> libs = new HashSet<ServerLibrary>();
214
                                libs.addAll(libManager.getDeployedLibraries());
215
                                libs.addAll(libManager.getDeployableLibraries());
216
217
                                for (ServerLibrary lib : libs) {
218
                                    // FIXME optimize
219
                                    if ("JavaServer Faces".equals(lib.getSpecificationTitle())) { // NOI18N
220
                                        if (Version.fromJsr277NotationWithFallback("2.0").equals(lib.getSpecificationVersion())) { // NOI18N
221
                                            serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_2_0));
222
                                        } else if (Version.fromJsr277NotationWithFallback("1.2").equals(lib.getSpecificationVersion())) { // NOI18N
223
                                            serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_1_2));
224
                                        } else if (Version.fromJsr277NotationWithFallback("1.1").equals(lib.getSpecificationVersion())) { // NOI18N
225
                                            serverJsfLibraries.add(new ServerLibraryItem(lib, JSFVersion.JSF_1_1));
226
                                        } else {
227
                                            LOG.log(Level.INFO, "Unknown JSF version {0}", lib.getSpecificationVersion());
228
                                        }
229
                                    }
230
                                }
231
                            }
232
                        } catch (InstanceRemovedException ex) {
233
                            LOG.log(Level.INFO, null, ex);
234
                            // use the old way
235
                        }
236
                    }
237
238
                    if (!serverLib) {
239
                        File[] cp;
240
                        J2eePlatform platform = null;
241
                        try {
242
                            if (serverInstanceID != null) {
243
                                platform = Deployment.getDefault().getServerInstance(serverInstanceID).getJ2eePlatform();
244
                            }
245
                        } catch (InstanceRemovedException ex) {
246
                            platform = null;
247
                            LOG.log(Level.INFO, org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "SERVER_INSTANCE_REMOVED"), ex);
248
                        }
249
                        // j2eeplatform can be null, when the target server is not accessible.
250
                        if (platform != null) {
251
                            cp = platform.getClasspathEntries();
252
                        } else {
253
                            cp = new File[0];
254
                        }
255
256
                        try {
257
                            // XXX: there should be a utility class for this:
258
                            boolean isJSF = Util.containsClass(Arrays.asList(cp), JSFUtils.FACES_EXCEPTION);
259
                            boolean isJSF12 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
260
                            boolean isJSF20 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
261
262
                            JSFVersion jsfVersion = null;
263
                            if (isJSF20) {
264
                                jsfVersion = JSFVersion.JSF_2_0;
265
                            } else if (isJSF12) {
266
                                jsfVersion = JSFVersion.JSF_1_2;
267
                            } else if (isJSF) {
268
                                jsfVersion = JSFVersion.JSF_1_1;
269
                            }
270
                            if (jsfVersion != null) {
271
                                serverJsfLibraries.add(new ServerLibraryItem(null, jsfVersion));
272
                            }
273
                        } catch (IOException ex) {
274
                            Exceptions.printStackTrace(ex);
275
                        }
276
                    }
277
278
//                    SwingUtilities.invokeLater(new Runnable() {
279
//                        @Override
280
//                        public void run() {
281
                            setServerLibraryModel(serverJsfLibraries);
282
                            updatePreferredLanguages();
283
//                        }
284
//                    });
285
                }
286
//            }
287
//        };
288
//        RequestProcessor.getDefault().post(libraryFinder);
289
    }
290
291
    private void setRegisteredLibraryModel(Vector<String> items) {
180
        long time = System.currentTimeMillis();
292
        long time = System.currentTimeMillis();
181
        cbLibraries.setModel(new DefaultComboBoxModel(items));
293
        cbLibraries.setModel(new DefaultComboBoxModel(items));
182
        if (items.size() == 0) {
294
        if (items.size() == 0) {
183
            rbRegisteredLibrary.setEnabled(false);
295
            rbRegisteredLibrary.setEnabled(false);
184
            cbLibraries.setEnabled(false);
296
            cbLibraries.setEnabled(false);
185
            rbNewLibrary.setSelected(true);
297
            rbNewLibrary.setSelected(true);
186
            panel.setLibrary(null);
298
            panel.setLibrary((Library) null);
187
        } else if (items.size() != 0 &&  panel.getLibraryType() == JSFConfigurationPanel.LibraryType.USED){
299
        } else if (items.size() != 0 &&  panel.getLibraryType() == JSFConfigurationPanel.LibraryType.USED){
188
            if (!customizer) {
300
            if (!customizer) {
189
                rbRegisteredLibrary.setEnabled(true);
301
                rbRegisteredLibrary.setEnabled(true);
Lines 199-205 Link Here
199
        repaint();
311
        repaint();
200
        LOG.finest("Time spent in "+this.getClass().getName() +" setLibraryModel = "+(System.currentTimeMillis()-time) +" ms");   //NOI18N
312
        LOG.finest("Time spent in "+this.getClass().getName() +" setLibraryModel = "+(System.currentTimeMillis()-time) +" ms");   //NOI18N
201
    }
313
    }
202
    
314
315
    private void setServerLibraryModel(Collection<ServerLibraryItem> items) {
316
        serverLibraries.setModel(new DefaultComboBoxModel(items.toArray()));
317
        if (items.isEmpty()) {
318
            rbServerLibrary.setEnabled(false);
319
            serverLibraries.setEnabled(false);
320
            rbRegisteredLibrary.setSelected(true);
321
            panel.setServerLibrary((ServerLibrary) null);
322
        } else if (!items.isEmpty() && panel.getLibraryType() == JSFConfigurationPanel.LibraryType.SERVER){
323
            if (!customizer) {
324
                rbServerLibrary.setEnabled(true);
325
                serverLibraries.setEnabled(true);
326
            }
327
            rbServerLibrary.setSelected(true);
328
            if (!serverJsfLibraries.isEmpty()) {
329
                ServerLibraryItem item = (ServerLibraryItem) serverLibraries.getSelectedItem();
330
                if (item != null) {
331
                    panel.setServerLibrary(item.getLibrary());
332
                }
333
            }
334
        }
335
336
        repaint();
337
    }
338
203
    /**
339
    /**
204
     * Init Preferred Languages check box with "JSP" and/or "Facelets"
340
     * Init Preferred Languages check box with "JSP" and/or "Facelets"
205
     * according to choosen library
341
     * according to choosen library
Lines 217-225 Link Here
217
            if (panel.getNewLibraryName()!=null) {
353
            if (panel.getNewLibraryName()!=null) {
218
                jsfLibrary = LibraryManager.getDefault().getLibrary(panel.getNewLibraryName());
354
                jsfLibrary = LibraryManager.getDefault().getLibrary(panel.getNewLibraryName());
219
            }
355
            }
220
        } else if (panel.getLibraryType() == JSFConfigurationPanel.LibraryType.NONE) {
356
        } else if (panel.getLibraryType() == JSFConfigurationPanel.LibraryType.SERVER) {
221
            //XXX: need to find lib version
357
            //XXX: need to find lib version
222
            if (rbNoneLibrary.getText().indexOf("2.0")!=-1) {
358
            ServerLibraryItem item = (ServerLibraryItem) serverLibraries.getSelectedItem();
359
            if (item != null && item.getVersion() == JSFVersion.JSF_2_0) {
223
                faceletsPresent = true;
360
                faceletsPresent = true;
224
            }
361
            }
225
        }
362
        }
Lines 262-268 Link Here
262
        buttonGroup1 = new javax.swing.ButtonGroup();
399
        buttonGroup1 = new javax.swing.ButtonGroup();
263
        jsfTabbedPane = new javax.swing.JTabbedPane();
400
        jsfTabbedPane = new javax.swing.JTabbedPane();
264
        libPanel = new javax.swing.JPanel();
401
        libPanel = new javax.swing.JPanel();
265
        rbNoneLibrary = new javax.swing.JRadioButton();
402
        rbServerLibrary = new javax.swing.JRadioButton();
266
        rbRegisteredLibrary = new javax.swing.JRadioButton();
403
        rbRegisteredLibrary = new javax.swing.JRadioButton();
267
        cbLibraries = new javax.swing.JComboBox();
404
        cbLibraries = new javax.swing.JComboBox();
268
        rbNewLibrary = new javax.swing.JRadioButton();
405
        rbNewLibrary = new javax.swing.JRadioButton();
Lines 271-276 Link Here
271
        jbBrowse = new javax.swing.JButton();
408
        jbBrowse = new javax.swing.JButton();
272
        lVersion = new javax.swing.JLabel();
409
        lVersion = new javax.swing.JLabel();
273
        jtNewLibraryName = new javax.swing.JTextField();
410
        jtNewLibraryName = new javax.swing.JTextField();
411
        serverLibraries = new javax.swing.JComboBox();
274
        confPanel = new javax.swing.JPanel();
412
        confPanel = new javax.swing.JPanel();
275
        lURLPattern = new javax.swing.JLabel();
413
        lURLPattern = new javax.swing.JLabel();
276
        tURLPattern = new javax.swing.JTextField();
414
        tURLPattern = new javax.swing.JTextField();
Lines 286-298 Link Here
286
        libPanel.setAlignmentX(0.2F);
424
        libPanel.setAlignmentX(0.2F);
287
        libPanel.setAlignmentY(0.2F);
425
        libPanel.setAlignmentY(0.2F);
288
426
289
        buttonGroup1.add(rbNoneLibrary);
427
        buttonGroup1.add(rbServerLibrary);
290
        rbNoneLibrary.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_rbNoAppend").charAt(0));
428
        rbServerLibrary.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_rbNoAppend").charAt(0));
291
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle"); // NOI18N
429
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle"); // NOI18N
292
        rbNoneLibrary.setText(bundle.getString("LBL_Any_Library")); // NOI18N
430
        rbServerLibrary.setText(bundle.getString("LBL_Any_Library")); // NOI18N
293
        rbNoneLibrary.addItemListener(new java.awt.event.ItemListener() {
431
        rbServerLibrary.addItemListener(new java.awt.event.ItemListener() {
294
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
432
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
295
                rbNoneLibraryItemStateChanged(evt);
433
                rbServerLibraryItemStateChanged(evt);
296
            }
434
            }
297
        });
435
        });
298
436
Lines 355-360 Link Here
355
            }
493
            }
356
        });
494
        });
357
495
496
        serverLibraries.addActionListener(new java.awt.event.ActionListener() {
497
            public void actionPerformed(java.awt.event.ActionEvent evt) {
498
                serverLibrariesActionPerformed(evt);
499
            }
500
        });
501
358
        org.jdesktop.layout.GroupLayout libPanelLayout = new org.jdesktop.layout.GroupLayout(libPanel);
502
        org.jdesktop.layout.GroupLayout libPanelLayout = new org.jdesktop.layout.GroupLayout(libPanel);
359
        libPanel.setLayout(libPanelLayout);
503
        libPanel.setLayout(libPanelLayout);
360
        libPanelLayout.setHorizontalGroup(
504
        libPanelLayout.setHorizontalGroup(
Lines 362-392 Link Here
362
            .add(libPanelLayout.createSequentialGroup()
506
            .add(libPanelLayout.createSequentialGroup()
363
                .addContainerGap()
507
                .addContainerGap()
364
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
508
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
365
                    .add(rbNoneLibrary, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
509
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, rbNewLibrary, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
366
                    .add(libPanelLayout.createSequentialGroup()
367
                        .add(rbRegisteredLibrary)
368
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
369
                        .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
370
                            .add(cbLibraries, 0, 293, Short.MAX_VALUE)
371
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, libPanelLayout.createSequentialGroup()
372
                                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
373
                                    .add(jtNewLibraryName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
374
                                    .add(jtFolder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
375
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
376
                                .add(jbBrowse))))
377
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, rbNewLibrary, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
378
                    .add(libPanelLayout.createSequentialGroup()
510
                    .add(libPanelLayout.createSequentialGroup()
379
                        .add(22, 22, 22)
511
                        .add(22, 22, 22)
380
                        .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
512
                        .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
381
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, lVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE)
513
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, lVersion, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
382
                            .add(lDirectory, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE))))
514
                            .add(lDirectory, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)))
515
                    .add(libPanelLayout.createSequentialGroup()
516
                        .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
517
                            .add(org.jdesktop.layout.GroupLayout.LEADING, rbServerLibrary, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
518
                            .add(org.jdesktop.layout.GroupLayout.LEADING, rbRegisteredLibrary, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
519
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
520
                        .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
521
                            .add(cbLibraries, 0, 283, Short.MAX_VALUE)
522
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, libPanelLayout.createSequentialGroup()
523
                                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
524
                                    .add(jtNewLibraryName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
525
                                    .add(jtFolder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE))
526
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
527
                                .add(jbBrowse))
528
                            .add(serverLibraries, 0, 283, Short.MAX_VALUE))))
383
                .addContainerGap())
529
                .addContainerGap())
384
        );
530
        );
385
        libPanelLayout.setVerticalGroup(
531
        libPanelLayout.setVerticalGroup(
386
            libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
532
            libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
387
            .add(org.jdesktop.layout.GroupLayout.TRAILING, libPanelLayout.createSequentialGroup()
533
            .add(org.jdesktop.layout.GroupLayout.TRAILING, libPanelLayout.createSequentialGroup()
388
                .addContainerGap()
534
                .addContainerGap()
389
                .add(rbNoneLibrary)
535
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
536
                    .add(rbServerLibrary)
537
                    .add(serverLibraries, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
390
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
538
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
391
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
539
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
392
                    .add(rbRegisteredLibrary)
540
                    .add(rbRegisteredLibrary)
Lines 400-406 Link Here
400
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
548
                .add(libPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
401
                    .add(jtNewLibraryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
549
                    .add(jtNewLibraryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
402
                    .add(lVersion))
550
                    .add(lVersion))
403
                .addContainerGap(27, Short.MAX_VALUE))
551
                .addContainerGap(59, Short.MAX_VALUE))
404
        );
552
        );
405
553
406
        jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Libraries"), libPanel); // NOI18N
554
        jsfTabbedPane.addTab(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_TAB_Libraries"), libPanel); // NOI18N
Lines 434-440 Link Here
434
                    .add(confPanelLayout.createSequentialGroup()
582
                    .add(confPanelLayout.createSequentialGroup()
435
                        .add(lURLPattern)
583
                        .add(lURLPattern)
436
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
584
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
437
                        .add(tURLPattern, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE))
585
                        .add(tURLPattern, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
438
                    .add(confPanelLayout.createSequentialGroup()
586
                    .add(confPanelLayout.createSequentialGroup()
439
                        .add(jLabel1)
587
                        .add(jLabel1)
440
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
588
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
Lines 467-478 Link Here
467
        jsfTabbedPane.getAccessibleContext().setAccessibleName("");
615
        jsfTabbedPane.getAccessibleContext().setAccessibleName("");
468
    }// </editor-fold>//GEN-END:initComponents
616
    }// </editor-fold>//GEN-END:initComponents
469
617
470
private void rbNoneLibraryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbNoneLibraryItemStateChanged
618
private void rbServerLibraryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_rbServerLibraryItemStateChanged
471
    updateLibrary();
619
    updateLibrary();
472
    if (rbNoneLibrary.isSelected()) {
620
    if (rbServerLibrary.isSelected()) {
473
        panel.fireChangeEvent();
621
        panel.fireChangeEvent();
474
    }
622
    }
475
}//GEN-LAST:event_rbNoneLibraryItemStateChanged
623
}//GEN-LAST:event_rbServerLibraryItemStateChanged
476
624
477
private void jtNewLibraryNameKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtNewLibraryNameKeyReleased
625
private void jtNewLibraryNameKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtNewLibraryNameKeyReleased
478
    panel.setNewLibraryName(jtNewLibraryName.getText().trim());
626
    panel.setNewLibraryName(jtNewLibraryName.getText().trim());
Lines 520-525 Link Here
520
    } else
668
    } else
521
        panel.setEnableFacelets(false);
669
        panel.setEnableFacelets(false);
522
}//GEN-LAST:event_cbPreferredLangActionPerformed
670
}//GEN-LAST:event_cbPreferredLangActionPerformed
671
672
private void serverLibrariesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverLibrariesActionPerformed
673
    // TODO add your handling code here:
674
    ServerLibraryItem item = (ServerLibraryItem) serverLibraries.getSelectedItem();
675
    if (item != null) {
676
        panel.setServerLibrary(item.getLibrary());
677
    }
678
    updatePreferredLanguages();
679
}//GEN-LAST:event_serverLibrariesActionPerformed
523
    
680
    
524
    
681
    
525
    // Variables declaration - do not modify//GEN-BEGIN:variables
682
    // Variables declaration - do not modify//GEN-BEGIN:variables
Lines 538-545 Link Here
538
    private javax.swing.JLabel lVersion;
695
    private javax.swing.JLabel lVersion;
539
    private javax.swing.JPanel libPanel;
696
    private javax.swing.JPanel libPanel;
540
    private javax.swing.JRadioButton rbNewLibrary;
697
    private javax.swing.JRadioButton rbNewLibrary;
541
    private javax.swing.JRadioButton rbNoneLibrary;
542
    private javax.swing.JRadioButton rbRegisteredLibrary;
698
    private javax.swing.JRadioButton rbRegisteredLibrary;
699
    private javax.swing.JRadioButton rbServerLibrary;
700
    private javax.swing.JComboBox serverLibraries;
543
    private javax.swing.JTextField tURLPattern;
701
    private javax.swing.JTextField tURLPattern;
544
    // End of variables declaration//GEN-END:variables
702
    // End of variables declaration//GEN-END:variables
545
 
703
 
Lines 577-587 Link Here
577
            return true;
735
            return true;
578
        }
736
        }
579
737
580
        if (rbNoneLibrary.isSelected() && isWebLogicServer){
738
        controller.getProperties().setProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
581
            controller.getProperties().setProperty(WizardDescriptor.PROP_INFO_MESSAGE, NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_Weblogic_Warning"));
582
        } else {
583
            controller.getProperties().setProperty(WizardDescriptor.PROP_INFO_MESSAGE, null);
584
        }
585
739
586
        if (rbRegisteredLibrary.isSelected()) {
740
        if (rbRegisteredLibrary.isSelected()) {
587
            if (jsfLibraries == null || jsfLibraries.size() == 0) {
741
            if (jsfLibraries == null || jsfLibraries.size() == 0) {
Lines 653-658 Link Here
653
            return true;
807
            return true;
654
        return false;
808
        return false;
655
    }
809
    }
810
656
    private boolean isWebLogic(String serverInstanceID) {
811
    private boolean isWebLogic(String serverInstanceID) {
657
        if (serverInstanceID == null || "".equals(serverInstanceID)) {
812
        if (serverInstanceID == null || "".equals(serverInstanceID)) {
658
            return false;
813
            return false;
Lines 682-754 Link Here
682
     *   according web module version.
837
     *   according web module version.
683
     */
838
     */
684
    private void initLibSettings(Profile profile, String serverInstanceID) {
839
    private void initLibSettings(Profile profile, String serverInstanceID) {
685
        if (panel==null || panel.getLibraryType() == null || isServerInstanceChanged()) {
840
        boolean serverChanged = isServerInstanceChanged();
686
            try {
841
        if (serverChanged) {
687
                File[] cp;
842
            initServerLibraries();
688
                J2eePlatform platform = null;
843
        }
689
                try {
844
690
                    if (serverInstanceID != null)
845
        if (panel==null || panel.getLibraryType() == null || serverChanged) {
691
                        platform = Deployment.getDefault().getServerInstance(serverInstanceID).getJ2eePlatform();
846
            if (serverJsfLibraries.isEmpty()) {
692
                } catch (InstanceRemovedException ex) {
847
                rbServerLibrary.setVisible(false);
693
                    platform = null;
848
                serverLibraries.setVisible(false);
694
                    LOG.log(Level.INFO, org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "SERVER_INSTANCE_REMOVED"), ex);
849
                Library preferredLibrary = null;
695
                }
850
                if (profile.equals(Profile.JAVA_EE_6_FULL) || profile.equals(Profile.JAVA_EE_6_WEB) || profile.equals(Profile.JAVA_EE_5)) {
696
                // j2eeplatform can be null, when the target server is not accessible.
851
                    preferredLibrary = LibraryManager.getDefault().getLibrary(JSFUtils.DEFAULT_JSF_2_0_NAME);
697
                if (platform != null) {
698
                    cp = platform.getClasspathEntries();
699
                } else {
852
                } else {
700
                    cp = new File[0];
853
                    preferredLibrary = LibraryManager.getDefault().getLibrary(JSFUtils.DEFAULT_JSF_1_2_NAME);
701
                }
854
                }
702
855
703
                // XXX: there should be a utility class for this:
856
                if (preferredLibrary != null) {
704
                boolean isJSF = Util.containsClass(Arrays.asList(cp), JSFUtils.FACES_EXCEPTION);
857
                    // if there is a proffered library, select
705
                boolean isJSF12 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_1_2__API_SPECIFIC_CLASS);
858
                    rbRegisteredLibrary.setSelected(true);
706
                boolean isJSF20 = Util.containsClass(Arrays.asList(cp), JSFUtils.JSF_2_0__API_SPECIFIC_CLASS);
859
                    cbLibraries.setSelectedItem(preferredLibrary.getDisplayName());
707
860
                    updateLibrary();
708
                String libName = null; //NOI18N
709
                if (isJSF20) {
710
                    libName = "JSF 2.0"; //NOI18N
711
                } else if (isJSF12) {
712
                    libName = "JSF 1.2"; //NOI18N
713
                } else if (isJSF) {
714
                    libName = "JSF 1.1"; //NOI18N
715
                } else {
861
                } else {
716
                    rbNoneLibrary.setVisible(false);
862
                    // there is not a proffered library -> select one or select creating new one
717
                    Library preferredLibrary = null;
863
                    if (jsfLibraries.isEmpty()) {
718
                    if (profile.equals(Profile.JAVA_EE_6_FULL) || profile.equals(Profile.JAVA_EE_6_WEB) || profile.equals(Profile.JAVA_EE_5)) {
864
                        rbNewLibrary.setSelected(true);
719
                        preferredLibrary = LibraryManager.getDefault().getLibrary(JSFUtils.DEFAULT_JSF_2_0_NAME);
720
                    } else {
721
                        preferredLibrary = LibraryManager.getDefault().getLibrary(JSFUtils.DEFAULT_JSF_1_2_NAME);
722
                    }
723
724
                    if (preferredLibrary != null) {
725
                        // if there is a proffered library, select
726
                        rbRegisteredLibrary.setSelected(true);
727
                        cbLibraries.setSelectedItem(preferredLibrary.getDisplayName());
728
                        updateLibrary();
729
                    } else {
730
                        // there is not a proffered library -> select one or select creating new one
731
                        if (jsfLibraries.size() == 0) {
732
                            rbNewLibrary.setSelected(true);
733
                        }
734
                    }
865
                    }
735
                }
866
                }
736
                if (libName != null) {
867
            } else {
737
                    if (!rbNoneLibrary.isVisible()) {
868
                if (!rbServerLibrary.isVisible()) {
738
                        rbNoneLibrary.setVisible(true);
869
                    rbServerLibrary.setVisible(true);
739
                        repaint();
870
                    serverLibraries.setVisible(true);
740
                    }
871
                    repaint();
741
                    rbNoneLibrary.setText(NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_Any_Library", libName)); //NOI18N
742
                    rbNoneLibrary.setSelected(true);
743
                    if (panel !=null)
744
                        panel.setLibraryType(JSFConfigurationPanel.LibraryType.NONE);
745
                    enableNewLibraryComponent(false);
746
                    enableDefinedLibraryComponent(false);
747
                    isWebLogicServer = isWebLogic(serverInstanceID);
748
                }
872
                }
749
873
                rbServerLibrary.setSelected(true);
750
            } catch (IOException exception) {
874
                if (panel !=null)
751
                Exceptions.printStackTrace(exception);
875
                    panel.setLibraryType(JSFConfigurationPanel.LibraryType.SERVER);
876
                enableNewLibraryComponent(false);
877
                enableDefinedLibraryComponent(false);
878
                isWebLogicServer = isWebLogic(serverInstanceID);
752
            }
879
            }
753
        } else {
880
        } else {
754
            switch( panel.getLibraryType()) {
881
            switch( panel.getLibraryType()) {
Lines 760-767 Link Here
760
                    rbRegisteredLibrary.setSelected(true);
887
                    rbRegisteredLibrary.setSelected(true);
761
                    break;
888
                    break;
762
                }
889
                }
763
                case NONE: {
890
                case SERVER: {
764
                    rbNoneLibrary.setSelected(true);
891
                    rbServerLibrary.setSelected(true);
765
                    enableDefinedLibraryComponent(false);
892
                    enableDefinedLibraryComponent(false);
766
                    enableNewLibraryComponent(false);
893
                    enableNewLibraryComponent(false);
767
                    break;
894
                    break;
Lines 831-845 Link Here
831
    private void updateLibrary(){
958
    private void updateLibrary(){
832
        if (cbLibraries.getItemCount() == 0)
959
        if (cbLibraries.getItemCount() == 0)
833
            rbRegisteredLibrary.setEnabled(false);
960
            rbRegisteredLibrary.setEnabled(false);
834
        
961
835
        if (rbNoneLibrary.isSelected()){
962
        if (rbServerLibrary.isSelected()){
836
            enableNewLibraryComponent(false);
963
            enableNewLibraryComponent(false);
837
            enableDefinedLibraryComponent(false);
964
            enableDefinedLibraryComponent(false);
838
            panel.setLibraryType(JSFConfigurationPanel.LibraryType.NONE);
965
            enableServerLibraryComponent(true);
966
            panel.setLibraryType(JSFConfigurationPanel.LibraryType.SERVER);
967
            if (!serverJsfLibraries.isEmpty()) {
968
                ServerLibraryItem item = (ServerLibraryItem) serverLibraries.getSelectedItem();
969
                if (item != null) {
970
                    panel.setServerLibrary(item.getLibrary());
971
                }
972
            }
839
            panel.getController().setErrorMessage(null);
973
            panel.getController().setErrorMessage(null);
840
        } else if (rbRegisteredLibrary.isSelected()){
974
        } else if (rbRegisteredLibrary.isSelected()){
841
            enableNewLibraryComponent(false);
975
            enableNewLibraryComponent(false);
842
            enableDefinedLibraryComponent(true);
976
            enableDefinedLibraryComponent(true);
977
            enableServerLibraryComponent(false);
843
            panel.setLibraryType(JSFConfigurationPanel.LibraryType.USED);
978
            panel.setLibraryType(JSFConfigurationPanel.LibraryType.USED);
844
            if (jsfLibraries.size() > 0){
979
            if (jsfLibraries.size() > 0){
845
                panel.setLibrary(jsfLibraries.get(cbLibraries.getSelectedIndex()).getLibrary());
980
                panel.setLibrary(jsfLibraries.get(cbLibraries.getSelectedIndex()).getLibrary());
Lines 848-853 Link Here
848
        } else if (rbNewLibrary.isSelected()){
983
        } else if (rbNewLibrary.isSelected()){
849
            enableNewLibraryComponent(true);
984
            enableNewLibraryComponent(true);
850
            enableDefinedLibraryComponent(false);
985
            enableDefinedLibraryComponent(false);
986
            enableServerLibraryComponent(false);
851
            panel.setLibraryType(JSFConfigurationPanel.LibraryType.NEW);
987
            panel.setLibraryType(JSFConfigurationPanel.LibraryType.NEW);
852
            setNewLibraryFolder();
988
            setNewLibraryFolder();
853
        }
989
        }
Lines 857-862 Link Here
857
    private void enableDefinedLibraryComponent(boolean enabled){
993
    private void enableDefinedLibraryComponent(boolean enabled){
858
        cbLibraries.setEnabled(enabled);
994
        cbLibraries.setEnabled(enabled);
859
    }
995
    }
996
997
    private void enableServerLibraryComponent(boolean enabled){
998
        serverLibraries.setEnabled(enabled);
999
    }
860
    
1000
    
861
    private void enableNewLibraryComponent(boolean enabled){
1001
    private void enableNewLibraryComponent(boolean enabled){
862
        lDirectory.setEnabled(enabled);
1002
        lDirectory.setEnabled(enabled);
Lines 914-917 Link Here
914
            return library.getDisplayName();
1054
            return library.getDisplayName();
915
        }
1055
        }
916
    }
1056
    }
1057
1058
    private static class ServerLibraryItem implements Comparable<ServerLibraryItem> {
1059
1060
        private final ServerLibrary library;
1061
1062
        private final JSFVersion version;
1063
1064
        private String name;
1065
1066
        public ServerLibraryItem(ServerLibrary library, JSFVersion version) {
1067
            this.library = library;
1068
            this.version = version;
1069
        }
1070
1071
        public ServerLibrary getLibrary() {
1072
            return library;
1073
        }
1074
1075
        public JSFVersion getVersion() {
1076
            return version;
1077
        }
1078
1079
        @Override
1080
        public String toString() {
1081
            synchronized (this) {
1082
                if (name != null) {
1083
                    return name;
1084
                }
1085
            }
1086
            
1087
            StringBuilder sb = new StringBuilder();
1088
            switch (version) {
1089
                case JSF_1_0:
1090
                    sb.append("JSF 1.0"); // NOI18N
1091
                    break;
1092
                case JSF_1_1:
1093
                    sb.append("JSF 1.1"); // NOI18N
1094
                    break;
1095
                case JSF_1_2:
1096
                    sb.append("JSF 1.2"); // NOI18N
1097
                    break;
1098
                case JSF_2_0:
1099
                    sb.append("JSF 2.0"); // NOI18N
1100
                    break;
1101
            }
1102
            if (library != null && (library.getImplementationTitle() != null || library.getImplementationVersion() != null)) {
1103
                sb.append(" "); // NOI18N
1104
                sb.append("["); // NOI18N
1105
                if (library.getImplementationTitle() != null) {
1106
                    sb.append(library.getImplementationTitle());
1107
                }
1108
                if (library.getImplementationVersion() != null) {
1109
                    if (library.getImplementationTitle() != null) {
1110
                        sb.append(" - "); // NOI18N
1111
                    }
1112
                    sb.append(library.getImplementationVersion().toString());
1113
                }
1114
                sb.append("]"); // NOI18N
1115
            }
1116
            // result is the same as all fields are final
1117
            synchronized (this) {
1118
                name = sb.toString();
1119
                return name;
1120
            }
1121
        }
1122
1123
        @Override
1124
        public boolean equals(Object obj) {
1125
            if (obj == null) {
1126
                return false;
1127
            }
1128
            if (getClass() != obj.getClass()) {
1129
                return false;
1130
            }
1131
            final ServerLibraryItem other = (ServerLibraryItem) obj;
1132
            if ((this.toString() == null) ? (other.toString() != null) : !this.toString().equals(other.toString())) {
1133
                return false;
1134
            }
1135
            return true;
1136
        }
1137
1138
        @Override
1139
        public int hashCode() {
1140
            int hash = 7;
1141
            hash = 67 * hash + (this.toString() != null ? this.toString().hashCode() : 0);
1142
            return hash;
1143
        }
1144
1145
        @Override
1146
        public int compareTo(ServerLibraryItem o) {
1147
            return -this.toString().compareTo(o.toString());
1148
        }
1149
1150
    }
917
}
1151
}
(-)a/web.project/src/org/netbeans/modules/web/project/WebProject.java (-22 / +54 lines)
Lines 715-742 Link Here
715
        j2eePlatformListener = new PropertyChangeListener() {
715
        j2eePlatformListener = new PropertyChangeListener() {
716
            public void propertyChange(PropertyChangeEvent evt) {
716
            public void propertyChange(PropertyChangeEvent evt) {
717
                if (evt.getPropertyName().equals(J2eePlatform.PROP_CLASSPATH)) {
717
                if (evt.getPropertyName().equals(J2eePlatform.PROP_CLASSPATH)) {
718
                    ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
718
                    updateClasspath(platform);
719
                        public Void run() {
720
                            EditableProperties ep = helper.getProperties(
721
                                    AntProjectHelper.PRIVATE_PROPERTIES_PATH);
722
                            EditableProperties projectProps = helper.getProperties(
723
                                    AntProjectHelper.PROJECT_PROPERTIES_PATH);
724
725
                            if (!J2EEProjectProperties.isUsingServerLibrary(projectProps,
726
                                    WebProjectProperties.J2EE_PLATFORM_CLASSPATH)) {
727
                                String root = J2EEProjectProperties.extractPlatformLibrariesRoot(platform);
728
                                String classpath = J2EEProjectProperties.toClasspathString(platform.getClasspathEntries(), root);
729
                                ep.setProperty(WebProjectProperties.J2EE_PLATFORM_CLASSPATH, classpath);
730
                            }
731
                            helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
732
                            try {
733
                                ProjectManager.getDefault().saveProject(WebProject.this);
734
                            } catch (IOException e) {
735
                                Exceptions.printStackTrace(e);
736
                            }
737
                            return null;
738
                        }
739
                    });
740
                }
719
                }
741
            }
720
            }
742
        };
721
        };
Lines 748-753 Link Here
748
            platform.removePropertyChangeListener(j2eePlatformListener);
727
            platform.removePropertyChangeListener(j2eePlatformListener);
749
        }
728
        }
750
    }
729
    }
730
731
    private void updateClasspath(final J2eePlatform platform) {
732
        ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
733
            public Void run() {
734
                EditableProperties ep = helper.getProperties(
735
                        AntProjectHelper.PRIVATE_PROPERTIES_PATH);
736
                EditableProperties projectProps = helper.getProperties(
737
                        AntProjectHelper.PROJECT_PROPERTIES_PATH);
738
739
                if (!J2EEProjectProperties.isUsingServerLibrary(projectProps,
740
                        WebProjectProperties.J2EE_PLATFORM_CLASSPATH)) {
741
                    String root = J2EEProjectProperties.extractPlatformLibrariesRoot(platform);
742
                    String classpath = J2EEProjectProperties.toClasspathString(
743
                            Util.getJ2eePlatformClasspathEntries(WebProject.this), root);
744
                    ep.setProperty(WebProjectProperties.J2EE_PLATFORM_CLASSPATH, classpath);
745
                }
746
                helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
747
                try {
748
                    ProjectManager.getDefault().saveProject(WebProject.this);
749
                } catch (IOException e) {
750
                    Exceptions.printStackTrace(e);
751
                }
752
                return null;
753
            }
754
        });
755
    }
756
751
    // Private innerclasses ----------------------------------------------------
757
    // Private innerclasses ----------------------------------------------------
752
    
758
    
753
    //when #110886 gets implemented, this class is obsolete
759
    //when #110886 gets implemented, this class is obsolete
Lines 1006-1011 Link Here
1006
            } catch (IOException e) {
1012
            } catch (IOException e) {
1007
                Logger.getLogger("global").log(Level.INFO, null, e);
1013
                Logger.getLogger("global").log(Level.INFO, null, e);
1008
            }
1014
            }
1015
1016
//            String servInstID = evaluator().getProperty(WebProjectProperties.J2EE_SERVER_INSTANCE);
1017
//            J2eePlatform platform = Deployment.getDefault().getJ2eePlatform(servInstID);
1018
//            if (platform != null) {
1019
//                String root = J2EEProjectProperties.extractPlatformLibrariesRoot(platform);
1020
//                String classpath = J2EEProjectProperties.toClasspathString(
1021
//                        Util.getJ2eePlatformClasspathEntries(WebProject.this), root);
1022
//
1023
//                EditableProperties ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
1024
//                String oldClasspath = ep.getProperty(WebProjectProperties.J2EE_PLATFORM_CLASSPATH);
1025
//                if (!oldClasspath.equals(classpath)) {
1026
//                    ep.setProperty(WebProjectProperties.J2EE_PLATFORM_CLASSPATH, classpath);
1027
//                }
1028
//            }
1029
1030
            webModule.getConfigSupport().addLibraryChangeListener(new ChangeListener() {
1031
1032
                @Override
1033
                public void stateChanged(ChangeEvent e) {
1034
                    String servInstID = evaluator().getProperty(WebProjectProperties.J2EE_SERVER_INSTANCE);
1035
                    J2eePlatform platform = Deployment.getDefault().getJ2eePlatform(servInstID);
1036
                    if (platform != null) {
1037
                        updateClasspath(platform);
1038
                    }
1039
                }
1040
            });
1009
            
1041
            
1010
            // register project's classpaths to GlobalPathRegistry
1042
            // register project's classpaths to GlobalPathRegistry
1011
            GlobalPathRegistry.getDefault().register(ClassPath.BOOT, cpProvider.getProjectClassPaths(ClassPath.BOOT));
1043
            GlobalPathRegistry.getDefault().register(ClassPath.BOOT, cpProvider.getProjectClassPaths(ClassPath.BOOT));

Return to bug 182282