From e43e28ca5bd90703f21933c97b0b3efa830e121c Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Sun, 12 Jan 2025 13:03:25 +0530 Subject: [PATCH] Payara Server instance running on WSL with deploy-on-save breaks "Web Application" Ant projects Revert distributeOnSave in DeployOnSaveManager Fixes application path to distribute file on save Tooltip for WSL and Docker WSL and Docker configuration in Payara Server Properties panel DeployOnSaveManager deprecated and available for older version (<2.2) --- .../deployment/impl/DeployOnSaveManager.java | 161 ------------------ .../org-netbeans-modules-payara-common.sig | 4 +- .../payara/common/CommonServerSupport.java | 4 + .../modules/payara/common/PayaraInstance.java | 52 ++++-- .../payara/common/ui/Bundle.properties | 13 +- .../payara/common/ui/InstancePanel.form | 71 +++++--- .../payara/common/ui/InstancePanel.java | 128 ++++++++++---- .../wizards/AddDomainLocationVisualPanel.form | 6 + .../wizards/AddDomainLocationVisualPanel.java | 2 + .../payara/common/wizards/Bundle.properties | 2 + .../micro/project/DeployOnSaveManager.java | 1 + .../micro/project/MicroApplication.java | 27 +++ .../micro/project/MicroProjectHook.java | 10 +- .../payara/tooling/utils/ServerUtils.java | 3 + 14 files changed, 254 insertions(+), 230 deletions(-) diff --git a/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java b/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java index d56b996b25a1..8eacd77ee4ba 100644 --- a/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java +++ b/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java @@ -468,12 +468,6 @@ private boolean notifyServer(J2eeModuleProvider provider, Iterable art LOGGER.log(Level.FINEST, builder.toString()); } - try { - distributeOnSave(FileUtil.toFile(provider.getJ2eeModule().getContentDirectory()), artifacts); - } catch (IOException ex) { - LOGGER.log(Level.INFO, null, ex); // NOI18N - } - String instanceID = provider.getServerInstanceID (); ServerInstance inst = ServerRegistry.getInstance ().getServerInstance (instanceID); if (inst == null && "DEV-NULL".equals(instanceID)) { // NOI18N @@ -603,161 +597,6 @@ private void runJPDAAppReloaded() { } } - private void distributeOnSave(File destDir, Iterable artifacts) throws IOException { - - try { - FileObject destRoot = FileUtil.createFolder(destDir); - - // create target FOs map keyed by relative paths - Enumeration destFiles = destRoot.getChildren(true); - Map destMap = new HashMap<>(); - int rootPathLen = destRoot.getPath().length(); - for (; destFiles.hasMoreElements();) { - FileObject destFO = (FileObject) destFiles.nextElement(); - destMap.put(destFO.getPath().substring(rootPathLen + 1), destFO); - } - - FileObject contentDirectory = destRoot; - assert contentDirectory != null; - - for (Artifact artifact : artifacts) { - File fsFile = artifact.getFile(); - File altDistFile = artifact.getDistributionPath(); - if (altDistFile == null) { - String classes = "target" + File.separator + "classes"; - String filePath = artifact.getFile().getPath(); - String altDistRelativePath = filePath.substring(filePath.indexOf(classes) + classes.length()); - altDistFile = new File(destRoot.getPath() + File.separator + "WEB-INF" + File.separator + "classes" + altDistRelativePath); - } - - FileObject file = FileUtil.toFileObject(FileUtil.normalizeFile(fsFile)); - - FileObject checkFile = FileUtil.toFileObject(FileUtil.normalizeFile(altDistFile)); - if (checkFile == null && file != null) { //#165045 - checkFile = FileUtil.createData(altDistFile); - } - - if (checkFile != null && file != null) { - String relative = FileUtil.getRelativePath(contentDirectory, checkFile); - if (relative != null) { - FileObject targetFO = destMap.get(relative); - if (file.isFolder()) { - destMap.remove(relative); - //continue; - } - - createOrReplace(file, targetFO, destRoot, relative, destMap, false); - } - } else if (checkFile != null && file == null) { - checkFile.delete(); - } - } - - } catch (Exception e) { - String msg = NbBundle.getMessage(DeployOnSaveManager.class, "MSG_IncrementalDeployFailed", e); - throw new RuntimeException(msg, e); - } - } - - private void createOrReplace( - FileObject sourceFO, - FileObject targetFO, - FileObject destRoot, - String relativePath, - Map destMap, boolean checkTimeStamps) throws IOException { - - FileObject destFolder; - OutputStream destStream = null; - InputStream sourceStream = null; - - try { - // double check that the target does not exist... 107526 - // the destMap seems to be incomplete.... - if (targetFO == null) { - targetFO = destRoot.getFileObject(relativePath); - } - if (targetFO == null) { - destFolder = findOrCreateParentFolder(destRoot, relativePath); - } else { - // remove from map to form of to-remove-target-list - destMap.remove(relativePath); - - //check timestamp - if (checkTimeStamps) { - if (!sourceFO.lastModified().after(targetFO.lastModified())) { - return; - } - } - if (targetFO.equals(sourceFO)) { - // do not write a file onto itself... - return; - } - destFolder = targetFO.getParent(); - - // we need to rewrite the content of the file here... thanks, - // to windows file locking. - destStream = targetFO.getOutputStream(); - - } - - if (sourceFO.isFolder()) { - FileUtil.createFolder(destFolder, sourceFO.getNameExt()); - return; - } - try { - if (null == destStream) { - FileUtil.copyFile(sourceFO, destFolder, sourceFO.getName()); - } else { - // this is where we need to push the content into the file.... - sourceStream = sourceFO.getInputStream(); - FileUtil.copy(sourceStream, destStream); - } - } catch (FileNotFoundException ex) { - // this may happen when the source file disappears - // perhaps when source is changing rapidly ? - LOGGER.log(Level.INFO, null, ex); - } - } finally { - if (null != sourceStream) { - try { - sourceStream.close(); - } catch (IOException ioe) { - LOGGER.log(Level.WARNING, null, ioe); - } - } - if (null != destStream) { - try { - destStream.close(); - } catch (IOException ioe) { - LOGGER.log(Level.WARNING, null, ioe); - } - } - } - } - - /** - * Find or create parent folder of a file given its root and its - * relative path. The target file does not need to exist. - * - * @param dest FileObject for the root of the target file - * @param relativePath relative path of the target file - * @return the FileObject for the parent folder target file. - * @throws java.io.IOException - */ - private FileObject findOrCreateParentFolder(FileObject dest, String relativePath) throws IOException { - File parentRelativePath = (new File(relativePath)).getParentFile(); - if (parentRelativePath == null) { - return dest; - } - - FileObject folder = FileUtil.createFolder(dest, parentRelativePath.getPath()); - if (folder.isData()) { - LOGGER.log(Level.FINER, "found file {0} when a folder was expecetd", folder.getPath()); - folder = null; - } - return folder; - } - } } diff --git a/enterprise/payara.common/nbproject/org-netbeans-modules-payara-common.sig b/enterprise/payara.common/nbproject/org-netbeans-modules-payara-common.sig index 62718c7d90dc..97cca4ff184b 100644 --- a/enterprise/payara.common/nbproject/org-netbeans-modules-payara-common.sig +++ b/enterprise/payara.common/nbproject/org-netbeans-modules-payara-common.sig @@ -1798,13 +1798,13 @@ meth protected void enableFields() meth protected void initCheckBoxes() meth protected void initCredentials() meth protected void initDirectoriesFields() -meth protected void initDockerVolume() +meth protected void initInstanceType() meth protected void initDomainAndTarget() meth protected void initFlagsFromProperties(org.netbeans.modules.payara.common.ui.InstancePanel$CheckBoxProperties) meth protected void initFormFields() meth protected void storeCheckBoxes() meth protected void storeCredentials() -meth protected void storeDockerVolume() +meth protected void storeInstanceType() meth protected void storeFormFields() meth protected void storeHost() meth protected void storePorts() diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/CommonServerSupport.java b/enterprise/payara.common/src/org/netbeans/modules/payara/common/CommonServerSupport.java index cc4746ef19be..60446815aefc 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/CommonServerSupport.java +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/CommonServerSupport.java @@ -1156,6 +1156,10 @@ && getInstance().getContainerPath() != null && !getInstance().getContainerPath().isEmpty()) { Path relativePath = Paths.get(getInstance().getContainerPath()).relativize(Paths.get(path)); path = Paths.get(getInstance().getHostPath(), relativePath.toString()).toString(); + } else if (getInstance().isWSL()) { + path = path.substring(5); // Remove the "/mnt/" part + path = path.substring(0, 1).toUpperCase() + ":" + path.substring(1); // Capitalize the first letter (drive letter) + path = path.replace("/", "\\"); } else { path = (new File(path)).getAbsolutePath(); } diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/PayaraInstance.java b/enterprise/payara.common/src/org/netbeans/modules/payara/common/PayaraInstance.java index 7a748d157464..1526bc51f9c2 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/PayaraInstance.java +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/PayaraInstance.java @@ -1031,25 +1031,51 @@ public String getAdminPassword() { } /** - * Get information if this Payara server instance is running in docker container. + * Get information if this Payara server instance is running in docker + * container. *

- * @return Value of true when this Payara server instance - * is docker instance or false otherwise. + * @return Value of true when this Payara server instance is + * docker instance or false otherwise. */ @Override public boolean isDocker() { - return Boolean.valueOf(properties.getOrDefault(PayaraModule.DOCKER_ATTR, "false")); + return Boolean.parseBoolean(properties.getOrDefault(PayaraModule.DOCKER_ATTR, "false")); } - + /** - * Get information if this Payara server instance is running in wsl container. + * Sets the flag indicating if this Payara server instance is running in + * Docker container. *

- * @return Value of true when this Payara server instance - * is wsl instance or false otherwise. + * @param isDocker A boolean indicating if the instance is running in + * Docker. + */ + public void setDocker(boolean isDocker) { + properties.put(PayaraModule.DOCKER_ATTR, Boolean.toString(isDocker)); + } + + /** + * Get information if this Payara server instance is running in wsl + * container. + *

+ * @return Value of true when this Payara server instance is + * wsl instance or false otherwise. */ @Override public boolean isWSL() { - return Boolean.valueOf(properties.getOrDefault(PayaraModule.WSL_ATTR, "false")); + return Boolean.parseBoolean(properties.getOrDefault(PayaraModule.WSL_ATTR, "false")); + } + + /** + * Sets the flag indicating if this Payara server instance is running in + * Windows Subsystem for Linux (WSL). + *

+ * @param isWSL A boolean indicating if the instance is running in WSL. + */ + public void setWSL(boolean isWSL) { + properties.put(PayaraModule.WSL_ATTR, Boolean.toString(isWSL)); + if (!isWSL) { + properties.put(PayaraModule.DOMAINS_FOLDER_ATTR, null); + } } /** @@ -1097,7 +1123,13 @@ public void setContainerPath(final String containerPath) { */ @Override public String getDomainsFolder() { - return properties.get(PayaraModule.DOMAINS_FOLDER_ATTR); + String domainsDir = properties.get(PayaraModule.DOMAINS_FOLDER_ATTR); + if(isDocker()) { + return null; + } else if(isWSL() && domainsDir == null) { + domainsDir = getPayaraRoot() + File.separator + "domains"; + } + return domainsDir; } /** diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/Bundle.properties b/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/Bundle.properties index d88a6dea44a4..14e0e2ff3e38 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/Bundle.properties +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/Bundle.properties @@ -156,10 +156,6 @@ InstancePanel.userNameField.text= InstancePanel.hostRemoteField.text= InstancePanel.hotDeploy.text=Enable Hot Deploy InstancePanel.showPassword.text= -InstancePanel.hostPathLabel.text=Host Path: -InstancePanel.hostPathField.text= -InstancePanel.containerPathLabel.text=Container Path: -InstancePanel.containerPathField.text= ConnectionPoolAdvancedAttributesCustomizer.logJDBCCallsCheckbox.text=Enable ConnectionPoolAdvancedAttributesCustomizer.logJDBCCallsLabel.text=Log JDBC Calls: ConnectionPoolAdvancedAttributesCustomizer.logJDBCCallsLayeredPane.toolTipText=When set to true, all JDBC calls will be logged allowing tracing of all JDBC interactions including SQL @@ -170,3 +166,12 @@ ConnectionPoolAdvancedAttributesCustomizer.slowQueryLogThresholdLayeredPane.tool ConnectionPoolAdvancedAttributesCustomizer.sqlTraceListenersTextField.text= ConnectionPoolAdvancedAttributesCustomizer.sqlTraceListenersLabel.text=SQL Trace Listeners: ConnectionPoolAdvancedAttributesCustomizer.sqlTraceListenersLayeredPane.toolTipText=Comma-separated list of classes that implement the org.glassfish.api.jdbc.SQLTraceListener interface +InstancePanel.dockerInstance.text=Docker Volume +InstancePanel.wslInstance.text=WSL +InstancePanel.dockerInstance.toolTipText=Enable this option to connect with a Payara Server instance hosted in a Docker container. +InstancePanel.wslInstance.toolTipText=Enable WSL integration to connect with a Payara Server instance running inside Windows Subsystem for Linux. The host IP can be determined using the 'hostname -I' command in WSL. +InstancePanel.hostPathField.text= +InstancePanel.containerPathField.text= +InstancePanel.hostPathLabel.text=Host Path: +InstancePanel.containerPathLabel.text=Container Path: +InstancePanel.instanceTypeLabel.text=Instance Type: diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.form b/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.form index 2593ceaf16a5..cf49e36b86a4 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.form +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.form @@ -57,7 +57,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -76,6 +76,7 @@ + @@ -86,7 +87,7 @@ - + @@ -94,27 +95,28 @@ - - + + + - + - + - + @@ -173,11 +175,16 @@ + + + + + - + - + @@ -189,9 +196,9 @@ - + - + @@ -445,39 +452,63 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.java b/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.java index e4e4f4b6d82b..0219cb7c23cb 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.java +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/ui/InstancePanel.java @@ -351,7 +351,14 @@ protected void initCredentials() { * Initialize host path and container path with values stored in Payara * instance object. */ - protected void initDockerVolume() { + protected void initInstanceType() { + if (instance.isDocker()) { + instanceTypeComboBox.setSelectedItem(DOCKER_INSTANCE); + } else if(instance.isWSL()) { + instanceTypeComboBox.setSelectedItem(WSL_INSTANCE); + } else { + instanceTypeComboBox.setSelectedItem(DEFAULT_INSTANCE); + } hostPathField.setText(instance.getHostPath()); containerPathField.setText(instance.getContainerPath()); } @@ -499,12 +506,29 @@ protected void storeCredentials() { } /** - * Docker volume path storage. + * Stores the instance type and related paths into the Payara instance + * object. + *

+ * This method checks the selected instance type from the combo box and + * updates the Payara instance accordingly. It also stores the host path and + * container path if they differ from the values stored in the instance + * object. *

- * Store docker volume path when form fields values differs from Payara - * instance properties. + * The instance type can be one of the following: Docker, WSL, or None. If + * Docker is selected, both host path and container path fields are enabled. + * Otherwise, they are disabled. */ - protected void storeDockerVolume() { + protected void storeInstanceType() { + if (instanceTypeComboBox.getSelectedItem().equals(DOCKER_INSTANCE)) { + instance.setDocker(true); + instance.setWSL(false); + } else if (instanceTypeComboBox.getSelectedItem().equals(WSL_INSTANCE)) { + instance.setWSL(true); + instance.setDocker(false); + } else { + instance.setWSL(false); + instance.setDocker(false); + } final String hostPath = hostPathField.getText().trim(); if (!hostPath.equals(instance.getHostPath())) { instance.setHostPath(hostPath); @@ -514,7 +538,7 @@ protected void storeDockerVolume() { instance.setContainerPath(containerPath); } } - + /** * Enable form fields that can be modified by user. *

@@ -530,14 +554,20 @@ protected void enableFields() { targetField.setEnabled(true); userNameField.setEnabled(true); passwordField.setEnabled(true); - hostPathField.setEnabled(true); - containerPathField.setEnabled(true); commetSupport.setEnabled(true); httpMonitor.setEnabled(true); jdbcDriverDeployment.setEnabled(true); hotDeploy.setEnabled(instance.isHotDeployFeatureAvailable()); showPassword.setEnabled(true); preserveSessions.setEnabled(true); + instanceTypeComboBox.setEnabled(true); + if (instanceTypeComboBox.getSelectedItem().equals(DOCKER_INSTANCE)) { + hostPathField.setEnabled(true); + containerPathField.setEnabled(true); + } else { + hostPathField.setEnabled(false); + containerPathField.setEnabled(false); + } } /** @@ -558,14 +588,15 @@ protected void disableAllFields() { targetField.setEnabled(false); userNameField.setEnabled(false); passwordField.setEnabled(false); - hostPathField.setEnabled(false); - containerPathField.setEnabled(false); commetSupport.setEnabled(false); httpMonitor.setEnabled(false); jdbcDriverDeployment.setEnabled(false); hotDeploy.setEnabled(false); showPassword.setEnabled(false); preserveSessions.setEnabled(false); + instanceTypeComboBox.setEnabled(false); + hostPathField.setEnabled(false); + containerPathField.setEnabled(false); } /** @@ -579,7 +610,7 @@ protected void initFormFields() { initHost(); initDomainAndTarget(); initCredentials(); - initDockerVolume(); + initInstanceType(); initCheckBoxes(); updatePasswordVisibility(); // do the magic according to loopback checkbox @@ -596,7 +627,7 @@ protected void storeFormFields() { storePorts(); storeTarget(); storeCredentials(); - storeDockerVolume(); + storeInstanceType(); storeCheckBoxes(); } @@ -673,10 +704,12 @@ private void initComponents() { hostRemoteField = new javax.swing.JTextField(); hotDeploy = new javax.swing.JCheckBox(); showPassword = new javax.swing.JToggleButton(); - hostPathLabel = new javax.swing.JLabel(); - hostPathField = new javax.swing.JTextField(); - containerPathLabel = new javax.swing.JLabel(); + instanceTypeLabel = new javax.swing.JLabel(); containerPathField = new javax.swing.JTextField(); + containerPathLabel = new javax.swing.JLabel(); + hostPathField = new javax.swing.JTextField(); + hostPathLabel = new javax.swing.JLabel(); + instanceTypeComboBox = new javax.swing.JComboBox<>(); setName(org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstanceLocalPanel.displayName")); // NOI18N setPreferredSize(new java.awt.Dimension(602, 304)); @@ -782,15 +815,26 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); - hostPathLabel.setLabelFor(domainField); - org.openide.awt.Mnemonics.setLocalizedText(hostPathLabel, org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.hostPathLabel.text")); // NOI18N + instanceTypeLabel.setLabelFor(dasPortField); + org.openide.awt.Mnemonics.setLocalizedText(instanceTypeLabel, org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.instanceTypeLabel.text")); // NOI18N - hostPathField.setText(org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.hostPathField.text")); // NOI18N + containerPathField.setText(org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.containerPathField.text")); // NOI18N - containerPathLabel.setLabelFor(domainField); + containerPathLabel.setLabelFor(httpPortField); org.openide.awt.Mnemonics.setLocalizedText(containerPathLabel, org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.containerPathLabel.text")); // NOI18N - containerPathField.setText(org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.containerPathField.text")); // NOI18N + hostPathField.setText(org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.hostPathField.text")); // NOI18N + + hostPathLabel.setLabelFor(dasPortField); + org.openide.awt.Mnemonics.setLocalizedText(hostPathLabel, org.openide.util.NbBundle.getMessage(InstancePanel.class, "InstancePanel.hostPathLabel.text")); // NOI18N + + instanceTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(getInstanceTypes())); + instanceTypeComboBoxActionPerformed(null); + instanceTypeComboBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + instanceTypeComboBoxActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -807,7 +851,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(domainsFolderField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) - .addComponent(installationLocationField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) + .addComponent(installationLocationField) .addComponent(hostRemoteField))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) @@ -821,6 +865,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(hostPathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(instanceTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(hostLocalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(domainLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -829,31 +874,32 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(hostLocalField, 0, 201, Short.MAX_VALUE) + .addComponent(hostLocalField, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(localIpCB)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(domainField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) .addComponent(dasPortField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) - .addComponent(userNameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) - .addComponent(hostPathField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)) + .addComponent(userNameField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE) + .addComponent(hostPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) + .addComponent(instanceTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(httpPortLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(targetLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(passwordLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(containerPathLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)) + .addComponent(containerPathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(httpPortField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) .addComponent(targetField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() - .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(passwordField, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(showPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(2, 2, 2)) - .addComponent(containerPathField, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE)))))) + .addComponent(containerPathField, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)))))) .addContainerGap()) ); @@ -902,11 +948,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(passwordLabel) .addComponent(userNameLabel))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(instanceTypeLabel) + .addComponent(instanceTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(hostPathLabel) - .addComponent(hostPathField) + .addComponent(hostPathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(containerPathLabel) - .addComponent(containerPathField)) + .addComponent(containerPathField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(commetSupport) @@ -915,12 +965,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(httpMonitor) .addComponent(preserveSessions)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jdbcDriverDeployment) .addContainerGap()) ); }// //GEN-END:initComponents + private final static String DEFAULT_INSTANCE = "None"; + private final static String DOCKER_INSTANCE = "Docker"; + private final static String WSL_INSTANCE = "WSL"; + + private String[] getInstanceTypes() { + return new String[] { + DEFAULT_INSTANCE, DOCKER_INSTANCE, WSL_INSTANCE + }; + } + private void commetSupportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_commetSupportActionPerformed cometSupportFlag = commetSupport.isSelected(); }//GEN-LAST:event_commetSupportActionPerformed @@ -961,6 +1021,12 @@ private void hotDeployActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR hotDeployFlag = hotDeploy.isSelected(); }//GEN-LAST:event_hotDeployActionPerformed + private void instanceTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_instanceTypeComboBoxActionPerformed + boolean isDockerInstance = instanceTypeComboBox.getSelectedItem().equals(DOCKER_INSTANCE); + hostPathField.setEnabled(isDockerInstance); + containerPathField.setEnabled(isDockerInstance); + }//GEN-LAST:event_instanceTypeComboBoxActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables protected javax.swing.JCheckBox commetSupport; protected javax.swing.JTextField containerPathField; @@ -983,6 +1049,8 @@ private void hotDeployActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR protected javax.swing.JLabel httpPortLabel; protected javax.swing.JTextField installationLocationField; protected javax.swing.JLabel installationLocationLabel; + protected javax.swing.JComboBox instanceTypeComboBox; + protected javax.swing.JLabel instanceTypeLabel; protected javax.swing.JCheckBox jdbcDriverDeployment; protected javax.swing.JCheckBox localIpCB; protected javax.swing.JPasswordField passwordField; diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.form b/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.form index 64e40eee70c0..ae28ac2c24f4 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.form +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.form @@ -464,6 +464,9 @@ + + + @@ -490,6 +493,9 @@ + + + diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.java b/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.java index 6d3cdea181c2..67866c01d50f 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.java +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/AddDomainLocationVisualPanel.java @@ -563,6 +563,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { containerPathLabel.setMinimumSize(new java.awt.Dimension(100, 14)); dockerVolumeCheckBox.setText(org.openide.util.NbBundle.getMessage(AddDomainLocationVisualPanel.class, "AddDomainLocationVisualPanel.dockerVolumeCheckBox.text")); // NOI18N + dockerVolumeCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(AddDomainLocationVisualPanel.class, "AddDomainLocationVisualPanel.dockerVolumeCheckBox.toolTipText")); // NOI18N dockerVolumeCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { dockerVolumeCheckBoxActionPerformed(evt); @@ -576,6 +577,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { containerPathField.setText(org.openide.util.NbBundle.getMessage(AddDomainLocationVisualPanel.class, "AddDomainLocationVisualPanel.containerPathField.text")); // NOI18N wslCheckBox.setText(org.openide.util.NbBundle.getMessage(AddDomainLocationVisualPanel.class, "AddDomainLocationVisualPanel.wslCheckBox.text")); // NOI18N + wslCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(AddDomainLocationVisualPanel.class, "AddDomainLocationVisualPanel.wslCheckBox.toolTipText")); // NOI18N wslCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { wslCheckBoxActionPerformed(evt); diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/Bundle.properties b/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/Bundle.properties index 5d7407e0607e..8bff8c065db2 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/Bundle.properties +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/wizards/Bundle.properties @@ -179,3 +179,5 @@ AddDomainLocationVisualPanel.hostPathField.text= AddDomainLocationVisualPanel.containerPathField.text= AddDomainLocationVisualPanel.dockerVolumeCheckBox.text=Docker Volume AddDomainLocationVisualPanel.wslCheckBox.text=WSL +AddDomainLocationVisualPanel.wslCheckBox.toolTipText=Enable WSL integration to connect with a Payara Server instance running inside Windows Subsystem for Linux. The host IP can be determined using the 'hostname -I' command in WSL. +AddDomainLocationVisualPanel.dockerVolumeCheckBox.toolTipText=Enable this option to connect with a Payara Server instance hosted in a Docker container. diff --git a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java index c75aa62c3e89..a9849ae40dc3 100644 --- a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java +++ b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java @@ -59,6 +59,7 @@ import org.openide.util.NbBundle; import static org.openide.util.NbBundle.getMessage; +@Deprecated public final class DeployOnSaveManager { public static enum DeploymentState { diff --git a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroApplication.java b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroApplication.java index 6c9792439735..e7bb66c9c88d 100644 --- a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroApplication.java +++ b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroApplication.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; import org.netbeans.api.project.Project; import static org.netbeans.modules.fish.payara.micro.plugin.Constants.PAYARA_MICRO_MAVEN_PLUGIN; @@ -171,4 +172,30 @@ public static boolean isPayaraMicroProject(Project project) { .get(PAYARA_MICRO_MAVEN_PLUGIN) != null; } + public static Artifact getPayaraMicroProject(Project project) { + NbMavenProject nbMavenProject = project.getLookup().lookup(NbMavenProject.class); + MavenProject mavenProject = nbMavenProject.getMavenProject(); + return mavenProject.getPluginArtifactMap() + .get(PAYARA_MICRO_MAVEN_PLUGIN); + } + + public static boolean isDevModeAvailable(Project project) { + if (isPayaraMicroProject(project)) { + String versionString = getPayaraMicroProject(project).getVersion(); + if (versionString != null) { + try { + double version = Double.parseDouble(versionString); + if (version > 2.1) { + return true; + } + } catch (NumberFormatException e) { + if ("RELEASE".equals(versionString)) { + return true; + } + } + } + } + return false; + } + } diff --git a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroProjectHook.java b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroProjectHook.java index 8b3dc1dbd5c7..d13d0a9a8649 100644 --- a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroProjectHook.java +++ b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/MicroProjectHook.java @@ -46,7 +46,9 @@ public MicroProjectHook(Project project) { @Override public void projectOpened() { if (MicroApplication.getInstance(project) != null) { - addDeployOnSaveManager(project); + if (!MicroApplication.isDevModeAvailable(project)) { + addDeployOnSaveManager(project); + } updateMicroIcon(); } } @@ -54,10 +56,12 @@ public void projectOpened() { @Override public void projectClosed() { if (MicroApplication.getInstance(project) != null) { - removeDeployOnSaveManager(project); + if (!MicroApplication.isDevModeAvailable(project)) { + removeDeployOnSaveManager(project); + } } } - + private void updateMicroIcon() { SpecialIcon specialIcon = project.getLookup().lookup(SpecialIcon.class); MicroIcon microIcon; diff --git a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/utils/ServerUtils.java b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/utils/ServerUtils.java index 4697d1da1f93..ef0fff2a51a4 100644 --- a/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/utils/ServerUtils.java +++ b/enterprise/payara.tooling/src/org/netbeans/modules/payara/tooling/utils/ServerUtils.java @@ -856,6 +856,9 @@ public static String serverLogFileRelativePath() { public static String getDomainPath(final PayaraServer server) { String domainName = server.getDomainName(); String domainsFolder = server.getDomainsFolder(); + if(domainsFolder == null) { + return null; + } boolean appendSeparator = domainsFolder.lastIndexOf(File.separator) + OsUtils.FILE_SEPARATOR_LENGTH != domainsFolder.length(); StringBuilder sb = new StringBuilder(domainsFolder.length()