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.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 (+449 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.FilenameFilter;
46
import java.io.IOException;
47
import java.util.ArrayList;
48
import java.util.Collections;
49
import java.util.HashSet;
50
import java.util.Iterator;
51
import java.util.List;
52
import java.util.Set;
53
import java.util.jar.Attributes;
54
import java.util.logging.Level;
55
import java.util.logging.Logger;
56
import javax.enterprise.deploy.spi.status.ProgressObject;
57
import javax.xml.parsers.ParserConfigurationException;
58
import javax.xml.parsers.SAXParser;
59
import javax.xml.parsers.SAXParserFactory;
60
import org.netbeans.api.annotations.common.CheckForNull;
61
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
62
import org.netbeans.modules.j2ee.deployment.common.api.Version;
63
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
64
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
65
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryFactory;
66
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryImplementation;
67
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
68
import org.netbeans.modules.j2ee.weblogic9.ProgressObjectSupport;
69
import org.netbeans.modules.j2ee.weblogic9.WLDeploymentFactory;
70
import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties;
71
import org.netbeans.modules.j2ee.weblogic9.deploy.WLCommandDeployer;
72
import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager;
73
import org.openide.filesystems.FileObject;
74
import org.openide.filesystems.FileUtil;
75
import org.openide.filesystems.JarFileSystem;
76
import org.openide.util.NbBundle;
77
import org.xml.sax.SAXException;
78
import org.xml.sax.helpers.DefaultHandler;
79
80
/**
81
 *
82
 * @author Petr Hejl
83
 */
84
public class WLServerLibraryManager implements ServerLibraryManager {
85
86
    private static final Logger LOGGER = Logger.getLogger(WLServerLibraryManager.class.getName());
87
88
    private static final FilenameFilter LIBRARY_FILTER = new FilenameFilter() {
89
90
        @Override
91
        public boolean accept(File dir, String name) {
92
            return name.endsWith(".jar") // NOI18N
93
                        || name.endsWith(".war") // NOI18N
94
                        || name.endsWith(".ear"); // NOI18N
95
        }
96
    };
97
98
    private final WLDeploymentManager manager;
99
100
    public WLServerLibraryManager(WLDeploymentManager manager) {
101
        this.manager = manager;
102
    }
103
104
    @Override
105
    public void deployRequiredLibraries(Set<ServerLibraryRange> libraries) throws ConfigurationException {
106
        Set<ServerLibraryRange> notHandled = new HashSet<ServerLibraryRange>(libraries);
107
        Set<ServerLibrary> deployed = getDeployedLibraries();
108
109
        for (ServerLibraryRange range : libraries) {
110
            for (ServerLibrary lib : deployed) {
111
                if (range.versionMatches(lib)) {
112
                    notHandled.remove(range);
113
                    break;
114
                }
115
            }
116
        }
117
118
        Set<ServerLibrary> toDeploy = new HashSet<ServerLibrary>();
119
        Set<ServerLibrary> deployable = getDeployableLibraries();
120
        for (Iterator<ServerLibraryRange> it = notHandled.iterator(); it.hasNext(); ) {
121
            ServerLibraryRange range = it.next();
122
            for (ServerLibrary lib : deployable) {
123
                if (range.versionMatches(lib)) {
124
                    it.remove();
125
                    toDeploy.add(lib);
126
                    break;
127
                }
128
            }
129
        }
130
131
        if (!notHandled.isEmpty()) {
132
            throw new ConfigurationException(NbBundle.getMessage(WLServerLibraryManager.class, "MSG_DidNotFindServerLibraries"));
133
        }
134
135
        deployLibraries(toDeploy);
136
    }
137
138
139
    // this handles only archives
140
    @Override
141
    public Set<ServerLibrary> getDeployableLibraries() {
142
        String serverDir = manager.getInstanceProperties().getProperty(WLPluginProperties.SERVER_ROOT_ATTR);
143
        File libPath = FileUtil.normalizeFile(new File(serverDir + File.separator
144
                + "common" + File.separator + "deployable-libraries")); // NOI18N
145
        if (!libPath.exists() || !libPath.isDirectory()) {
146
            return Collections.emptySet();
147
        }
148
149
        Set<ServerLibrary> res = new HashSet<ServerLibrary>();
150
        for (File file : libPath.listFiles(LIBRARY_FILTER)) {
151
            WLServerLibrary lib = readFromFile(file);
152
            if (lib != null) {
153
                res.add(ServerLibraryFactory.createServerLibrary(lib));
154
            }
155
        }
156
        return res;
157
    }
158
159
    @Override
160
    public Set<ServerLibrary> getDeployedLibraries() {
161
        String domainDir = manager.getInstanceProperties().getProperty(WLPluginProperties.DOMAIN_ROOT_ATTR);
162
        File domainPath = FileUtil.normalizeFile(new File(domainDir));
163
        FileObject domain = FileUtil.toFileObject(domainPath);
164
        FileObject domainConfig = null;
165
        if (domain != null) {
166
            domainConfig = domain.getFileObject("config/config.xml"); // NOI18N
167
        }
168
        if (domainConfig == null) {
169
            return Collections.emptySet();
170
        }
171
172
        try {
173
            SAXParserFactory factory = SAXParserFactory.newInstance();
174
            SAXParser parser = factory.newSAXParser();
175
            LibraryHandler handler = new LibraryHandler(domainPath);
176
            parser.parse(new BufferedInputStream(domainConfig.getInputStream()), handler);
177
178
            Set<ServerLibrary> libs = new HashSet<ServerLibrary>();
179
            for (Library library : handler.getLibraries()) {
180
                File file = library.resolveFile();
181
                WLServerLibrary parsed = readFromFile(file);
182
                if (parsed != null) {
183
                    // checking the version - maybe we can avoid it
184
                    if (parsed.getSpecificationVersion() != library.getSpecificationVersion()
185
                        && (parsed.getSpecificationVersion() == null
186
                                || !parsed.getSpecificationVersion().equals(library.getSpecificationVersion()))) {
187
                        LOGGER.log(Level.INFO, "Inconsistent specification version for {0}", library.getName());
188
                    } else if (parsed.getImplementationVersion() != library.getImplementationVersion()
189
                        && (parsed.getImplementationVersion() == null
190
                                || !parsed.getImplementationVersion().equals(library.getImplementationVersion()))) {
191
                        LOGGER.log(Level.INFO, "Inconsistent implementation version for {0}", library.getName());
192
                    } else {
193
                        libs.add(ServerLibraryFactory.createServerLibrary(new WLServerLibrary(
194
                                parsed.getSpecificationTitle(), parsed.getSpecificationVersion(),
195
                                parsed.getImplementationTitle(), parsed.getImplementationVersion(),
196
                                file, library.getName())));
197
                    }
198
                } else {
199
                    LOGGER.log(Level.INFO, "Source path does not exists for {0}", library.getName());
200
                    // XXX we use name as spec title
201
                    libs.add(ServerLibraryFactory.createServerLibrary(new WLServerLibrary(
202
                            null, library.getSpecificationVersion(),
203
                            null, library.getImplementationVersion(), file, library.getName())));
204
                }
205
            }
206
207
            return libs;
208
        } catch (IOException ex) {
209
            return Collections.emptySet();
210
        } catch (ParserConfigurationException ex) {
211
            return Collections.emptySet();
212
        } catch (SAXException ex) {
213
            return Collections.emptySet();
214
        }
215
    }
216
217
    private void deployLibraries(Set<ServerLibrary> libraries) throws ConfigurationException {
218
        WLCommandDeployer deployer = new WLCommandDeployer(WLDeploymentFactory.getInstance(),
219
                manager.getInstanceProperties());
220
        ProgressObject po = deployer.deployLibraries(libraries);
221
        ProgressObjectSupport.waitFor(po);
222
        if (po.getDeploymentStatus().isFailed()) {
223
            String msg = NbBundle.getMessage(WLDatasourceManager.class, "MSG_FailedToDeployLibrary");
224
            throw new ConfigurationException(msg);
225
        }
226
    }
227
228
    private static WLServerLibrary readFromFile(File file) {
229
        if (file == null || !file.exists() || !file.canRead()) {
230
            return null;
231
        }
232
233
        try {
234
            JarFileSystem jar = new JarFileSystem();
235
            jar.setJarFile(file);
236
            Attributes attributes = jar.getManifest().getMainAttributes();
237
            String specVersionValue = attributes.getValue("Specification-Version"); // NOI18N
238
            String implVersionValue = attributes.getValue("Implementation-Version"); // NOI18N
239
            String specTitle = attributes.getValue("Specification-Title"); // NOI18N
240
            String implTitle = attributes.getValue("Implementation-Title"); // NOI18N
241
            String name = attributes.getValue("Extension-Name"); // NOI18N
242
243
            Version specVersion = specVersionValue == null ? null : Version.fromJsr277NotationWithFallback(specVersionValue);
244
            Version implVersion = implVersionValue == null ? null : Version.fromJsr277NotationWithFallback(implVersionValue);
245
246
            return new WLServerLibrary(specTitle, specVersion, implTitle, implVersion, file, name);
247
        } catch (IOException ex) {
248
            LOGGER.log(Level.INFO, null, ex);
249
        } catch (PropertyVetoException ex) {
250
            LOGGER.log(Level.INFO, null, ex);
251
        }
252
        return null;
253
    }
254
255
    private static class WLServerLibrary implements ServerLibraryImplementation {
256
257
        private final String specTitle;
258
259
        private final Version specVersion;
260
261
        private final String implTitle;
262
263
        private final Version implVersion;
264
265
        private final File file;
266
267
        private final String name;
268
269
        public WLServerLibrary(String specTitle, Version specVersion,
270
                String implTitle, Version implVersion, File file, String name) {
271
            this.specTitle = specTitle;
272
            this.specVersion = specVersion;
273
            this.implTitle = implTitle;
274
            this.implVersion = implVersion;
275
            this.file = file;
276
            this.name = name;
277
        }
278
279
        @Override
280
        public String getSpecificationTitle() {
281
            return specTitle;
282
        }
283
284
        @Override
285
        public Version getSpecificationVersion() {
286
            return specVersion;
287
        }
288
289
        @Override
290
        public String getImplementationTitle() {
291
            return implTitle;
292
        }
293
294
        @Override
295
        public Version getImplementationVersion() {
296
            return implVersion;
297
        }
298
299
        @Override
300
        public File getLibraryFile() {
301
            return file;
302
        }
303
304
        @Override
305
        public String getName() {
306
            return name;
307
        }
308
    }
309
310
    private static class LibraryHandler extends DefaultHandler {
311
312
        private final List<Library> libraries = new ArrayList<Library>();
313
314
        private final File domainDir;
315
316
        private Library library;
317
318
        private String value;
319
320
        public LibraryHandler(File domainDir) {
321
            this.domainDir = domainDir;
322
        }
323
324
        @Override
325
        public void startElement(String uri, String localName, String qName, org.xml.sax.Attributes attributes) throws SAXException {
326
            value = null;
327
            if ("library".equals(qName)) { // NOI18N
328
                library = new Library(domainDir);
329
            }
330
        }
331
332
        @Override
333
        public void endElement(String uri, String localName, String qName) {
334
            if (library == null) {
335
                return;
336
            }
337
338
            if ("library".equals(qName)) { // NOI18N
339
                libraries.add(library);
340
                library = null;
341
            } else if("name".equals(qName)) { // NOI18N
342
                String[] splitted = value.split("#"); // NOI18N
343
                if (splitted.length > 1) {
344
                    library.setName(splitted[0]);
345
                    splitted = splitted[1].split("@"); // NOI18N
346
                    library.setSpecificationVersion(Version.fromJsr277NotationWithFallback(splitted[0]));
347
                    if (splitted.length > 1) {
348
                        library.setImplementationVersion(Version.fromJsr277NotationWithFallback(splitted[1]));
349
                    }
350
                } else {
351
                    library.setName(value);
352
                }
353
            } else if ("taget".equals(qName)) { // NOI18N
354
                library.setTarget(value);
355
            } else if ("source-path".equals(qName)) { // NOI18N
356
                library.setFile(value);
357
            }
358
        }
359
360
        @Override
361
        public void characters(char[] ch, int start, int length) {
362
            value = new String(ch, start, length);
363
        }
364
365
        public List<Library> getLibraries() {
366
            return libraries;
367
        }
368
    }
369
370
    private static class Library {
371
372
        private final File baseFile;
373
374
        private String name;
375
376
        private Version specVersion;
377
378
        private Version implVersion;
379
380
        private String file;
381
382
        private String target;
383
384
        public Library(File baseFile) {
385
            this.baseFile = baseFile;
386
        }
387
388
        @CheckForNull
389
        public File resolveFile() {
390
            if (file == null) {
391
                return null;
392
            }
393
394
            File config = new File(file);
395
            if (!config.isAbsolute()) {
396
                if (baseFile != null) {
397
                    config = new File(baseFile, file);
398
                } else {
399
                    return null;
400
                }
401
            }
402
            if (config.exists() && config.isFile() && config.canRead()) {
403
                return config;
404
            }
405
            return null;
406
        }
407
408
        public String getName() {
409
            return name;
410
        }
411
412
        public void setName(String name) {
413
            this.name = name;
414
        }
415
416
        public Version getSpecificationVersion() {
417
            return specVersion;
418
        }
419
420
        public void setSpecificationVersion(Version specVersion) {
421
            this.specVersion = specVersion;
422
        }
423
424
        public Version getImplementationVersion() {
425
            return implVersion;
426
        }
427
428
        public void setImplementationVersion(Version implVersion) {
429
            this.implVersion = implVersion;
430
        }
431
432
        public String getTarget() {
433
            return target;
434
        }
435
436
        public void setTarget(String target) {
437
            this.target = target;
438
        }
439
440
        public String getFile() {
441
            return file;
442
        }
443
444
        public void setFile(String file) {
445
            this.file = file;
446
        }
447
448
    }
449
}
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WarDeploymentConfiguration.java (-3 / +74 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.HashSet;
55
import java.util.Set;
54
import javax.swing.text.BadLocationException;
56
import javax.swing.text.BadLocationException;
55
import javax.swing.text.StyledDocument;
57
import javax.swing.text.StyledDocument;
58
import org.netbeans.api.annotations.common.NonNull;
56
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
59
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
60
import org.netbeans.modules.j2ee.deployment.common.api.Version;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
61
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
62
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
58
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
63
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
59
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
64
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
60
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
65
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfiguration;
66
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration;
67
import org.netbeans.modules.j2ee.weblogic9.config.gen.LibraryRefType;
61
import org.netbeans.modules.j2ee.weblogic9.config.gen.WeblogicWebApp;
68
import org.netbeans.modules.j2ee.weblogic9.config.gen.WeblogicWebApp;
62
import org.netbeans.modules.schema2beans.AttrProp;
69
import org.netbeans.modules.schema2beans.AttrProp;
63
import org.netbeans.modules.schema2beans.BaseBean;
70
import org.netbeans.modules.schema2beans.BaseBean;
Lines 81-87 Link Here
81
 * @author sherold
88
 * @author sherold
82
 */
89
 */
83
public class WarDeploymentConfiguration extends WLDeploymentConfiguration
90
public class WarDeploymentConfiguration extends WLDeploymentConfiguration
84
        implements ModuleConfiguration, ContextRootConfiguration, DeploymentPlanConfiguration, PropertyChangeListener {
91
        implements ServerLibraryConfiguration, ModuleConfiguration,
92
        ContextRootConfiguration, DeploymentPlanConfiguration, PropertyChangeListener {
85
    
93
    
86
    private final File file;
94
    private final File file;
87
    private final J2eeModule j2eeModule;
95
    private final J2eeModule j2eeModule;
Lines 328-335 Link Here
328
            }
336
            }
329
        });
