diff --git a/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/EjbJarVersion.java b/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/EjbJarVersion.java
index b8ca518b4f50..933e0a79effc 100644
--- a/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/EjbJarVersion.java
+++ b/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/EjbJarVersion.java
@@ -126,6 +126,8 @@ public static EjbJarVersion getEjbJarVersion(String version) {
result = EJBJAR_3_2_6;
} else if(EJBJAR_4_0.toString().equals(version)) {
result = EJBJAR_4_0;
+ } else if(EJBJAR_4_0_1.toString().equals(version)) {
+ result = EJBJAR_4_0_1;
}
return result;
diff --git a/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/ServletVersion.java b/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/ServletVersion.java
index 84308b0b5e4d..af10e6c5c2c8 100644
--- a/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/ServletVersion.java
+++ b/enterprise/glassfish.eecommon/src/org/netbeans/modules/glassfish/eecommon/api/config/ServletVersion.java
@@ -102,6 +102,7 @@ private ServletVersion(String version, int nv, String specVersion, int nsv) {
* than the version passed in as an argument.
* @throws ClassCastException if obj is not a ServletVersion object.
*/
+ @Override
public int compareTo(Object obj) {
ServletVersion target = (ServletVersion) obj;
return numericCompare(target);
@@ -126,6 +127,8 @@ public static ServletVersion getServletVersion(String version) {
result = SERVLET_5_0;
} else if(SERVLET_6_0.toString().equals(version)) {
result = SERVLET_6_0;
+ } else if(SERVLET_6_1.toString().equals(version)) {
+ result = SERVLET_6_1;
}
return result;
diff --git a/enterprise/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/resources/layer.xml b/enterprise/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/resources/layer.xml
index f94dd78e480b..394436361dfe 100644
--- a/enterprise/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/resources/layer.xml
+++ b/enterprise/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/ui/resources/layer.xml
@@ -57,6 +57,7 @@
+
diff --git a/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/J2eeProjectCapabilities.java b/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/J2eeProjectCapabilities.java
index 6fdcfd672e2d..b9ae12cd1adc 100644
--- a/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/J2eeProjectCapabilities.java
+++ b/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/J2eeProjectCapabilities.java
@@ -64,24 +64,24 @@ public static J2eeProjectCapabilities forProject(@NonNull Project project) {
if (provider == null) {
return null;
}
+ J2eeModule.Type type = provider.getJ2eeModule().getType();
Profile ejbJarProfile = null;
Profile webProfile = null;
Profile carProfile = null;
- if (provider.getJ2eeModule().getType() == J2eeModule.Type.EJB ||
- provider.getJ2eeModule().getType() == J2eeModule.Type.WAR) {
+ if (type == J2eeModule.Type.EJB || type == J2eeModule.Type.WAR) {
EjbJar[] ejbJars = EjbJar.getEjbJars(project);
if (ejbJars.length > 0) {
// just use first one to test profile:
ejbJarProfile = ejbJars[0].getJ2eeProfile();
}
- if (provider.getJ2eeModule().getType() == J2eeModule.Type.WAR) {
+ if (type == J2eeModule.Type.WAR) {
WebModule module = WebModule.getWebModule(project.getProjectDirectory());
if (module != null) {
webProfile = module.getJ2eeProfile();
}
}
}
- if (provider.getJ2eeModule().getType() == J2eeModule.Type.CAR) {
+ if (type == J2eeModule.Type.CAR) {
Car car = Car.getCar(project.getProjectDirectory());
if (car != null) {
carProfile = car.getJ2eeProfile();
diff --git a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/client/ClientParseUtils.java b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/client/ClientParseUtils.java
index 6a47f866bf76..2d2c93b97f95 100644
--- a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/client/ClientParseUtils.java
+++ b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/client/ClientParseUtils.java
@@ -42,18 +42,15 @@ public class ClientParseUtils {
/** Parsing just for detecting the version SAX parser used
*/
- public static String getVersion(java.io.InputStream is) throws java.io.IOException, SAXException {
+ public static String getVersion(InputStream is) throws IOException, SAXException {
return ParseUtils.getVersion(is, new VersionHandler(), DDResolver.getInstance());
}
/** Parsing just for detecting the version SAX parser used
*/
- public static String getVersion(FileObject fo) throws java.io.IOException, SAXException {
- InputStream inputStream = fo.getInputStream();
- try {
+ public static String getVersion(FileObject fo) throws IOException, SAXException {
+ try (InputStream inputStream = fo.getInputStream()) {
return ParseUtils.getVersion(inputStream, new VersionHandler(), DDResolver.getInstance());
- } finally {
- inputStream.close();
}
}
@@ -97,6 +94,7 @@ static synchronized DDResolver getInstance() {
}
return resolver;
}
+ @Override
public InputSource resolveEntity(String publicId, String systemId) {
if ("-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN".equals(publicId)) {
return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_1_3.dtd"); //NOI18N
@@ -106,6 +104,16 @@ public InputSource resolveEntity(String publicId, String systemId) {
return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_5.xsd"); //NOI18N
} else if ("http://java.sun.com/xml/ns/javaee/application-client_6.xsd".equals(systemId)) {
return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_6.xsd"); //NOI18N
+ } else if ("http://xmlns.jcp.org/xml/ns/javaee/application-client_7.xsd".equals(systemId)) {
+ return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_7.xsd"); //NOI18N
+ } else if ("http://xmlns.jcp.org/xml/ns/javaee/application-client_8.xsd".equals(systemId)) {
+ return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_8.xsd"); //NOI18N
+ } else if ("https://jakarta.ee/xml/ns/jakartaee/application-client_9.xsd".equals(systemId)) {
+ return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_9.xsd"); //NOI18N
+ } else if ("https://jakarta.ee/xml/ns/jakartaee/application-client_10.xsd".equals(systemId)) {
+ return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_10.xsd"); //NOI18N
+ } else if ("https://jakarta.ee/xml/ns/jakartaee/application-client_11.xsd".equals(systemId)) {
+ return new InputSource("nbres:/org/netbeans/modules/j2ee/dd/impl/resources/application-client_11.xsd"); //NOI18N
} else {
// use the default behaviour
return null;
@@ -115,17 +123,14 @@ public InputSource resolveEntity(String publicId, String systemId) {
public static SAXParseException parse(FileObject fo)
- throws org.xml.sax.SAXException, java.io.IOException {
- InputStream inputStream = fo.getInputStream();
- try {
+ throws SAXException, IOException {
+ try (InputStream inputStream = fo.getInputStream()) {
return parse(new InputSource(inputStream));
- } finally {
- inputStream.close();
}
}
public static SAXParseException parse (InputSource is)
- throws org.xml.sax.SAXException, java.io.IOException {
+ throws SAXException, IOException {
return ParseUtils.parseDD(is, DDResolver.getInstance());
}
@@ -137,7 +142,7 @@ public static SAXParseException parse (InputSource is)
* no exception.
*/
public static SAXParseException parse(InputSource inputSource, EntityResolver resolver)
- throws org.xml.sax.SAXException, java.io.IOException {
+ throws SAXException, IOException {
return ParseUtils.parseDD(inputSource, resolver);
}
}
diff --git a/enterprise/maven.j2ee/nbproject/project.properties b/enterprise/maven.j2ee/nbproject/project.properties
index 5f9e836dbcef..5b10422d7663 100644
--- a/enterprise/maven.j2ee/nbproject/project.properties
+++ b/enterprise/maven.j2ee/nbproject/project.properties
@@ -18,5 +18,5 @@
is.eager=true
javac.compilerargs=-Xlint -Xlint:-serial -Xlint -Xlint:-serial
-javac.source=1.8
+javac.release=17
test.config.stableBTD.includes=**/*Test.class
diff --git a/enterprise/maven.j2ee/nbproject/project.xml b/enterprise/maven.j2ee/nbproject/project.xml
index cf72801a24bd..68b600e960c8 100644
--- a/enterprise/maven.j2ee/nbproject/project.xml
+++ b/enterprise/maven.j2ee/nbproject/project.xml
@@ -52,6 +52,15 @@
2.16
+
+ org.netbeans.api.java
+
+
+
+ 1
+ 1.95
+
+
org.netbeans.api.java.classpath
@@ -539,6 +548,7 @@
+ org.netbeans.modules.maven.jaxws
org.netbeans.modules.payara.micro
org.netbeans.modules.jakarta.transformer
org.netbeans.modules.maven.j2ee
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ProjectHookImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ProjectHookImpl.java
index 838fedb22391..fa2aacfff3d3 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ProjectHookImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ProjectHookImpl.java
@@ -27,6 +27,7 @@
import java.util.prefs.Preferences;
import org.netbeans.api.j2ee.core.Profile;
import org.netbeans.api.project.Project;
+import org.netbeans.modules.j2ee.api.ejbjar.Car;
import org.netbeans.modules.j2ee.api.ejbjar.Ear;
import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
@@ -133,7 +134,9 @@ public void preferenceChange(PreferenceChangeEvent evt) {
RP.post(new Runnable() {
@Override
public void run() {
- LoggingUtils.logUsage(ExecutionChecker.class, "USG_PROJECT_OPEN_MAVEN_EE", new Object[] { getServerName(), getEEversion(), getProjectType() }, "maven"); //NOI18N
+ LoggingUtils.logUsage(ExecutionChecker.class, "USG_PROJECT_OPEN_MAVEN_EE", new Object[] { //NOI18N
+ getServerName(), getEEversion(), getProjectType()
+ }, "maven"); //NOI18N
}
});
}
@@ -192,24 +195,30 @@ private String getEEversion() {
String projectType = getProjectType();
if (projectType != null) {
switch (projectType) {
- case "ear": //NOI18N
+ case "ear" -> { //NOI18N
Ear earProj = Ear.getEar(project.getProjectDirectory());
if (earProj != null) {
profile = earProj.getJ2eeProfile();
}
- break;
- case "war": //NOI18N
+ }
+ case "war" -> { //NOI18N
WebModule webM = WebModule.getWebModule(project.getProjectDirectory());
if (webM != null) {
profile = webM.getJ2eeProfile();
}
- break;
- case "ejb": //NOI18N
+ }
+ case "ejb" -> { //NOI18N
EjbJar ejbProj = EjbJar.getEjbJar(project.getProjectDirectory());
if (ejbProj != null) {
profile = ejbProj.getJ2eeProfile();
}
- break;
+ }
+ case "app-client" -> { //NOI18N
+ Car carM = Car.getCar(project.getProjectDirectory());
+ if (carM != null) {
+ profile = carM.getJ2eeProfile();
+ }
+ }
}
}
if (profile != null) {
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientImpl.java
index e653a03d3cb1..b4eb4a745df3 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientImpl.java
@@ -32,9 +32,11 @@
import org.netbeans.modules.j2ee.dd.spi.client.AppClientMetadataModelFactory;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.metadata.model.api.MetadataModel;
+import org.netbeans.modules.j2ee.spi.ejbjar.CarImplementation2;
import org.netbeans.modules.javaee.project.api.JavaEEProjectSettings;
import org.netbeans.modules.maven.api.classpath.ProjectSourcesClassPathProvider;
import org.netbeans.modules.maven.j2ee.BaseEEModuleImpl;
+import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@@ -44,7 +46,7 @@
*
* @author Martin Janicek
*/
-public class AppClientImpl extends BaseEEModuleImpl {
+public class AppClientImpl extends BaseEEModuleImpl implements CarImplementation2 {
private MetadataModel appClientMetadataModel;
@@ -52,7 +54,6 @@ public class AppClientImpl extends BaseEEModuleImpl {
AppClientImpl(Project project, AppClientModuleProviderImpl provider) {
super(project, provider, "application-client.xml", J2eeModule.CLIENT_XML); // NOI18N
}
-
@Override
public J2eeModule.Type getModuleType() {
@@ -64,12 +65,17 @@ public FileObject getArchive() throws IOException {
return getArchive(Constants.GROUP_APACHE_PLUGINS, "maven-acr-plugin", "acr", "jar"); // NOI18N
}
+ @Override
public Profile getJ2eeProfile() {
Profile profile = JavaEEProjectSettings.getProfile(project);
if (profile != null) {
return profile;
}
- return Profile.JAVA_EE_7_FULL;
+ Profile pomProfile = MavenProjectSupport.getProfileFromPOM(project);
+ if (pomProfile != null) {
+ return pomProfile;
+ }
+ return Profile.JAKARTA_EE_8_FULL;
}
@Override
@@ -85,8 +91,7 @@ public String getModuleVersion() {
ErrorManager.getDefault().notify(exc);
}
}
-
- return AppClient.VERSION_6_0;
+ return AppClient.VERSION_8_0;
}
@Override
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientModuleProviderImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientModuleProviderImpl.java
index 1cefb4b4a230..6d445b73d6a2 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientModuleProviderImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/appclient/AppClientModuleProviderImpl.java
@@ -26,8 +26,13 @@
import java.util.Iterator;
import java.util.List;
import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
+import org.netbeans.modules.j2ee.api.ejbjar.Car;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
+import org.netbeans.modules.j2ee.spi.ejbjar.CarFactory;
+import org.netbeans.modules.j2ee.spi.ejbjar.CarProvider;
+import org.netbeans.modules.j2ee.spi.ejbjar.CarsInProject;
import org.netbeans.modules.maven.api.NbMavenProject;
import org.netbeans.modules.maven.api.classpath.ProjectSourcesClassPathProvider;
import org.netbeans.modules.maven.j2ee.BaseEEModuleProvider;
@@ -35,27 +40,62 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
-@ProjectServiceProvider(service = {AppClientModuleProviderImpl.class, J2eeModuleProvider.class}, projectType = {"org-netbeans-modules-maven/" + NbMavenProject.TYPE_APPCLIENT})
-public class AppClientModuleProviderImpl extends BaseEEModuleProvider {
+/**
+ * Application Client module provider implementation for maven2 project type.
+ * @author Milos Kleint
+ */
+@ProjectServiceProvider(
+ service = {
+ AppClientModuleProviderImpl.class,
+ CarProvider.class,
+ CarsInProject.class,
+ J2eeModuleProvider.class
+ },
+ projectType = {
+ "org-netbeans-modules-maven/" + NbMavenProject.TYPE_APPCLIENT
+ }
+)
+public class AppClientModuleProviderImpl extends BaseEEModuleProvider implements CarProvider, CarsInProject {
private AppClientImpl appClientImpl;
-
+ private Car apiCarJar;
+
public AppClientModuleProviderImpl(Project project) {
super(project);
- appClientImpl = new AppClientImpl(project, this);
}
@Override
public AppClientImpl getModuleImpl() {
+ if (appClientImpl == null) {
+ appClientImpl = new AppClientImpl(project, this);
+ }
return appClientImpl;
}
+ @Override
+ public Car findCar(FileObject file) {
+ getModuleImpl();
+ Project proj = FileOwnerQuery.getOwner(file);
+ if (proj != null) {
+ proj = proj.getLookup().lookup(Project.class);
+ }
+ if (proj != null && project == proj) {
+ if (appClientImpl.isValid()) {
+ if (apiCarJar == null) {
+ apiCarJar = CarFactory.createCar(appClientImpl);
+ }
+ return apiCarJar;
+ }
+ }
+ return null;
+ }
+
@Override
public FileObject[] getSourceRoots() {
ProjectSourcesClassPathProvider cppImpl = project.getLookup().lookup(ProjectSourcesClassPathProvider.class);
ClassPath cp = cppImpl.getProjectSourcesClassPath(ClassPath.SOURCE);
- List resUris = new ArrayList();
+ List resUris = new ArrayList<>();
for (URI uri : project.getLookup().lookup(NbMavenProject.class).getResources(false)) {
try {
resUris.add(uri.toURL());
@@ -64,7 +104,7 @@ public FileObject[] getSourceRoots() {
}
}
Iterator en = cp.entries().listIterator();
- List toRet = new ArrayList();
+ List toRet = new ArrayList<>();
int index = 0;
while (en.hasNext()) {
ClassPath.Entry ent = en.next();
@@ -77,7 +117,7 @@ public FileObject[] getSourceRoots() {
toRet.add(ent.getRoot());
}
}
- return toRet.toArray(new FileObject[0]);
+ return toRet.toArray(FileObject[]::new);
}
@Override
@@ -86,7 +126,7 @@ public File[] getRequiredLibraries() {
// do not use COMPILE classpath here because it contains dependencies
// with *provided* scope which should not be deployed
ClassPath cp = cppImpl.getProjectSourcesClassPath(ClassPath.EXECUTE);
- List files = new ArrayList();
+ List files = new ArrayList<>();
for (FileObject fo : cp.getRoots()) {
fo = FileUtil.getArchiveFile(fo);
if (fo == null) {
@@ -94,6 +134,19 @@ public File[] getRequiredLibraries() {
}
files.add(FileUtil.toFile(fo));
}
- return files.toArray(new File[0]);
+ return files.toArray(File[]::new);
+ }
+
+ @Override
+ public Car[] getCars() {
+ getModuleImpl();
+ if (appClientImpl.isValid()) {
+ if (apiCarJar == null) {
+ apiCarJar = CarFactory.createCar(appClientImpl);
+ }
+ return new Car[] {apiCarJar};
+ }
+ return new Car[0];
}
+
}
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java
index e6baefd668f2..c321791494b9 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarImpl.java
@@ -20,12 +20,16 @@
package org.netbeans.modules.maven.j2ee.ear;
import java.beans.PropertyChangeListener;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
@@ -33,8 +37,6 @@
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
-import org.codehaus.plexus.util.StringInputStream;
-import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.netbeans.api.j2ee.core.Profile;
import org.netbeans.api.project.FileOwnerQuery;
@@ -107,15 +109,11 @@ public Profile getJ2eeProfile() {
if (isApplicationXmlGenerated()) {
String version = PluginPropertyUtils.getPluginProperty(project, Constants.GROUP_APACHE_PLUGINS,
Constants.PLUGIN_EAR, "version", "generate-application-xml", null); //NOI18N
- // the default version in maven plugin is also 1.3
//TODO what if the default changes?
if (version != null) {
version = version.trim();
- // 5, 6, 7 are not valid versions in NB it is 1.5, 1.6, 1.7
- if (!version.startsWith("1.")) { // NOI18N
- version = "1." + version; // NOI18N
- }
- return Profile.fromPropertiesString(version);
+ profile = getProfile(version);
+ return profile;
}
} else {
DDProvider prov = DDProvider.getDefault();
@@ -125,22 +123,37 @@ public Profile getJ2eeProfile() {
Application app = prov.getDDRoot(dd);
String appVersion = app.getVersion().toString();
appVersion = appVersion.trim();
- // 5, 6, 7 are not valid versions in NB it is 1.5, 1.6, 1.7
- if (!appVersion.startsWith("1.")) { // NOI18N
- appVersion = "1." + appVersion; // NOI18N
- }
- return Profile.fromPropertiesString(appVersion);
+ profile = getProfile(appVersion);
+ return profile;
} catch (IOException exc) {
ErrorManager.getDefault().notify(exc);
}
} else {
//TODO try to check the pom model again and user 'version' element if existing..
- return Profile.JAVA_EE_6_FULL;
+ return Profile.JAKARTA_EE_8_FULL;
}
}
// hardwire?
// System.out.println("eariml: getj2eepaltform");
- return Profile.JAVA_EE_5;
+ return Profile.JAKARTA_EE_8_FULL;
+ }
+
+ /**
+ * Get {@code Profile} based on the EAR version written in the pom.xml file
+ * @param version
+ * @return Profile
+ */
+ private static Profile getProfile(String version) {
+ return switch (version) {
+ case "11" -> Profile.JAKARTA_EE_11_FULL;
+ case "10" -> Profile.JAKARTA_EE_10_FULL;
+ case "9" -> Profile.JAKARTA_EE_9_1_FULL;
+ case "8" -> Profile.JAKARTA_EE_8_FULL;
+ case "7" -> Profile.JAVA_EE_7_FULL;
+ case "6" -> Profile.JAVA_EE_6_FULL;
+ case "5" -> Profile.JAVA_EE_5;
+ default -> Profile.JAKARTA_EE_8_FULL;
+ };
}
@Override
@@ -239,7 +252,7 @@ private boolean isApplicationXmlGenerated() {
"generateApplicationXml", //NOI18N
"generate-application-xml", null);//NOI18N
//either the default or explicitly set generation of application.xml file
- return (str == null || Boolean.valueOf(str));
+ return (str == null || Boolean.parseBoolean(str));
}
boolean isValid() {
@@ -257,15 +270,21 @@ public J2eeModule.Type getModuleType() {
*/
@Override
public String getModuleVersion() {
- Profile prf = getJ2eeProfile();
- if (prf == Profile.JAKARTA_EE_11_FULL || prf == Profile.JAKARTA_EE_11_FULL) return Application.VERSION_11;
- if (prf == Profile.JAKARTA_EE_10_FULL || prf == Profile.JAKARTA_EE_10_FULL) return Application.VERSION_10;
- if (prf == Profile.JAKARTA_EE_9_1_FULL || prf == Profile.JAKARTA_EE_9_FULL) return Application.VERSION_9;
- if (prf == Profile.JAKARTA_EE_8_FULL || prf == Profile.JAVA_EE_8_FULL) return Application.VERSION_8;
- if (prf == Profile.JAVA_EE_7_FULL) return Application.VERSION_7;
- if (prf == Profile.JAVA_EE_6_FULL) return Application.VERSION_6;
- if (prf == Profile.JAVA_EE_5) return Application.VERSION_5;
- return Application.VERSION_1_4;
+ Profile profile = getJ2eeProfile();
+ if (null == profile) {
+ return Application.VERSION_8;
+ } else {
+ return switch (profile) {
+ case JAKARTA_EE_11_FULL -> Application.VERSION_11;
+ case JAKARTA_EE_10_FULL -> Application.VERSION_10;
+ case JAKARTA_EE_9_1_FULL, JAKARTA_EE_9_FULL -> Application.VERSION_9;
+ case JAKARTA_EE_8_FULL, JAVA_EE_8_FULL -> Application.VERSION_8;
+ case JAVA_EE_7_FULL -> Application.VERSION_7;
+ case JAVA_EE_6_FULL -> Application.VERSION_6;
+ case JAVA_EE_5 -> Application.VERSION_5;
+ default -> Application.VERSION_8;
+ };
+ }
}
/**
@@ -359,15 +378,16 @@ public RootInterface getDeploymentDescriptor(String location) {
FileObject content = getDeploymentDescriptor();
if (content == null) {
// System.out.println("getDeploymentDescriptor.application dd is null");
- StringInputStream str = new StringInputStream(
- "" +//NOI18N
+ String str =
+ "" + //NOI18N
"description" +//NOI18N
- "" + mavenproject().getMavenProject().getArtifactId() + "");//NOI18N
+ "" + mavenproject().getMavenProject().getArtifactId() + "";//NOI18N
try {
- return DDProvider.getDefault().getDDRoot(new InputSource(str));
- } catch (SAXException ex) {
- ex.printStackTrace();
- } catch (IOException ex) {
+ ByteArrayInputStream bais = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
+ return DDProvider.getDefault().getDDRoot(new InputSource(bais));
+ } catch (SAXException | IOException ex) {
ex.printStackTrace();
}
} else {
@@ -397,7 +417,7 @@ public J2eeModule[] getModules() {
fileNameMapping = "standard"; //NOI18N
}
- List toRet = new ArrayList();
+ List toRet = new ArrayList<>();
EarImpl.MavenModule[] mm = readPomModules();
//#162173 order by dependency list, artifacts is unsorted set.
for (Dependency d : deps) {
@@ -405,7 +425,7 @@ public J2eeModule[] getModules() {
for (Artifact a : artifactSet) {
if (a.getGroupId().equals(d.getGroupId()) &&
a.getArtifactId().equals(d.getArtifactId()) &&
- StringUtils.equals(a.getClassifier(), d.getClassifier())) {
+ Objects.equals(a.getClassifier(), d.getClassifier())) {
URI uri = Utilities.toURI(FileUtil.normalizeFile(a.getFile()));
//#174744 - it's of essence we use the URI based method. items in local repo might not be available yet.
Project owner = FileOwnerQuery.getOwner(uri);
@@ -443,7 +463,7 @@ public J2eeModule[] getModules() {
}
}
}
- return toRet.toArray(new J2eeModule[0]);
+ return toRet.toArray(J2eeModule[]::new);
}
@Override
@@ -453,7 +473,7 @@ public List getProjects() {
Set artifactSet = mp.getArtifacts();
@SuppressWarnings("unchecked")
List deps = mp.getRuntimeDependencies();
- List toRet = new ArrayList();
+ List toRet = new ArrayList<>();
EarImpl.MavenModule[] mm = readPomModules();
//#162173 order by dependency list, artifacts is unsorted set.
for (Dependency d : deps) {
@@ -461,7 +481,7 @@ public List getProjects() {
for (Artifact a : artifactSet) {
if (a.getGroupId().equals(d.getGroupId()) &&
a.getArtifactId().equals(d.getArtifactId()) &&
- StringUtils.equals(a.getClassifier(), d.getClassifier())) {
+ Objects.equals(a.getClassifier(), d.getClassifier())) {
URI uri = Utilities.toURI(FileUtil.normalizeFile(a.getFile()));
//#174744 - it's of essence we use the URI based method. items in local repo might not be available yet.
Project owner = FileOwnerQuery.getOwner(uri);
@@ -540,8 +560,8 @@ public void addCarModule(Car arg0) {
private static final class ContentIterator implements Iterator {
- private List filesUnderRoot;
- private FileObject root;
+ private final List filesUnderRoot;
+ private final FileObject root;
private ContentIterator(FileObject root) {
@@ -562,9 +582,7 @@ public Object next() {
filesUnderRoot.remove(0);
if (nextFile.isFolder()) {
nextFile.refresh();
- for (FileObject child : nextFile.getChildren()) {
- filesUnderRoot.add(child);
- }
+ filesUnderRoot.addAll(Arrays.asList(nextFile.getChildren()));
}
return new RootedFileObject(root, nextFile);
}
@@ -577,8 +595,8 @@ public void remove() {
private static final class RootedFileObject implements J2eeModule.RootedEntry {
- private FileObject file;
- private FileObject root;
+ private final FileObject file;
+ private final FileObject root;
private RootedFileObject(FileObject root, FileObject file) {
@@ -724,10 +742,9 @@ private EarImpl.MavenModule[] readPomModules() {
}
private MavenModule[] checkConfiguration(MavenProject prj, Object conf) {
- List toRet = new ArrayList();
- if (conf instanceof Xpp3Dom) {
+ List toRet = new ArrayList<>();
+ if (conf instanceof Xpp3Dom dom) {
ExpressionEvaluator eval = PluginPropertyUtils.createEvaluator(project);
- Xpp3Dom dom = (Xpp3Dom) conf;
Xpp3Dom modules = dom.getChild("modules"); //NOI18N
if (modules != null) {
int index = 0;
@@ -746,20 +763,16 @@ private MavenModule[] checkConfiguration(MavenProject prj, Object conf) {
} catch (ExpressionEvaluationException e) {
//log silently
}
- if ("groupId".equals(param.getName())) { //NOI18N
- mm.groupId = value;
- } else if ("artifactId".equals(param.getName())) { //NOI18N
- mm.artifactId = value;
- } else if ("classifier".equals(param.getName())) { //NOI18N
- mm.classifier = value;
- } else if ("uri".equals(param.getName())) { //NOI18N
- mm.uri = value;
- } else if ("bundleDir".equals(param.getName())) { //NOI18N
- mm.bundleDir = value;
- } else if ("bundleFileName".equals(param.getName())) { //NOI18N
- mm.bundleFileName = value;
- } else if ("excluded".equals(param.getName())) { //NOI18N
- mm.excluded = Boolean.valueOf(value);
+ if (null != param.getName()) {
+ switch (param.getName()) {
+ case "groupId" -> mm.groupId = value;
+ case "artifactId" -> mm.artifactId = value;
+ case "classifier" -> mm.classifier = value;
+ case "uri" -> mm.uri = value;
+ case "bundleDir"-> mm.bundleDir = value;
+ case "bundleFileName"-> mm.bundleFileName = value;
+ case "excluded"-> mm.excluded = Boolean.parseBoolean(value);
+ }
}
}
}
@@ -769,7 +782,7 @@ private MavenModule[] checkConfiguration(MavenProject prj, Object conf) {
}
}
}
- return toRet.toArray(new MavenModule[0]);
+ return toRet.toArray(MavenModule[]::new);
}
private static class MavenModule {
@@ -836,7 +849,6 @@ String resolveBundleName(String fileNameMapping) {
}
-
private static class ProxyJ2eeModule implements J2eeModuleImplementation2 {
private final J2eeModule module;
private final EarImpl.MavenModule mavenModule;
@@ -897,7 +909,7 @@ public File getDeploymentConfigurationFile(String name) {
public void addPropertyChangeListener(PropertyChangeListener listener) {
module.addPropertyChangeListener(listener);
}
-
+
@Override
public void removePropertyChangeListener(PropertyChangeListener listener) {
module.removePropertyChangeListener(listener);
@@ -905,12 +917,28 @@ public void removePropertyChangeListener(PropertyChangeListener listener) {
@Override
public boolean equals(Object obj) {
- return module.equals(obj);
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ProxyJ2eeModule other = (ProxyJ2eeModule) obj;
+ return Objects.equals(this.module, other.module)
+ && Objects.equals(this.mavenModule, other.mavenModule)
+ && Objects.equals(this.fileNameMapping, other.fileNameMapping);
}
@Override
public int hashCode() {
- return module.hashCode();
+ int hash = 5;
+ hash = 31 * hash + Objects.hashCode(this.module);
+ hash = 31 * hash + Objects.hashCode(this.mavenModule);
+ hash = 31 * hash + Objects.hashCode(this.fileNameMapping);
+ return hash;
}
}
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarModuleProviderImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarModuleProviderImpl.java
index dceb3952c104..e79673782fe7 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarModuleProviderImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ear/EarModuleProviderImpl.java
@@ -19,7 +19,6 @@
package org.netbeans.modules.maven.j2ee.ear;
import java.io.File;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
@@ -32,7 +31,6 @@
import org.netbeans.modules.maven.api.NbMavenProject;
import org.netbeans.api.project.FileOwnerQuery;
import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
import org.netbeans.modules.j2ee.api.ejbjar.Ear;
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.api.ModuleChangeReporter;
@@ -51,7 +49,6 @@
import org.netbeans.spi.project.ProjectServiceProvider;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
/**
* provider for ear specific functionality
@@ -59,10 +56,8 @@
*/
@ProjectServiceProvider(
service = {
- EarModuleProviderImpl.class,
EarProvider.class,
- J2eeModuleProvider.class,
- J2eeApplicationProvider.class
+ J2eeModuleProvider.class
},
projectType = {
"org-netbeans-modules-maven/" + NbMavenProject.TYPE_EAR
@@ -76,6 +71,7 @@ public class EarModuleProviderImpl extends J2eeApplicationProvider implements Ea
private J2eeModule j2eemodule;
private final DeployOnSaveSupport deployOnSaveSupport = new DeployOnSaveSupportProxy();
+ private static final Logger LOGGER = Logger.getLogger(EarModuleProviderImpl.class.getName());
public EarModuleProviderImpl(Project proj) {
@@ -125,10 +121,10 @@ public J2eeModuleProvider getChildModuleProvider(String uri) {
*/
@Override
public J2eeModuleProvider[] getChildModuleProviders() {
- List provs = new ArrayList();
+ List provs = new ArrayList<>();
for (Project prj : earimpl.getProjects()) {
if(prj.getProjectDirectory().equals(project.getProjectDirectory())) {
- Logger.getLogger(EarModuleProviderImpl.class.getName()).log(Level.WARNING, "EarImpl.getProjects() for project {0} returns itself as a child project!", project.getProjectDirectory());
+ LOGGER.log(Level.WARNING, "EarImpl.getProjects() for project {0} returns itself as a child project!", project.getProjectDirectory());
continue;
}
J2eeModuleProvider prv = prj.getLookup().lookup(J2eeModuleProvider.class);
@@ -136,7 +132,7 @@ public J2eeModuleProvider[] getChildModuleProviders() {
provs.add(prv);
}
}
- return provs.toArray(new J2eeModuleProvider[0]);
+ return provs.toArray(J2eeModuleProvider[]::new);
}
@Override
@@ -161,7 +157,7 @@ public EarImpl getEarImpl() {
* Returns source deployment configuration file path for the given deployment
* configuration file name.
*
- * @param name file name of the deployement configuration file.
+ * @param name file name of the deployment configuration file.
* @return non-null absolute path to the deployment configuration file.
*/
public File getDeploymentConfigurationFile(String name) {
@@ -176,13 +172,11 @@ public File getDeploymentConfigurationFile(String name) {
return earimpl.getDDFile(path);
}
-
-
/**
* Finds source deployment configuration file object for the given deployment
* configuration file name.
*
- * @param name file name of the deployement configuration file.
+ * @param name file name of the deployment configuration file.
* @return FileObject of the configuration descriptor file; null if the file does not exists.
*/
public FileObject findDeploymentConfigurationFile(String name) {
@@ -222,13 +216,12 @@ public String getServerID() {
return ExecutionChecker.DEV_NULL;
}
-
@Override
public FileObject[] getSourceRoots() {
ProjectSourcesClassPathProvider cppImpl = project.getLookup().lookup(ProjectSourcesClassPathProvider.class);
ClassPath cp = cppImpl.getProjectSourcesClassPath(ClassPath.SOURCE);
NbMavenProject prj = project.getLookup().lookup(NbMavenProject.class);
- List resUris = new ArrayList();
+ List resUris = new ArrayList<>();
for (URI uri : prj.getResources(false)) {
try {
resUris.add(uri.toURL());
@@ -237,7 +230,7 @@ public FileObject[] getSourceRoots() {
}
}
Iterator en = cp.entries().listIterator();
- List toRet = new ArrayList();
+ List toRet = new ArrayList<>();
int index = 0;
while (en.hasNext()) {
ClassPath.Entry ent = en.next();
@@ -250,7 +243,7 @@ public FileObject[] getSourceRoots() {
toRet.add(ent.getRoot());
}
}
- return toRet.toArray(new FileObject[0]);
+ return toRet.toArray(FileObject[]::new);
}
@Override
@@ -283,7 +276,7 @@ public DeployOnSaveSupport getDeployOnSaveSupport() {
*/
private class DeployOnSaveSupportProxy implements ArtifactListener, DeployOnSaveSupport {
- private final List listeners = new ArrayList();
+ private final List listeners = new ArrayList<>();
public DeployOnSaveSupportProxy() {
super();
@@ -296,7 +289,7 @@ public synchronized void addArtifactListener(ArtifactListener listener) {
boolean register = listeners.isEmpty();
if (listener != null) {
if(listener == DeployOnSaveSupportProxy.this) {
- Logger.getLogger(EarModuleProviderImpl.class.getName()).log(Level.WARNING, "DeployOnSaveSupportProxy.addArtifactListener for project {0} was about to register itself as a listener!", project.getProjectDirectory());
+ LOGGER.log(Level.WARNING, "DeployOnSaveSupportProxy.addArtifactListener for project {0} was about to register itself as a listener!", project.getProjectDirectory());
} else {
listeners.add(listener);
}
@@ -342,7 +335,6 @@ public boolean containsIdeArtifacts() {
}
return false;
}
-
@Override
public void artifactsUpdated(Iterable artifacts) {
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbJarImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbJarImpl.java
index 4d5b2a6f3ae8..198ac42a8270 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbJarImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbJarImpl.java
@@ -39,6 +39,7 @@
import org.netbeans.modules.j2ee.spi.ejbjar.EjbJarImplementation2;
import org.netbeans.modules.javaee.project.api.JavaEEProjectSettings;
import org.netbeans.modules.maven.j2ee.BaseEEModuleImpl;
+import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
@@ -75,24 +76,27 @@ public Profile getJ2eeProfile() {
if (profile != null) {
return profile;
}
- String ver = getModuleVersion();
-
- if (EjbJar.VERSION_4_0.equals(ver)) {
- return Profile.JAKARTA_EE_9_FULL;
- }
- if (EjbJar.VERSION_3_2.equals(ver)) {
- return Profile.JAVA_EE_7_FULL;
+
+ Profile pomProfile = MavenProjectSupport.getProfileFromPOM(project);
+ if (pomProfile != null) {
+ return pomProfile;
}
- if (EjbJar.VERSION_3_1.equals(ver)) {
- return Profile.JAVA_EE_6_FULL;
- }
- if (EjbJar.VERSION_3_0.equals(ver)) {
- return Profile.JAVA_EE_5;
- }
- if (EjbJar.VERSION_2_1.equals(ver)) {
- return Profile.J2EE_14;
+
+ // Should we check CDI(beans.xml) too?
+
+ String ver = getModuleVersion();
+ if (null == ver) {
+ return Profile.JAKARTA_EE_8_FULL;
+ } else {
+ return switch (ver) {
+ case EjbJar.VERSION_4_0 -> Profile.JAKARTA_EE_10_FULL;
+ case EjbJar.VERSION_3_2 -> Profile.JAKARTA_EE_8_FULL;
+ case EjbJar.VERSION_3_1 -> Profile.JAVA_EE_6_FULL;
+ case EjbJar.VERSION_3_0 -> Profile.JAVA_EE_5;
+ case EjbJar.VERSION_2_1 -> Profile.J2EE_14;
+ default -> Profile.JAKARTA_EE_8_FULL;
+ };
}
- return Profile.JAVA_EE_8_FULL;
}
@Override
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbModuleProviderImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbModuleProviderImpl.java
index dab6ec3f038e..4d6593e76eea 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbModuleProviderImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ejb/EjbModuleProviderImpl.java
@@ -40,7 +40,21 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
-@ProjectServiceProvider(service = {EjbModuleProviderImpl.class, J2eeModuleProvider.class, EjbJarProvider.class, EjbJarsInProject.class}, projectType = {"org-netbeans-modules-maven/" + NbMavenProject.TYPE_EJB})
+/**
+ * EJB module provider implementation for maven2 project type.
+ * @author Milos Kleint
+ */
+@ProjectServiceProvider(
+ service = {
+ EjbModuleProviderImpl.class,
+ J2eeModuleProvider.class,
+ EjbJarProvider.class,
+ EjbJarsInProject.class
+ },
+ projectType = {
+ "org-netbeans-modules-maven/" + NbMavenProject.TYPE_EJB
+ }
+)
public class EjbModuleProviderImpl extends BaseEEModuleProvider implements EjbJarProvider, EjbJarsInProject {
private EjbJarImpl ejbimpl;
@@ -62,7 +76,7 @@ public EjbJarImpl getModuleImpl() {
@Override
public EjbJar findEjbJar(FileObject file) {
getModuleImpl();
- Project proj = FileOwnerQuery.getOwner (file);
+ Project proj = FileOwnerQuery.getOwner(file);
if (proj != null) {
proj = proj.getLookup().lookup(Project.class);
}
@@ -81,7 +95,7 @@ public EjbJar findEjbJar(FileObject file) {
public FileObject[] getSourceRoots() {
ProjectSourcesClassPathProvider cppImpl = project.getLookup().lookup(ProjectSourcesClassPathProvider.class);
ClassPath cp = cppImpl.getProjectSourcesClassPath(ClassPath.SOURCE);
- List resUris = new ArrayList();
+ List resUris = new ArrayList<>();
for (URI uri : project.getLookup().lookup(NbMavenProject.class).getResources(false)) {
try {
resUris.add(uri.toURL());
@@ -90,7 +104,7 @@ public FileObject[] getSourceRoots() {
}
}
Iterator en = cp.entries().listIterator();
- List toRet = new ArrayList();
+ List toRet = new ArrayList<>();
int index = 0;
while (en.hasNext()) {
ClassPath.Entry ent = en.next();
@@ -124,7 +138,7 @@ public File[] getRequiredLibraries() {
// do not use COMPILE classpath here because it contains dependencies
// with *provided* scope which should not be deployed
ClassPath cp = cppImpl.getProjectSourcesClassPath(ClassPath.EXECUTE);
- List files = new ArrayList();
+ List files = new ArrayList<>();
for (FileObject fo : cp.getRoots()) {
fo = FileUtil.getArchiveFile(fo);
if (fo == null) {
@@ -132,6 +146,6 @@ public File[] getRequiredLibraries() {
}
files.add(FileUtil.toFile(fo));
}
- return files.toArray(new File[0]);
+ return files.toArray(File[]::new);
}
}
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/SelectAppServerPanel.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/SelectAppServerPanel.java
index 1e3dba953bb4..560dce982690 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/SelectAppServerPanel.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/SelectAppServerPanel.java
@@ -33,6 +33,7 @@
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.modules.j2ee.api.ejbjar.Car;
import org.netbeans.modules.j2ee.api.ejbjar.Ear;
import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
@@ -232,12 +233,23 @@ private void loadComboModel() {
Ear ear = Ear.getEar(project.getProjectDirectory());
EjbJar ejb = EjbJar.getEjbJar(project.getProjectDirectory());
WebModule war = WebModule.getWebModule(project.getProjectDirectory());
- J2eeModule.Type type = ear != null ? J2eeModule.Type.EAR :
- ( war != null ? J2eeModule.Type.WAR :
- (ejb != null ? J2eeModule.Type.EJB : J2eeModule.Type.CAR));
- Profile profile = ear != null ? ear.getJ2eeProfile() :
- ( war != null ? war.getJ2eeProfile() :
- (ejb != null ? ejb.getJ2eeProfile() : Profile.JAVA_EE_6_FULL));
+ Car car = Car.getCar(project.getProjectDirectory());
+
+ J2eeModule.Type type;
+ Profile profile;
+ if (ear != null) {
+ type = J2eeModule.Type.EAR;
+ profile = ear.getJ2eeProfile();
+ } else if (ejb != null) {
+ type = J2eeModule.Type.EJB;
+ profile = ejb.getJ2eeProfile();
+ } else if (war != null) {
+ type = J2eeModule.Type.WAR;
+ profile = war.getJ2eeProfile();
+ } else {
+ type = J2eeModule.Type.CAR;
+ profile = car.getJ2eeProfile();
+ }
String[] ids = Deployment.getDefault().getServerInstanceIDs(Collections.singletonList(type), profile);
Collection col = new ArrayList<>();
col.add(new Server(ExecutionChecker.DEV_NULL));
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunEjb.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunEjb.java
index ca11af1de560..f6bebfbbc17a 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunEjb.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunEjb.java
@@ -38,7 +38,8 @@ public CustomizerRunEjb(ModelHandle2 handle, Project project) {
module = EjbJar.getEjbJar(project.getProjectDirectory());
if (module != null) {
- txtJ2EEVersion.setText(module.getJ2eeProfile().getDisplayName());
+ String profile = module.getJ2eeProfile().getDisplayName();
+ txtJ2EEVersion.setText(profile);
}
initDeployOnSave(jCheckBoxDeployOnSave, dosDescription);
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/EAVisualPanel.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/EAVisualPanel.java
index eed67c5c326f..f86db2ff7c93 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/EAVisualPanel.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/EAVisualPanel.java
@@ -101,7 +101,7 @@ void storeSettings(WizardDescriptor d) {
Profile profile = helper.getSelectedProfile();
if (profile == null) {
- profile = Profile.JAVA_EE_8_FULL;
+ profile = Profile.JAKARTA_EE_8_FULL;
}
helper.storeServerSettings(d);
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/archetype/J2eeArchetypeFactory.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/archetype/J2eeArchetypeFactory.java
index 1e02f73856a0..c5b5a25f300f 100755
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/archetype/J2eeArchetypeFactory.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/wizard/archetype/J2eeArchetypeFactory.java
@@ -74,7 +74,7 @@ public Archetype findArchetypeFor(J2eeModule.Type projectType, Profile profile)
// Such situation might happened if user wants to create project with server that
// doesn't support any of EE version we supported in NetBeans (e.g. Tomcat 5.5)
if (profile == null) {
- profile = Profile.J2EE_14;
+ profile = Profile.JAKARTA_EE_8_FULL;
}
return getProvider(projectType).getArchetypeFor(profile);
}
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/utils/MavenProjectSupport.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/utils/MavenProjectSupport.java
index 6408d1eee826..2016cbe50124 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/utils/MavenProjectSupport.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/utils/MavenProjectSupport.java
@@ -20,7 +20,11 @@
import java.awt.event.ActionEvent;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.BackingStoreException;
@@ -28,11 +32,15 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.SwingUtilities;
+import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.j2ee.core.Profile;
+import org.netbeans.api.java.project.JavaProjectConstants;
+import org.netbeans.api.java.queries.SourceLevelQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.api.project.SourceGroup;
import org.netbeans.modules.j2ee.common.dd.DDHelper;
import org.netbeans.modules.j2ee.common.ui.BrokenServerLibrarySupport;
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
@@ -279,7 +287,7 @@ public static String obtainServerID(String serverInstanceID) {
/**
* Store given property pair to pom.xml file of the given project
*
- * @param projectFile project to which pom.xml should be updated
+ * @param project project to which pom.xml should be updated
* @param name property name
* @param value property value
*/
@@ -482,7 +490,8 @@ public void actionPerformed(ActionEvent e) {
public void run() {
final String newOne = ServerManager.showAddServerInstanceWizard();
final String serverType = newOne != null ? obtainServerID(newOne) : null;
- Utilities.performPOMModelOperations(prj.getProjectDirectory().getFileObject("pom.xml"), Collections.singletonList(new ModelOperation() { //NOI18N
+ final FileObject fileObject = prj.getProjectDirectory().getFileObject("pom.xml"); //NOI18N
+ Utilities.performPOMModelOperations(fileObject, Collections.singletonList(new ModelOperation() {
@Override public void performOperation(POMModel model) {
if (newOne != null) {
Properties props = model.getProject().getProperties();
@@ -523,4 +532,215 @@ public void run() {
});
}
}
+
+ /**
+ * Trying to guess the Java/Jakarta EE version based on the dependency in pom.xml
+ * - See issue #230447
+ * @param project
+ * @return Profile
+ */
+ public static Profile getProfileFromPOM(final Project project) {
+ NbMavenProject nbMavenProject = project.getLookup().lookup(NbMavenProject.class);
+ if (nbMavenProject != null) {
+ MavenProject mavenProject = nbMavenProject.getMavenProject();
+ List dependencies = mavenProject.getDependencies();
+
+ for (Map.Entry> entry : JAKARTA_EE_MAP.entrySet()) {
+ for (DependencyDesc dependencyDesc : entry.getValue()) {
+ Dependency dependency = checkForDependency(dependencies, dependencyDesc);
+ if (dependency != null) {
+ String version = dependency.getVersion();
+ if (dependencyDesc.version() == null || (version != null && version.startsWith(dependencyDesc.version()))) {
+ return entry.getKey();
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * {@link List} containing Java/Jakarta EE implementations described by {@link DependencyDesc}.
+ *
+ * Fore more information see this link.
+ *
+ * In more detail:
+ *
+ * GlassFish:
+ * - 5.0 supports Java EE 8
+ * - 5.1 supports Jakarta EE 8
+ * - 6.0 supports Jakarta EE 9
+ * - 6.1 supports Jakarta EE 9.1
+ * - 6.2 supports Jakarta EE 9.1
+ * - 7.X supports Jakarta EE 10
+ * - 8.X supports Jakarta EE 11
+ * WebLogic:
+ * - 10.X supports Java EE 5
+ * - 12.X supports Java EE 6
+ * - No support for Java EE 7 yet
+ *
+ *
+ */
+ private static final Map> JAKARTA_EE_MAP = new LinkedHashMap<>();
+ static {
+ List javaEE5 = new ArrayList<>();
+ List javaEE6Web = new ArrayList<>();
+ List javaEE6Full = new ArrayList<>();
+ List javaEE7Web = new ArrayList<>();
+ List javaEE7Full = new ArrayList<>();
+ List javaEE8Web = new ArrayList<>();
+ List javaEE8Full = new ArrayList<>();
+ List jakartaEE8Web = new ArrayList<>();
+ List jakartaEE8Full = new ArrayList<>();
+ List jakartaEE9Web = new ArrayList<>();
+ List jakartaEE9Full = new ArrayList<>();
+ List jakartaEE91Web = new ArrayList<>();
+ List jakartaEE91Full = new ArrayList<>();
+ List jakartaEE10Web = new ArrayList<>();
+ List jakartaEE10Full = new ArrayList<>();
+ List jakartaEE11Web = new ArrayList<>();
+ List jakartaEE11Full = new ArrayList<>();
+
+ // The version field from the DependencyDesc Java Record will be
+ // matched with a String.startsWith(...) method, hence the version
+ // should be declared at is minimum expression. e.g
+ // GlassFish 7.0.24 will be matched to 7.0 and return true for
+ // Profile.JakartaEE_10
+
+ // Java/Jakarta EE specification
+ javaEE5.add(new DependencyDesc("javaee", "javaee-api", "5.0"));
+ javaEE5.add(new DependencyDesc("javax", "javaee-web-api", "5.0"));
+ javaEE6Full.add(new DependencyDesc("javax", "javaee-api", "6.0"));
+ javaEE6Web.add(new DependencyDesc("javax", "javaee-web-api", "6.0"));
+ javaEE7Full.add(new DependencyDesc("javax", "javaee-api", "7.0"));
+ javaEE7Web.add(new DependencyDesc("javax", "javaee-web-api", "7.0"));
+ javaEE8Full.add(new DependencyDesc("javax", "javaee-api", "8.0"));
+ javaEE8Web.add(new DependencyDesc("javax", "javaee-web-api", "8.0"));
+ jakartaEE8Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","8.0.0"));
+ jakartaEE8Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","8.0.0"));
+ jakartaEE9Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","9.0.0"));
+ jakartaEE9Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","9.0.0"));
+ jakartaEE91Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","9.1.0"));
+ jakartaEE91Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","9.1.0"));
+ jakartaEE10Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","10.0.0"));
+ jakartaEE10Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","10.0.0"));
+ jakartaEE11Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","11.0.0"));
+ jakartaEE11Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","11.0.0"));
+
+ // GlassFish implementations
+ javaEE5.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "2"));
+ javaEE5.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "2"));
+ javaEE6Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "3"));
+ javaEE6Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "3"));
+ javaEE7Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "4.0"));
+ javaEE7Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "4.0"));
+ javaEE7Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "4.1"));
+ javaEE7Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "4.1"));
+ javaEE8Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "5.0"));
+ javaEE8Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "5.0"));
+ jakartaEE8Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "5.1"));
+ jakartaEE8Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "5.1"));
+ jakartaEE9Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "6.0"));
+ jakartaEE9Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "6.0"));
+ jakartaEE91Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "6.1"));
+ jakartaEE91Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "6.1"));
+ jakartaEE91Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "6.2"));
+ jakartaEE91Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "6.2"));
+ jakartaEE10Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "7.0"));
+ jakartaEE10Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "7.0"));
+ jakartaEE11Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "8.0"));
+ jakartaEE11Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "8.0"));
+
+ // Tomcat implementations
+ javaEE6Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "7"));
+ javaEE7Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "8"));
+ javaEE8Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "9"));
+ jakartaEE8Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "9"));
+ jakartaEE91Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "10.0"));
+ jakartaEE10Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "10.1"));
+ jakartaEE11Web.add(new DependencyDesc("org.apache.tomcat.embed", "tomcat-embed-core", "11"));
+
+
+ // TomEE implementations
+ javaEE7Web.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "7"));
+ javaEE7Full.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "7"));
+ jakartaEE8Web.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "8"));
+ jakartaEE91Full.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "9"));
+ jakartaEE91Web.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "9"));
+ jakartaEE10Full.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "10"));
+ jakartaEE10Web.add(new DependencyDesc("org.apache.tomee", "tomee-embedded", "10"));
+
+ // WebLogic implementations
+ javaEE5.add(new DependencyDesc("weblogic", "weblogic", "10"));
+ javaEE6Full.add(new DependencyDesc("weblogic", "weblogic", "12"));
+
+ // JBoss implementations
+ javaEE5.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-5.0", null));
+ javaEE5.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-5.0", null));
+ javaEE6Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-6.0", null));
+ javaEE6Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-6.0", null));
+ javaEE6Web.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-web-6.0", null));
+ javaEE7Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-7.0", null));
+ javaEE7Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-7.0", null));
+ javaEE7Web.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-web-7.0", null));
+ javaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-8.0", null));
+ javaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-8.0", null));
+ javaEE8Web.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-web-8.0", null));
+ jakartaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-jakartaee-8.0", null));
+ jakartaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-jakartaee-all-8.0", null));
+ jakartaEE8Web.add(new DependencyDesc("org.jboss.spec", "jboss-jakartaee-web-8.0", null));
+
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_11_FULL, jakartaEE11Full);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_11_WEB, jakartaEE11Web);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_10_FULL, jakartaEE10Full);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_10_WEB, jakartaEE10Web);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_9_1_FULL, jakartaEE91Full);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_9_1_WEB, jakartaEE91Web);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_9_FULL, jakartaEE9Full);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_9_WEB, jakartaEE9Web);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_8_FULL, jakartaEE8Full);
+ JAKARTA_EE_MAP.put(Profile.JAKARTA_EE_8_WEB, jakartaEE8Web);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_8_FULL, javaEE8Full);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_8_WEB, javaEE8Web);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_7_FULL, javaEE7Full);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_7_WEB, javaEE7Web);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_6_FULL, javaEE6Full);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_6_WEB, javaEE6Web);
+ JAKARTA_EE_MAP.put(Profile.JAVA_EE_5, javaEE5);
+ }
+
+ private static record DependencyDesc (
+ String groupID,
+ String artifactID,
+ String version) {
+ }
+
+ private static Dependency checkForDependency(List dependencies, DependencyDesc dependencyDesc) {
+ if (dependencies != null) {
+ for (Dependency dependency : dependencies) {
+ if (dependency.getArtifactId().equals(dependencyDesc.artifactID()) && dependency.getGroupId().equals(dependencyDesc.groupID())) {
+ return dependency;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the string representation of the source level.
+ * @param project
+ * @return a source level of the Java file, e.g. "1.8", "11", "21"
+ * or null if the source level is unknown.
+ */
+ public static String getSourceLevel(Project project) {
+ SourceGroup[] srcGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
+ String sl = SourceLevelQuery.getSourceLevel2(srcGroups[0].getRootFolder()).getSourceLevel();
+ int index = sl.indexOf('.'); // NOI18N
+ if (index > 0) {
+ sl = sl.substring(index + 1);
+ }
+ return sl;
+ }
+
}
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleImpl.java
index a2e7324cffe9..a937adaca1ff 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleImpl.java
@@ -22,13 +22,6 @@
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.netbeans.api.j2ee.core.Profile;
import org.netbeans.api.java.classpath.ClassPath;
@@ -47,9 +40,9 @@
import org.netbeans.modules.javaee.project.api.JavaEEProjectSettings;
import org.netbeans.modules.maven.api.Constants;
import org.netbeans.modules.maven.api.FileUtilities;
-import org.netbeans.modules.maven.api.NbMavenProject;
import org.netbeans.modules.maven.api.classpath.ProjectSourcesClassPathProvider;
import org.netbeans.modules.maven.j2ee.BaseEEModuleImpl;
+import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
import org.netbeans.modules.web.spi.webmodule.WebModuleImplementation2;
import org.openide.ErrorManager;
import org.openide.filesystems.FileChangeAdapter;
@@ -133,35 +126,24 @@ public Profile getJ2eeProfile() {
return profile;
}
- Profile pomProfile = getProfileFromPOM(project);
+ Profile pomProfile = MavenProjectSupport.getProfileFromPOM(project);
if (pomProfile != null) {
+ if (pomProfile.isWebProfile()) {
+ return pomProfile;
+ }
// If might happened in cases when WAR project uses Java EE full stack
// Simply return corresponding Web profile until #232478 will be resolved
- if (Profile.JAVA_EE_6_FULL.equals(pomProfile)) {
- return Profile.JAVA_EE_6_WEB;
- }
- if (Profile.JAVA_EE_7_FULL.equals(pomProfile)) {
- return Profile.JAVA_EE_7_WEB;
- }
- if (Profile.JAVA_EE_8_FULL.equals(pomProfile)) {
- return Profile.JAVA_EE_8_WEB;
- }
- if (Profile.JAKARTA_EE_8_FULL.equals(pomProfile)) {
- return Profile.JAKARTA_EE_8_WEB;
- }
- if (Profile.JAKARTA_EE_9_FULL.equals(pomProfile)) {
- return Profile.JAKARTA_EE_9_WEB;
- }
- if (Profile.JAKARTA_EE_9_1_FULL.equals(pomProfile)) {
- return Profile.JAKARTA_EE_9_1_WEB;
- }
- if (Profile.JAKARTA_EE_10_FULL.equals(pomProfile)) {
- return Profile.JAKARTA_EE_10_WEB;
- }
- if (Profile.JAKARTA_EE_11_FULL.equals(pomProfile)) {
- return Profile.JAKARTA_EE_11_WEB;
- }
- return pomProfile;
+ return switch (pomProfile) {
+ case JAVA_EE_6_FULL -> Profile.JAVA_EE_6_WEB;
+ case JAVA_EE_7_FULL -> Profile.JAVA_EE_7_WEB;
+ case JAVA_EE_8_FULL -> Profile.JAVA_EE_8_WEB;
+ case JAKARTA_EE_8_FULL -> Profile.JAKARTA_EE_8_WEB;
+ case JAKARTA_EE_9_FULL -> Profile.JAKARTA_EE_9_WEB;
+ case JAKARTA_EE_9_1_FULL -> Profile.JAKARTA_EE_9_1_WEB;
+ case JAKARTA_EE_10_FULL -> Profile.JAKARTA_EE_10_WEB;
+ case JAKARTA_EE_11_FULL -> Profile.JAKARTA_EE_11_WEB;
+ default -> pomProfile;
+ };
}
Profile descriptorProfile = getProfileFromDescriptor();
@@ -169,7 +151,7 @@ public Profile getJ2eeProfile() {
return descriptorProfile;
}
- return Profile.JAVA_EE_8_WEB;
+ return Profile.JAKARTA_EE_8_WEB;
}
private Profile getProfileFromDescriptor() {
@@ -179,30 +161,18 @@ private Profile getProfileFromDescriptor() {
try {
WebApp wa = prov.getDDRoot(dd);
String waVersion = wa.getVersion();
-
- if (WebApp.VERSION_2_4.equals(waVersion)) {
- return Profile.J2EE_14;
- }
- if (WebApp.VERSION_2_5.equals(waVersion)) {
- return Profile.JAVA_EE_5;
- }
- if (WebApp.VERSION_3_0.equals(waVersion)) {
- return Profile.JAVA_EE_6_WEB;
- }
- if (WebApp.VERSION_3_1.equals(waVersion)) {
- return Profile.JAVA_EE_7_WEB;
- }
- if (WebApp.VERSION_4_0.equals(waVersion)) {
- return Profile.JAKARTA_EE_8_WEB;
- }
- if (WebApp.VERSION_5_0.equals(waVersion)) {
- return Profile.JAKARTA_EE_9_WEB;
- }
- if (WebApp.VERSION_6_0.equals(waVersion)) {
- return Profile.JAKARTA_EE_10_WEB;
- }
- if (WebApp.VERSION_6_1.equals(waVersion)) {
- return Profile.JAKARTA_EE_11_WEB;
+ if (null != waVersion) {
+ return switch (waVersion) {
+ case WebApp.VERSION_2_4 -> Profile.J2EE_14;
+ case WebApp.VERSION_2_5 -> Profile.JAVA_EE_5;
+ case WebApp.VERSION_3_0 -> Profile.JAVA_EE_6_WEB;
+ case WebApp.VERSION_3_1 -> Profile.JAVA_EE_7_WEB;
+ case WebApp.VERSION_4_0 -> Profile.JAKARTA_EE_8_WEB;
+ case WebApp.VERSION_5_0 -> Profile.JAKARTA_EE_9_1_WEB;
+ case WebApp.VERSION_6_0 -> Profile.JAKARTA_EE_10_WEB;
+ case WebApp.VERSION_6_1 -> Profile.JAKARTA_EE_11_WEB;
+ default -> Profile.JAKARTA_EE_8_WEB;
+ };
}
} catch (IOException exc) {
ErrorManager.getDefault().notify(exc);
@@ -211,177 +181,6 @@ private Profile getProfileFromDescriptor() {
return null;
}
- /**
- * {@link List} containing Java EE implementations described by {@link DependencyDesc}.
- *
- * Fore more information see this link.
- *
- * In more detail:
- *
- * GlassFish:
- * - 2.X supports Java EE 5
- * - 3.X supports Java EE 6
- * - 4.X supports Java EE 7
- * WebLogic:
- * - 10.X supports Java EE 5
- * - 12.X supports Java EE 6
- * - No support for Java EE 7 yet
- *
- *
- */
- private static Map> javaEEMap = new LinkedHashMap<>();
- static {
- List javaEE5 = new ArrayList<>();
- List javaEE6Web = new ArrayList<>();
- List javaEE6Full = new ArrayList<>();
- List javaEE7Web = new ArrayList<>();
- List javaEE7Full = new ArrayList<>();
- List javaEE8Web = new ArrayList<>();
- List javaEE8Full = new ArrayList<>();
- List jakartaEE8Web = new ArrayList<>();
- List jakartaEE8Full = new ArrayList<>();
- List jakartaEE9Web = new ArrayList<>();
- List jakartaEE9Full = new ArrayList<>();
- List jakartaEE91Web = new ArrayList<>();
- List jakartaEE91Full = new ArrayList<>();
- List jakartaEE10Web = new ArrayList<>();
- List jakartaEE10Full = new ArrayList<>();
- List jakartaEE11Web = new ArrayList<>();
- List jakartaEE11Full = new ArrayList<>();
-
- // Java EE specification
- javaEE5.add(new DependencyDesc("javaee", "javaee-api", "5.0"));
- javaEE5.add(new DependencyDesc("javax", "javaee-web-api", "5.0"));
- javaEE6Full.add(new DependencyDesc("javax", "javaee-api", "6.0"));
- javaEE6Web.add(new DependencyDesc("javax", "javaee-web-api", "6.0"));
- javaEE7Full.add(new DependencyDesc("javax", "javaee-api", "7.0"));
- javaEE7Web.add(new DependencyDesc("javax", "javaee-web-api", "7.0"));
- javaEE8Full.add(new DependencyDesc("javax", "javaee-api", "8.0"));
- javaEE8Web.add(new DependencyDesc("javax", "javaee-web-api", "8.0"));
- jakartaEE8Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","8.0.0"));
- jakartaEE8Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","8.0.0"));
- jakartaEE9Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","9.0.0"));
- jakartaEE9Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","9.0.0"));
- jakartaEE91Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","9.1.0"));
- jakartaEE91Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","9.1.0"));
- jakartaEE10Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","10.0.0"));
- jakartaEE10Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","10.0.0"));
- jakartaEE11Web.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-api","11.0.0-M1"));
- jakartaEE11Full.add(new DependencyDesc("jakarta.platform","jakarta.jakartaee-web-api","11.0.0-M1"));
-
- // GlassFish implementations
- javaEE5.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "2"));
- javaEE5.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "2"));
- javaEE6Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "3"));
- javaEE6Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "3"));
- javaEE7Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "4.0"));
- javaEE7Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "4.0.1"));
- javaEE7Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "4.1.2"));
- javaEE7Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "4.1.2"));
- javaEE8Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "5.1.0"));
- javaEE8Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "5.1.0"));
- jakartaEE8Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "5.1.0"));
- jakartaEE8Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "5.1.0"));
- jakartaEE9Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "6.0.0"));
- jakartaEE9Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "6.0.0"));
- jakartaEE91Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "6.2.5"));
- jakartaEE91Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "6.2.5"));
- jakartaEE10Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "7.0.11"));
- jakartaEE10Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "7.0.11"));
- jakartaEE11Full.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-all", "8.0.0-M1"));
- jakartaEE11Web.add(new DependencyDesc("org.glassfish.main.extras", "glassfish-embedded-web", "8.0.0-M1"));
-
-
- // WebLogic implementations
- javaEE5.add(new DependencyDesc("weblogic", "weblogic", "10"));
- javaEE6Full.add(new DependencyDesc("weblogic", "weblogic", "12"));
-
- // JBoss implementations
- javaEE5.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-5.0", null));
- javaEE5.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-5.0", null));
- javaEE6Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-6.0", null));
- javaEE6Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-6.0", null));
- javaEE6Web.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-web-6.0", null));
- javaEE7Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-7.0", null));
- javaEE7Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-7.0", null));
- javaEE7Web.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-web-7.0", null));
- javaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-8.0", null));
- javaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-all-8.0", null));
- javaEE8Web.add(new DependencyDesc("org.jboss.spec", "jboss-javaee-web-8.0", null));
- jakartaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-jakartaee-8.0", null));
- jakartaEE8Full.add(new DependencyDesc("org.jboss.spec", "jboss-jakartaee-all-8.0", null));
- jakartaEE8Web.add(new DependencyDesc("org.jboss.spec", "jboss-jakartaee-web-8.0", null));
-
- javaEEMap.put(Profile.JAKARTA_EE_11_FULL, jakartaEE11Full);
- javaEEMap.put(Profile.JAKARTA_EE_11_WEB, jakartaEE11Web);
- javaEEMap.put(Profile.JAKARTA_EE_10_FULL, jakartaEE10Full);
- javaEEMap.put(Profile.JAKARTA_EE_10_WEB, jakartaEE10Web);
- javaEEMap.put(Profile.JAKARTA_EE_9_1_FULL, jakartaEE91Full);
- javaEEMap.put(Profile.JAKARTA_EE_9_1_WEB, jakartaEE91Web);
- javaEEMap.put(Profile.JAKARTA_EE_9_FULL, jakartaEE9Full);
- javaEEMap.put(Profile.JAKARTA_EE_9_WEB, jakartaEE9Web);
- javaEEMap.put(Profile.JAKARTA_EE_8_FULL, jakartaEE8Full);
- javaEEMap.put(Profile.JAKARTA_EE_8_WEB, jakartaEE8Web);
- javaEEMap.put(Profile.JAVA_EE_8_FULL, javaEE8Full);
- javaEEMap.put(Profile.JAVA_EE_8_WEB, javaEE8Web);
- javaEEMap.put(Profile.JAVA_EE_7_FULL, javaEE7Full);
- javaEEMap.put(Profile.JAVA_EE_7_WEB, javaEE7Web);
- javaEEMap.put(Profile.JAVA_EE_6_FULL, javaEE6Full);
- javaEEMap.put(Profile.JAVA_EE_6_WEB, javaEE6Web);
- javaEEMap.put(Profile.JAVA_EE_5, javaEE5);
- }
-
- private static class DependencyDesc {
-
- private final String groupID;
- private final String artifactID;
- private final String version;
-
-
- public DependencyDesc(
- String groupID,
- String artifactID,
- String version) {
-
- this.groupID = groupID;
- this.artifactID = artifactID;
- this.version = version;
- }
- }
-
- // Trying to guess the Java EE version based on the dependency in pom.xml - See issue #230447
- private Profile getProfileFromPOM(final Project project) {
- final NbMavenProject nbMavenProject = project.getLookup().lookup(NbMavenProject.class);
- if (nbMavenProject != null) {
- MavenProject mavenProject = nbMavenProject.getMavenProject();
- List dependencies = mavenProject.getDependencies();
-
- for (Map.Entry> entry : javaEEMap.entrySet()) {
- for (DependencyDesc dependencyDesc : entry.getValue()) {
- Dependency dependency = checkForDependency(dependencies, dependencyDesc);
- if (dependency != null) {
- String version = dependency.getVersion();
- if (dependencyDesc.version == null || (version != null && version.startsWith(dependencyDesc.version))) {
- return entry.getKey();
- }
- }
- }
- }
- }
- return null;
- }
-
- private Dependency checkForDependency(List dependencies, DependencyDesc dependencyDesc) {
- if (dependencies != null) {
- for (Dependency dependency : dependencies) {
- if (dependency.getArtifactId().equals(dependencyDesc.artifactID) && dependency.getGroupId().equals(dependencyDesc.groupID)) {
- return dependency;
- }
- }
- }
- return null;
- }
-
@Override
public File getDDFile(final String path) {
URI webappDir = mavenproject().getWebAppDirectory();
diff --git a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleProviderImpl.java b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleProviderImpl.java
index 123760cd43e4..f9f86563839f 100644
--- a/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleProviderImpl.java
+++ b/enterprise/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebModuleProviderImpl.java
@@ -56,7 +56,7 @@
J2eeModuleProvider.class
},
projectType = {
- "org-netbeans-modules-maven/" + NbMavenProject.TYPE_WAR,
+ "org-netbeans-modules-maven/" + NbMavenProject.TYPE_WAR
}
)
public class WebModuleProviderImpl extends BaseEEModuleProvider implements WebModuleProvider {
diff --git a/enterprise/maven.j2ee/test/unit/src/org/netbeans/modules/maven/j2ee/web/WebModuleImplTest.java b/enterprise/maven.j2ee/test/unit/src/org/netbeans/modules/maven/j2ee/web/WebModuleImplTest.java
index e70edf752d5a..7dce934f3247 100644
--- a/enterprise/maven.j2ee/test/unit/src/org/netbeans/modules/maven/j2ee/web/WebModuleImplTest.java
+++ b/enterprise/maven.j2ee/test/unit/src/org/netbeans/modules/maven/j2ee/web/WebModuleImplTest.java
@@ -151,11 +151,11 @@ public void testGetJ2eeProfile_jakartaEE10WebSpecification() throws IOException
}
public void testGetJ2eeProfile_warProject_jakartaEE11FullSpecification() throws IOException {
- checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "jakarta.platform", "jakarta.jakartaee-api", "11.0.0-M1"); //NOI18N
+ checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "jakarta.platform", "jakarta.jakartaee-api", "11.0.0-RC1"); //NOI18N
}
public void testGetJ2eeProfile_jakartaEE11WebSpecification() throws IOException {
- checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "jakarta.platform", "jakarta.jakartaee-web-api", "11.0.0-M1"); //NOI18N
+ checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "jakarta.platform", "jakarta.jakartaee-web-api", "11.0.0-RC1"); //NOI18N
}
public void testGetJ2eeProfile_javaEE5Full_glassfish() throws IOException {
@@ -215,19 +215,19 @@ public void testGetJ2eeProfile_jakartaEE91Web_glassfish() throws IOException {
}
public void testGetJ2eeProfile_warProject_jakartaEE10Full_glassfish() throws IOException {
- checkJ2eeProfile(Profile.JAKARTA_EE_10_WEB, "org.glassfish.main.extras", "glassfish-embedded-all", "7.0.11"); //NOI18N
+ checkJ2eeProfile(Profile.JAKARTA_EE_10_WEB, "org.glassfish.main.extras", "glassfish-embedded-all", "7.0.24"); //NOI18N
}
public void testGetJ2eeProfile_jakartaEE10Web_glassfish() throws IOException {
- checkJ2eeProfile(Profile.JAKARTA_EE_10_WEB, "org.glassfish.main.extras", "glassfish-embedded-web", "7.0.11"); //NOI18N
+ checkJ2eeProfile(Profile.JAKARTA_EE_10_WEB, "org.glassfish.main.extras", "glassfish-embedded-web", "7.0.24"); //NOI18N
}
public void testGetJ2eeProfile_warProject_jakartaEE11Full_glassfish() throws IOException {
- checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "org.glassfish.main.extras", "glassfish-embedded-all", "8.0.0-M1"); //NOI18N
+ checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "org.glassfish.main.extras", "glassfish-embedded-all", "8.0.0-M11"); //NOI18N
}
public void testGetJ2eeProfile_jakartaEE11Web_glassfish() throws IOException {
- checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "org.glassfish.main.extras", "glassfish-embedded-web", "8.0.0-M1"); //NOI18N
+ checkJ2eeProfile(Profile.JAKARTA_EE_11_WEB, "org.glassfish.main.extras", "glassfish-embedded-web", "8.0.0-M11"); //NOI18N
}
public void testGetJ2eeProfile_javaEE5_weblogic() throws IOException {
diff --git a/enterprise/maven.jaxws/nbproject/project.properties b/enterprise/maven.jaxws/nbproject/project.properties
index d9eb0f68eb69..bb8182b75b7e 100644
--- a/enterprise/maven.jaxws/nbproject/project.properties
+++ b/enterprise/maven.jaxws/nbproject/project.properties
@@ -17,4 +17,4 @@
is.eager=true
javac.compilerargs=-Xlint:unchecked
-javac.source=1.8
+javac.release=17
diff --git a/enterprise/maven.jaxws/nbproject/project.xml b/enterprise/maven.jaxws/nbproject/project.xml
index 5309f332c49c..63434c1b0524 100644
--- a/enterprise/maven.jaxws/nbproject/project.xml
+++ b/enterprise/maven.jaxws/nbproject/project.xml
@@ -25,6 +25,15 @@
org.netbeans.modules.maven.jaxws
+
+ org.netbeans.api.java
+
+
+
+ 1
+ 1.95
+
+
org.netbeans.api.java.classpath
diff --git a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/MavenModelUtils.java b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/MavenModelUtils.java
index fc53f436c49e..97e327f17627 100644
--- a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/MavenModelUtils.java
+++ b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/MavenModelUtils.java
@@ -24,8 +24,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.maven.artifact.Artifact;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.netbeans.api.java.classpath.ClassPath;
@@ -38,10 +36,12 @@
import org.netbeans.modules.maven.model.ModelOperation;
import org.netbeans.modules.maven.model.Utilities;
import org.netbeans.modules.maven.model.pom.Dependency;
-import org.netbeans.modules.maven.model.pom.Repository;
import org.openide.filesystems.FileObject;
import javax.xml.namespace.QName;
import org.apache.maven.project.MavenProject;
+import org.netbeans.api.j2ee.core.Profile;
+import org.netbeans.modules.j2ee.api.ejbjar.Car;
+import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
import org.netbeans.modules.javaee.specs.support.api.JaxWs;
import org.netbeans.modules.maven.model.pom.Build;
import org.netbeans.modules.maven.model.pom.Configuration;
@@ -51,6 +51,7 @@
import org.netbeans.modules.maven.model.pom.Plugin;
import org.netbeans.modules.maven.model.pom.PluginExecution;
import org.netbeans.modules.maven.model.pom.Resource;
+import org.netbeans.modules.web.api.webmodule.WebModule;
import org.netbeans.modules.websvc.wsstack.api.WSStack;
/**
@@ -59,14 +60,30 @@
*/
public final class MavenModelUtils {
+ private static Profile profile;
+
+ // Maven coordinates
private static final String WSIPMORT_GENERATE_PREFIX = "wsimport-generate-"; //NOI18N
private static final String STALE_FILE_DIRECTORY = "${project.build.directory}/jaxws/stale/"; //NOI18N
private static final String STALE_FILE_EXTENSION = ".stale"; //NOI18N
- public static final String JAXWS_GROUP_ID = "org.jvnet.jax-ws-commons"; //NOI18N
+ public static final String JAXWS_GROUP_ID = "com.sun.xml.ws"; //NOI18N
public static final String JAXWS_ARTIFACT_ID = "jaxws-maven-plugin"; //NOI18N
public static final String JAXWS_PLUGIN_KEY = JAXWS_GROUP_ID+":"+JAXWS_ARTIFACT_ID; //NOI18N
private static final String JAXWS_CATALOG = "jax-ws-catalog.xml"; //NOI18N
- public static final String JAX_WS_PLUGIN_VERSION = "2.3"; //NOI18N
+ public static final String JAXWS_JAKARTAEE_8_PLUGIN_VERSION = "2.3.7"; //NOI18N
+ public static final String JAXWS_JAKARTAEE_9_PLUGIN_VERSION = "3.0.2"; //NOI18N
+ public static final String JAXWS_JAKARTAEE_10_PLUGIN_VERSION = "4.0.3"; //NOI18N
+
+ public static final String WEBSERVICES_METRO_GROUP_ID = "org.glassfish.metro"; //NOI18N
+ public static final String WEBSERVICES_API_ARTIFACT_ID = "webservices-api"; //NOI18N
+ public static final String WEBSERVICES_RT_ARTIFACT_ID = "webservices-rt"; //NOI18N
+ public static final String WEBSERVICES_API_JAKARTAEE_8_VERSION = "2.4.10"; //NOI18N
+ public static final String WEBSERVICES_API_JAKARTAEE_9_VERISON = "3.0.3"; //NOI18N
+ public static final String WEBSERVICES_API_JAKARTAEE_10_VERISON = "4.0.4"; //NOI18N
+
+ public static final String MAVEN_PLUGINS_GROUP_ID = "org.apache.maven.plugins"; //NOI18N
+ public static final String WAR_PLUGIN_ARTIFACT_ID = "maven-war-plugin"; //NOI18N
+ public static final String WAR_PLUGIN_VERSION = "3.4.0"; //NOI18N
/**
* adds jaxws plugin, requires the model to have a transaction started,
@@ -100,7 +117,7 @@ public static Plugin addJaxWSPlugin(POMModel model, String jaxWsVersion) {
plugin = model.getFactory().createPlugin();
plugin.setGroupId(JAXWS_GROUP_ID);
plugin.setArtifactId(JAXWS_ARTIFACT_ID);
- plugin.setVersion(JAX_WS_PLUGIN_VERSION);
+ plugin.setVersion(getJaxWsVersion(profile));
bld.addPlugin(plugin);
// setup global configuration
@@ -114,13 +131,10 @@ public static Plugin addJaxWSPlugin(POMModel model, String jaxWsVersion) {
config.setSimpleParameter("verbose", "true"); //NOI18N
config.setSimpleParameter("extension", "true"); //NOI18N
config.setSimpleParameter("catalog", "${basedir}/" + MavenJAXWSSupportImpl.CATALOG_PATH);
- if (jaxWsVersion != null) {
- config.setSimpleParameter("target", jaxWsVersion); //NOI18N
- }
Dependency webservicesDep = model.getFactory().createDependency();
- webservicesDep.setGroupId("javax.xml"); //NOI18N
- webservicesDep.setArtifactId("webservices-api"); //NOI18N
- webservicesDep.setVersion("2.0"); //NOI18N
+ webservicesDep.setGroupId(WEBSERVICES_METRO_GROUP_ID);
+ webservicesDep.setArtifactId(WEBSERVICES_API_ARTIFACT_ID);
+ webservicesDep.setVersion(getMetroVersion(profile));
plugin.addDependency(webservicesDep);
return plugin;
}
@@ -137,12 +151,12 @@ public static Plugin addWarPlugin(POMModel model, boolean client) {
bld = model.getFactory().createBuild();
model.getProject().setBuild(bld);
}
- Plugin plugin = bld.findPluginById("org.apache.maven.plugins", "maven-war-plugin"); //NOI18N
+ Plugin plugin = bld.findPluginById(MAVEN_PLUGINS_GROUP_ID, WAR_PLUGIN_ARTIFACT_ID);
if (plugin == null) {
plugin = model.getFactory().createPlugin();
- plugin.setGroupId("org.apache.maven.plugins"); //NOI18N
- plugin.setArtifactId("maven-war-plugin"); //NOI18N
- plugin.setVersion("2.0.2"); //NOI18N
+ plugin.setGroupId(MAVEN_PLUGINS_GROUP_ID);
+ plugin.setArtifactId(WAR_PLUGIN_ARTIFACT_ID);
+ plugin.setVersion(WAR_PLUGIN_VERSION);
bld.addPlugin(plugin);
}
@@ -158,7 +172,7 @@ public static Plugin addWarPlugin(POMModel model, boolean client) {
config.addExtensibilityElement(webResources);
}
//check for resource containing jax-ws-catalog.xml
- List includes = new ArrayList(2);
+ List includes = new ArrayList<>(4);
Collections.addAll(includes, JAXWS_CATALOG, "wsdl/**"); // NOI18N
if (!hasResource(webResources, JAXWS_CATALOG, "WEB-INF")) { // NOI18N
addResource(model, webResources, "WEB-INF", includes); // NOI18N
@@ -173,7 +187,6 @@ public static Plugin addWarPlugin(POMModel model, boolean client) {
*
* @param handle ModelHandle object
*/
-
public static void addWsdlResources(POMModel model) {
assert model.isIntransaction();
Build bld = model.getProject().getBuild();
@@ -199,7 +212,7 @@ else if ( "src/main/resources".equals(resource.getDirectory())){
Resource res = model.getFactory().createResource();
res.setTargetPath("META-INF"); //NOI18N
res.setDirectory("src"); //NOI18N
- res.addInclude("jax-ws-catalog.xml"); //NOI18N
+ res.addInclude(JAXWS_CATALOG);
res.addInclude("wsdl/**"); //NOI18N
bld.addResource(res);
}
@@ -211,8 +224,6 @@ else if ( "src/main/resources".equals(resource.getDirectory())){
}
-
-
private static POMExtensibilityElement findChild(List elems, String name) {
for (POMExtensibilityElement e : elems) {
if (name.equals(e.getQName().getLocalPart())) {
@@ -404,26 +415,29 @@ public static void addMetroLibrary(Project project) {
scope = Artifact.SCOPE_PROVIDED;
}
ModelUtils.addDependency(project.getProjectDirectory().getFileObject("pom.xml"),
- "org.glassfish.metro",
- "webservices-rt",
- "2.3",
+ WEBSERVICES_METRO_GROUP_ID,
+ WEBSERVICES_RT_ARTIFACT_ID,
+ getMetroVersion(profile),
null, scope, null, false);
}
/** Detect JAX-WS Library in project.
*
* @param project Project
+ * @param isJakartaEENameSpace Project is at least Jakarta EE 9
* @return true if library was detected
*/
- public static boolean hasJaxWsAPI(Project project) {
- SourceGroup[] srcGroups = ProjectUtils.getSources(project).getSourceGroups(
- JavaProjectConstants.SOURCES_TYPE_JAVA);
+ public static boolean hasJaxWsAPI(Project project, boolean isJakartaEENameSpace) {
+ SourceGroup[] srcGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
+ getProfile(project);
if (srcGroups.length > 0) {
ClassPath classPath = ClassPath.getClassPath(srcGroups[0].getRootFolder(), ClassPath.BOOT);
- FileObject wsFeature = classPath.findResource("javax/xml/ws/WebServiceFeature.class"); // NOI18N
+ String wsfClazz = isJakartaEENameSpace ?
+ "jakarta/xml/ws/WebServiceFeature.class" : "javax/xml/ws/WebServiceFeature.class"; // NOI18N
+ FileObject wsFeature = classPath.findResource(wsfClazz);
if (wsFeature == null) {
classPath = ClassPath.getClassPath(srcGroups[0].getRootFolder(), ClassPath.COMPILE);
- wsFeature = classPath.findResource("javax/xml/ws/WebServiceFeature.class"); // NOI18N
+ wsFeature = classPath.findResource(wsfClazz);
if (wsFeature == null) {
return false;
}
@@ -452,7 +466,7 @@ static List getWsdlFiles(Project project) {
assert mavenProject != null;
@SuppressWarnings("unchecked")
List plugins = mavenProject.getBuildPlugins();
- List wsdlList = new ArrayList();
+ List wsdlList = new ArrayList<>();
for (org.apache.maven.model.Plugin plg : plugins) {
if (JAXWS_PLUGIN_KEY.equalsIgnoreCase(plg.getKey())) {
@SuppressWarnings("unchecked")
@@ -503,7 +517,7 @@ private static String findHandler(Xpp3Dom parent) {
private static void updateLibraryScope(POMModel model, String groupId, String targetScope) {
assert model.isIntransaction() : "need to call model modifications under transaction."; //NOI18N
- Dependency wsDep = model.getProject().findDependencyById(groupId, "webservices-rt", null); //NOI18N
+ Dependency wsDep = model.getProject().findDependencyById(groupId, WEBSERVICES_RT_ARTIFACT_ID, null);
if (wsDep != null) {
wsDep.setScope(targetScope);
}
@@ -521,17 +535,17 @@ static void reactOnServerChanges(final Project prj) {
boolean foundMetroDep = false;
String groupId = null;
for (org.apache.maven.model.Dependency dep:deps) {
- if ("com.sun.xml.ws".equals(dep.getGroupId()) && "webservices-rt".equals(dep.getArtifactId())) { //NOI18N
+ if (JAXWS_GROUP_ID.equals(dep.getGroupId()) && WEBSERVICES_RT_ARTIFACT_ID.equals(dep.getArtifactId())) {
String scope = dep.getScope();
metroScope = scope == null ? "compile" : scope; //NOI18N
foundMetroDep = true;
- groupId = "com.sun.xml.ws";
+ groupId = JAXWS_GROUP_ID;
break;
- } else if ("org.glassfish.metro".equals(dep.getGroupId()) && "webservices-rt".equals(dep.getArtifactId())) { //NOI18N
+ } else if (WEBSERVICES_METRO_GROUP_ID.equals(dep.getGroupId()) && WEBSERVICES_RT_ARTIFACT_ID.equals(dep.getArtifactId())) {
String scope = dep.getScope();
metroScope = scope == null ? "compile" : scope; //NOI18N
foundMetroDep = true;
- groupId = "org.glassfish.metro";
+ groupId = WEBSERVICES_METRO_GROUP_ID;
break;
}
}
@@ -622,7 +636,7 @@ public static String getUniqueId(Plugin plugin, String id) {
String result = id;
List executions = plugin.getExecutions();
if (executions != null) {
- Set execIdSet = new HashSet();
+ Set execIdSet = new HashSet<>();
for (PluginExecution ex : executions) {
String execId = ex.getId();
if (execId != null) {
@@ -641,4 +655,82 @@ public static String getUniqueId(Plugin plugin, String id) {
}
return result;
}
+
+ /**
+ * Metro webservices-api/webservices-rt version to use e.g.
+ * {@code Profile.JAKARTA_EE_10_WEB} will return Metro version 4.0.x
+ * @param profile Jakarta EE profile
+ * @return Metro webservices-api/webservices-rt version
+ */
+ private static String getMetroVersion(Profile profile) {
+ if (profile.isAtLeast(Profile.JAKARTA_EE_10_WEB)) {
+ return WEBSERVICES_API_JAKARTAEE_10_VERISON;
+ } else if (profile.isAtLeast(Profile.JAKARTA_EE_9_WEB)) {
+ return WEBSERVICES_API_JAKARTAEE_9_VERISON;
+ } else {
+ return WEBSERVICES_API_JAKARTAEE_8_VERSION;
+ }
+ }
+
+ /**
+ * JAX-WS Plugin to use e.g. {@code Profile.JAKARTA_EE_10_WEB}
+ * will return plugin version 4.0.X
+ * @param profile Jakarta EE profile
+ * @return JAX-WS Plugin version
+ */
+ private static String getJaxWsVersion(Profile profile) {
+ if (profile.isAtLeast(Profile.JAKARTA_EE_10_WEB)) {
+ return JAXWS_JAKARTAEE_10_PLUGIN_VERSION;
+ } else if (profile.isAtLeast(Profile.JAKARTA_EE_9_WEB)) {
+ return JAXWS_JAKARTAEE_9_PLUGIN_VERSION;
+ } else {
+ return JAXWS_JAKARTAEE_8_PLUGIN_VERSION;
+ }
+ }
+
+ /**
+ * Get {@code Profile} to use when generating the web service client, the
+ * {@code Profile} will be computed every time there is a call to
+ * {@code hasJaxWsAPI}.
+ * @param project
+ * @see hasJaxWsAPI
+ */
+ private static void getProfile(Project project) {
+ FileObject projectDirectory = project.getProjectDirectory();
+ if(WSUtils.isWeb(project)) {
+ WebModule wm = WebModule.getWebModule(projectDirectory);
+ profile = wm.getJ2eeProfile();
+ } else if (WSUtils.isEJB(project)) {
+ EjbJar ejbm = EjbJar.getEjbJar(projectDirectory);
+ profile = ejbm.getJ2eeProfile();
+ } else if (WSUtils.isCar(project)) {
+ Car cm = Car.getCar(projectDirectory);
+ profile = cm.getJ2eeProfile();
+ } else if (WSUtils.isJar(project)) {
+ String sourceLevel = WSUtils.getSourceLevel(project);
+ profile = getJarProfile(sourceLevel);
+ } else {
+ profile = Profile.JAKARTA_EE_8_WEB;
+ }
+ }
+
+ /**
+ * Given the source level return an appropriate {@code Profile} to use
+ * with JSE projects to generate web services clients.
+ * @param jseVersion sourceLevel
+ * @return Profile
+ */
+ private static Profile getJarProfile(String jseVersion) {
+ int sourceLevel = Integer.parseInt(jseVersion);
+ if (sourceLevel >= 17) {
+ return Profile.JAKARTA_EE_11_WEB;
+ } else if (sourceLevel >= 11) {
+ return Profile.JAKARTA_EE_10_WEB;
+ } else if (sourceLevel >= 8) {
+ return Profile.JAKARTA_EE_8_WEB;
+ }
+ return Profile.JAKARTA_EE_8_WEB;
+ }
+
+
}
diff --git a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/WSUtils.java b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/WSUtils.java
index 2e7b43e0a994..78696d0b2d25 100644
--- a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/WSUtils.java
+++ b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/WSUtils.java
@@ -39,11 +39,15 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
+import org.netbeans.api.j2ee.core.Profile;
import org.netbeans.api.java.project.JavaProjectConstants;
+import org.netbeans.api.java.queries.SourceLevelQuery;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
+import org.netbeans.modules.j2ee.api.ejbjar.Car;
+import org.netbeans.modules.j2ee.api.ejbjar.EjbJar;
import org.netbeans.modules.j2ee.common.dd.DDHelper;
import org.netbeans.modules.j2ee.dd.api.common.NameAlreadyUsedException;
import org.netbeans.modules.j2ee.dd.api.web.DDProvider;
@@ -52,7 +56,6 @@
import org.netbeans.modules.j2ee.dd.api.web.ServletMapping;
import org.netbeans.modules.j2ee.dd.api.web.ServletMapping25;
import org.netbeans.modules.j2ee.dd.api.web.WebApp;
-import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
import org.netbeans.modules.javaee.specs.support.api.JaxWs;
import org.netbeans.modules.maven.api.NbMavenProject;
@@ -93,7 +96,8 @@ public class WSUtils {
/** downloads XML resources from source URI to target folder
* (USAGE : this method can download a wsdl file and all wsdl/XML schemas,
* that are recursively imported by this wsdl)
- * @param targetFolder A folder inside a NB project (ONLY) to which the retrieved resource will be copied to. All retrieved imported/included resources will be copied relative to this directory.
+ * @param targetFolder A folder inside a NB project (ONLY) to which the retrieved resource will be copied to.
+ * All retrieved imported/included resources will be copied relative to this directory.
* @param source URI of the XML resource that will be retrieved into the project
* @return FileObject of the retrieved resource in the local file system
*/
@@ -137,24 +141,10 @@ public static void generateSunJaxwsFile(final FileObject targetDir) throws IOExc
@Override
public void run() throws IOException {
FileObject sunJaxwsFo = FileUtil.createData(targetDir, "sun-jaxws.xml");//NOI18N
- FileLock lock = sunJaxwsFo.lock();
- BufferedWriter bw = null;
- OutputStream os = null;
- OutputStreamWriter osw = null;
- try {
- os = sunJaxwsFo.getOutputStream(lock);
- osw = new OutputStreamWriter(os, StandardCharsets.UTF_8);
- bw = new BufferedWriter(osw);
+ try (FileLock lock = sunJaxwsFo.lock();
+ BufferedWriter bw = new BufferedWriter(
+ new OutputStreamWriter(sunJaxwsFo.getOutputStream(lock), StandardCharsets.UTF_8))) {
bw.write(sunJaxwsContent);
- } finally {
- if(bw != null)
- bw.close();
- if(os != null)
- os.close();
- if(osw != null)
- osw.close();
- if(lock != null)
- lock.releaseLock();
}
}
});
@@ -168,14 +158,14 @@ private static String readResource(InputStream is) throws IOException {
// read the config from resource first
StringBuffer sb = new StringBuffer();
String lineSep = System.getProperty("line.separator");//NOI18N
- BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
- String line = br.readLine();
- while (line != null) {
- sb.append(line);
- sb.append(lineSep);
- line = br.readLine();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
+ String line = br.readLine();
+ while (line != null) {
+ sb.append(line);
+ sb.append(lineSep);
+ line = br.readLine();
+ }
}
- br.close();
return sb.toString();
}
@@ -206,24 +196,22 @@ public void run() {
}
private static void deleteFile(FileObject f) {
- FileLock lock = null;
try {
DataObject dObj = DataObject.find(f);
if (dObj != null) {
SaveCookie save = dObj.getCookie(SaveCookie.class);
- if (save!=null) save.save();
+ if (save!=null) {
+ save.save();
+ }
+ }
+ try (FileLock lock = f.lock()) {
+ f.delete(lock);
}
- lock = f.lock();
- f.delete(lock);
} catch(java.io.IOException e) {
NotifyDescriptor ndd =
new NotifyDescriptor.Message(NbBundle.getMessage(WSUtils.class, "MSG_Unable_Delete_File", f.getNameExt()),
NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(ndd);
- } finally {
- if(lock != null) {
- lock.releaseLock();
- }
}
}
@@ -257,8 +245,8 @@ private static String getPackageNameFromNamespace(String ns) {
}
StringTokenizer tokens = new StringTokenizer(base,"/"); //NOI18N
if (tokens.countTokens() > 0) {
- List packageParts = new ArrayList();
- List nsParts = new ArrayList();
+ List packageParts = new ArrayList<>();
+ List nsParts = new ArrayList<>();
while (tokens.hasMoreTokens()) {
String part = tokens.nextToken();
if (part.length() >= 0) {
@@ -269,7 +257,7 @@ private static String getPackageNameFromNamespace(String ns) {
StringTokenizer tokens1 = new StringTokenizer(nsParts.get(0),"."); //NOI18N
int countTokens = tokens1.countTokens();
if (countTokens > 0) {
- List list = new ArrayList();
+ List list = new ArrayList<>();
while(tokens1.hasMoreTokens()) {
list.add(tokens1.nextToken());
}
@@ -308,23 +296,56 @@ public static boolean isProjectReferenceable(Project sourceProject, Project targ
}
}
-
public static boolean isEJB(Project project) {
- J2eeModuleProvider j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class);
- if (j2eeModuleProvider != null) {
- J2eeModule.Type moduleType = j2eeModuleProvider.getJ2eeModule().getType();
- if (J2eeModule.Type.EJB.equals(moduleType)) {
- return true;
- }
- }
- return false;
+ String packaging = project.getLookup().lookup(NbMavenProject.class).getPackagingType();
+ return packaging != null && packaging.equals(NbMavenProject.TYPE_EJB);
}
public static boolean isWeb(Project project) {
- J2eeModuleProvider j2eeModuleProvider = project.getLookup().lookup(J2eeModuleProvider.class);
- if (j2eeModuleProvider != null) {
- J2eeModule.Type moduleType = j2eeModuleProvider.getJ2eeModule().getType();
- if (J2eeModule.Type.WAR.equals(moduleType)) {
+ String packaging = project.getLookup().lookup(NbMavenProject.class).getPackagingType();
+ return packaging != null && packaging.equals(NbMavenProject.TYPE_WAR);
+ }
+
+ public static boolean isCar(Project project) {
+ String packaging = project.getLookup().lookup(NbMavenProject.class).getPackagingType();
+ return packaging != null && packaging.equals(NbMavenProject.TYPE_APPCLIENT);
+ }
+
+ public static boolean isJar(Project project) {
+ String packaging = project.getLookup().lookup(NbMavenProject.class).getPackagingType();
+ return packaging != null && packaging.equals(NbMavenProject.TYPE_JAR);
+ }
+
+ /**
+ * Check if this project is at least Jakarta EE 9 and will use the
+ * {@code jakarta.*} namespace. Java SE projects that use source level
+ * equal or greater than 11 should use jakarta namespace.
+ * @param project
+ * @return True if this project use jakarta namespace {@code false} otherwise
+ */
+ public static boolean isJakartaEENameSpace(Project project) {
+
+ FileObject projectDirectory = project.getProjectDirectory();
+ boolean isJakarta;
+ Profile profile;
+ if(isWeb(project)) {
+ WebModule wm = WebModule.getWebModule(projectDirectory);
+ profile = wm.getJ2eeProfile();
+ isJakarta = profile.isAtLeast(Profile.JAKARTA_EE_9_WEB);
+ return isJakarta;
+ } else if (isEJB(project)) {
+ EjbJar ejbm = EjbJar.getEjbJar(projectDirectory);
+ profile = ejbm.getJ2eeProfile();
+ isJakarta = profile.isAtLeast(Profile.JAKARTA_EE_9_WEB);
+ return isJakarta;
+ } else if (isCar(project)) {
+ Car cm = Car.getCar(projectDirectory);
+ profile = cm.getJ2eeProfile();
+ isJakarta = profile.isAtLeast(Profile.JAKARTA_EE_9_WEB);
+ return isJakarta;
+ } else if (isJar(project)) {
+ int sourceLevel = Integer.parseInt(getSourceLevel(project));
+ if (sourceLevel >= 11) {
return true;
}
}
@@ -370,8 +391,8 @@ public void run() {
private static void doUpdateClients(Project prj, JAXWSLightSupport jaxWsSupport) {
// get old clients
- List oldClients = new ArrayList();
- Set oldNames = new HashSet();
+ List oldClients = new ArrayList<>();
+ Set oldNames = new HashSet<>();
for (JaxWsService s : jaxWsSupport.getServices()) {
if (!s.isServiceProvider()) {
oldClients.add(s);
@@ -381,7 +402,7 @@ private static void doUpdateClients(Project prj, JAXWSLightSupport jaxWsSupport)
FileObject wsdlFolder = jaxWsSupport.getWsdlFolder(false);
if (wsdlFolder != null) {
List newClients = getJaxWsClients(prj);
- Set commonNames = new HashSet();
+ Set commonNames = new HashSet<>();
for (JaxWsService client : newClients) {
String id = client.getId();
if (oldNames.contains(id)) {
@@ -412,7 +433,7 @@ private static void doUpdateClients(Project prj, JAXWSLightSupport jaxWsSupport)
private static List getJaxWsClients(Project prj) {
List candidates = MavenModelUtils.getWsdlFiles(prj);
- List clients = new ArrayList();
+ List clients = new ArrayList<>();
for (WsimportPomInfo candidate : candidates) {
if (isClient(prj, candidate)) {
String wsdlPath = candidate.getWsdlPath();
@@ -532,19 +553,10 @@ public static Endpoint addSunJaxWsEntry(FileObject ddFolder, JaxWsService servic
endpoints.findEndpointByImplementation(service.getImplementationClass());
if (oldEndpoint == null) {
Endpoint newEndpoint = addService(endpoints, service);
- FileLock lock = null;
- OutputStream os = null;
synchronized (sunjaxwsFile) {
- try {
- lock = sunjaxwsFile.lock();
- os = sunjaxwsFile.getOutputStream(lock);
+ try (FileLock lock = sunjaxwsFile.lock();
+ OutputStream os = sunjaxwsFile.getOutputStream(lock);) {
endpoints.write(os);
- } finally{
- if (lock != null)
- lock.releaseLock();
-
- if(os != null)
- os.close();
}
}
return newEndpoint;
@@ -564,19 +576,10 @@ private static void addJaxWsEntries(FileObject ddFolder, JAXWSLightSupport jaxWs
addService(endpoints, service);
}
}
- FileLock lock = null;
- OutputStream os = null;
synchronized (sunjaxwsFile) {
- try {
- lock = sunjaxwsFile.lock();
- os = sunjaxwsFile.getOutputStream(lock);
+ try (FileLock lock = sunjaxwsFile.lock();
+ OutputStream os = sunjaxwsFile.getOutputStream(lock)) {
endpoints.write(os);
- } finally{
- if (lock != null)
- lock.releaseLock();
-
- if(os != null)
- os.close();
}
}
}
@@ -598,20 +601,10 @@ public static void removeSunJaxWsEntry(FileObject ddFolder, JaxWsService service
Endpoint endpoint = endpoints.findEndpointByName(service.getServiceName());
if (endpoint != null) {
endpoints.removeEndpoint(endpoint);
- FileLock lock = null;
- OutputStream os = null;
synchronized (sunjaxwsFile) {
- try {
- lock = sunjaxwsFile.lock();
- os = sunjaxwsFile.getOutputStream(lock);
+ try (FileLock lock = sunjaxwsFile.lock();
+ OutputStream os = sunjaxwsFile.getOutputStream(lock)) {
endpoints.write(os);
- } finally {
- if (lock != null) {
- lock.releaseLock();
- }
- if (os != null) {
- os.close();
- }
}
}
}
@@ -636,20 +629,10 @@ public static void replaceSunJaxWsEntries(FileObject ddFolder, String oldService
if (endpoint != null) {
endpoint.setEndpointName(newServiceName);
endpoint.setUrlPattern("/" + newServiceName);
- FileLock lock = null;
- OutputStream os = null;
synchronized (sunjaxwsFile) {
- try {
- lock = sunjaxwsFile.lock();
- os = sunjaxwsFile.getOutputStream(lock);
+ try (FileLock lock = sunjaxwsFile.lock();
+ OutputStream os = sunjaxwsFile.getOutputStream(lock)) {
endpoints.write(os);
- } finally {
- if (lock != null) {
- lock.releaseLock();
- }
- if (os != null) {
- os.close();
- }
}
}
}
@@ -1041,7 +1024,7 @@ public static void checkNonJSR109Entries(Project prj) {
public static String getUniqueId(String id, List services) {
String result = id;
- Set serviceIdSet = new HashSet();
+ Set serviceIdSet = new HashSet<>();
for (JaxWsService s : services) {
String serviceId = s.getId();
if (serviceId != null) {
@@ -1074,4 +1057,20 @@ static boolean isInSourceGroup(Project prj, String serviceClass) {
return false;
}
+ /**
+ * Get the string representation of the source level from a project.
+ * @param project
+ * @return a source level of the Java file, e.g. "8", "11", "21"
+ * or null if the source level is unknown.
+ */
+ public static String getSourceLevel(Project project) {
+ SourceGroup[] srcGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
+ String sl = SourceLevelQuery.getSourceLevel2(srcGroups[0].getRootFolder()).getSourceLevel();
+ int index = sl.indexOf('.'); // NOI18N
+ if (index > 0) {
+ sl = sl.substring(index + 1);
+ }
+ return sl;
+ }
+
}
diff --git a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsClientCreator.java b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsClientCreator.java
index 75bae39d298d..3ed9d740f5dc 100644
--- a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsClientCreator.java
+++ b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsClientCreator.java
@@ -43,6 +43,7 @@
import org.netbeans.modules.maven.model.ModelOperation;
import org.netbeans.modules.maven.model.Utilities;
import org.netbeans.modules.maven.model.pom.POMModel;
+import org.netbeans.modules.maven.model.pom.Plugin;
import org.netbeans.modules.websvc.jaxws.light.api.JAXWSLightSupport;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
@@ -59,6 +60,11 @@ public class JaxWsClientCreator implements ClientCreator {
private Project project;
private WizardDescriptor wiz;
+ private boolean isWeb;
+ private boolean isEJB;
+ private boolean isJakartaEENameSpace;
+
+ private static final Logger LOG = Logger.getLogger(JaxWsClientCreator.class.getCanonicalName());
/**
* Creates a new instance of WebServiceClientCreator
@@ -66,6 +72,9 @@ public class JaxWsClientCreator implements ClientCreator {
public JaxWsClientCreator(Project project, WizardDescriptor wiz) {
this.project = project;
this.wiz = wiz;
+ this.isWeb = WSUtils.isWeb(project);
+ this.isEJB = WSUtils.isEJB(project);
+ this.isJakartaEENameSpace = WSUtils.isJakartaEENameSpace(project);
}
@Override
@@ -89,10 +98,9 @@ public void createClient() throws IOException {
}
if (localWsdlFolder != null) {
- FileObject wsdlFo = retrieveWsdl(wsdlUrl, localWsdlFolder,
- hasSrcFolder);
+ FileObject wsdlFo = retrieveWsdl(wsdlUrl, localWsdlFolder, hasSrcFolder);
if (wsdlFo != null) {
- final boolean isJaxWsLibrary = MavenModelUtils.hasJaxWsAPI(project);
+ final boolean isJaxWsLibrary = MavenModelUtils.hasJaxWsAPI(project, isJakartaEENameSpace);
final String relativePath = FileUtil.getRelativePath(localWsdlFolder, wsdlFo);
final String clientName = wsdlFo.getName();
@@ -107,9 +115,7 @@ public void createClient() throws IOException {
MavenModelUtils.addMetroLibrary(project);
MavenModelUtils.addJavadoc(project);
} catch (Exception ex) {
- Logger.getLogger(
- JaxWsClientCreator.class.getName()).log(
- Level.INFO, "Cannot add Metro libbrary to pom file", ex); //NOI18N
+ LOG.log(Level.INFO, "Cannot add Metro library to pom file", ex); //NOI18N
}
}
@@ -119,20 +125,18 @@ public void createClient() throws IOException {
public void performOperation(POMModel model) {
String packageName = (String) wiz.getProperty(WizardProperties.WSDL_PACKAGE_NAME);
- org.netbeans.modules.maven.model.pom.Plugin plugin =
- WSUtils.isEJB(project) ?
- MavenModelUtils.addJaxWSPlugin(model, "2.0") : //NOI18N
- MavenModelUtils.addJaxWSPlugin(model);
+ Plugin plugin = MavenModelUtils.addJaxWSPlugin(model);
MavenModelUtils.addWsimportExecution(plugin, clientName,
relativePath,wsdlLocation, packageName);
- if (WSUtils.isWeb(project)) { // expecting web project
+ if (isWeb) { // expecting web project
MavenModelUtils.addWarPlugin(model, true);
} else { // J2SE Project
MavenModelUtils.addWsdlResources(model);
}
}
};
+
Utilities.performPOMModelOperations(project.getProjectDirectory().getFileObject("pom.xml"),
Collections.singletonList(operation));
@@ -144,7 +148,7 @@ public void performOperation(POMModel model) {
Collections.singletonList("compile")); //NOI18N
RunUtils.executeMaven(cfg);
- }
+ }
}
}
diff --git a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsServiceCreator.java b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsServiceCreator.java
index 018d36e17547..3f2ebab286d9 100644
--- a/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsServiceCreator.java
+++ b/enterprise/maven.jaxws/src/org/netbeans/modules/maven/jaxws/wizards/JaxWsServiceCreator.java
@@ -88,6 +88,7 @@
import org.netbeans.modules.maven.api.execute.RunConfig;
import org.netbeans.modules.maven.api.execute.RunUtils;
import org.netbeans.modules.maven.jaxws.MavenModelUtils;
+import org.netbeans.modules.maven.model.pom.Plugin;
import org.netbeans.modules.websvc.api.support.java.GenerationUtils;
import org.netbeans.modules.websvc.api.support.java.SourceUtils;
import org.netbeans.modules.websvc.jaxws.light.api.JAXWSLightSupport;
@@ -114,14 +115,19 @@
public class JaxWsServiceCreator implements ServiceCreator {
private static final String SOAP_BINDING_TYPE = "javax.xml.ws.soap.SOAPBinding"; //NOI18N
private static final String BINDING_TYPE_ANNOTATION = "javax.xml.ws.BindingType"; //NOI18N
+ private static final String JAKARTAEE_SOAP_BINDING_TYPE = "jakarta.xml.ws.soap.SOAPBinding"; //NOI18N
+ private static final String JAKARTAEE_BINDING_TYPE_ANNOTATION = "jakarta.xml.ws.BindingType"; //NOI18N
private static final String SOAP12_HTTP_BINDING = "SOAP12HTTP_BINDING"; //NOI18N
private Project project;
private WizardDescriptor wiz;
- private boolean addJaxWsLib;
+ private final boolean addJaxWsLib;
+ private final boolean isWeb;
+ private final boolean isEJB;
+ private final boolean isJakartaEENameSpace;
private int serviceType;
- private static final Logger LOG = Logger.getLogger( JaxWsServiceCreator.class.getCanonicalName());
+ private static final Logger LOG = Logger.getLogger(JaxWsServiceCreator.class.getCanonicalName());
/**
* Creates a new instance of WebServiceClientCreator
@@ -130,6 +136,9 @@ public JaxWsServiceCreator(Project project, WizardDescriptor wiz, boolean addJax
this.project = project;
this.wiz = wiz;
this.addJaxWsLib = addJaxWsLib;
+ this.isWeb = WSUtils.isWeb(project);
+ this.isEJB = WSUtils.isEJB(project);
+ this.isJakartaEENameSpace = WSUtils.isJakartaEENameSpace(project);
}
@Override
@@ -201,11 +210,11 @@ private void generateWebService(ProgressHandle handle) throws IOException {
if (serviceType == WizardProperties.FROM_SCRATCH) {
handle.progress(NbBundle.getMessage(JaxWsServiceCreator.class, "MSG_GEN_WS"), 50); //NOI18N
- //add the JAXWS 2.0 library, if not already added
+ //add the JAX-WS library, if not already added
if (addJaxWsLib) {
MavenModelUtils.addMetroLibrary(project);
}
- generateJaxWSImplFromTemplate(pkg, WSUtils.isEJB(project), false, false);
+ generateJaxWSImplFromTemplate(pkg, isEJB, false, false);
handle.finish();
} else if (serviceType == WizardProperties.ENCAPSULATE_SESSION_BEAN) {
String wsName = Templates.getTargetName(wiz);
@@ -279,7 +288,7 @@ private void generateWsFromWsdl15(final ProgressHandle handle) throws IOExceptio
handle.finish();
}
} else {
- final boolean isJaxWsLibrary = MavenModelUtils.hasJaxWsAPI(project);
+ final boolean isJaxWsLibrary = MavenModelUtils.hasJaxWsAPI(project, isJakartaEENameSpace);
final String relativePath = FileUtil.getRelativePath(localWsdlFolder, wsdlFo);
final String serviceName = wsdlFo.getName();
@@ -294,22 +303,17 @@ private void generateWsFromWsdl15(final ProgressHandle handle) throws IOExceptio
MavenModelUtils.addMetroLibrary(project);
MavenModelUtils.addJavadoc(project);
} catch (Exception ex) {
- Logger.getLogger(
- JaxWsServiceCreator.class.getName()).log(
- Level.INFO, "Cannot add Metro libbrary to pom file", ex); //NOI18N
+ LOG.log(Level.INFO, "Cannot add Metro libbrary to pom file", ex); //NOI18N
}
}
ModelOperation operation = new ModelOperation() {
@Override
public void performOperation(POMModel model) {
- org.netbeans.modules.maven.model.pom.Plugin plugin =
- WSUtils.isEJB(project) ?
- MavenModelUtils.addJaxWSPlugin(model, "2.0") : //NOI18N
- MavenModelUtils.addJaxWSPlugin(model);
+ Plugin plugin = MavenModelUtils.addJaxWSPlugin(model);
MavenModelUtils.addWsimportExecution(plugin,
serviceName, relativePath,null );
- if (WSUtils.isWeb(project)) { // expecting web project
+ if (isWeb) { // expecting web project
MavenModelUtils.addWarPlugin(model, false);
} else { // J2SE Project
MavenModelUtils.addWsdlResources(model);
@@ -340,8 +344,8 @@ public void performOperation(POMModel model) {
}
try {
- String wsdlLocationPrefix = WSUtils.isWeb(project) ? "WEB-INF/wsdl/" : "META-INF/wsdl/"; //NOI18N
- generateJaxWsImplClass(targetFile, wsdlService, wsdlPort, wsdlLocationPrefix+relativePath, useProvider); //NOI18N
+ String wsdlLocationPrefix = isWeb ? "WEB-INF/wsdl/" : "META-INF/wsdl/"; //NOI18N
+ generateJaxWsImplClass(targetFile, wsdlService, wsdlPort, wsdlLocationPrefix+relativePath, useProvider);
DataObject targetDo = DataObject.find(targetFile);
if (targetDo != null) {
SaveCookie save = targetDo.getCookie(SaveCookie.class);
@@ -421,7 +425,9 @@ public void run() {
}
}
- private void generateJaxWsImplClass(FileObject targetFile, final WsdlService service, final WsdlPort port, final String wsdlLocation, final boolean useProvider) throws IOException {
+ private void generateJaxWsImplClass(FileObject targetFile,
+ final WsdlService service, final WsdlPort port,
+ final String wsdlLocation, final boolean useProvider) throws IOException {
final JavaSource targetSource = JavaSource.forFileObject(targetFile);
final boolean[] isIncomplete = new boolean[1];
@@ -436,7 +442,7 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
GenerationUtils genUtils = GenerationUtils.newInstance(workingCopy);
//add @WebService annotation
- List attrs = new ArrayList();
+ List attrs = new ArrayList<>();
attrs.add(
make.Assignment(make.Identifier("serviceName"),
make.Literal(service.getName()))); //NOI18N
@@ -456,23 +462,39 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
make.Assignment(make.Identifier("wsdlLocation"),
make.Literal(wsdlLocation))); //NOI18N
+ final String wspClazz = isJakartaEENameSpace ?
+ "jakarta.xml.ws.WebServiceProvider" : "javax.xml.ws.WebServiceProvider"; //NOI18N
+ final String wsClazz = isJakartaEENameSpace ?
+ "jakarta.jws.WebService" : "javax.jws.WebService"; //NOI18N
AnnotationTree WSAnnotation = make.Annotation(
useProvider ?
- make.QualIdent("javax.xml.ws.WebServiceProvider") : make.QualIdent("javax.jws.WebService"), //NOI18N
- attrs);
+ make.QualIdent(wspClazz) : make.QualIdent(wsClazz), attrs);
+
ClassTree modifiedClass = genUtils.addAnnotation(javaClass,
WSAnnotation);
if (WsdlPort.SOAP_VERSION_12.equals(port.getSOAPVersion())) {
//if SOAP 1.2 binding, add BindingType annotation
- TypeElement bindingElement = workingCopy.getElements().
- getTypeElement(BINDING_TYPE_ANNOTATION);
+ TypeElement bindingElement;
+ if (isJakartaEENameSpace) {
+ bindingElement = workingCopy.getElements().
+ getTypeElement(JAKARTAEE_BINDING_TYPE_ANNOTATION);
+ } else {
+ bindingElement = workingCopy.getElements().
+ getTypeElement(BINDING_TYPE_ANNOTATION);
+ }
if (bindingElement == null) {
isIncomplete[0] = true;
}
else {
- TypeElement soapBindingElement = workingCopy.
- getElements().getTypeElement(SOAP_BINDING_TYPE);
+ TypeElement soapBindingElement;
+ if (isJakartaEENameSpace) {
+ soapBindingElement = workingCopy.
+ getElements().getTypeElement(JAKARTAEE_SOAP_BINDING_TYPE);
+ } else {
+ soapBindingElement = workingCopy.
+ getElements().getTypeElement(SOAP_BINDING_TYPE);
+ }
ExpressionTree exp = make.MemberSelect(
make.QualIdent(soapBindingElement), SOAP12_HTTP_BINDING);
@@ -487,9 +509,11 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
if (!useProvider) {
// add @Stateless annotation
- if (WSUtils.isEJB(project)) {
+ if (isEJB) {
+ final String statelessClazz = isJakartaEENameSpace ?
+ "jakarta.ejb.Stateless" : "javax.ejb.Stateless"; //NOI18N
TypeElement statelessAn = workingCopy.getElements().
- getTypeElement("javax.ejb.Stateless"); //NOI18N
+ getTypeElement(statelessClazz);
if (statelessAn != null) {
AnnotationTree StatelessAnnotation = make.Annotation(
make.QualIdent(statelessAn),
@@ -510,7 +534,7 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
// create parameters
List parameters = operation.getParameters();
- List params = new ArrayList();
+ List params = new ArrayList<>();
for (WsdlParameter parameter : parameters) {
// create parameter:
// final ObjectOutput arg0
@@ -526,7 +550,7 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
// create exceptions
Iterator exceptions = operation.getExceptions();
- List exc = new ArrayList();
+ List exc = new ArrayList<>();
while (exceptions.hasNext()) {
String exception = exceptions.next();
TypeElement excEl = workingCopy.getElements().getTypeElement(exception);
@@ -631,7 +655,9 @@ private void generateWebServiceFromEJB(String wsName, FileObject pkg, Node[] nod
ClassPath classPath = getClassPathForFile(project, createdFile);
if (classPath != null) {
- if (classPath.findResource("javax/ejb/EJB.class") == null) { //NOI19\8N
+ final String ejbClazz = isJakartaEENameSpace ?
+ "jakarta/ejb/EJB.class" : "javax/ejb/EJB.class"; //NOI18N
+ if (classPath.findResource(ejbClazz) == null) {
// ad EJB API on classpath
ContainerClassPathModifier modifier = project.getLookup().lookup(ContainerClassPathModifier.class);
if (modifier != null) {
@@ -732,8 +758,9 @@ public void run() {
}
private VariableTree generateEjbInjection(WorkingCopy workingCopy, TreeMaker make, String beanInterface, boolean[] onClassPath) {
- TypeElement ejbAnElement = workingCopy.getElements().getTypeElement("javax.ejb.EJB"); //NOI18N
- TypeElement interfaceElement = workingCopy.getElements().getTypeElement(beanInterface); //NOI18N
+ final String ejbClazz = isJakartaEENameSpace ? "jakarta.ejb.EJB" : "javax.ejb.EJB"; //NOI18N
+ TypeElement ejbAnElement = workingCopy.getElements().getTypeElement(ejbClazz);
+ TypeElement interfaceElement = workingCopy.getElements().getTypeElement(beanInterface);
AnnotationTree ejbAnnotation = make.Annotation(
make.QualIdent(ejbAnElement),
@@ -761,13 +788,14 @@ private ClassTree generateMethods(WorkingCopy workingCopy,
GeneratorUtilities utils = GeneratorUtilities.get(workingCopy);
List extends Element> interfaceElements = beanInterface.getEnclosedElements();
- TypeElement webMethodEl = workingCopy.getElements().getTypeElement("javax.jws.WebMethod"); //NOI18N
+ final String webMethodClazz = isJakartaEENameSpace ? "jakarta.jws.WebMethod" : "javax.jws.WebMethod"; //NOI18N
+ TypeElement webMethodEl = workingCopy.getElements().getTypeElement(webMethodClazz);
assert (webMethodEl != null);
if (webMethodEl == null) {
return modifiedClass;
}
- Set operationNames = new HashSet();
+ Set operationNames = new HashSet<>();
for (Element el : interfaceElements) {
if (el.getKind() == ElementKind.METHOD) {
ExecutableElement methodEl = (ExecutableElement) el;
@@ -791,8 +819,12 @@ private ClassTree generateMethods(WorkingCopy workingCopy,
// generate @RequestWrapper and @RequestResponse annotations
if (!methodName.contentEquals(operationName)) {
- TypeElement requestWrapperEl = workingCopy.getElements().getTypeElement("javax.xml.ws.RequestWrapper"); //NOI18N
- TypeElement responseWrapperEl = workingCopy.getElements().getTypeElement("javax.xml.ws.ResponseWrapper"); //NOI18N
+ final String reqWrapperClazz = isJakartaEENameSpace ?
+ "jakarta.xml.ws.RequestWrapper" : "javax.xml.ws.RequestWrapper"; //NOI18N
+ final String resWrapperClazz = isJakartaEENameSpace ?
+ "jakarta.xml.ws.ResponseWrapper" : "javax.xml.ws.ResponseWrapper"; //NOI18N
+ TypeElement requestWrapperEl = workingCopy.getElements().getTypeElement(reqWrapperClazz);
+ TypeElement responseWrapperEl = workingCopy.getElements().getTypeElement(resWrapperClazz);
AssignmentTree className = make.Assignment(make.Identifier("className"), make.Literal(operationName)); //NOI18N
AnnotationTree requestWrapperAn = make.Annotation(
make.QualIdent(requestWrapperEl),
@@ -810,7 +842,9 @@ private ClassTree generateMethods(WorkingCopy workingCopy,
// generate @Oneway annotation
if (isVoid && method.getThrows().isEmpty()) {
- TypeElement onewayEl = workingCopy.getElements().getTypeElement("javax.jws.Oneway"); //NOI18N
+ final String oneWayClazz = isJakartaEENameSpace ?
+ "jakarta.jws.Oneway" : "javax.jws.Oneway"; //NOI18N
+ TypeElement onewayEl = workingCopy.getElements().getTypeElement(oneWayClazz);
AnnotationTree onewayAn = make.Annotation(
make.QualIdent(onewayEl),
Collections.emptyList());
@@ -818,9 +852,11 @@ private ClassTree generateMethods(WorkingCopy workingCopy,
}
// parameters
List extends VariableTree> params = method.getParameters();
- List newParams = new ArrayList();
+ List newParams = new ArrayList<>();
if (params.size() > 0) {
- TypeElement paramEl = workingCopy.getElements().getTypeElement("javax.jws.WebParam"); //NOI18N
+ final String webParamClazz = isJakartaEENameSpace ?
+ "jakarta.jws.WebParam" : "javax.jws.WebParam"; //NOI18N
+ TypeElement paramEl = workingCopy.getElements().getTypeElement(webParamClazz);
for (VariableTree param: params) {
String paramName = param.getName().toString();
AssignmentTree nameAttr = make.Assignment(make.Identifier("name"), make.Literal(paramName)); //NOI18N
@@ -833,7 +869,7 @@ private ClassTree generateMethods(WorkingCopy workingCopy,
}
// method body
- List arguments = new ArrayList();
+ List arguments = new ArrayList<>();
for (VariableElement ve : methodEl.getParameters()) {
arguments.add(make.Identifier(ve.getSimpleName()));
}
diff --git a/enterprise/websvc.core/src/org/netbeans/modules/websvc/core/client/wizard/ClientInfo.java b/enterprise/websvc.core/src/org/netbeans/modules/websvc/core/client/wizard/ClientInfo.java
index 7fcfff85573b..1625606a674f 100644
--- a/enterprise/websvc.core/src/org/netbeans/modules/websvc/core/client/wizard/ClientInfo.java
+++ b/enterprise/websvc.core/src/org/netbeans/modules/websvc/core/client/wizard/ClientInfo.java
@@ -37,7 +37,6 @@
import java.net.ProxySelector;
import java.net.URL;
import java.net.URLDecoder;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -75,7 +74,6 @@
import org.netbeans.api.java.project.JavaProjectConstants;
import org.netbeans.api.java.queries.SourceLevelQuery;
-import org.netbeans.api.options.OptionsDisplayer;
import org.netbeans.api.progress.ProgressUtils;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
@@ -1401,6 +1399,7 @@ private J2eePlatform getJ2eePlatform(Project project){
try {
return Deployment.getDefault().getServerInstance(serverInstanceID).getJ2eePlatform();
} catch (InstanceRemovedException ex) {
+ // Probably NO server selected!
Logger.getLogger(getClass().getName()).log(Level.INFO, "Failed to find J2eePlatform", ex);
}
}
diff --git a/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java b/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
index 2deeb9eb1f1a..e998749da6f2 100644
--- a/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
+++ b/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
@@ -243,11 +243,8 @@ public static void saveChanges(AbstractDocumentModel> model) throws IOExceptio
if (fo == null) {
fo = fParentFo.createData(file.getName());
}
- OutputStream os = fo.getOutputStream();
- try {
+ try (OutputStream os = fo.getOutputStream()) {
os.write(text.getBytes(StandardCharsets.UTF_8));
- } finally {
- os.close();
}
}
});