messaging-activemq/src/main/java/org/wildfly/extension/messaging/activemq/jms/ExternalPooledConnectionFactoryDefinition.java
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
        int size = common.length + specific.length;
        ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
        for (int i = 0; i < specific.length; i++) {
            ConnectionFactoryAttribute attr = specific[i];
            AttributeDefinition definition = attr.getDefinition();
            if (definition == ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS) {
                result[i] = ConnectionFactoryAttribute.create(
                        SimpleAttributeDefinitionBuilder
                                .create(ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS)
                                .setDefaultValue(new ModelNode(-1))
                                .build(),
                        attr.getPropertyName(),
                        true);
            } else {
                result[i] = attr;
            }
        }
        for (int i = 0; i < common.length; i++) {
            ConnectionFactoryAttribute attr = common[i];
            AttributeDefinition definition = attr.getDefinition();

            ConnectionFactoryAttribute newAttr;
            // replace the reconnect-attempts attribute to use a different default value for pooled CF
            if (definition == Common.RECONNECT_ATTEMPTS) {
                AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
                newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
            } else if (definition == CommonAttributes.HA) {
                newAttr = ConnectionFactoryAttribute.create(
                        SimpleAttributeDefinitionBuilder
                                .create(CommonAttributes.HA)
                                .setDefaultValue(ModelNode.TRUE)
                                .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
                                .build(),
                        attr.getPropertyName(),
                        true);
            } else if (definition == Common.CONNECTORS) {
                StringListAttributeDefinition copy = new StringListAttributeDefinition.Builder(Common.CONNECTORS)
                        .setAlternatives(CommonAttributes.DISCOVERY_GROUP)
                        .setRequired(true)
                        .setAttributeParser(AttributeParser.STRING_LIST)
                        .setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
                        .setCapabilityReference(new AbstractTransportDefinition.TransportCapabilityReferenceRecorder(CAPABILITY_NAME, CONNECTOR_CAPABILITY_NAME, true))
                        .setRestartAllServices()
                        .build();
                newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
            } else {
                AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
                newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
            }
            result[specific.length + i] = newAttr;
        }
        return result;
    }
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
        int size = common.length + specific.length;
        ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
        for (int i = 0; i < specific.length; i++) {
            ConnectionFactoryAttribute attr = specific[i];
            AttributeDefinition definition = attr.getDefinition();
            if (definition == ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS) {
                result[i] = ConnectionFactoryAttribute.create(
                        SimpleAttributeDefinitionBuilder
                                .create(ConnectionFactoryAttributes.Pooled.INITIAL_CONNECT_ATTEMPTS)
                                .setDefaultValue(new ModelNode(-1))
                                .build(),
                        attr.getPropertyName(),
                        true);
            } else {
                result[i] = attr;
            }
        }
        for (int i = 0; i < common.length; i++) {
            ConnectionFactoryAttribute attr = common[i];
            AttributeDefinition definition = attr.getDefinition();

            ConnectionFactoryAttribute newAttr;
            // replace the reconnect-attempts attribute to use a different default value for pooled CF
            if (definition == Common.RECONNECT_ATTEMPTS) {
                AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
                newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
            } else if (definition == CommonAttributes.HA) {
                newAttr = ConnectionFactoryAttribute.create(
                        SimpleAttributeDefinitionBuilder
                                .create(CommonAttributes.HA)
                                .setDefaultValue(ModelNode.TRUE)
                                .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
                                .build(),
                        attr.getPropertyName(),
                        true);
            } else if (definition == Common.CONNECTORS) {
                StringListAttributeDefinition copy = new StringListAttributeDefinition.Builder(Common.CONNECTORS)
                        .setAlternatives(CommonAttributes.DISCOVERY_GROUP)
                        .setRequired(true)
                        .setAttributeParser(AttributeParser.STRING_LIST)
                        .setAttributeMarshaller(AttributeMarshaller.STRING_LIST)
                        .setCapabilityReference(new AbstractTransportDefinition.TransportCapabilityReferenceRecorder(CAPABILITY_NAME, CONNECTOR_CAPABILITY_NAME, true))
                        .setRestartAllServices()
                        .build();
                newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
            } else {
                AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
                newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.getConfigType());
            }
            result[specific.length + i] = newAttr;
        }
        return result;
    }
private static ConnectionFactoryAttribute [ ] define ( ConnectionFactoryAttribute [ ] specific , ConnectionFactoryAttribute ... common ) { int size = common . length + specific . length ; ConnectionFactoryAttribute [ ] result = new ConnectionFactoryAttribute [ size ] ; for ( int i = 0 ; i < specific . length ; i ++ ) { ConnectionFactoryAttribute attr = specific [ i ] ; AttributeDefinition definition = attr . getDefinition ( ) ; if ( definition == ConnectionFactoryAttributes . Pooled . INITIAL_CONNECT_ATTEMPTS ) { result [ i ] = ConnectionFactoryAttribute . create ( SimpleAttributeDefinitionBuilder . create ( ConnectionFactoryAttributes . Pooled . INITIAL_CONNECT_ATTEMPTS ) . setDefaultValue ( new ModelNode ( - 1 ) ) . build ( ) , attr . getPropertyName ( ) , true ) ; } else { result [ i ] = attr ; } } for ( int i = 0 ; i < common . length ; i ++ ) { ConnectionFactoryAttribute attr = common [ i ] ; AttributeDefinition definition = attr . getDefinition ( ) ; ConnectionFactoryAttribute newAttr ; // replace the reconnect-attempts attribute to use a different default value for pooled CF if ( definition == Common . RECONNECT_ATTEMPTS ) { AttributeDefinition copy = copy ( Pooled . RECONNECT_ATTEMPTS , AttributeAccess . Flag . RESTART_ALL_SERVICES ) ; newAttr = ConnectionFactoryAttribute . create ( copy , Pooled . RECONNECT_ATTEMPTS_PROP_NAME , true ) ; } else if ( definition == CommonAttributes . HA ) { newAttr = ConnectionFactoryAttribute . create ( SimpleAttributeDefinitionBuilder . create ( CommonAttributes . HA ) . setDefaultValue ( ModelNode . TRUE ) . setFlags ( AttributeAccess . Flag . RESTART_ALL_SERVICES ) . build ( ) , attr . getPropertyName ( ) , true ) ; } else if ( definition == Common . CONNECTORS ) { StringListAttributeDefinition copy = new StringListAttributeDefinition . Builder ( Common . CONNECTORS ) . setAlternatives ( CommonAttributes . DISCOVERY_GROUP ) . setRequired ( true ) . setAttributeParser ( AttributeParser . STRING_LIST ) . setAttributeMarshaller ( AttributeMarshaller . STRING_LIST ) . setCapabilityReference ( new AbstractTransportDefinition . TransportCapabilityReferenceRecorder ( CAPABILITY_NAME , CONNECTOR_CAPABILITY_NAME , true ) ) . setRestartAllServices ( ) . build ( ) ; newAttr = ConnectionFactoryAttribute . create ( copy , attr . getPropertyName ( ) , attr . isResourceAdapterProperty ( ) , attr . getConfigType ( ) ) ; } else { AttributeDefinition copy = copy ( definition , AttributeAccess . Flag . RESTART_ALL_SERVICES ) ; newAttr = ConnectionFactoryAttribute . create ( copy , attr . getPropertyName ( ) , attr . isResourceAdapterProperty ( ) , attr . getConfigType ( ) ) ; } result [ specific . length + i ] = newAttr ; } return result ; }
the regular and pooled CF
the regular and pooled CF