Search in sources :

Example 1 with WildFlySubsystem

use of org.wildfly.swarm.spi.api.annotations.WildFlySubsystem in project wildfly-swarm by wildfly-swarm.

the class SubsystemMarshaller method marshal.

public void marshal(List<ModelNode> list) {
    for (Fraction each : this.fractions) {
        MarshalDMR anno = each.getClass().getAnnotation(MarshalDMR.class);
        if (anno != null) {
            try {
                try (AutoCloseable handle = Performance.time("marshall " + each.getClass().getSimpleName())) {
                    LinkedList<ModelNode> subList = Marshaller.marshal(each);
                    if (!isAlreadyConfigured(subList, list)) {
                        list.addAll(subList);
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } else {
            WildFlySubsystem subsysAnno = each.getClass().getAnnotation(WildFlySubsystem.class);
            if (subsysAnno != null) {
                PathAddress address = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, subsysAnno.value()));
                if (!isAlreadyConfigured(address.toModelNode(), list)) {
                    ModelNode node = new ModelNode();
                    node.get(OP_ADDR).set(address.toModelNode());
                    node.get(OP).set(ADD);
                    list.add(node);
                }
            }
        }
    }
}
Also used : MarshalDMR(org.wildfly.swarm.spi.api.annotations.MarshalDMR) PathAddress(org.jboss.as.controller.PathAddress) WildFlySubsystem(org.wildfly.swarm.spi.api.annotations.WildFlySubsystem) Fraction(org.wildfly.swarm.spi.api.Fraction) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)1 ModelNode (org.jboss.dmr.ModelNode)1 Fraction (org.wildfly.swarm.spi.api.Fraction)1 MarshalDMR (org.wildfly.swarm.spi.api.annotations.MarshalDMR)1 WildFlySubsystem (org.wildfly.swarm.spi.api.annotations.WildFlySubsystem)1