-
Notifications
You must be signed in to change notification settings - Fork 466
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
[WFCORE-6750][Preview] Integrate the scanner for the unstable API annotations #5913
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...em/layers/base/org/wildfly/_internal/unstable-api-annotation-index/main/content/index.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Comment to include file |
22 changes: 22 additions & 0 deletions
22
...es/system/layers/base/org/wildfly/_internal/unstable-api-annotation-index/main/module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ Copyright The WildFly Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<module xmlns="urn:jboss:module:1.9" name="org.wildfly._internal.unstable-api-annotation-index"> | ||
|
||
<properties> | ||
<property name="jboss.api" value="private"/> | ||
</properties> | ||
|
||
<resources> | ||
<resource-root path="content"></resource-root> | ||
</resources> | ||
|
||
<exports> | ||
<include path="*"/> | ||
<include path="**/*"/> | ||
</exports> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...es/modules/system/layers/base/org/wildfly/unstable/annotation/api/indexer/main/module.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
~ Copyright The WildFly Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<module xmlns="urn:jboss:module:1.9" name="org.wildfly.unstable.annotation.api.indexer"> | ||
<properties> | ||
<property name="jboss.api" value="private"/> | ||
</properties> | ||
|
||
<resources> | ||
<artifact name="${org.wildfly.unstable.api.annotation:unstable-api-annotation-classpath-indexer}"/> | ||
</resources> | ||
|
||
<dependencies> | ||
<module name="org.jboss.logging"/> | ||
<module name="io.smallrye.jandex"/> | ||
</dependencies> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
...rc/main/java/org/wildfly/extension/core/management/CoreManagementSubsystemParser_1_0.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
...em/src/main/java/org/wildfly/extension/core/management/CoreManagementSubsystemSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.extension.core.management; | ||
|
||
import org.jboss.as.controller.Feature; | ||
import org.jboss.as.controller.PersistentResourceXMLDescription; | ||
import org.jboss.as.controller.PersistentSubsystemSchema; | ||
import org.jboss.as.controller.SubsystemSchema; | ||
import org.jboss.as.controller.xml.VersionedNamespace; | ||
import org.jboss.as.version.Stability; | ||
import org.jboss.staxmapper.IntVersion; | ||
|
||
import java.util.EnumSet; | ||
import java.util.Map; | ||
|
||
/** | ||
* Parser and Marshaller for core-management subsystem. | ||
* | ||
* <em>All resources and attributes must be listed explicitly and not through any collections.</em> | ||
* This ensures that if the resource definitions change in later version (e.g. a new attribute is added), | ||
* this will have no impact on parsing this specific version of the subsystem. | ||
* | ||
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2016 Red Hat inc. | ||
*/ | ||
public enum CoreManagementSubsystemSchema implements PersistentSubsystemSchema<CoreManagementSubsystemSchema> { | ||
|
||
VERSION_1_0(1), | ||
VERSION_1_0_PREVIEW(1, Stability.PREVIEW); | ||
static final Map<Stability, CoreManagementSubsystemSchema> CURRENT = Feature.map(EnumSet.of(VERSION_1_0, VERSION_1_0_PREVIEW)); | ||
|
||
private final VersionedNamespace<IntVersion, CoreManagementSubsystemSchema> namespace; | ||
|
||
CoreManagementSubsystemSchema(int major) { | ||
this.namespace = SubsystemSchema.createLegacySubsystemURN(CoreManagementExtension.SUBSYSTEM_NAME, new IntVersion(major, 0)); | ||
} | ||
|
||
CoreManagementSubsystemSchema(int major, Stability stability) { | ||
this.namespace = SubsystemSchema.createLegacySubsystemURN(CoreManagementExtension.SUBSYSTEM_NAME, stability, new IntVersion(major, 0)); | ||
} | ||
|
||
@Override | ||
public VersionedNamespace<IntVersion, CoreManagementSubsystemSchema> getNamespace() { | ||
return this.namespace; | ||
} | ||
|
||
@Override | ||
public PersistentResourceXMLDescription getXMLDescription() { | ||
PersistentResourceXMLDescription.Factory factory = PersistentResourceXMLDescription.factory(this); | ||
PersistentResourceXMLDescription.Builder builder = factory.builder(CoreManagementExtension.SUBSYSTEM_PATH); | ||
builder.addChild( | ||
factory.builder(ConfigurationChangeResourceDefinition.PATH) | ||
.addAttribute(ConfigurationChangeResourceDefinition.MAX_HISTORY) | ||
.build()); | ||
builder.addChild( | ||
factory.builder(UnstableApiAnnotationResourceDefinition.RESOURCE_REGISTRATION) | ||
.addAttribute(UnstableApiAnnotationResourceDefinition.LEVEL) | ||
.build()); | ||
builder.addChild( | ||
factory.builder(CoreManagementExtension.PROCESS_STATE_LISTENER_PATH) | ||
|
||
.addAttribute(ProcessStateListenerResourceDefinition.LISTENER_CLASS) | ||
.addAttribute(ProcessStateListenerResourceDefinition.LISTENER_MODULE) | ||
.addAttribute(ProcessStateListenerResourceDefinition.PROPERTIES) | ||
.addAttribute(ProcessStateListenerResourceDefinition.TIMEOUT) | ||
.build()); | ||
return builder.build(); | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
...n/java/org/wildfly/extension/core/management/UnstableApiAnnotationResourceDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.wildfly.extension.core.management; | ||
|
||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVICE; | ||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UNSTABLE_API_ANNOTATIONS; | ||
import static org.jboss.as.server.deployment.Phase.PARSE; | ||
import static org.jboss.as.server.deployment.Phase.PARSE_REPORT_EXPERIMENTAL_ANNOTATIONS; | ||
import static org.jboss.as.server.deployment.Phase.PARSE_SCAN_EXPERIMENTAL_ANNOTATIONS; | ||
import static org.wildfly.extension.core.management.CoreManagementExtension.SUBSYSTEM_NAME; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.jboss.as.controller.AbstractBoottimeAddStepHandler; | ||
import org.jboss.as.controller.AttributeDefinition; | ||
import org.jboss.as.controller.OperationContext; | ||
import org.jboss.as.controller.OperationFailedException; | ||
import org.jboss.as.controller.PathElement; | ||
import org.jboss.as.controller.PersistentResourceDefinition; | ||
import org.jboss.as.controller.ReloadRequiredRemoveStepHandler; | ||
import org.jboss.as.controller.ResourceRegistration; | ||
import org.jboss.as.controller.SimpleAttributeDefinition; | ||
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; | ||
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | ||
import org.jboss.as.controller.operations.validation.EnumValidator; | ||
import org.jboss.as.controller.registry.Resource; | ||
import org.jboss.as.server.AbstractDeploymentChainStep; | ||
import org.jboss.as.server.DeploymentProcessorTarget; | ||
import org.jboss.as.version.Stability; | ||
import org.jboss.dmr.ModelNode; | ||
import org.jboss.dmr.ModelType; | ||
import org.wildfly.extension.core.management.deployment.ReportUnstableApiAnnotationsProcessor; | ||
import org.wildfly.extension.core.management.deployment.ScanUnstableApiAnnotationsProcessor; | ||
|
||
/** | ||
* Resource to configure the unstable api annotation usage reporting. | ||
* | ||
*/ | ||
public class UnstableApiAnnotationResourceDefinition extends PersistentResourceDefinition { | ||
pferraro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public static final Stability STABILITY = Stability.PREVIEW; | ||
public static final SimpleAttributeDefinition LEVEL = SimpleAttributeDefinitionBuilder.create( | ||
ModelDescriptionConstants.LEVEL, ModelType.STRING, true) | ||
.setValidator(EnumValidator.create(UnstableApiAnnotationLevel.class)) | ||
.setDefaultValue(new ModelNode(UnstableApiAnnotationLevel.LOG.name())) | ||
.setRestartAllServices() | ||
.build(); | ||
public static final PathElement PATH = PathElement.pathElement(SERVICE, UNSTABLE_API_ANNOTATIONS); | ||
kabir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
static final ResourceRegistration RESOURCE_REGISTRATION = ResourceRegistration.of(PATH, STABILITY); | ||
static final UnstableApiAnnotationResourceDefinition INSTANCE = new UnstableApiAnnotationResourceDefinition(); | ||
|
||
private static final List<AttributeDefinition> ATTRIBUTES = Collections.singletonList(LEVEL); | ||
|
||
private UnstableApiAnnotationResourceDefinition() { | ||
super( | ||
new Parameters( | ||
RESOURCE_REGISTRATION, | ||
CoreManagementExtension.getResourceDescriptionResolver(UNSTABLE_API_ANNOTATIONS)) | ||
.setAddHandler(UnstableApiAnnotationResourceAddHandler.INSTANCE) | ||
.setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE)); | ||
} | ||
|
||
|
||
@Override | ||
public Collection<AttributeDefinition> getAttributes() { | ||
return ATTRIBUTES; | ||
} | ||
|
||
private static class UnstableApiAnnotationResourceAddHandler extends AbstractBoottimeAddStepHandler { | ||
|
||
|
||
static final UnstableApiAnnotationResourceAddHandler INSTANCE = new UnstableApiAnnotationResourceAddHandler(); | ||
@Override | ||
public void performBoottime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { | ||
ModelNode model = resource.getModel(); | ||
String levelValue = UnstableApiAnnotationResourceDefinition.LEVEL.resolveModelAttribute(context, model).asString(); | ||
UnstableApiAnnotationLevel level = UnstableApiAnnotationLevel.valueOf(levelValue); | ||
|
||
if (context.isNormalServer()) { | ||
context.addStep(new AbstractDeploymentChainStep() { | ||
@Override | ||
protected void execute(DeploymentProcessorTarget processorTarget) { | ||
processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, PARSE, PARSE_SCAN_EXPERIMENTAL_ANNOTATIONS, | ||
new ScanUnstableApiAnnotationsProcessor(context.getRunningMode(), context.getStability(), level)); | ||
processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, PARSE, PARSE_REPORT_EXPERIMENTAL_ANNOTATIONS, | ||
new ReportUnstableApiAnnotationsProcessor(level)); | ||
} | ||
}, OperationContext.Stage.RUNTIME); | ||
} | ||
} | ||
} | ||
|
||
|
||
public enum UnstableApiAnnotationLevel { | ||
LOG, | ||
ERROR | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't those modules be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehsavoie The indices and the dependency on the scanner need to always be added, or we would need a layer which doesn't seem practical for a preview feature. A bit further down the line (once this reaches community level) I would like to add a layer which enables the configuration to turn the scanning on. But still there is a hard dependency on the indexer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I was wondering about adding all those indexes and jars if one just doesn't want the feature