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/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) {

Return to bug 182282