-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WFCORE-6663 Add new AttributeDefinition implementations that resolves…
… a model directly to a ServiceDependency.
- Loading branch information
Showing
16 changed files
with
1,133 additions
and
53 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ | |
/** | ||
* @author <a href="mailto:[email protected]">Tomaz Cerar</a> | ||
*/ | ||
public final class StringListAttributeDefinition extends PrimitiveListAttributeDefinition { | ||
public class StringListAttributeDefinition extends PrimitiveListAttributeDefinition { | ||
|
||
private StringListAttributeDefinition(Builder builder) { | ||
protected StringListAttributeDefinition(Builder builder) { | ||
super(builder, ModelType.STRING); | ||
} | ||
|
||
|
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: 37 additions & 0 deletions
37
subsystem/src/main/java/org/wildfly/subsystem/resource/ResourceResolver.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,37 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.subsystem.resource; | ||
|
||
import org.jboss.as.controller.OperationContext; | ||
import org.jboss.as.controller.OperationFailedException; | ||
import org.jboss.as.controller.PathAddress; | ||
import org.jboss.as.controller.registry.Resource; | ||
|
||
/** | ||
* Resolves a value from a resource. | ||
*/ | ||
public interface ResourceResolver<T> { | ||
|
||
/** | ||
* Resolves a value from the specified resource, using the specified operation context. | ||
* @param context an operation context | ||
* @param resource a resource | ||
* @return the resolved value | ||
* @throws OperationFailedException if the value could not be resolved | ||
*/ | ||
default T resolve(OperationContext context) throws OperationFailedException { | ||
return this.resolve(context, context.readResource(PathAddress.EMPTY_ADDRESS, false)); | ||
} | ||
|
||
/** | ||
* Resolves a value from the specified resource, using the specified operation context. | ||
* @param context an operation context | ||
* @param resource a resource | ||
* @return the resolved value | ||
* @throws OperationFailedException if the value could not be resolved | ||
*/ | ||
T resolve(OperationContext context, Resource resource) throws OperationFailedException; | ||
} |
115 changes: 115 additions & 0 deletions
115
subsystem/src/main/java/org/wildfly/subsystem/resource/SimpleResource.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,115 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.wildfly.subsystem.resource; | ||
|
||
import java.util.Set; | ||
|
||
import org.jboss.as.controller.PathAddress; | ||
import org.jboss.as.controller.PathElement; | ||
import org.jboss.as.controller.registry.Resource; | ||
import org.jboss.dmr.ModelNode; | ||
|
||
/** | ||
* A resource facade for an existing resource model, i.e. with no children | ||
*/ | ||
public class SimpleResource implements Resource { | ||
private final ModelNode model; | ||
|
||
public SimpleResource(ModelNode model) { | ||
this.model = model; | ||
} | ||
|
||
@Override | ||
public ModelNode getModel() { | ||
return this.model; | ||
} | ||
|
||
@Override | ||
public void writeModel(ModelNode newModel) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public boolean isModelDefined() { | ||
return this.model.isDefined(); | ||
} | ||
|
||
@Override | ||
public boolean hasChild(PathElement element) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Resource getChild(PathElement element) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Resource requireChild(PathElement element) { | ||
throw new NoSuchResourceException(element); | ||
} | ||
|
||
@Override | ||
public boolean hasChildren(String childType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Resource navigate(PathAddress address) { | ||
if (address.size() == 0) return this; | ||
throw new NoSuchResourceException(address.getElement(0)); | ||
} | ||
|
||
@Override | ||
public Set<String> getChildTypes() { | ||
return Set.of(); | ||
} | ||
|
||
@Override | ||
public Set<String> getChildrenNames(String childType) { | ||
return Set.of(); | ||
} | ||
|
||
@Override | ||
public Set<ResourceEntry> getChildren(String childType) { | ||
return Set.of(); | ||
} | ||
|
||
@Override | ||
public void registerChild(PathElement address, Resource resource) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void registerChild(PathElement address, int index, Resource resource) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Resource removeChild(PathElement address) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Set<String> getOrderedChildTypes() { | ||
return Set.of(); | ||
} | ||
|
||
@Override | ||
public boolean isRuntime() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isProxy() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Resource clone() { | ||
return new SimpleResource(this.model.clone()); | ||
} | ||
} |
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
Oops, something went wrong.