Skip to content

Commit

Permalink
Merge pull request #6110 from pferraro/WFCORE-6931
Browse files Browse the repository at this point in the history
WFCORE-6931 Remove usage of deprecated AbstractWriteAttributeHandler constructors in threads subsystem
  • Loading branch information
yersan authored Aug 26, 2024
2 parents e0273ac + 19c3d7e commit 6437f95
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ public class BoundedQueueThreadPoolAdd extends AbstractAddStepHandler {

static final AttributeDefinition[] NON_BLOCKING_ATTRIBUTES = new AttributeDefinition[BLOCKING_ATTRIBUTES.length + 1] ;

static final AttributeDefinition[] RW_ATTRIBUTES = new AttributeDefinition[] {PoolAttributeDefinitions.KEEPALIVE_TIME,
PoolAttributeDefinitions.MAX_THREADS, PoolAttributeDefinitions.CORE_THREADS, PoolAttributeDefinitions.QUEUE_LENGTH,
PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT};

static {
System.arraycopy(BLOCKING_ATTRIBUTES, 0, NON_BLOCKING_ATTRIBUTES, 0, BLOCKING_ATTRIBUTES.length);
NON_BLOCKING_ATTRIBUTES[NON_BLOCKING_ATTRIBUTES.length - 1] = PoolAttributeDefinitions.HANDOFF_EXECUTOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,20 @@
import static org.jboss.as.threads.CommonAttributes.BLOCKING_BOUNDED_QUEUE_THREAD_POOL;
import static org.jboss.as.threads.CommonAttributes.BOUNDED_QUEUE_THREAD_POOL;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.msc.service.ServiceName;

import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.msc.service.ServiceName;

/**
* {@link org.jboss.as.controller.ResourceDefinition} for a bounded queue thread pool resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class BoundedQueueThreadPoolResourceDefinition extends PersistentResourceDefinition {
public class BoundedQueueThreadPoolResourceDefinition extends SimpleResourceDefinition {
public static final BoundedQueueThreadPoolResourceDefinition BLOCKING = create(true, false);
public static final BoundedQueueThreadPoolResourceDefinition NON_BLOCKING = create(false, false);
private final BoundedQueueThreadPoolMetricsHandler metricsHandler;
Expand Down Expand Up @@ -112,11 +107,6 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
}
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(writeHandler.attributes);
}

public boolean isBlocking() {
return blocking;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.jboss.as.threads;



import java.util.concurrent.TimeUnit;

import org.jboss.as.controller.OperationContext;
Expand All @@ -25,9 +24,8 @@ public class BoundedQueueThreadPoolWriteAttributeHandler extends ThreadsWriteAtt
private final ServiceName serviceNameBase;
private final RuntimeCapability capability;

public BoundedQueueThreadPoolWriteAttributeHandler(boolean blocking, final RuntimeCapability capability, ServiceName serviceNameBase) {
super(blocking ? BoundedQueueThreadPoolAdd.BLOCKING_ATTRIBUTES : BoundedQueueThreadPoolAdd.NON_BLOCKING_ATTRIBUTES,
BoundedQueueThreadPoolAdd.RW_ATTRIBUTES);
public BoundedQueueThreadPoolWriteAttributeHandler(boolean blocking, final RuntimeCapability capability, ServiceName serviceNameBase) {
super(blocking ? BoundedQueueThreadPoolAdd.BLOCKING_ATTRIBUTES : BoundedQueueThreadPoolAdd.NON_BLOCKING_ATTRIBUTES);
this.serviceNameBase = serviceNameBase;
this.capability = capability;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class EnhancedQueueExecutorAdd extends AbstractAddStepHandler {
static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[]{PoolAttributeDefinitions.KEEPALIVE_TIME,
PoolAttributeDefinitions.MAX_THREADS, PoolAttributeDefinitions.CORE_THREADS, PoolAttributeDefinitions.THREAD_FACTORY};

static final AttributeDefinition[] RW_ATTRIBUTES = new AttributeDefinition[]{PoolAttributeDefinitions.KEEPALIVE_TIME,
PoolAttributeDefinitions.MAX_THREADS, PoolAttributeDefinitions.CORE_THREADS};

private final ThreadFactoryResolver threadFactoryResolver;
private final ServiceName serviceNameBase;
private final RuntimeCapability<Void> capability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

import static org.jboss.as.threads.CommonAttributes.ENHANCED_QUEUE_THREAD_POOL;

import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.ExecutorService;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
Expand All @@ -23,7 +19,7 @@
/**
* {@link org.jboss.as.controller.ResourceDefinition} for an {@code org.jboss.threads.EnhancedQueueExecutor} resource.
*/
public final class EnhancedQueueExecutorResourceDefinition extends PersistentResourceDefinition {
public final class EnhancedQueueExecutorResourceDefinition extends SimpleResourceDefinition {
private final EnhancedQueueExecutorWriteAttributeHandler writeAttributeHandler;
private final EnhancedQueueExecutorMetricsHandler metricsHandler;
private final boolean registerRuntimeOnly;
Expand Down Expand Up @@ -76,9 +72,4 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
metricsHandler.registerAttributes(resourceRegistration);
}
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(writeAttributeHandler.attributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EnhancedQueueExecutorWriteAttributeHandler extends ThreadsWriteAttributeOp
private final RuntimeCapability capability;

EnhancedQueueExecutorWriteAttributeHandler(final RuntimeCapability capability, ServiceName serviceNameBase) {
super(EnhancedQueueExecutorAdd.ATTRIBUTES, EnhancedQueueExecutorAdd.RW_ATTRIBUTES);
super(EnhancedQueueExecutorAdd.ATTRIBUTES);
this.serviceNameBase = serviceNameBase;
this.capability = capability;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public class QueuelessThreadPoolAdd extends AbstractAddStepHandler {

static final AttributeDefinition[] NON_BLOCKING_ATTRIBUTES = new AttributeDefinition[BLOCKING_ATTRIBUTES.length + 1];

static final AttributeDefinition[] RW_ATTRIBUTES = new AttributeDefinition[] {PoolAttributeDefinitions.KEEPALIVE_TIME,
PoolAttributeDefinitions.MAX_THREADS};

static {
System.arraycopy(BLOCKING_ATTRIBUTES, 0, NON_BLOCKING_ATTRIBUTES, 0, BLOCKING_ATTRIBUTES.length);
NON_BLOCKING_ATTRIBUTES[NON_BLOCKING_ATTRIBUTES.length - 1] = PoolAttributeDefinitions.HANDOFF_EXECUTOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,21 @@
import static org.jboss.as.threads.CommonAttributes.BLOCKING_QUEUELESS_THREAD_POOL;
import static org.jboss.as.threads.CommonAttributes.QUEUELESS_THREAD_POOL;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.msc.service.ServiceName;

import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.msc.service.ServiceName;

/**
* {@link org.jboss.as.controller.ResourceDefinition} for a queueless thread pool resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
* @author Tomaz Cerar (c) 2015 Red Hat Inc.
*/
public class QueuelessThreadPoolResourceDefinition extends PersistentResourceDefinition {
public class QueuelessThreadPoolResourceDefinition extends SimpleResourceDefinition {
private final QueuelessThreadPoolWriteAttributeHandler writeHandler;
private final QueuelessThreadPoolMetricsHandler metricsHandler;
private final boolean blocking;
Expand Down Expand Up @@ -95,9 +90,4 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
public boolean isBlocking() {
return blocking;
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(writeHandler.attributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.jboss.as.threads;



import java.util.concurrent.TimeUnit;

import org.jboss.as.controller.OperationContext;
Expand All @@ -27,7 +26,7 @@ public class QueuelessThreadPoolWriteAttributeHandler extends ThreadsWriteAttrib
private final RuntimeCapability capability;

public QueuelessThreadPoolWriteAttributeHandler(boolean blocking, final RuntimeCapability capability, ServiceName serviceNameBase) {
super(blocking ? QueuelessThreadPoolAdd.BLOCKING_ATTRIBUTES : QueuelessThreadPoolAdd.NON_BLOCKING_ATTRIBUTES, QueuelessThreadPoolAdd.RW_ATTRIBUTES);
super(blocking ? QueuelessThreadPoolAdd.BLOCKING_ATTRIBUTES : QueuelessThreadPoolAdd.NON_BLOCKING_ATTRIBUTES);
this.serviceNameBase = serviceNameBase;
this.capability = capability;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public class ScheduledThreadPoolAdd extends AbstractAddStepHandler {
static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] {PoolAttributeDefinitions.KEEPALIVE_TIME,
PoolAttributeDefinitions.MAX_THREADS, PoolAttributeDefinitions.THREAD_FACTORY};

static final AttributeDefinition[] RW_ATTRIBUTES = new AttributeDefinition[]{};

private final ThreadFactoryResolver threadFactoryResolver;
private final ServiceName serviceNameBase;
private final RuntimeCapability<Void> capability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@

import static org.jboss.as.threads.CommonAttributes.SCHEDULED_THREAD_POOL;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.msc.service.ServiceName;

import java.util.Arrays;
import java.util.Collection;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.msc.service.ServiceName;

/**
* {@link org.jboss.as.controller.ResourceDefinition} for a scheduled thread pool resource.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ScheduledThreadPoolResourceDefinition extends PersistentResourceDefinition {
public class ScheduledThreadPoolResourceDefinition extends SimpleResourceDefinition {
private final ScheduledThreadPoolWriteAttributeHandler writeAttributeHandler;
private final ScheduledThreadPoolMetricsHandler metricsHandler;
private final boolean registerRuntimeOnly;
Expand Down Expand Up @@ -74,9 +69,4 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
metricsHandler.registerAttributes(resourceRegistration);
}
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(writeAttributeHandler.attributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.jboss.as.threads;



import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.capability.RuntimeCapability;
Expand All @@ -25,7 +24,7 @@ public class ScheduledThreadPoolWriteAttributeHandler extends ThreadsWriteAttrib
private final RuntimeCapability capability;

public ScheduledThreadPoolWriteAttributeHandler(final RuntimeCapability capability, ServiceName serviceNameBase) {
super(ScheduledThreadPoolAdd.ATTRIBUTES, ScheduledThreadPoolAdd.RW_ATTRIBUTES);
super(ScheduledThreadPoolAdd.ATTRIBUTES);
this.serviceNameBase = serviceNameBase;
this.capability = capability;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public class ThreadFactoryAdd extends AbstractAddStepHandler {
static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] {
PoolAttributeDefinitions.GROUP_NAME, PoolAttributeDefinitions.THREAD_NAME_PATTERN, PoolAttributeDefinitions.PRIORITY};

static final AttributeDefinition[] RW_ATTRIBUTES = new AttributeDefinition[] {
PoolAttributeDefinitions.GROUP_NAME, PoolAttributeDefinitions.THREAD_NAME_PATTERN, PoolAttributeDefinitions.PRIORITY};

private final RuntimeCapability cap;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@

package org.jboss.as.threads;

import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.ThreadFactory;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.ReadResourceNameOperationStepHandler;
import org.jboss.as.controller.ServiceRemoveStepHandler;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
Expand All @@ -24,7 +20,7 @@
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
public class ThreadFactoryResourceDefinition extends PersistentResourceDefinition {
public class ThreadFactoryResourceDefinition extends SimpleResourceDefinition {
public static final ThreadFactoryResourceDefinition DEFAULT_INSTANCE = new ThreadFactoryResourceDefinition();

public ThreadFactoryResourceDefinition() {
Expand All @@ -50,9 +46,4 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
resourceRegistration.registerReadOnlyAttribute(PoolAttributeDefinitions.NAME, ReadResourceNameOperationStepHandler.INSTANCE);
ThreadFactoryWriteAttributeHandler.INSTANCE.registerAttributes(resourceRegistration);
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ThreadFactoryWriteAttributeHandler.INSTANCE.attributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ThreadFactoryWriteAttributeHandler extends ThreadsWriteAttributeOpe
public static final ThreadFactoryWriteAttributeHandler INSTANCE = new ThreadFactoryWriteAttributeHandler();

private ThreadFactoryWriteAttributeHandler() {
super(ThreadFactoryAdd.ATTRIBUTES, ThreadFactoryAdd.RW_ATTRIBUTES);
super(ThreadFactoryAdd.ATTRIBUTES);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,38 @@

package org.jboss.as.threads;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.descriptions.DeprecatedResourceDescriptionResolver;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.OperationEntry;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
* {@link org.jboss.as.controller.ResourceDefinition} for the root resource of the threads subsystem.
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
@Deprecated(forRemoval = true)
@SuppressWarnings({"removal", "DeprecatedIsStillUsed"})
class ThreadSubsystemResourceDefinition extends PersistentResourceDefinition {
class ThreadSubsystemResourceDefinition extends SimpleResourceDefinition {
private final boolean registerRuntimeOnly;

ThreadSubsystemResourceDefinition(boolean runtimeOnly) {
super(ThreadsExtension.SUBSYSTEM_PATH,
new DeprecatedResourceDescriptionResolver(ThreadsExtension.SUBSYSTEM_NAME, ThreadsExtension.SUBSYSTEM_NAME, ThreadsExtension.RESOURCE_NAME,
ThreadsExtension.class.getClassLoader(), true, false), ThreadsSubsystemAdd.INSTANCE, ReloadRequiredRemoveStepHandler.INSTANCE,
OperationEntry.Flag.RESTART_NONE, OperationEntry.Flag.RESTART_ALL_SERVICES);
super(new Parameters(ThreadsExtension.SUBSYSTEM_PATH, new DeprecatedResourceDescriptionResolver(ThreadsExtension.SUBSYSTEM_NAME, ThreadsExtension.SUBSYSTEM_NAME, ThreadsExtension.RESOURCE_NAME, ThreadsExtension.class.getClassLoader(), true, false))
.setAddHandler(ThreadsSubsystemAdd.INSTANCE).setAddRestartLevel(OperationEntry.Flag.RESTART_NONE)
.setRemoveHandler(ReloadRequiredRemoveStepHandler.INSTANCE).setRemoveRestartLevel(OperationEntry.Flag.RESTART_ALL_SERVICES));
setDeprecated(ThreadsExtension.DEPRECATED_SINCE);
this.registerRuntimeOnly = runtimeOnly;
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Collections.emptySet();
}

@Override
protected List<? extends PersistentResourceDefinition> getChildren() {
return Arrays.asList(
ThreadFactoryResourceDefinition.DEFAULT_INSTANCE,
QueuelessThreadPoolResourceDefinition.create(true, registerRuntimeOnly),
QueuelessThreadPoolResourceDefinition.create(false, registerRuntimeOnly),

BoundedQueueThreadPoolResourceDefinition.create(true, registerRuntimeOnly),
BoundedQueueThreadPoolResourceDefinition.create(false, registerRuntimeOnly),

UnboundedQueueThreadPoolResourceDefinition.create(registerRuntimeOnly),
ScheduledThreadPoolResourceDefinition.create(registerRuntimeOnly)
);
public void registerChildren(ManagementResourceRegistration registration) {
registration.registerSubModel(ThreadFactoryResourceDefinition.DEFAULT_INSTANCE);
registration.registerSubModel(QueuelessThreadPoolResourceDefinition.create(true, this.registerRuntimeOnly));
registration.registerSubModel(QueuelessThreadPoolResourceDefinition.create(false, this.registerRuntimeOnly));
registration.registerSubModel(BoundedQueueThreadPoolResourceDefinition.create(true, this.registerRuntimeOnly));
registration.registerSubModel(BoundedQueueThreadPoolResourceDefinition.create(false, this.registerRuntimeOnly));
registration.registerSubModel(UnboundedQueueThreadPoolResourceDefinition.create(this.registerRuntimeOnly));
registration.registerSubModel(ScheduledThreadPoolResourceDefinition.create(this.registerRuntimeOnly));
}
}
Loading

0 comments on commit 6437f95

Please sign in to comment.