Skip to content

Commit be9522a

Browse files
authored
Merge pull request #68 from jGauravGupta/FISH-7326
FISH-7326 Eclipse support Payara Server running on WSL
2 parents 7b000d6 + 3ab32a9 commit be9522a

9 files changed

Lines changed: 63 additions & 17 deletions

File tree

bundles/fish.payara.eclipse.tools.micro/src/fish/payara/eclipse/tools/micro/ui/wizards/MicroProjectWizardPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void createControl(Composite parent) {
6060
createUI(composite);
6161
validate();
6262
createAdvancedSettings(composite, new GridData(SWT.FILL, SWT.TOP, false, false, 3, 1));
63-
resolverConfigurationComponent.setModifyListener(e -> validate());
63+
// resolverConfigurationComponent.setModifyListener(e -> validate());
6464
setControl(composite);
6565
}
6666

bundles/fish.payara.eclipse.tools.server/plugin.xml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@
686686
class="fish.payara.eclipse.tools.server.handlers.PayaraStateTester"
687687
id="fish.payara.eclipse.tools.server.PayaraStateTester"
688688
namespace="fish.payara.eclipse.tools.server"
689-
properties="isRunning,isRemote"
689+
properties="isRunning,isRemote,isWSLInstance"
690690
type="org.eclipse.wst.server.core.IServer">
691691
</propertyTester>
692692
<propertyTester
@@ -739,6 +739,16 @@
739739
</and>
740740
</adapt>
741741
</definition>
742+
<definition id="fish.payara.eclipse.tools.server.isWSLInstance">
743+
<and>
744+
<count value="1"/>
745+
<iterate ifEmpty="false">
746+
<and>
747+
<test property="fish.payara.eclipse.tools.server.isWSLInstance"/>
748+
</and>
749+
</iterate>
750+
</and>
751+
</definition>
742752

