Skip to content

Commit

Permalink
Merge pull request #45 from gaol/issue_43
Browse files Browse the repository at this point in the history
[issue-43] Drop the file based attributes and resources
  • Loading branch information
gaol authored Nov 29, 2024
2 parents 6e4a2f2 + 5ff78ff commit 5d7e050
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected AbstractVertxOptionsResourceDefinition(SimpleResourceDefinition.Parame
protected static class VertxOptionRemoveHandler extends AbstractVertxOptionRemoveHandler {
@Override
protected void doPerform(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceName vertxServiceName = VertxOptionFileResourceDefinition.VERTX_OPTIONS_CAPABILITY.getCapabilityServiceName(context.getCurrentAddressValue());
ServiceName vertxServiceName = VERTX_OPTIONS_CAPABILITY.getCapabilityServiceName(context.getCurrentAddressValue());
context.removeService(vertxServiceName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class AddressResolverResourceDefinition extends SimpleResourceDefinition impleme
.build();

// AddressResolverOptions
public static final SimpleAttributeDefinition ATTR_HOSTS_PATH = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_HOSTS_PATH, ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
.build();

public static final SimpleAttributeDefinition ATTR_HOSTS_VALUE = new SimpleAttributeDefinitionBuilder(VertxConstants.ATTR_HOSTS_VALUE, ModelType.STRING)
.setRequired(false)
.setAllowExpression(true)
Expand Down Expand Up @@ -129,7 +124,6 @@ class AddressResolverResourceDefinition extends SimpleResourceDefinition impleme

private static final List<AttributeDefinition> VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS = new ArrayList<>();
static {
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_HOSTS_PATH);
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_HOSTS_VALUE);
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_SERVERS);
VERTX_ADDRESS_RESOLVER_OPTIONS_ATTRS.add(ATTR_OPT_RES_ENABLED);
Expand Down Expand Up @@ -218,9 +212,6 @@ public void stop(StopContext stopContext) {

private AddressResolverOptions parseAddressResolverOptions(ModelNode operation) throws OperationFailedException {
AddressResolverOptions addressResolverOptions = new AddressResolverOptions();
if (operation.hasDefined(VertxConstants.ATTR_HOSTS_PATH)) {
addressResolverOptions.setHostsPath(ATTR_HOSTS_PATH.validateOperation(operation).asString());
}
if (operation.hasDefined(VertxConstants.ATTR_HOSTS_VALUE)) {
addressResolverOptions.setHostsValue(Buffer.buffer(ATTR_HOSTS_VALUE.validateOperation(operation).asString()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.function.Consumer;
import java.util.function.Supplier;

import static org.wildfly.extension.vertx.AbstractVertxOptionsResourceDefinition.VERTX_OPTIONS_CAPABILITY;
import static org.wildfly.extension.vertx.VertxConstants.ATTR_FS_FILE_CACHE_DIR;
import static org.wildfly.extension.vertx.VertxConstants.ELEMENT_VERTX_OPTION_ADDRESS_RESOLVER;

Expand All @@ -36,11 +37,6 @@ public class NamedVertxOptionsService implements Service {
private final Supplier<ServerEnvironment> serverEnvironmentSupplier;
private final boolean defaultFileCacheDir;

NamedVertxOptionsService(NamedVertxOptions namedVertxOptions,
Consumer<NamedVertxOptions> consumer) {
this(namedVertxOptions, null, null, false, consumer);
}

NamedVertxOptionsService(NamedVertxOptions namedVertxOptions,
Supplier<AddressResolverOptions> addressResolverOptionsSupplier,
Supplier<ServerEnvironment> serverEnvironmentSupplier,
Expand All @@ -65,7 +61,7 @@ public class NamedVertxOptionsService implements Service {
static void installVertxOptionsService(OperationContext context, ModelNode operation) throws OperationFailedException {
final String name = context.getCurrentAddressValue();
VertxOptions vertxOptions = VertxOptionsResourceDefinition.parseOptions(operation);
ServiceName vertxServiceName = VertxOptionFileResourceDefinition.VERTX_OPTIONS_CAPABILITY.getCapabilityServiceName(name);
ServiceName vertxServiceName = VERTX_OPTIONS_CAPABILITY.getCapabilityServiceName(name);
ServiceBuilder<?> vertxServiceBuilder = context.getCapabilityServiceTarget().addService();
Supplier<AddressResolverOptions> addressResolverOptionsSupplier = null;
if (operation.hasDefined(ELEMENT_VERTX_OPTION_ADDRESS_RESOLVER)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public interface VertxConstants {
String ATTR_FS_FILE_CACHE_DIR = "file-cache-dir";

// address resolver options
String ATTR_HOSTS_PATH = "hosts-path";
String ATTR_HOSTS_VALUE = "hosts-value";
String ATTR_HOSTS_REFRESH_PERIOD = "hosts-refresh-period";
String ATTR_SERVERS = "servers";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class VertxSubsystemDefinition extends SimpleResourceDefinition {
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
resourceRegistration.registerSubModel(VertxResourceDefinition.INSTANCE);
resourceRegistration.registerSubModel(VertxOptionFileResourceDefinition.INSTANCE);
resourceRegistration.registerSubModel(VertxOptionsResourceDefinition.INSTANCE);
resourceRegistration.registerSubModel(AddressResolverResourceDefinition.INSTANCE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public PersistentResourceXMLDescription getXMLDescription() {
)
.addChild(
decorator(ELEMENT_VERTX_OPTIONS)
.addChild(
builder(VertxOptionFileResourceDefinition.INSTANCE.getPathElement())
.addAttributes(VertxOptionsAttributes.getVertxOptionsFileAttributes().toArray(new AttributeDefinition[0]))
)
.addChild(
builder(VertxOptionsResourceDefinition.INSTANCE.getPathElement())
.addAttributes(VertxOptionsAttributes.getVertxOptionsAttributes().toArray(new AttributeDefinition[0]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ vertx.remove=Remove Vertx Subsystem
vertx.vertx=The service which provides a Vert.x instance
vertx.option-name=The option name used to refer to the VertxOptions definition

vertx.vertx-option-file=VertxOptions that comes from a Json file path
vertx.vertx-option-file.add=Add a VertxOptions by specifying the json file path
vertx.vertx-option-file.remove=Remove a VertxOptions defined by a json file path
vertx.vertx-option-file.path=A JSON file path where to read the VertxOptions from

vertx.vertx-option=The VertxOptions Definition
vertx.vertx-option.add=Add a VertxOptions
vertx.vertx-option.remove=Remove a VertxOptions
Expand All @@ -41,7 +36,6 @@ vertx.vertx-option.show-info=Show VertxOptions information
vertx.address-resolver-option=Configuration options for Vert.x hostname resolver.
vertx.address-resolver-option.add=Add the AddressResolverOptions
vertx.address-resolver-option.remove=Remove the AddressResolverOptions
vertx.address-resolver-option.hosts-path=The path of an alternate hosts configuration file to use instead of the one provided by the os.
vertx.address-resolver-option.hosts-value=The alternate hosts configuration file to use instead of the one provided by the os.
vertx.address-resolver-option.servers=The list of DNS server addresses, an address is the IP of the dns server, followed by an optional colon and a port.
vertx.address-resolver-option.opt-resource-enabled=The option to enable the automatic inclusion in DNS queries of an optional record that hints the remote DNS server about how much data the resolver can read per response.
Expand Down
15 changes: 0 additions & 15 deletions subsystem/src/main/resources/schema/wildfly-vertx_1_0_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@

<xs:complexType name="vertxOptionsType">
<xs:sequence>
<xs:element name="vertx-option-file" type="vertxOptionFileType" maxOccurs="unbounded" minOccurs="0">
<xs:annotation>
<xs:documentation>Define a VertxOptions from a Json file</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vertx-option" type="vertxOptionType" maxOccurs="unbounded" minOccurs="0">
<xs:annotation>
<xs:documentation>Define a VertxOptions by specifying each property</xs:documentation>
Expand All @@ -48,15 +43,6 @@
</xs:sequence>
</xs:complexType>

<xs:complexType name="vertxOptionFileType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="path" type="xs:string">
<xs:annotation>
<xs:documentation>Specify the json file path where to read VertxOptions from.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>

<xs:complexType name="vertxOptionType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="event-loop-pool-size" type="xs:int"/>
Expand Down Expand Up @@ -86,7 +72,6 @@

<xs:complexType name="addressResolverOptionType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="hosts-path" type="xs:string" />
<xs:attribute name="hosts-value" type="xs:string" />
<xs:attribute name="servers" type="xs:string" />
<xs:attribute name="opt-resource-enabled" type="xs:boolean" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
warning-exception-time="5" warning-exception-time-unit="SECONDS"
classpath-resolving-enabled="true" file-cache-enabled="true" file-cache-dir="tmp"
/>
<address-resolver-option name="aro" max-queries="20" hosts-path="/etc/hosts" hosts-value="127.0.0.1 localhost"
<address-resolver-option name="aro" max-queries="20" hosts-value="127.0.0.1 localhost"
servers="192.168.1.1,8.8.8.8" opt-resource-enabled="true"
cache-min-time-to-live="30" cache-max-time-to-live="600" cache-negative-time-to-live="10"
query-time-out="5000" rd-flag="true" search-domains="local,remote" n-dots="-1" rotate-servers="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public void testAddVertxOption() throws IOException {
public void testAddressResolverOption() throws IOException {
final String addressResolverName = "aro";
ModelNode operation = addressResolverOperation(addressResolverName, "add");
operation.get(ATTR_HOSTS_PATH).set("local-path");
operation.get(ATTR_HOSTS_VALUE).set("127.0.0.1 localhost");
operation.get(ATTR_SERVERS).add("localhost").add("127.0.0.1");
operation.get(ATTR_OPT_RES_ENABLED).set(true);
Expand All @@ -116,7 +115,6 @@ public void testAddressResolverOption() throws IOException {
ModelNode response = executeOperation(managementClient, addressResolverOperation(addressResolverName, "read-resource"));
ModelNode result = response.get(RESULT);
Assert.assertNotNull(result);
Assert.assertEquals("local-path", result.get(ATTR_HOSTS_PATH).asString());

List<String> serverList = result.get(ATTR_SERVERS).asList().stream().map(ModelNode::asString).collect(Collectors.toList());
Assert.assertTrue(serverList.contains("localhost"));
Expand Down Expand Up @@ -145,7 +143,6 @@ public void testAddressResolverOption() throws IOException {
VertxOptions vertxOptions = readVertxOptions(managementClient, optionName);
AddressResolverOptions addressResolverOptions = vertxOptions.getAddressResolverOptions();
Assert.assertNotNull(addressResolverOptions);
Assert.assertEquals("local-path", addressResolverOptions.getHostsPath());
Assert.assertTrue(addressResolverOptions.getServers().contains("localhost"));
Assert.assertTrue(addressResolverOptions.getServers().contains("127.0.0.1"));
Assert.assertTrue(addressResolverOptions.isOptResourceEnabled());
Expand Down

0 comments on commit 5d7e050

Please sign in to comment.