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

MicroProfile Config 3.0 Support #23807

Merged
merged 17 commits into from
Jun 11, 2022
Merged

MicroProfile Config 3.0 Support #23807

merged 17 commits into from
Jun 11, 2022

Commits on Jun 10, 2022

  1. Create MP Config TCK Runner

    This change creates a MP Config TCK runner module to run the TCK
    against a managed instance of Glassfish. There are existing dependency
    issues, which means there are a decent proportion of tests that don't
    run correctly. At this point it's fine to test that the basic deployment
    of MP Config apps works as expected.
    
    Each MP TCK module will have its own instance of Glassfish, but will be
    passed a common arquillian.xml.
    
    The TCK requires a Weld impl to run due to the Arquillian CDI enricher.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    54224df View commit details
    Browse the repository at this point in the history
  2. Create MP Config container

    This change implements Smallrye Config as a GF container.
    Currently Smallrye config and common are packaged together.
    If other Smallrye libraries are used elsewhere, the common
    library should be separated out into its own bundle.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    636a5d9 View commit details
    Browse the repository at this point in the history
  3. Enable MP Config for archives using it statically

    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    323eaa1 View commit details
    Browse the repository at this point in the history
  4. Optimise MP Config sniffer

    The sniffer can now exit early without type scanning if the archive contains
    a microprofile-config.properties in the correct location.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    2746774 View commit details
    Browse the repository at this point in the history
  5. Add MP Config TCK Arquillian extension

    Hamcrest isn't loaded with the applications by default, despite
    the deployed applications requiring it. This change adds an
    Arquillian extension to deploy a Hamcrest dependency with the
    apps.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    d97cd76 View commit details
    Browse the repository at this point in the history
  6. Replace beans.xml files in MP Config TCK

    The TCK wrongly assumes that, like in CDI versions <4, the 'all'
    bean discovery mode is assumed. GlassFish is now CDI 4.0 compliant,
    which means that the 'all' bean discovery mode now needs to be
    manually specified. To fix this, the arquillian extension now replaces
    the beans.xml files with custom versions. This will need modifying if
    the TCK contains any meaningful beans.xml tests.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    8c8d297 View commit details
    Browse the repository at this point in the history
  7. Cast GlassfishClientExceptions to expected exception type

    When using managed and remote clients, the Arquillian GF connectors throw
    each deployment exception as a GlassfishClientException, with the body of
    the actual exception. For the TCK to expect a certain exception type, we
    need an extension to interpret the response as the correct type. This
    change adds an extension to convert the "CDI deployment failure"
    responses to jakarta namespaced DeploymentExceptions, as the server produces.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    1c64ee3 View commit details
    Browse the repository at this point in the history
  8. Refactor Arquillian extensions

    This change separated the Arquillian extension behaviours
    into their own separate classes for readability.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    3371eba View commit details
    Browse the repository at this point in the history
  9. Configure the required container system properties

    System properties should ideally be configured via the arquillian
    container. This isn't possible via the official managed extension,
    so a workaround is needed. The options were either to configure it
    via a remote Arquillian extension (which doesn't currently work as
    Smallrye initialises its config sources before these extensions
    run), or to run a new test which sets it up. This change creates a
    new test purely to setup the container programmatically.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    0126d43 View commit details
    Browse the repository at this point in the history
  10. Modify non-testable TCK deployments

    The MP TCK uses ShouldThrowException to check some deployment failures.
    By default, Arquillian will not apply the extension services to those
    deployments. The beans.xml processor is still required in some cases
    though, to force the container to create bean deployments for the app.
    This change applies the processer during the BeforeDeploy event when
    the archive is non testable.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    e5ff39d View commit details
    Browse the repository at this point in the history
  11. Fix Arquillian beans xml transformer

    A beans.xml file appears in the TCK deployments in WEB-INF
    as well as META-INF. This change adds the WEB-INF directory
    to the extension.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    1274b52 View commit details
    Browse the repository at this point in the history
  12. Enable multi-release Smallrye classes

    The OSGI bundle plugin was importing the classes directly based
    on package. This was a problem, as Smallrye has multi-release
    JARs which wouldn't have their versioned classes imported. This
    change adds the Multi-Release instruction to the manifest, as
    well as imports the Smallrye versioned classes to allow JDK9
    compatibility.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    2e8d7a2 View commit details
    Browse the repository at this point in the history
  13. Allow sniffers to scan annotated parameters

    MicroProfile annotations are allowed to be injected into method parameters,
    but the sniffer code currently tries to cast the parameter to a member
    (i.e. field or method), which causes a ClassCastException. This change
    modifies the sniffer code to allow the sniffer to find the class containing
    the parameter annotation.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    e7f530f View commit details
    Browse the repository at this point in the history
  14. Replace Smallrye with Helidon

    Helidon may be a better fit in the long term for GlassFish.
    The OSGI includes have been trimmed as much as possible to reduce
    bundle size, and unnecessary OSGI instructions have been removed.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    45816fa View commit details
    Browse the repository at this point in the history
  15. Prevent Helidon microprofile-config.properties caching

    Smallrye used a custom file loading mechanism that doesn't have this bug.
    Since Helidon config uses JarURLConnection to load the microprofile-config.properties
    file, applications with the same name will return the same cached file contents.
    
    Disabling it server-wide would be a big performance hit, so instead this fix disables
    the cache during the config provider initialisation, and then returns it to the default
    behaviour. This shouldn't cause performance problems as I expect the file to only be
    read from the same archive once.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    3595905 View commit details
    Browse the repository at this point in the history
  16. Fix Helidon ClassConverter

    The config converter to convert config properties to application classes was broken,
    as the implementation was using the server classloader (for GF this is a bundle
    classloader). Thankfully Helidon discovers converters using the ServiceLoader, so
    this change overwrites the default with a class converter that uses the webapp
    classloader
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    2b09c7a View commit details
    Browse the repository at this point in the history
  17. Fix deployment exception transformer

    Helidon config causes some deployment errors to present as a
    "CDI definition failure", rather than a "CDI deployment failure".
    
    The Arquillian extension to transform exceptions has been made
    more generic to allow this.
    
    Signed-off-by: Matthew Gill <matthew.gill@live.co.uk>
    MattGill98 committed Jun 10, 2022
    Configuration menu
    Copy the full SHA
    b56317a View commit details
    Browse the repository at this point in the history