@Override protected void convertAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { if (attributeValue.isDefined()) { List<ModelNode> remoteServers = attributeValue.clone().asList(); ModelNode legacyListObject = new ModelNode(); for (ModelNode server : remoteServers) { ModelNode legacyListItem = new ModelNode(); legacyListItem.get("outbound-socket-binding").set(server); legacyListObject.add(legacyListItem); } attributeValue.set(legacyListObject); } } }, Attribute.SOCKET_BINDINGS.getDefinition());
@Override public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { for (ModelNode property : resourceModel.get(attribute.getName()).asList()) { writer.writeStartElement(attribute.getXmlName()); writer.writeAttribute(org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(), property.asProperty().getName()); writer.writeCharacters(property.asProperty().getValue().asString()); writer.writeEndElement(); } }
protected List<ProcessEnginePluginXml> getPlugins(final ModelNode plugins) { List<ProcessEnginePluginXml> pluginConfigurations = new ArrayList<ProcessEnginePluginXml>(); if (plugins.isDefined()) { for (final ModelNode plugin : plugins.asList()) { ProcessEnginePluginXml processEnginePluginXml = new ProcessEnginePluginXml() { @Override public String getPluginClass() { return plugin.get(Element.PLUGIN_CLASS.getLocalName()).asString(); } @Override public Map<String, String> getProperties() { return ProcessEngineAdd.this.getPropertiesMap(plugin.get(Element.PROPERTIES.getLocalName())); } }; pluginConfigurations.add(processEnginePluginXml); } } return pluginConfigurations; }
.setProxyURL(PROXY_URL.resolveModelAttribute(context, model).asString()) .setAutoEnableContexts(AUTO_ENABLE_CONTEXTS.resolveModelAttribute(context, model).asBoolean()) .setStopContextTimeout(STOP_CONTEXT_TIMEOUT.resolveModelAttribute(context, model).asInt()) .setStopContextTimeoutUnit(TimeUnit.valueOf(STOP_CONTEXT_TIMEOUT.getDefinition().getMeasurementUnit().getName())) .setSocketTimeout(SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt() * 1000) .setSessionDrainingStrategy(Enum.valueOf(SessionDrainingStrategyEnum.class, SESSION_DRAINING_STRATEGY.resolveModelAttribute(context, model).asString())) if (model.hasDefined(EXCLUDED_CONTEXTS.getName())) { String contexts = EXCLUDED_CONTEXTS.resolveModelAttribute(context, model).asString(); Map<String, Set<String>> excludedContextsPerHost; if (contexts == null) { if (node.isDefined()) { builder.node().setBalancer(node.asString()); if (node.isDefined()) { builder.node().setLoadBalancingGroup(node.asString()); if (node.isDefined()) { for (ModelNode ref : node.asList()) { String asString = ref.asString(); this.outboundSocketBindings.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, asString))); if (model.get(SSLResourceDefinition.PATH.getKeyValuePair()).isDefined()) { if (node.isDefined()) { throw ROOT_LOGGER.bothElytronAndLegacySslContextDefined(); ModelNode sslModel = model.get(SSLResourceDefinition.PATH.getKeyValuePair());
if(node.hasDefined(CommonAttributes.JTS) && node.get(CommonAttributes.JTS).asBoolean()) { writer.writeStartElement(Element.JTS.getLocalName()); writer.writeEndElement(); if(node.hasDefined(CommonAttributes.USE_JOURNAL_STORE) && node.get(CommonAttributes.USE_JOURNAL_STORE).asBoolean()) { writer.writeStartElement(Element.USE_JOURNAL_STORE.getLocalName()); TransactionSubsystemRootResourceDefinition.JOURNAL_STORE_ENABLE_ASYNC_IO.marshallAsAttribute(node, writer); if (node.hasDefined(CommonAttributes.USE_JDBC_STORE) && node.get(CommonAttributes.USE_JDBC_STORE).asBoolean()) { writer.writeStartElement(Element.JDBC_STORE.getLocalName()); TransactionSubsystemRootResourceDefinition.JDBC_STORE_DATASOURCE.marshallAsAttribute(node, writer); if (node.hasDefined(CommonAttributes.CM_RESOURCE) && node.get(CommonAttributes.CM_RESOURCE).asList().size() > 0) { writer.writeStartElement(Element.CM_RESOURCES.getLocalName()); for (Property cmr : node.get(CommonAttributes.CM_RESOURCE).asPropertyList()) {
@Override public Collection<IEnvironmentVariable> getEnvVars() { String[] path = JBossDmrExtentions.getPath(getPropertyKeys(), ENV); ModelNode envNode = getNode().get(path); if (envNode.isDefined()) { return envNode.asList().stream().map(n -> new EnvironmentVariable(n, getPropertyKeys())) .collect(Collectors.toList()); } return Collections.emptyList(); }
protected List<ProcessEnginePluginXml> getPlugins(ModelNode plugins) { List<ProcessEnginePluginXml> pluginConfigurations = new ArrayList<>(); if (plugins.isDefined()) { for (final ModelNode plugin : plugins.asList()) { ProcessEnginePluginXml processEnginePluginXml = new ProcessEnginePluginXml() { @Override public String getPluginClass() { return plugin.get(Element.PLUGIN_CLASS.getLocalName()).asString(); } @Override public Map<String, String> getProperties() { return ProcessEngineAdd.this.getProperties(plugin.get(Element.PROPERTIES.getLocalName())); } }; pluginConfigurations.add(processEnginePluginXml); } } return pluginConfigurations; }
public static Map<String,String> extractMap(ModelNode operation, ObjectListAttributeDefinition objList, SimpleAttributeDefinition keyAttribute, SimpleAttributeDefinition valueAttribute) { Map<String, String> returnMap = null; if (operation.hasDefined(objList.getName())) { returnMap = new HashMap<String, String>(operation.get(objList.getName()).asList().size()); for (ModelNode node : operation.get(objList.getName()).asList()) { returnMap.put(node.asObject().get(keyAttribute.getName()).asString(), node.asObject().get(valueAttribute.getName()).asString()); } } return returnMap; } }
@Override public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException { assert attribute instanceof ObjectListAttributeDefinition; ObjectListAttributeDefinition list = ((ObjectListAttributeDefinition) attribute); ObjectTypeAttributeDefinition objectType = (ObjectTypeAttributeDefinition) CustomMarshaller.getValueType(list, ObjectListAttributeDefinition.class); AttributeDefinition[] valueTypes = CustomMarshaller.getValueTypes(list, ObjectTypeAttributeDefinition.class); if (resourceModel.hasDefined(attribute.getName())) { writer.writeStartElement(attribute.getXmlName()); for (ModelNode element: resourceModel.get(attribute.getName()).asList()) { writer.writeStartElement(objectType.getXmlName()); for (AttributeDefinition valueType : valueTypes) { valueType.getAttributeMarshaller().marshallAsElement(valueType, element, false, writer); } writer.writeEndElement(); } writer.writeEndElement(); } } }
@Override public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { for (ModelNode property : resourceModel.get(attribute.getName()).asList()) { writer.writeStartElement(attribute.getXmlName()); writer.writeAttribute(org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(), property.asProperty().getName()); writer.writeCharacters(property.asProperty().getValue().asString()); writer.writeEndElement(); } }
@Override public Collection<IEnvironmentVariable> getEnvVars() { String[] path = JBossDmrExtentions.getPath(getPropertyKeys(), ENV); ModelNode envNode = getNode().get(path); if (envNode.isDefined()) { return envNode.asList().stream().map(n -> new EnvironmentVariable(n, getPropertyKeys())) .collect(Collectors.toList()); } return Collections.emptyList(); }
protected List<ProcessEnginePluginXml> getPlugins(ModelNode plugins) { List<ProcessEnginePluginXml> pluginConfigurations = new ArrayList<>(); if (plugins.isDefined()) { for (final ModelNode plugin : plugins.asList()) { ProcessEnginePluginXml processEnginePluginXml = new ProcessEnginePluginXml() { @Override public String getPluginClass() { return plugin.get(Element.PLUGIN_CLASS.getLocalName()).asString(); } @Override public Map<String, String> getProperties() { return ProcessEngineAdd.this.getProperties(plugin.get(Element.PROPERTIES.getLocalName())); } }; pluginConfigurations.add(processEnginePluginXml); } } return pluginConfigurations; }
@Override protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { if (attributeValue.isDefined()) { for (ModelNode node : attributeValue.asList()) { if (node.hasDefined(ANNOTATIONS)) { ModelNode annotations = node.get(ANNOTATIONS); if (EXPRESSION_PATTERN.matcher(annotations.asString()).matches() || annotations.asBoolean()) { return true; } } if (node.hasDefined(SERVICES)) { ModelNode services = node.get(SERVICES); if (EXPRESSION_PATTERN.matcher(services.asString()).matches() || !services.asBoolean()) { return true; } } if (node.hasDefined(META_INF)) { ModelNode metaInf = node.get(META_INF); if (EXPRESSION_PATTERN.matcher(metaInf.asString()).matches() || metaInf.asBoolean()) { return true; } } } } return false; }
@Override public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException { assert attribute instanceof ObjectListAttributeDefinition; ObjectListAttributeDefinition list = ((ObjectListAttributeDefinition) attribute); ObjectTypeAttributeDefinition objectType = (ObjectTypeAttributeDefinition) CustomMarshaller.getValueType(list, ObjectListAttributeDefinition.class); AttributeDefinition[] valueTypes = CustomMarshaller.getValueTypes(list, ObjectTypeAttributeDefinition.class); if (resourceModel.hasDefined(attribute.getName())) { writer.writeStartElement(attribute.getXmlName()); for (ModelNode element: resourceModel.get(attribute.getName()).asList()) { writer.writeStartElement(objectType.getXmlName()); for (AttributeDefinition valueType : valueTypes) { valueType.getAttributeMarshaller().marshallAsElement(valueType, element, false, writer); } writer.writeEndElement(); } writer.writeEndElement(); } } }
public static List<StaticEjbDiscovery> createStaticEjbList(final OperationContext context, final ModelNode ejbList) throws OperationFailedException { final List<StaticEjbDiscovery> ret = new ArrayList<>(); if (ejbList.isDefined()) { for (final ModelNode disc : ejbList.asList()) { ModelNode app = APP_AD.resolveModelAttribute(context, disc); String module = MODULE_AD.resolveModelAttribute(context, disc).asString(); ModelNode distinct = DISTINCT_AD.resolveModelAttribute(context, disc); String url = URI_AD.resolveModelAttribute(context, disc).asString(); ret.add(new StaticEjbDiscovery(app.isDefined() ? app.asString() : null, module, distinct.isDefined() ? distinct.asString() : null, url)); } } return ret; }