337
        });
330
    }
338
    }
331
    
339
332
    
340
    @Override
341
    public void configureRequiredLibrary(@NonNull final ServerLibraryRange library) throws ConfigurationException {
342
        assert library != null;
343
344
        modifyWeblogicWebApp(new WeblogicWebAppModifier() {
345
            public void modify(WeblogicWebApp webLogicWebApp) {
346
                for (LibraryRefType libRef : webLogicWebApp.getLibraryRef()) {
347
                    ServerLibraryRange lib = getServerLibraryRange(libRef);
348
                    if (library.equals(lib)) {
349
                        return;
350
                    }
351
                }
352
353
                setServerLibraryRange(webLogicWebApp, library);
354
            }
355
        });
356
    }
357
358
    @Override
359
    public Set<ServerLibraryRange> getRequiredLibraries() throws ConfigurationException {
360
        WeblogicWebApp webLogicWebApp = getWeblogicWebApp();
361
        if (webLogicWebApp == null) { // graph not parseable
362
            String msg = NbBundle.getMessage(WarDeploymentConfiguration.class, "MSG_CannotReadServerLibraries", file.getPath());
363
            throw new ConfigurationException(msg);
364
        }
365
366
        Set<ServerLibraryRange> ranges = new HashSet<ServerLibraryRange>();
367
        for (LibraryRefType libRef : webLogicWebApp.getLibraryRef()) {
368
            ranges.add(getServerLibraryRange(libRef));
369
        }
370
371
        return ranges;
372
    }
