Skip to content

Commit

Permalink
Application deployment support to locally running Payara Server docke…
Browse files Browse the repository at this point in the history
…r container (apache#3330)

* FISH-511 Web Application deployment support to locally running Payara Server docker container

* FISH-511 Javadoc format fix
  • Loading branch information
jGauravGupta authored Feb 2, 2022
1 parent 416e6fb commit 8774f8d
Show file tree
Hide file tree
Showing 17 changed files with 568 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.*;
Expand Down Expand Up @@ -1147,7 +1149,16 @@ private Map<String, List<AppDesc>> processApplications(Map<String,
}
if (path.startsWith("file:")) { // NOI18N
path = path.substring(5);
path = (new File(path)).getAbsolutePath();
if (getInstance().isDocker()
&& getInstance().getHostPath() != null
&& !getInstance().getHostPath().isEmpty()
&& 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 {
path = (new File(path)).getAbsolutePath();
}
}

String enabledKey = "servers.server.server.application-ref."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,25 @@ private static void untagUnderConstruction(String url) {
}
}

@Deprecated
public static PayaraInstance create(String displayName,
String installRoot, String payaraRoot, String domainsDir,
String domainName, int httpPort, int adminPort,
String userName, String password, String target, String url,
PayaraInstanceProvider pip) {
return create(displayName,
installRoot, payaraRoot, domainsDir,
domainName, httpPort, adminPort,
userName, password,
false, null, null,
target, url,
pip);
}

/**
* Creates a PayaraInstance object for a server installation. This
* Creates a PayaraInstance object for a server installation.This
* instance should be added to the the provider registry if the caller wants
* it to be persisted for future sessions or searchable.
* <p/>
* it to be persisted for future sessions or searchable.<p/>
* @param displayName Display name for this server instance.
* @param installRoot Payara installation root directory.
* @param payaraRoot Payara server home directory.
Expand All @@ -368,14 +382,19 @@ private static void untagUnderConstruction(String url) {
* @param adminPort Payara server HTTP port for administration.
* @param userName Payara server administrator's user name.
* @param password Payara server administrator's password.
* @param docker info about Payara server instance is running in docker container
* @param hostPath The docker volume host path
* @param containerPath The docker container path
* @param url Payara server URL (Java EE SPI unique identifier).
* @param pip Payara instance provider.
* @return PayaraInstance object for this server instance.
*/
public static PayaraInstance create(String displayName,
String installRoot, String payaraRoot, String domainsDir,
String domainName, int httpPort, int adminPort,
String userName, String password, String target, String url,
String userName, String password,
boolean docker, String hostPath, String containerPath,
String target, String url,
PayaraInstanceProvider pip) {
Map<String, String> ip = new HashMap<>();
ip.put(PayaraModule.DISPLAY_NAME_ATTR, displayName);
Expand All @@ -392,6 +411,13 @@ public static PayaraInstance create(String displayName,
if (password != null) {
ip.put(PayaraModule.PASSWORD_ATTR, password);
}
ip.put(PayaraModule.DOCKER_ATTR, String.valueOf(docker));
if(hostPath != null) {
ip.put(PayaraModule.HOST_PATH_ATTR, hostPath);
}
if(containerPath != null) {
ip.put(PayaraModule.CONTAINER_PATH_ATTR, containerPath);
}
ip.put(PayaraModule.URL_ATTR, url);
// extract the host from the URL
String[] bigUrlParts = url.split("]");
Expand Down Expand Up @@ -998,6 +1024,55 @@ public String getAdminPassword() {
return properties.get(PayaraModule.PASSWORD_ATTR);
}

/**
* Get information if this Payara server instance is running in docker container.
* <p/>
* @return Value of <code>true</code> when this Payara server instance
* is docker instance or <code>false</code> otherwise.
*/
@Override
public boolean isDocker() {
return Boolean.valueOf(properties.getOrDefault(PayaraModule.DOCKER_ATTR, "false"));
}

/**
* Get the docker volume host path.
* <p/>
* @return The host path.
*/
@Override
public String getHostPath() {
return properties.get(PayaraModule.HOST_PATH_ATTR);
}

/**
* Set the docker volume host path from stored properties.
* <p/>
* @param hostPath the docker volume host path.
*/
public void setHostPath(final String hostPath) {
properties.put(PayaraModule.HOST_PATH_ATTR, hostPath);
}

/**
* Get the docker volume container path.
* <p/>
* @return The container path.
*/
@Override
public String getContainerPath() {
return properties.get(PayaraModule.CONTAINER_PATH_ATTR);
}

/**
* Set the docker volume container path from stored properties.
* <p/>
* @param containerPath the docker volume container path.
*/
public void setContainerPath(final String containerPath) {
properties.put(PayaraModule.CONTAINER_PATH_ATTR, containerPath);
}

/**
* Get Payara server domains folder from stored properties.
* <p/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ InstancePanel.installationLocationField.text=
InstancePanel.domainsFolderField.text=
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
Expand All @@ -164,5 +170,3 @@ 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.hotDeploy.text=Enable Hot Deploy
InstancePanel.showPassword.text=
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,31 @@
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jdbcDriverDeployment" alignment="0" pref="0" max="32767" attributes="0"/>
<Component id="httpMonitor" alignment="0" max="32767" attributes="0"/>
<Component id="commetSupport" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="hostLocalLabel" linkSize="1" alignment="0" min="-2" pref="59" max="-2" attributes="0"/>
<Component id="domainLabel" linkSize="1" alignment="0" min="-2" pref="59" max="-2" attributes="0"/>
<Component id="dasPortLabel" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="userNameLabel" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="preserveSessions" max="32767" attributes="0"/>
<Component id="hotDeploy" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="hostPathLabel" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="hostLocalLabel" linkSize="1" alignment="0" min="-2" pref="59" max="-2" attributes="0"/>
<Component id="domainLabel" linkSize="1" alignment="0" min="-2" pref="59" max="-2" attributes="0"/>
<Component id="dasPortLabel" linkSize="1" alignment="1" max="32767" attributes="0"/>
<Component id="userNameLabel" linkSize="1" alignment="1" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="hostLocalField" pref="207" max="32767" attributes="0"/>
<Component id="hostLocalField" pref="201" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="localIpCB" min="-2" max="-2" attributes="0"/>
</Group>
Expand All @@ -80,12 +95,14 @@
<Component id="domainField" alignment="0" pref="0" max="32767" attributes="0"/>
<Component id="dasPortField" alignment="0" pref="0" max="32767" attributes="0"/>
<Component id="userNameField" alignment="0" pref="0" max="32767" attributes="0"/>
<Component id="hostPathField" alignment="0" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="httpPortLabel" linkSize="1" max="32767" attributes="0"/>
<Component id="targetLabel" linkSize="1" max="32767" attributes="0"/>
<Component id="passwordLabel" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="containerPathLabel" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
Expand All @@ -97,22 +114,11 @@
<Component id="showPassword" min="-2" pref="27" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
</Group>
<Component id="containerPathField" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jdbcDriverDeployment" alignment="0" pref="0" max="32767" attributes="0"/>
<Component id="httpMonitor" alignment="0" max="32767" attributes="0"/>
<Component id="commetSupport" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="preserveSessions" max="32767" attributes="0"/>
<Component id="hotDeploy" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand Down Expand Up @@ -167,18 +173,25 @@
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="hostPathLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="hostPathField" alignment="3" max="32767" attributes="0"/>
<Component id="containerPathLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="containerPathField" alignment="3" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="commetSupport" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="hotDeploy" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="httpMonitor" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="preserveSessions" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jdbcDriverDeployment" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="120" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -432,5 +445,39 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="showPasswordActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="hostPathLabel">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="domainField"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/payara/common/ui/Bundle.properties" key="InstancePanel.hostPathLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="hostPathField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/payara/common/ui/Bundle.properties" key="InstancePanel.hostPathField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="containerPathLabel">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="domainField"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/payara/common/ui/Bundle.properties" key="InstancePanel.containerPathLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="containerPathField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/payara/common/ui/Bundle.properties" key="InstancePanel.containerPathField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
Loading

0 comments on commit 8774f8d

Please sign in to comment.