743753
<definition id="fish.payara.eclipse.tools.server.moreGlassfishSelected">
744754
<iterate ifEmpty="false">
@@ -969,9 +979,12 @@
969979
>
970980
<enabledWhen>
971981
<and>
972-
<not>
973-
<reference definitionId="fish.payara.eclipse.tools.server.isRemoteGlassfish"/>
974-
</not>
982+
<or>
983+
<reference definitionId="fish.payara.eclipse.tools.server.isWSLInstance"/>
984+
<not>
985+
<reference definitionId="fish.payara.eclipse.tools.server.isRemoteGlassfish"/>
986+
</not>
987+
</or>
975988
<reference definitionId="fish.payara.eclipse.tools.server.oneGlassfishSelected"/>
976989
</and>
977990
</enabledWhen>

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/PayaraServer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public final class PayaraServer extends ServerDelegate implements IURLProvider {
144144
public static final String DEFAULT_HOT_DEPLOY = "false";
145145
public static final String DEFAULT_TYPE = "";
146146
public static final String DOCKER_TYPE = "Docker";
147+
public static final String WSL_TYPE = "WSL";
147148
protected static final String PROP_INSTANCE_TYPE = "instance.type";
148149
protected static final String PROP_HOST_PATH = "host.path";
149150
protected static final String PROP_CONTAINER_PATH = "container.path";
@@ -238,16 +239,14 @@ private static String lastSegment(String path) {
238239

239240
public boolean isRemote() {
240241
return getServer().getServerType().supportsRemoteHosts()
241-
&& (DOCKER_TYPE.equals(getInstanceType()) || !isLocalhost(getServer().getHost()));
242+
&& (DOCKER_TYPE.equals(getInstanceType()) || WSL_TYPE.equals(getInstanceType()) || !isLocalhost(getServer().getHost()));
242243
}
243244

244-
public String getDebugOptions(int debugPort) {
245+
public String getDebugOptions(int debugPort) {
245246
Version version = getVersion();
246-
247247
if (version.matches("[4")) {
248248
return "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + debugPort;
249249
}
250-
251250
return "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort;
252251
}
253252

@@ -536,7 +535,7 @@ public void setAdminUser(String value) {
536535
}
537536

538537
public String getDomainsFolder() {
539-
if (!isRemote()) {
538+
if (!isRemote() || isWSLInstance()) {
540539
return new File(getDomainPath()).getParent();
541540
}
542541

@@ -559,6 +558,10 @@ public boolean isDockerInstance() {
559558
return DOCKER_TYPE.equals(getAttribute(PROP_INSTANCE_TYPE, (String) null));
560559
}
561560

561+
public boolean isWSLInstance() {
562+
return WSL_TYPE.equals(getAttribute(PROP_INSTANCE_TYPE, (String) null));
563+
}
564+
562565
public String getInstanceType() {
563566
return this.getAttribute(PROP_INSTANCE_TYPE, (String) null);
564567
}

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/deploying/PayaraServerBehaviour.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,10 @@ private void publishModuleForPayara(int kind, int deltaKind, IModule[] module, I
533533

534534
boolean isRemote = getPayaraServerDelegate().isRemote();
535535
boolean isDockerInstance = getPayaraServerDelegate().isDockerInstance();
536+
boolean isWSLInstance = getPayaraServerDelegate().isWSLInstance();
536537
boolean isJarDeploy = getPayaraServerDelegate().getJarDeploy();
537538

538-
if ((!isRemote && !isJarDeploy) || isDockerInstance) {
539+
if ((!isRemote && !isJarDeploy) || isDockerInstance || isWSLInstance) {
539540
publishDeployedDirectory(kind, deltaKind, publishProperties, module, monitor);
540541
} else {
541542
publishJarFile(kind, deltaKind, publishProperties, module, monitor);
@@ -612,6 +613,7 @@ private void publishDeployedDirectory(int kind, int deltaKind, Properties publis
612613
// the deployed apps
613614
// so that the move operation Eclipse is doing sometimes can work.
614615
boolean dockerInstance = getPayaraServerDelegate().isDockerInstance();
616+
boolean wslInstance = getPayaraServerDelegate().isWSLInstance();
615617
String hostPath = getPayaraServerDelegate().getHostPath();
616618
String containerPath = getPayaraServerDelegate().getContainerPath();
617619

@@ -680,7 +682,7 @@ private void publishDeployedDirectory(int kind, int deltaKind, Properties publis
680682
CommandTarget command = null;
681683
if (deltaKind == ADDED) {
682684
command = new CommandDeploy(name, null, new File("" + path), contextRoot, properties, new File[0],
683-
dockerInstance, hostPath, containerPath, hotDeploy);
685+
dockerInstance, wslInstance, hostPath, containerPath, hotDeploy);
684686
} else {
685687
command = new CommandRedeploy(name, null, contextRoot, properties, new File[0], keepSession,
686688
hotDeploy, metadataChanged, sourcesChanged);
@@ -724,6 +726,7 @@ private void publishJarFile(int kind, int deltaKind, Properties p, IModule[] mod
724726
String contextRoot = null;
725727

726728
boolean dockerInstance = getPayaraServerDelegate().isDockerInstance();
729+
boolean wslInstance = getPayaraServerDelegate().isWSLInstance();
727730
String hostPath = getPayaraServerDelegate().getHostPath();
728731
String containerPath = getPayaraServerDelegate().getContainerPath();
729732

@@ -738,7 +741,7 @@ private void publishJarFile(int kind, int deltaKind, Properties p, IModule[] mod
738741
try {
739742
ServerAdmin.executeOn(getPayaraServerDelegate())
740743
.command(new CommandDeploy(name, null, archivePath, contextRoot, getDeploymentProperties(),
741-
new File[0], dockerInstance, hostPath, containerPath, hotDeploy))
744+
new File[0], dockerInstance, wslInstance, hostPath, containerPath, hotDeploy))
742745
.timeout(520).onNotCompleted(result -> {
743746
logMessage("deploy is failing=" + result.getValue());
744747
throw new IllegalStateException("deploy is failing=" + result.getValue());

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/handlers/PayaraStateTester.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public boolean test(Object receiver, String property, Object[] args, Object expe
4444
}
4545
}
4646

47+
if (property.equals("isWSLInstance")) {
48+
PayaraServer payaraServer = load(server, PayaraServer.class);
49+
50+
if (payaraServer != null) {
51+
return payaraServer.isWSLInstance();
52+
}
53+
}
54+
4755
return false;
4856
}
4957

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/sdk/admin/CommandDeploy.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static ResultString deploy(PayaraServer server, File application, TaskSta
6969
throws PayaraIdeException {
7070
try {
7171
return ServerAdmin.<ResultString>exec(server, new CommandDeploy(null, null, application, null, null, null,
72-
server.isDockerInstance(), server.getHostPath(), server.getContainerPath(), false), listener).get();
72+
server.isDockerInstance(), server.isWSLInstance(), server.getHostPath(), server.getContainerPath(), false), listener).get();
7373
} catch (InterruptedException | ExecutionException | CancellationException ie) {
7474
throw new PayaraIdeException(ERROR_MESSAGE, ie);
7575
}
@@ -100,6 +100,9 @@ public static ResultString deploy(PayaraServer server, File application, TaskSta
100100
/** Docker Instance. */
101101
final boolean dockerInstance;
102102

103+
/** WSL Instance. */
104+
final boolean wslInstance;
105+
103106
/** Host Path. */
104107
final String hostPath;
105108

@@ -122,10 +125,13 @@ public static ResultString deploy(PayaraServer server, File application, TaskSta
122125
* @param properties Deployment properties.
123126
* @param libraries Not used in actual deploy command.
124127
* @param dockerInstance Docker Instance.
128+
* @param wslInstance WSL Instance
129+
* @param hostPath
130+
* @param containerPath
125131
* @param hotDeploy Hot Deploy.
126132
*/
127133
public CommandDeploy(String name, String target, File path, String contextRoot, Map<String, String> properties,
128-
File[] libraries, final boolean dockerInstance, final String hostPath, final String containerPath,
134+
File[] libraries, final boolean dockerInstance, final boolean wslInstance, final String hostPath, final String containerPath,
129135
final boolean hotDeploy) {
130136
super(COMMAND, name, target);
131137

@@ -135,9 +141,10 @@ public CommandDeploy(String name, String target, File path, String contextRoot,
135141
this.libraries = libraries;
136142
this.dirDeploy = path.isDirectory();
137143
this.dockerInstance = dockerInstance;
144+
this.wslInstance = wslInstance;
138145
this.hostPath = hostPath;
139146
this.containerPath = containerPath;
140147
this.hotDeploy = hotDeploy;
141148
}
142149

143-
}
150+
}

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/sdk/admin/RunnerHttpDeploy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ private static String query(final Command command) {
137137
throw new CommandException(CommandException.DOCKER_HOST_APPLICATION_PATH);
138138
}
139139
}
140+
if (deploy.wslInstance) {
141+
// Replace backslashes with forward slashes
142+
path = path.replace("\\", "/");
143+
// Add "mnt" prefix and drive letter
144+
path = "/mnt/" + path.substring(0, 1).toLowerCase() + path.substring(2);
145+
}
140146
// Calculate StringBuilder initial length to avoid resizing
141147
StringBuilder sb = new StringBuilder(DEFAULT_PARAM.length() + 1 + path.length() + 1 + FORCE_PARAM.length() + 1
142148
+ force.length() + queryPropertiesLength(deploy.properties, PROPERTIES_PARAM)

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/sdk/admin/RunnerRestDeploy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ protected void handleSend(HttpURLConnection hconn) throws IOException {
102102
throw new CommandException(CommandException.DOCKER_HOST_APPLICATION_PATH);
103103
}
104104
}
105+
if (command.wslInstance) {
106+
// Replace backslashes with forward slashes
107+
path = path.replace("\\", "/");
108+
// Add "mnt" prefix and drive letter
109+
path = "/mnt/" + path.substring(0, 1).toLowerCase() + path.substring(2);
110+
}
105111
OutputStreamWriter wr = new OutputStreamWriter(hconn.getOutputStream());
106112
if (!command.dirDeploy) {
107113
writeParam(wr, "path", path);

bundles/fish.payara.eclipse.tools.server/src/fish/payara/eclipse/tools/server/ui/wizards/NewPayaraServerWizardFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class NewPayaraServerWizardFragment extends WizardFragment {
111111

112112
private Combo instanceTypeCombo;
113113

114-
private String[] instanceTypes = { PayaraServer.DEFAULT_TYPE, PayaraServer.DOCKER_TYPE };
114+
private String[] instanceTypes = { PayaraServer.DEFAULT_TYPE, PayaraServer.DOCKER_TYPE, PayaraServer.WSL_TYPE };
115115

116116
private Label hostLocationLabel;
117117

0 commit comments

Comments
 (0)