373
374
    private ServerLibraryRange getServerLibraryRange(LibraryRefType libRef) {
375
        String name = libRef.getLibraryName();
376
        String specVersionString = libRef.getSpecificationVersion();
377
        String implVersionString = libRef.getImplementationVersion();
378
        boolean exactMatch = libRef.isExactMatch();
379
380
        Version spec = specVersionString == null ? null : Version.fromJsr277NotationWithFallback(specVersionString);
381
        Version impl = implVersionString == null ? null : Version.fromJsr277NotationWithFallback(implVersionString);
382
        if (exactMatch) {
383
            return ServerLibraryRange.exactVersion(name, spec, impl);
384
        } else {
385
            return ServerLibraryRange.minimalVersion(name, spec, impl);
386
        }
387
    }
388
389
    private void setServerLibraryRange(WeblogicWebApp webApp, ServerLibraryRange library) {
390
        LibraryRefType libRef = new LibraryRefType();
391
        libRef.setLibraryName(library.getName());
392
        if (library.isExactMatch()) {
393
            libRef.setExactMatch(true);
394
        }
395
        if (library.getSpecificationVersion() != null) {
396
            libRef.setSpecificationVersion(library.getSpecificationVersion().toString());
397
        }
398
        if (library.getImplementationVersion() != null) {
399
            libRef.setImplementationVersion(library.getImplementationVersion().toString());
400
        }
401
        webApp.setLibraryRef(new LibraryRefType[] {libRef});
402
    }
