Skip to content

Commit

Permalink
Merge pull request wildfly#18235 from darranl/WFLY-19397
Browse files Browse the repository at this point in the history
[WFLY-19397] Jakarta Data support in WildFly Preview
  • Loading branch information
bstansberry authored Sep 24, 2024
2 parents 8dba6c4 + bf7c73a commit 4cd450d
Show file tree
Hide file tree
Showing 21 changed files with 549 additions and 15 deletions.
23 changes: 23 additions & 0 deletions boms/preview-ee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.data</groupId>
<artifactId>jakarta.data-api</artifactId>
<version>${version.jakarta.data.jakarta-data-api}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
Expand Down Expand Up @@ -568,6 +579,18 @@
</exclusions>
</dependency>

<dependency>
<groupId>${ee.maven.groupId}</groupId>
<artifactId>wildfly-jakarta-data</artifactId>
<version>${ee.maven.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.wildfly.deployment</groupId>
<artifactId>wildfly-ee-9-deployment-transformer</artifactId>
Expand Down
9 changes: 6 additions & 3 deletions docs/src/main/asciidoc/WildFly_and_WildFly_Preview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ compliance of WildFly Preview should check the https://github.com/wildfly/certif
[wildfly-preview-ee11]
=== EE 11 Support in WildFly Preview

The 32 release introduces a significant inflection in how we are using WildFly Preview. Beginning with this release we are starting to use WildFly Preview to provide a look at what we're doing for Jakarta EE 11 support. EE 11 is not yet GA, and standard WildFly won't support EE 11 before the WildFly 34 release, at earliest. But there are milestone, release candidate and final releases of many EE 11 specs and implementations available, so we decided to provide those in WildFly Preview. This means for a number of EE APIs, WildFly Preview no long provides an EE 10 compatible implementation.
The 32 release introduces a significant inflection in how we are using WildFly Preview. Beginning with this release we are starting to use WildFly Preview to provide a look at what we're doing for Jakarta EE 11 support. EE 11 is not yet GA, and standard WildFly won't support EE 11 before the WildFly 36 release, at earliest. But there are milestone, release candidate and final releases of many EE 11 specs and implementations available, so we decided to provide those in WildFly Preview. This means for a number of EE APIs, WildFly Preview no long provides an EE 10 compatible implementation.

However, for a number of specifications that are planning changes for EE 11 we are still offering the EE 10 variant. In future releases we'll shift those to the EE 11 variants.

The following table lists the various Jakarta technologies offered by WildFly Preview 32, along with information about which EE platform version the specification relates to. Note that a number of Jakarta specifications are unchanged between EE 10 and EE 11, while other EE technologies that WildFly offers are not part of EE 11.
The following table lists the various Jakarta technologies offered by WildFly Preview, along with information about which EE platform version the specification relates to. Note that a number of Jakarta specifications are unchanged between EE 10 and EE 11, while other EE technologies that WildFly offers are not part of EE 11. Jakarta Data is a new specification added in EE 11.

[cols=",,",options="header"]
|=======================================================================
Expand All @@ -97,6 +97,9 @@ The following table lists the various Jakarta technologies offered by WildFly Pr

|Jakarta Contexts and Dependency Injection| 4.1.0 |11

|Jakarta Data
(_xref:Admin_Guide.adoc#Feature_stability_levels[preview stability] only_)| 1.0 |11

|Jakarta Debugging Support for Other Languages| 2.0 |10 & 11

|Jakarta Dependency Injection| 2.0 |10 & 11
Expand All @@ -120,7 +123,7 @@ The following table lists the various Jakarta technologies offered by WildFly Pr
|Jakarta Messaging| 3.1 |10 & 11

| Jakarta MVC
(_preview stability only_)| 2.1| N/A xref:note2[^2^]
(_xref:Admin_Guide.adoc#Feature_stability_levels[preview stability] only_)| 2.1| N/A xref:note2[^2^]

|Jakarta Pages| 3.1 |10

Expand Down
6 changes: 6 additions & 0 deletions docs/src/main/asciidoc/_galleon/Galleon_layers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ link:#gal.naming[naming] +
|
link:#gal.base-server[base-server] +

|[[gal.jaxrs-core]]jakarta-data
|Support for Jakarta Data. (xref:Admin_Guide.adoc#Feature_stability_levels[`preview` stability] in xref:WildFly_and_WildFly_Preview.adoc[WildFly Preview] only) The _link:#gal.jpa[jpa]_ dependency can be excluded and _link:#gal.jpa-distributed[jpa-distributed]_ used instead.
|
link:#gal.jpa[jpa] OR +
link:#gal.jpa-distributed[jpa-distributed]

|[[gal.jaxrs-core]]jaxrs-core
|Support for Jakarta RESTful Web Services.
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<module name="com.fasterxml.jackson.core.jackson-core" optional="true"/>
<module name="com.fasterxml.jackson.core.jackson-databind" optional="true"/>
<module name="jakarta.annotation.api"/>
<!-- If Jakarta Data is provisioned, depend on it -->
<module name="jakarta.data.api" optional="true"/>
<module name="jakarta.enterprise.api"/>
<module name="jakarta.json.bind.api"/>
<module name="jakarta.persistence.api"/>
Expand Down
106 changes: 106 additions & 0 deletions jakarta-data/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright The WildFly Authors
~ SPDX-License-Identifier: Apache-2.0
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-parent</artifactId>
<!--
Maintain separation between the artifact id and the version to help prevent
merge conflicts between commits changing the GA and those changing the V.
-->
<version>34.0.0.Beta1-SNAPSHOT</version>
</parent>

<artifactId>wildfly-jakarta-data</artifactId>

<name>WildFly: Jakarta Data Integration</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wildfly-standard-ee-bom</artifactId>
<version>${ee.maven.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wildfly-standard-test-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-server</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-subsystem</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
projects that depend on this project.-->
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
projects that depend on this project.-->
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.jboss.msc</groupId>
<artifactId>jboss-msc</artifactId>
</dependency>

<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<!-- Test depedencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-subsystem-test</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/

package org.wildfly.extension.jakarta.data;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.wildfly.extension.jakarta.data._private.JakartaDataLogger.ROOT_LOGGER;

import org.jboss.as.controller.Extension;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentSubsystemSchema;
import org.jboss.as.controller.ResourceDefinition;
import org.jboss.as.controller.ResourceRegistration;
import org.jboss.as.controller.SubsystemModel;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.SubsystemSchema;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.descriptions.ParentResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.SubsystemResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.RuntimePackageDependency;
import org.jboss.as.controller.xml.VersionedNamespace;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.Phase;
import org.jboss.as.server.deployment.module.ModuleDependency;
import org.jboss.as.server.deployment.module.ModuleSpecification;
import org.jboss.as.version.Stability;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
import org.jboss.staxmapper.IntVersion;
import org.kohsuke.MetaInfServices;
import org.wildfly.subsystem.SubsystemConfiguration;
import org.wildfly.subsystem.SubsystemExtension;
import org.wildfly.subsystem.SubsystemPersistence;
import org.wildfly.subsystem.resource.ManagementResourceRegistrar;
import org.wildfly.subsystem.resource.ManagementResourceRegistrationContext;
import org.wildfly.subsystem.resource.ResourceDescriptor;
import org.wildfly.subsystem.resource.SubsystemResourceDefinitionRegistrar;


/**
* WildFly extension that provides Jakarta MVC support based on Eclipse Krazo.
*
* @author <a href="mailto:[email protected]">Brian Stansberry</a>
*/
@MetaInfServices(Extension.class)
public class JakartaDataExtension extends SubsystemExtension<JakartaDataExtension.JakartaDataSubsystemSchema> {

/**
* The name of our subsystem within the model.
*/
static final String SUBSYSTEM_NAME = "jakarta-data";
private static final Stability FEATURE_STABILITY = Stability.PREVIEW;

static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);

public JakartaDataExtension() {
super(SubsystemConfiguration.of(SUBSYSTEM_NAME, JakartaDataSubsystemModel.CURRENT, JakartaDataSubsystemRegistrar::new),
SubsystemPersistence.of(JakartaDataSubsystemSchema.CURRENT));
}

@Override
public Stability getStability() {
return FEATURE_STABILITY;
}

/**
* Model for the 'jakarta-data' subsystem.
*/
public enum JakartaDataSubsystemModel implements SubsystemModel {
VERSION_1_0_0(1, 0, 0),
;

static final JakartaDataSubsystemModel CURRENT = VERSION_1_0_0;

private final ModelVersion version;

JakartaDataSubsystemModel(int major, int minor, int micro) {
this.version = ModelVersion.create(major, minor, micro);
}

@Override
public ModelVersion getVersion() {
return this.version;
}
}

/**
* Schema for the 'jakarta-data' subsystem.
*/
public enum JakartaDataSubsystemSchema implements PersistentSubsystemSchema<JakartaDataSubsystemSchema> {

VERSION_1_0_PREVIEW(1, 0, FEATURE_STABILITY),
;

static final JakartaDataSubsystemSchema CURRENT = VERSION_1_0_PREVIEW;

private final VersionedNamespace<IntVersion, JakartaDataSubsystemSchema> namespace;

JakartaDataSubsystemSchema(int major, int minor, Stability stability) {
this.namespace = SubsystemSchema.createSubsystemURN(SUBSYSTEM_NAME, stability, new IntVersion(major, minor));
}

@Override
public VersionedNamespace<IntVersion, JakartaDataSubsystemSchema> getNamespace() {
return this.namespace;
}

@Override
public Stability getStability() {
return this.getNamespace().getStability();
}

@Override
public PersistentResourceXMLDescription getXMLDescription() {
PersistentResourceXMLDescription.Factory factory = PersistentResourceXMLDescription.factory(this);
return factory.builder(SUBSYSTEM_PATH).build();
}
}

private static final class JakartaDataSubsystemRegistrar implements SubsystemResourceDefinitionRegistrar {

private static final RuntimeCapability<Void> JAKARTA_DATA_CAPABILITY = RuntimeCapability.Builder.of("org.wildfly.jakarta.data")
.addRequirements("org.wildfly.jpa")
.build();
static final ParentResourceDescriptionResolver RESOLVER = new SubsystemResourceDescriptionResolver(SUBSYSTEM_NAME, JakartaDataSubsystemRegistrar.class);

static final String JAKARTA_DATA_API = "jakarta.data.api";

@Override
public ManagementResourceRegistration register(SubsystemRegistration parent, ManagementResourceRegistrationContext managementResourceRegistrationContext) {
ResourceDefinition definition = ResourceDefinition.builder(ResourceRegistration.of(SUBSYSTEM_PATH), RESOLVER).build();
ManagementResourceRegistration registration = parent.registerSubsystemModel(definition);
ResourceDescriptor descriptor = ResourceDescriptor.builder(RESOLVER)
.addCapability(JAKARTA_DATA_CAPABILITY)
.withDeploymentChainContributor(JakartaDataSubsystemRegistrar::registerDeploymentUnitProcessors)
.build();
ManagementResourceRegistrar.of(descriptor).register(registration);
registration.registerAdditionalRuntimePackages(
RuntimePackageDependency.required(JAKARTA_DATA_API)
);
return registration;
}

private static void registerDeploymentUnitProcessors(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(JakartaDataExtension.SUBSYSTEM_NAME,
Phase.DEPENDENCIES,
Phase.DEPENDENCIES_JPA + 1,
new DeploymentUnitProcessor() {
@Override
public void deploy(DeploymentPhaseContext phaseContext) {

final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();

// all applications get the jakarta.persistence module added to their deplyoment by default
addDependencies(moduleSpecification, moduleLoader, deploymentUnit, JAKARTA_DATA_API);
}
});
}
}

private static void addDependencies(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader,
DeploymentUnit deploymentUnit, String... moduleIdentifiers) {
for ( String moduleIdentifier : moduleIdentifiers) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, false, false, true, false));
ROOT_LOGGER.debugf("added %s dependency to %s", moduleIdentifier, deploymentUnit.getName());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/

package org.wildfly.extension.jakarta.data._private;

import java.lang.invoke.MethodHandles;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;

@MessageLogger(projectCode = "WFLYJDATA", length = 4)
public interface JakartaDataLogger extends BasicLogger {

JakartaDataLogger ROOT_LOGGER = Logger.getMessageLogger(MethodHandles.lookup(), JakartaDataLogger.class, "org.wildfly.extension.jakarta.data");
}
Loading

0 comments on commit 4cd450d

Please sign in to comment.