Skip to content

Commit

Permalink
Merge pull request wildfly#9977 from ctomc/deprecated-api
Browse files Browse the repository at this point in the history
WFLY-7576  stop using deprecated api
  • Loading branch information
kabir committed Apr 30, 2017
2 parents 5ec7502 + 6873c42 commit dc93207
Show file tree
Hide file tree
Showing 213 changed files with 912 additions and 1,227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void initialize(final ExtensionContext context) {

@Override
public void initializeParsers(final ExtensionParsingContext context) {
context.setSubsystemXmlMapping(Constants.SUBSYSTEM_NAME, AppClientExtension.NAMESPACE_1_0, parser);
context.setSubsystemXmlMapping(Constants.SUBSYSTEM_NAME, AppClientExtension.NAMESPACE_1_0, () -> parser);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class AppClientSubsystemResourceDefinition extends SimpleResourceDefiniti
.setAllowExpression(true).build();

public static final StringListAttributeDefinition PARAMETERS = new StringListAttributeDefinition.Builder(Constants.PARAMETERS)
.setAllowNull(true)
.setRequired(false)
.setAllowExpression(true)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void initializeParsers(ExtensionParsingContext context) {
for (Namespace namespace : Namespace.values()) {
final String uri = namespace.getUriString();
if (uri != null) {
context.setSubsystemXmlMapping(BatchSubsystemDefinition.NAME, uri, BatchSubsystemParser.INSTANCE);
context.setSubsystemXmlMapping(BatchSubsystemDefinition.NAME, uri, BatchSubsystemParser::new);
}
}
}
Expand All @@ -54,7 +54,7 @@ public void initializeParsers(ExtensionParsingContext context) {
public void initialize(ExtensionContext context) {
final SubsystemRegistration subsystem = context.registerSubsystem(BatchSubsystemDefinition.NAME, CURRENT_MODEL_VERSION);
subsystem.registerSubsystemModel(BatchSubsystemDefinition.INSTANCE);
subsystem.registerXMLElementWriter(BatchSubsystemParser.INSTANCE);
subsystem.registerXMLElementWriter(new BatchSubsystemParser());
// Register the deployment resources
if (context.isRuntimeOnlyRegistrationValid()) {
final SimpleResourceDefinition deploymentResource = new SimpleResourceDefinition(new SimpleResourceDefinition.Parameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@
*/
class BatchSubsystemParser implements XMLStreamConstants, XMLElementReader<List<ModelNode>>, XMLElementWriter<SubsystemMarshallingContext> {

static final BatchSubsystemParser INSTANCE = new BatchSubsystemParser();

private final ThreadsParser threadsParser;

public BatchSubsystemParser() {
BatchSubsystemParser() {
threadsParser = ThreadsParser.getInstance();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public void initialize(final ExtensionContext context) {

@Override
public void initializeParsers(final ExtensionParsingContext context) {
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.BEAN_VALIDATION_1_0.getUriString(), BeanValidationSubsystemParser.INSTANCE);
context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.BEAN_VALIDATION_1_0.getUriString(), () -> BeanValidationSubsystemParser.INSTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jboss.as.controller.CapabilityReferenceRecorder;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.registry.Resource;
import org.wildfly.clustering.service.BinaryRequirement;
import org.wildfly.clustering.service.Requirement;
import org.wildfly.clustering.service.UnaryRequirement;
Expand Down Expand Up @@ -59,7 +60,7 @@ public CapabilityReference(Capability capability, UnaryRequirement requirement)
* @param requirement the requirement of the specified capability
*/
public CapabilityReference(Capability capability, BinaryRequirement requirement) {
this(capability, requirement, context -> context.getCurrentAddressValue());
this(capability, requirement, OperationContext::getCurrentAddressValue);
}

/**
Expand Down Expand Up @@ -89,18 +90,28 @@ public CapabilityReference(Capability capability, BinaryRequirement requirement,
}

@Override
public void addCapabilityRequirements(OperationContext context, String attributeName, String... values) {
public void addCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... values) {
String dependentName = this.capability.resolve(context.getCurrentAddress()).getName();
Stream.of(values).forEach(value -> this.requirementResolver.apply(context, value).ifPresent(requirementName -> context.registerAdditionalCapabilityRequirement(requirementName, dependentName, attributeName)));
}

@Override
public void removeCapabilityRequirements(OperationContext context, String attributeName, String... values) {
public void removeCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... values) {
String dependentName = this.capability.resolve(context.getCurrentAddress()).getName();
Stream.of(values).forEach(value -> this.requirementResolver.apply(context, value).ifPresent(requirementName -> context.deregisterCapabilityRequirement(requirementName, dependentName)));
}
//todo remove once it is removed from core
@Deprecated
public void addCapabilityRequirements(OperationContext context, String attributeName, String... attributeValues) {
addCapabilityRequirements(context, null, attributeName, attributeValues);
}
//todo remove once it is removed from core
@Deprecated
public void removeCapabilityRequirements(OperationContext context, String attributeName, String... attributeValues) {
removeCapabilityRequirements(context, null, attributeName, attributeValues);
}

@Override
@Deprecated
public String getBaseDependentName() {
return this.capability.getDefinition().getName();
}
Expand All @@ -117,7 +128,7 @@ public boolean isDynamicDependent() {

@Override
public int hashCode() {
return this.getBaseDependentName().hashCode();
return this.capability.getDefinition().getName().hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute
}
}
this.definition = ObjectTypeAttributeDefinition.Builder.of(name, definitions.toArray(new AttributeDefinition[size]))
.setAllowNull(true)
.setRequired(false)
.setDeprecated(InfinispanModel.VERSION_4_0_0.getVersion())
.setSuffix("table")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute

DeprecatedAttribute(String name, InfinispanModel deprecation) {
this(new SimpleMapAttributeDefinition.Builder(name, true)
.setAllowNull(true)
.setRequired(false)
.setAttributeMarshaller(AttributeMarshallers.PROPERTY_LIST)
.setAttributeParser(AttributeParsers.COLLECTION)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES), deprecation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute
}
}
this.definition = ObjectTypeAttributeDefinition.Builder.of(name, definitions.toArray(new AttributeDefinition[size]))
.setAllowNull(true)
.setRequired(false)
.setDeprecated(InfinispanModel.VERSION_4_0_0.getVersion())
.setSuffix("table")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@ public org.jboss.as.clustering.controller.Capability getCapability() {
@Deprecated
static final ObjectTypeAttributeDefinition TRANSPORT = ObjectTypeAttributeDefinition.Builder.of(TransportResourceDefinition.WILDCARD_PATH.getKey(), AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getDefinition(), TransportResourceDefinition.Attribute.SHARED.getDefinition(), SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING.getDefinition(), TransportResourceDefinition.Attribute.DIAGNOSTICS_SOCKET_BINDING.getDefinition(), TransportResourceDefinition.ThreadingAttribute.DEFAULT_EXECUTOR.getDefinition(), TransportResourceDefinition.ThreadingAttribute.OOB_EXECUTOR.getDefinition(), TransportResourceDefinition.ThreadingAttribute.TIMER_EXECUTOR.getDefinition(), TransportResourceDefinition.ThreadingAttribute.THREAD_FACTORY.getDefinition(), TransportResourceDefinition.Attribute.SITE.getDefinition(), TransportResourceDefinition.Attribute.RACK.getDefinition(), TransportResourceDefinition.Attribute.MACHINE.getDefinition(), AbstractProtocolResourceDefinition.Attribute.PROPERTIES.getDefinition())
.setDeprecated(JGroupsModel.VERSION_3_0_0.getVersion())
.setAllowNull(true)
.setRequired(false)
.setSuffix(null)
.build();

@Deprecated
static final ObjectTypeAttributeDefinition PROTOCOL = ObjectTypeAttributeDefinition.Builder.of(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getDefinition(), ProtocolResourceDefinition.DeprecatedAttribute.SOCKET_BINDING.getDefinition(), AbstractProtocolResourceDefinition.Attribute.PROPERTIES.getDefinition())
.setAllowNull(true)
.setRequired(false)
.setSuffix("protocol")
.build();

@Deprecated
static final AttributeDefinition PROTOCOLS = ObjectListAttributeDefinition.Builder.of("protocols", PROTOCOL)
.setDeprecated(JGroupsModel.VERSION_3_0_0.getVersion())
.setAllowNull(true)
.setRequired(false)
.build();

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
}
}, OperationContext.Stage.RUNTIME);
}
context.stepCompleted();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
}
}, OperationContext.Stage.RUNTIME);
}
context.stepCompleted();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static List<AttributeDefinition> getAttributesFromPlugin(StatisticsPlugin
modelType = ModelType.LONG;
}
SimpleAttributeDefinition attribute = new SimpleAttributeDefinitionBuilder(name, modelType)
.setAllowNull(true)
.setRequired(false)
.setStorageRuntime()
.build();
result.add(attribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public class Constants {
public static final SimpleAttributeDefinition INITIAL_POOL_SIZE = new SimpleAttributeDefinitionBuilder(INITIAL_POOL_SIZE_NAME, ModelType.INT)
.setXmlName(Pool.Tag.INITIAL_POOL_SIZE.getLocalName())
.setAllowExpression(true)
.setAllowNull(true)
.setRequired(false)
.setDefaultValue(new ModelNode(Defaults.MIN_POOL_SIZE))
.build();

Expand All @@ -156,7 +156,7 @@ public class Constants {

public static PropertiesAttributeDefinition CAPACITY_INCREMENTER_PROPERTIES = new PropertiesAttributeDefinition.Builder(CAPACITY_INCREMENTER_PROPERTIES_NAME, true)
.setXmlName(org.jboss.jca.common.api.metadata.common.Extension.Tag.CONFIG_PROPERTY.getLocalName())
.setAllowNull(true)
.setRequired(false)
.setAllowExpression(true)
.setAttributeMarshaller(new AttributeMarshaller() {
@Override
Expand All @@ -181,7 +181,7 @@ public void marshallAsElement(final AttributeDefinition attribute, final ModelNo

public static PropertiesAttributeDefinition CAPACITY_DECREMENTER_PROPERTIES = new PropertiesAttributeDefinition.Builder(CAPACITY_DECREMENTER_PROPERTIES_NAME, true)
.setXmlName(org.jboss.jca.common.api.metadata.common.Extension.Tag.CONFIG_PROPERTY.getLocalName())
.setAllowNull(true)
.setRequired(false)
.setAllowExpression(true)
.setAttributeMarshaller(new AttributeMarshaller() {
@Override
Expand Down Expand Up @@ -221,7 +221,7 @@ public void marshallAsElement(final AttributeDefinition attribute, final ModelNo
public static final SimpleAttributeDefinition POOL_FLUSH_STRATEGY = new SimpleAttributeDefinitionBuilder(FLUSH_STRATEGY_NAME, ModelType.STRING)
.setDefaultValue(new ModelNode(Defaults.FLUSH_STRATEGY.getName()))
.setXmlName(Pool.Tag.FLUSH_STRATEGY.getLocalName())
.setAllowNull(true)
.setRequired(false)
.setAllowExpression(true)
.setAllowedValues(Stream.of(FlushStrategy.values()).map(FlushStrategy::toString).filter(Objects::nonNull).toArray(String[]::new))
.setValidator(new EnumValidator<FlushStrategy>(FlushStrategy.class, true, true))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
final ModelNode currentValue = submodel.hasDefined(parameterName) ? submodel.get(parameterName).clone() : new ModelNode();

context.getResult().set(currentValue);

context.stepCompleted();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage()));
}
}
context.stepCompleted();
}
}, OperationContext.Stage.RUNTIME);
}

context.stepCompleted();
}

protected abstract List<StatisticsPlugin> getMatchingStats(String jndiName, ManagementRepository repository);
Expand Down Expand Up @@ -102,13 +99,9 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage()));
}
}
context.stepCompleted();
}
}, OperationContext.Stage.RUNTIME);
}

context.stepCompleted();

}

private void setModelValue(ModelNode result, String attributeName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
}
}, OperationContext.Stage.RUNTIME);
}
context.stepCompleted();
}

protected abstract ModelNode invokeCommandOn(Pool pool, Object... parameters) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,9 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
} catch (Exception e) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToGetMetrics(e.getLocalizedMessage()));
}

context.stepCompleted();
}
}, OperationContext.Stage.RUNTIME);
}

context.stepCompleted();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
}

}
context.stepCompleted();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected void executeRuntimeStep(OperationContext context, ModelNode operation)
if (ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION.equals(opName)) {
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
executeReadAttribute(attributeName, context, dataSource, address);
context.stepCompleted();
} else {
throw unknownOperation(opName);
}
Expand Down
Loading

0 comments on commit dc93207

Please sign in to comment.