403
333
    // private helper interface -----------------------------------------------
404
    // private helper interface -----------------------------------------------
334
     
405
     
335
    private interface WeblogicWebAppModifier {
406
    private interface WeblogicWebAppModifier {
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/deploy/Bundle.properties (+8 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_File=Library deployment failed. No file to deploy.
95
MSG_Library_Failed=Library deployment failed. Check the configured credentials.
96
MSG_Library_Completed=Library deployment completed.
97
MSG_Library_Failed_With_Message=Library deployment failed. Message was: {0}
98
MSG_Library_Failed_Timeout=Library deployment failed. The timeout expired.
99
MSG_Library_Failed_Interrupted=Library deployment failed. The deployment was interrupted.
(-)a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/deploy/WLCommandDeployer.java (+71 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<ServerLibrary> 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 (ServerLibrary library : libraries) {
460
                    if (library.getLibraryFile() == null) {
461
                        failed = true;
462
                        progress.fireProgressEvent(null, new WLDeploymentStatus(
463
                                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
464
                                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed_File")));
465
                        break;
466
                    }
467
468
                    ExecutionService service = createService("-deploy", null,
469
                            "-library" , library.getLibraryFile().getAbsolutePath()); // NOI18N
470
                    Future<Integer> result = service.run();
471
                    try {
472
                        Integer value = result.get(TIMEOUT, TimeUnit.MILLISECONDS);
473
                        if (value.intValue() != 0) {
474
                            failed = true;
475
                            progress.fireProgressEvent(null, new WLDeploymentStatus(
476
                                    ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
477
                                    NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed")));
478
                            break;
479
                        } else {
480
                            continue;
481
                        }
482
                    } catch (InterruptedException 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_Interrupted")));
487
                        result.cancel(true);
488
                        Thread.currentThread().interrupt();
489
                        break;
490
                    } catch (TimeoutException ex) {
491
                        failed = true;
492
                        progress.fireProgressEvent(null, new WLDeploymentStatus(
493
                                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
494
                                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed_Timeout")));
495
                        result.cancel(true);
496
                        break;
497
                    } catch (ExecutionException ex) {
498
                        failed = true;
499
                        progress.fireProgressEvent(null, new WLDeploymentStatus(
500
                                ActionType.EXECUTE, CommandType.DISTRIBUTE, StateType.FAILED,
501
                                NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Failed_With_Message")));
502
                        break;
503
                    }
504
                }
505
                if (!failed) {
506
                    progress.fireProgressEvent(null, new WLDeploymentStatus(
507
                            ActionType.EXECUTE, CommandType.START, StateType.COMPLETED,
508
                            NbBundle.getMessage(WLCommandDeployer.class, "MSG_Library_Completed")));
509
                }
510
            }
511
        });
512
513
        return progress;
514
    }
515
445
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) {
516
    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) {
446
517
447
        assert !SwingUtilities.isEventDispatchThread() : "Should not be executed in EDT";
518
        assert !SwingUtilities.isEventDispatchThread() : "Should not be executed in EDT";
(-)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 / +33 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 org.netbeans.api.annotations.common.NonNull;
59
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
60
import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
60
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
61
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeApplication;
61
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
62
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
Lines 66-71 Link Here
66
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
67
import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
67
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
68
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
68
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
69
import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
70
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
69
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
71
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ContextRootConfiguration;
70
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration;
72
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DatasourceConfiguration;
71
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.DeploymentPlanConfiguration;
73
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;
86
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
85
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
87
import org.netbeans.modules.j2ee.deployment.execution.ModuleConfigurationProvider;
86
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration;
88
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.MessageDestinationConfiguration;
89
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration;
87
import org.openide.util.Mutex.Action;
90
import org.openide.util.Mutex.Action;
88
import org.openide.util.Parameters;
91
import org.openide.util.Parameters;
89
92
Lines 334-340 Link Here
334
            mappingConfiguration.setCMPResource(ejbName, jndiName);
337
            mappingConfiguration.setCMPResource(ejbName, jndiName);
335
        }
338
        }
336
    }
339
    }
337
    
340
341
    @Override
342
    public void configureRequiredLibrary(@NonNull ServerLibraryRange library) throws ConfigurationException {
343
        if (server != null) {
344
            ModuleConfiguration config = getModuleConfiguration();
345
            if (config != null) {
346
                ServerLibraryConfiguration libraryConfiguration = config.getLookup().lookup(ServerLibraryConfiguration.class);
347
                if (libraryConfiguration != null) {
348
                    libraryConfiguration.configureRequiredLibrary(library);
349
                }
350
            }
351
        }
352
    }
353
354
    @Override
355
    public Set<ServerLibraryRange> getRequiredServerLibraries() throws ConfigurationException {
356
        Set<ServerLibraryRange> libs = Collections.emptySet();
357
358
        if (server != null) {
359
            ModuleConfiguration config = getModuleConfiguration();
360
            if (config != null) {
361
                ServerLibraryConfiguration libraryConfiguration = config.getLookup().lookup(ServerLibraryConfiguration.class);
362
                if (libraryConfiguration != null) {
363
                    libs = libraryConfiguration.getRequiredLibraries();
364
                }
365
            }
366
        }
367
        return libs;
368
    }
369
338
    public Set<Datasource> getDatasources() throws ConfigurationException {
370
    public Set<Datasource> getDatasources() throws ConfigurationException {
339
        
371
        
340
        Set<Datasource> projectDS = Collections.<Datasource>emptySet();
372
        Set<Datasource> projectDS = Collections.<Datasource>emptySet();
(-)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/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 / +32 lines)
Lines 76-83 Link Here
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 org.netbeans.api.annotations.common.CheckForNull;
78
import org.netbeans.api.annotations.common.CheckForNull;
79
import org.netbeans.api.annotations.common.NonNull;
79
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
80
import org.netbeans.modules.j2ee.deployment.common.api.MessageDestination;
80
import org.netbeans.modules.j2ee.deployment.impl.projects.J2eeModuleProviderAccessor;
81
import org.netbeans.modules.j2ee.deployment.impl.projects.J2eeModuleProviderAccessor;
82
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
83
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
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 (range) 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 configureRequiredLibrary(@NonNull ServerLibraryRange library) throws ConfigurationException;
505
506
        /**
507
         * Returns the server library ranges the enterprise module needs
508
         * to work properly.
509
         *
510
         * @return the server library ranges
511
         * @throws ConfigurationException if there was a problem reading
512
         *             configuration
513
         * @since 1.68
514
         */
515
        @NonNull
516
        public Set<ServerLibraryRange> getRequiredServerLibraries() throws ConfigurationException;
517
518
        /**
488
         * Retrieves message destinations stored in the module.
519
         * Retrieves message destinations stored in the module.
489
         * 
520
         * 
490
         * @return set of message destinations
521
         * @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.ServerLibraryRange;
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<ServerLibraryRange> libraries = jmp.getConfigSupport().getRequiredServerLibraries();
123
            si.deployRequiredLibraries(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 / +66 lines)
Lines 78-83 Link Here
78
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
78
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
79
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
79
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformImpl;
80
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
80
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
81
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
82
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
81
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
83
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer;
82
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
84
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver;
83
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
85
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
Lines 88-93 Link Here
88
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory;
90
import org.netbeans.modules.j2ee.deployment.plugins.spi.J2eePlatformFactory;
89
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
91
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment;
90
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
92
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor;
93
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerLibraryManager;
91
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
94
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerServerSettings;
92
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
95
import org.netbeans.modules.j2ee.deployment.profiler.api.ProfilerSupport;
93
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
96
import org.netbeans.modules.j2ee.deployment.profiler.spi.Profiler;
Lines 145-150 Link Here
145
    private J2eePlatformImpl j2eePlatformImpl;
148
    private J2eePlatformImpl j2eePlatformImpl;
146
    private StartServer startServer;
149
    private StartServer startServer;
147
    private FindJSPServlet findJSPServlet;
150
    private FindJSPServlet findJSPServlet;
151
    private ServerLibraryManager libraryManager;
152
    private ServerLibraryManager disconnectedLibraryManager;
148
    private DatasourceManager dsMgr;
153
    private DatasourceManager dsMgr;
149
    private DatasourceManager ddsMgr;
154
    private DatasourceManager ddsMgr;
150
    private MessageDestinationDeployment msgDestDeploymentConnected;
155
    private MessageDestinationDeployment msgDestDeploymentConnected;
Lines 685-691 Link Here
685
            return ddsMgr;
690
            return ddsMgr;
686
        }
691
        }
687
    }
692
    }
688
    
693
694
    private ServerLibraryManager getServerLibraryManager() {
695
        DeploymentManager dm = getDeploymentManager();
696
        synchronized (this) {
697
            if (libraryManager == null) {
698
                libraryManager = server.getOptionalFactory().getServerLibraryManager(dm);
699
            }
700
            return libraryManager;
701
        }
702
    }
703
704
    private ServerLibraryManager getDisconnectedServerLibraryManager() {
705
        DeploymentManager dm = null;
706
        try {
707
            dm = getDisconnectedDeploymentManager();
708
        }  catch (DeploymentManagerCreationException dmce) {
709
            throw new RuntimeException(dmce);
710
        }
711
        synchronized (this) {
712
            if (disconnectedLibraryManager == null) {
713
                disconnectedLibraryManager = server.getOptionalFactory().getServerLibraryManager(dm);
714
            }
715
            return disconnectedLibraryManager;
716
        }
717
    }
718
689
    /**
719
    /**
690
     * Gets the data sources deployed on the this server instance.
720
     * Gets the data sources deployed on the this server instance.
691
     *
721
     *
Lines 716-722 Link Here
716
        if (dsMgr != null) 
746
        if (dsMgr != null) 
717
            dsMgr.deployDatasources(datasources);
747
            dsMgr.deployDatasources(datasources);
718
    }
748
    }
719
    
749
750
    public boolean isServerLibraryManagementSupported() {
751
        return getDisconnectedServerLibraryManager() != null;
752
    }
753
754
    public Set<ServerLibrary> getDeployableLibraries() {
755
        ServerLibraryManager libraryManager = getDisconnectedServerLibraryManager();
756
757
        Set<ServerLibrary> libraries = Collections.emptySet();
758
        if (libraryManager != null) {
759
            libraries = libraryManager.getDeployableLibraries();
760
        }
761
762
        return libraries;
763
    }
764
765
    public Set<ServerLibrary> getDeployedLibraries() {
766
        ServerLibraryManager libraryManager = getDisconnectedServerLibraryManager();
767
768
        Set<ServerLibrary> libraries = Collections.emptySet();
769
        if (libraryManager != null) {
770
            libraries = libraryManager.getDeployedLibraries();
771
        }
772
773
        return libraries;
774
    }
775
776
    public void deployRequiredLibraries(Set<ServerLibraryRange> libraries) throws ConfigurationException {
777
        ServerLibraryManager libraryManager = getServerLibraryManager();
778
779
        if (libraryManager != null) {
780
            libraryManager.deployRequiredLibraries(libraries);
781
        }
782
    }
783
720
    private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() {
784
    private synchronized MessageDestinationDeployment getMessageDestinationDeploymentConnected() {
721
        if (msgDestDeploymentConnected == null) {
785
        if (msgDestDeploymentConnected == null) {
722
            msgDestDeploymentConnected = server.getOptionalFactory().
786
            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 (+150 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 file from which the library should be deployed or the from
129
     * which the library was deployed. May return <code>null</code>.
130
     *
131
     * @return the file from which the library should be deployed or the from
132
     *             which the library was deployed; may return <code>null</code>
133
     */
134
    @CheckForNull
135
    public File getLibraryFile() {
136
        return impl.getLibraryFile();
137
    }
138
139
    /**
140
     * Returns the library name. May return <code>null</code>.
141
     *
142
     * @return the library name; may return <code>null</code>
143
     */
144
    @CheckForNull
145
    public String getName() {
146
        return impl.getName();
147
    }
148
149
    // TODO should we implement equals and hashCode ?
150
}
(-)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 version. For example library version required by
50
 * the enterprise module.
51
 *
52
 * @since 1.68
53
 * @author Petr Hejl
54
 */
55
public final class ServerLibraryRange {
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 ServerLibraryRange(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 range which specifies the minimal specification and
75
     * 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 range which specifies the minimal specification and
84
     *             implementation version
85
     */
86
    public static ServerLibraryRange minimalVersion(@NonNull String name,
87
            @NullAllowed Version specificationVersion, @NullAllowed Version implementationVersion) {
88
89
        Parameters.notNull("name", name);
90
91
        return new ServerLibraryRange(name, specificationVersion, implementationVersion, false);
92
    }
93
94
    /**
95
     * Creates the library range 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 range which specifies the exact specification and
102
     *             implementation version
103
     */
104
    public static ServerLibraryRange 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 ServerLibraryRange(name, specificationVersion, implementationVersion, true);
111
    }
112
113
    /**
114
     * Returns <code>true</code> if the given library matches the range.
115
     * <p>
116
     * The library matches the range if the range specify the minimal versions
117
     * (specification and/or implementation) and corresponding versions
118
     * of the library are equal or greater. If the range specify the exact
119
     * version the corresponding versions of library must be the same as those
120
     * specified for range.
121
     *
122
     * @param library the library to check
123
     * @return <code>true</code> if the given library matches the range
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 range to match the library.
178
     *
179
     * @return <code>true</code> if the exactly the same version are required
180
     *             by the range to match the library
181
     */
182
    public boolean isExactMatch() {
183
        return exactMatch;
184
    }
185
186
    /**
187
     * @{@inheritDoc}
188
     *
189
     * Ranges 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 ServerLibraryRange other = (ServerLibraryRange) 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/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 (+117 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 file from which the library should be deployed or the from
102
     * which the library was deployed. May return <code>null</code>.
103
     *
104
     * @return the file from which the library should be deployed or the from
105
     *             which the library was deployed; may return <code>null</code>
106
     */
107
    @CheckForNull
108
    File getLibraryFile();
109
110
    /**
111
     * Returns the library name. May return <code>null</code>.
112
     * 
113
     * @return the library name; may return <code>null</code>
114
     */
115
    @CheckForNull
116
    String getName();
117
}
(-)5eda48228ef2 (+86 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.util.Set;
43
import org.netbeans.api.annotations.common.NonNull;
44
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
45
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibrary;
46
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
47
48
/**
49
 * The interface that should serverplugin should implement in order to
50
 * support the server library management.
51
 *
52
 * @since 1.68
53
 * @author Petr Hejl
54
 * @see org.netbeans.modules.j2ee.deployment.plugins.spi.config.ServerLibraryConfiguration
55
 */
56
public interface ServerLibraryManager {
57
58
    /**
59
     * Returns the set of libraries the server has access to and can be deployed
60
     * on request (by call to {@link #deployRequiredLibraries(java.util.Set)}.
61
     *
62
     * @return the set of libraries which can be deployed on server
63
     */
64
    @NonNull
65
    Set<ServerLibrary> getDeployableLibraries();
66
67
    /**
68
     * Returns the set of libraries already deployed to the server.
69
     *
70
     * @return the set of libraries already deployed to the server
71
     */
72
    @NonNull
73
    Set<ServerLibrary> getDeployedLibraries();
74
75
    /**
76
     * Deploys all the required libraries passed to the method. The libraries
77
     * passed to the method may be already deployed and it is up to implementor
78
     * to handle such case.
79
     *
80
     * @param libraries the libraries to deploy
81
     * @throws ConfigurationException if there was a problem during
82
     *             the deployment
83
     */
84
    void deployRequiredLibraries(@NonNull Set<ServerLibraryRange> libraries) throws ConfigurationException;
85
86
}
(-)5eda48228ef2 (+84 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 org.netbeans.api.annotations.common.NonNull;
44
import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException;
45
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerLibraryRange;
46
47
/**
48
 * The interface defining the methods that can handle the server libraries in
49
 * scope of enterprise module.
50
 * <p>
51
 * This interface is typically looked up in {@link ModuleConfiguration}'s
52
 * lookup.
53
 *
54
 * @since 1.68
55
 * @author Petr Hejl
56
 */
57
public interface ServerLibraryConfiguration {
58
59
    /**
60
     * Configure the library (range) the enterprise module needs in order
61
     * to work properly.
62
     * <p>
63
     * Once library is configured it should be present in the result
64
     * of the {@link #getRequiredLibraries()} call.
65
     *
66
     * @param library the library the enterprise module needs in order to work
67
     *             properly
68
     * @throws ConfigurationException if there was a problem writing
69
     *             configuration
70
     */
71
    void configureRequiredLibrary(@NonNull ServerLibraryRange library) throws ConfigurationException;
72
73
    /**
74
     * Returns the server library ranges the enterprise module needs
75
     * to work properly.
76
     *
77
     * @return the server library ranges
78
     * @throws ConfigurationException if there was a problem reading
79
     *             configuration
80
     */
81
    @NonNull
82
    Set<ServerLibraryRange> getRequiredLibraries() throws ConfigurationException;
83
84
}
(-)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.ServerLibraryRange;
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().configureRequiredLibrary(
219
                                ServerLibraryRange.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
}

Return to bug 182282