Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

SWARM-1471: Do not auto-generate the JAX-RS application if the application-path has not been defined in YAML. #847

Merged
merged 1 commit into from Mar 26, 2018

Conversation

roguexz
Copy link
Contributor

@roguexz roguexz commented Mar 22, 2018

Motivation

Currently WF Swarm auto-generates a JAX-RS application class which leads to an inconsistent behavior (does not comply with the JAX-RS spec). Developers tend to get confused with the presence of multiple Application references being printed in the console. The intention of this auto-generation was to help developers easily define the JAX-RS application-path declaratively without needing to define a superfluous empty class. As discussed in the Jira issue, we should be generating the class only if the declarative parameter is defined.

Modifications

  1. Add the Application subclass only if no sub-class of Application is present and the YAML file defines the "application-path" entry.
  2. Updated the deployment definitions for various test cases that were relying on this implicit behavior.

Result

Verified the behavior (across many, many test cases).

  • Have you followed the guidelines in our Contributing document?
  • Have you created a JIRA and used it in the commit message?
  • Have you checked to ensure there aren't other open Pull Requests for the same issue?
  • Have you built the project locally prior to submission with mvn clean install?

@roguexz roguexz requested a review from a team as a code owner March 22, 2018 01:07
addGeneratedApplication(archive.as(JAXRSArchive.class));
if (applicationPath.isExplicit()) {
addGeneratedApplication(archive.as(JAXRSArchive.class));
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only change that was required. All the other changes pertain to the test cases.

@bobmcwhirter
Copy link
Contributor

bobmcwhirter commented Mar 22, 2018 via email

@roguexz
Copy link
Contributor Author

roguexz commented Mar 22, 2018

In addition to the release notes, the JAX-RS framework would automatically print a message that there are no Application subclasses or Servlet mappings present.

It might be a manageable scenario.

@@ -76,7 +76,9 @@ public void process() throws Exception {
return;
}

addGeneratedApplication(archive.as(JAXRSArchive.class));
if (applicationPath.isExplicit()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably change a bit the @AttributeDocumentation of applicationPath, to reflect the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a stab at providing some useful documentation for the annotation. Will need a customer focussed doc-review of that line though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a single sentence, not an overly big deal. My suggestion: If set, WildFly Swarm will automatically generate a JAX-RS Application class and use this value as the @ApplicationPath

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I haven't looked at the existing documentation that much, I wasn't aware of the tone / technical details that are included in the documentation. Will use the above sentence and update.

@Ladicek
Copy link
Contributor

Ladicek commented Mar 22, 2018

I myself would create the Application classes inside the tests, instead of adding project-defaults.yml, but I don't really mind :-) I mean, I don't really mind in the tests, but maybe in the howtos, we should really prefer creating the Application class, as that's the common JAX-RS way. WDYT?

@kenfinnigan
Copy link
Member

I agree it's fine to use the yml version for tests, but the howto's should create the Application class directly

@@ -0,0 +1,5 @@
swarm:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this contain the port setting from the removed project-defaults.yml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. The file was (for some reason) not being picked up. The test case was still pointing to 8080.

Copy link
Contributor Author

@roguexz roguexz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall create Application classes in the how-to projects as well and remove the application-path entries (and the whole file if applicable).

@@ -0,0 +1,5 @@
swarm:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. The file was (for some reason) not being picked up. The test case was still pointing to 8080.

@@ -76,7 +76,9 @@ public void process() throws Exception {
return;
}

addGeneratedApplication(archive.as(JAXRSArchive.class));
if (applicationPath.isExplicit()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a stab at providing some useful documentation for the annotation. Will need a customer focussed doc-review of that line though.

…ation-path has not been defined in YAML.

Motivation
----------
Currently WF Swarm auto-generates a JAX-RS application class which leads to an inconsistent behavior (does not comply with the JAX-RS spec). Developers tend to get confused with the presence of multiple Application references being printed in the console. The intention of this auto-generation was to help developers easily define the JAX-RS application-path declaratively without needing to define a superfluous empty class. As discussed in the Jira issue, we should be generating the class only if the declarative parameter is defined.

Modifications
-------------
1. Add the Application subclass only if no sub-class of Application is present **and** the YAML file defines the "application-path" entry.
2. Updated the deployment definitions for various test cases that were relying on this implicit behavior.
3. Updated the howto projects to include an Application subclass.

Result
------
Verified the behavior (across many, many test cases).
@roguexz
Copy link
Contributor Author

roguexz commented Mar 22, 2018

Incorporate the changes. Executed a build from the howto folder, which went through fine.
Can you please review and provide your comments?

@roguexz
Copy link
Contributor Author

roguexz commented Mar 22, 2018

A little less than 3 hours for completion of the builds. I wonder if we can optimize that! Anyways, ready for merging.

@roguexz
Copy link
Contributor Author

roguexz commented Mar 26, 2018

@kenfinnigan @bobmcwhirter Is this PR good to be merged? Do you have any additional comments about it? Or should we put it on hold?

@kenfinnigan kenfinnigan merged commit 7171653 into thorntail:master Mar 26, 2018
@roguexz roguexz deleted the SWARM-1471 branch April 2, 2018 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
4 participants