Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #10437 - Refactor Local Deployment Scanning #12583

Open
wants to merge 119 commits into
base: jetty-12.1.x
Choose a base branch
from

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Nov 26, 2024

A single scanner for all Environments.
Environment attributes are how the environment specific deployment configuration is controlled.
Existing properties behaviors maintained.
Moved optional Environment XML resolution from ${jetty.base}/webapps/<env>.xml to ${jetty.base}/environments/<env>.xml to avoid name collision with deployable XML contexts.

@joakime joakime added Enhancement Bug For general bugs on Jetty side labels Nov 26, 2024
@joakime joakime requested a review from sbordet November 26, 2024 21:48
@joakime joakime self-assigned this Nov 26, 2024
@joakime joakime changed the base branch from jetty-12.0.x to jetty-12.1.x November 26, 2024 21:48
@joakime joakime linked an issue Nov 26, 2024 that may be closed by this pull request
@joakime joakime marked this pull request as ready for review December 3, 2024 00:01
@janbartel janbartel requested a review from gregw December 10, 2024 04:35
@sbordet
Copy link
Contributor

sbordet commented Dec 10, 2024

I'd like to see:

  • alphabetical sort of scanned files
  • DeploymentManager does not need to know AppProviders. It's AppProviders that call the DeploymentManager to deploy Apps. AppProviders can just be added as beans to DeploymentManager
  • Documentation
  • ContextProvider renamed to something more telling. DeploymentScanningAppProvider? The word "Context" has no meaning in this class, and it is lost in the current class name that it is a ScanningAppProvider.

@joakime
Copy link
Contributor Author

joakime commented Feb 5, 2025

This is ready to review again.
Note: the 2 test failures seem to be flakes, they are unrelated to the changes in this branch.

@gregw
Copy link
Contributor

gregw commented Feb 12, 2025

@olamy @lachlan-roberts @lorban I've added you as reviewers, as even though this PR is receiving a lot of review (too much?) it is really important and we need at least everybody to be passingly aware of it and to at least have a little look.

return h;
// Create a ContextHandler suitable to deploy in OSGi
ContextHandler contextHandler = _contextFactory.createContextHandler(this, metadata);
Util.setBundle(contextHandler, metadata.getBundle());
Copy link
Contributor

Choose a reason for hiding this comment

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

The setting of the BUNDLE attribute should be done by the context factory, not separated out here. It doesn't need a Util method to do it either. Util.getBundle(contextHandler) is confusing - seems like you want to get the bundle in which the class of the contexthandler is defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the code revision you just reviewed, this is what's going on there ...

The Util.setBundle(ContextHandler) exists so that the Bundle can be tracked through the ContextHandler itself.

The other side, Util.getBundle(ContextHandler) will use this information (stored in the ContextHandler attributes btw), for ...

  • OSGiDeployer - for events
  • OSGiUndeployer - for events
  • getBundleSymbolicName
  • getBundleVersionAsString
  • Util.registerAsOSGiService

I should be able to collapse the getBundleSymbolicName and getBundleVersionAsString into Util.registerAsOSGiService.
But the other cases are not that obvious to 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.

I'll rework this to be in a better place, but with this change, instead of being in 1 place and doing it right, now we have at least 8 places to set it, and 3 places to get it.

}
}
}
_defaultContextPath = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be deleted

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 no longer the role of WebAppContext.initializeDefaults().

That is better handled via the other places that already exist.
Leaving this here will actually fail most tests.

Keep in mind that initializeDefaults() can be called multiple times depending on the arrangement of deployable files, and if environment XML are also used.

Copy link
Contributor Author

@joakime joakime Feb 14, 2025

Choose a reason for hiding this comment

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

I'm adding test cases for these (as they are not present), not sure if ee8 can support default-context-path (yet).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See new DeploymentDefaultContextPathTest test case.

This removed line doesn't need to be there.
It was only a hack to work around behavior of the old Deployment Scanner.

Where the old deployment scanner would do the following steps...

  1. create the context via reflection from default context classname configuration.
  2. call .setDisplayName() and .setContextPath(basename) on context.
  3. call .initializeDefaults() on that context.
  4. run the XML to configure that context.
  5. eventually that context starts and StandardDescriptorProcessor would read the <default-context-path> and only set the actual context-path if that flag was true.

In the new deployment scanner the steps are ...

  1. create the context via the XML.
  2. call .setDisplayName() and .setAttribute(DEFAULT_CONTEXT_PATH, basename) on context.
  3. call .initializeDefaults() on that context.
  4. eventually that context starts and StandardDescriptorProcessor would read the <default-context-path> and only set the actual context-path if that flag was still true.

The difference is that in the new code, that initial context class creation is skipped if the XML exists.
This allows the use cases (which we have test cases for since Jetty 9) of a custom WebAppContext to be used in the XML to create a webapp.

The scanner determined default context path should have remained a default, not a hardcoded one.
So the new code just uses the Attributes instead to pass on the scanner determined default.
Allowing the optional XML to override this default if set.

@joakime joakime requested a review from janbartel February 13, 2025 22:02
@joakime joakime changed the title Issue #10437 - Unify Deployer ContextProvider Issue #10437 - Refactor Local Deployment Scanning Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side Enhancement
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

Review DeploymentManager and ScanningAppProvider
5 participants