Exemplo n.º 1
0
  @Override
  protected void populateModel(OperationContext context, ModelNode operation, Resource resource)
      throws OperationFailedException {
    super.populateModel(context, operation, resource);

    final ModelNode connectorRefs = resource.getModel().get(CONNECTOR_REFS.getName());
    if (connectorRefs.isDefined()) {
      context.addStep(
          new OperationStepHandler() {
            @Override
            public void execute(OperationContext context, ModelNode operation)
                throws OperationFailedException {
              validateConnectors(context, operation, connectorRefs);
            }
          },
          OperationContext.Stage.MODEL);
    }
  }
Exemplo n.º 2
0
 private static void writeClusterConnections(XMLExtendedStreamWriter writer, ModelNode node)
     throws XMLStreamException {
   if (!node.isDefined()) {
     return;
   }
   List<Property> properties = node.asPropertyList();
   if (!properties.isEmpty()) {
     writer.writeStartElement(Element.CLUSTER_CONNECTIONS.getLocalName());
     for (final Property property : node.asPropertyList()) {
       writer.writeStartElement(Element.CLUSTER_CONNECTION.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
       final ModelNode cluster = property.getValue();
       for (AttributeDefinition attribute : ClusterConnectionDefinition.ATTRIBUTES) {
         if (attribute == ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY) {
           // we nest it in static-connectors
           continue;
         }
         if (attribute == CONNECTOR_REFS) {
           if (attribute.isMarshallable(cluster)) {
             writer.writeStartElement(Element.STATIC_CONNECTORS.getLocalName());
             ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
             CONNECTOR_REFS.marshallAsElement(cluster, writer);
             writer.writeEndElement();
           } else if (ALLOW_DIRECT_CONNECTIONS_ONLY.isMarshallable(cluster)) {
             writer.writeEmptyElement(Element.STATIC_CONNECTORS.getLocalName());
             ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
           }
         } else {
           attribute.marshallAsElement(property.getValue(), writer);
         }
       }
       writer.writeEndElement();
     }
     writer.writeEndElement();
     writeNewLine(writer);
   }
 }