@Override public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { if (resourceModel.hasDefined(attribute.getName())) { writer.writeStartElement(attribute.getName()); writer.writeAttribute(Attribute.VALUE.getLocalName(), resourceModel.get(attribute.getName()).asString()); writer.writeEndElement(); } } };
static List<String> validateDeprecatedProperites(final ModelNode model) { final List<String> propertiesToReject = new LinkedList<>(); for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName()) && model.get(attribute.getName()).equals(JacORBSubsystemDefinitions.DEFAULT_ENABLED_PROPERTY)) { propertiesToReject.add(attribute.getName()); } } for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName())) { propertiesToReject.add(attribute.getName()); } } return propertiesToReject; }
static ModelNode resolveValue(final OperationContext context, final ModelNode operation, final AttributeDefinition attribute) throws OperationFailedException { final ModelNode value = new ModelNode(); if (operation.has(attribute.getName())) { value.set(operation.get(attribute.getName())); } return attribute.resolveValue(context, value); }
@Override public HttpHandler createHttpHandler(Predicate predicate, ModelNode model, HttpHandler next) { int code = model.get(CODE.getName()).asInt(); String path = model.get(PATH.getName()).asString(); FileErrorPageHandler handler = new FileErrorPageHandler(Paths.get(path), code); handler.setNext(next); if(predicate == null) { return handler; } else { return Handlers.predicate(predicate, handler, next); } }
private void getAttributeValueOrDefault(AttributeDefinition def, OperationContext context) throws OperationFailedException { //TODO fails in the validator //final ModelNode result = def.resolveModelAttribute(context, context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel()); final ModelNode result = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel().get(def.getName()); context.getResult().set(result.isDefined() ? result : new ModelNode().setEmptyList()); } }
static Properties resolvePropertyValue(final OperationContext context, final ModelNode operation, final AttributeDefinition attribute) throws OperationFailedException { // Get the properties final Properties properties = new Properties(); if (operation.hasDefined(attribute.getName())) { for (Property p : resolveValue(context, operation, attribute).asPropertyList()) { properties.put(p.getName(), p.getValue().asString()); } } return properties; }
private static void validateSupportedAttribute(final OperationContext context, final ModelNode resourceModel, final AttributeDefinition attributeDefinition, final List<String> warnings) throws OperationFailedException{ final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); if(attributeNode.isDefined() && !attributeNode.asString().equals(Constants.IOR_SUPPORTED)) { final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName(), Constants.IOR_SUPPORTED); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } }
@Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { for (String name : resource.getChildrenNames(ProtocolResourceDefinition.WILDCARD_PATH.getKey())) { resource.getModel().get(PROTOCOLS.getName()).add(name); } context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource).processChildren(resource); } };
@Override protected void executeReadAttribute(String attributeName, OperationContext context, MessageDrivenComponent component, PathAddress address) { if (DELIVERY_ACTIVE.getName().equals(attributeName)) { context.getResult().set(component.isDeliveryActive()); } else { super.executeReadAttribute(attributeName, context, component, address); } }
if (param == INSTALL || param == DEBUG || param == ERROR || param == IGNORE_UNKNOWN_CONNECTIONS) { AttributeDefinition ad = param.getAttribute(); assert !ad.isRequired() : ad.getName(); // else someone changed something and we need to account for that if (model.hasDefined(ad.getName())) { allDefault = false; break;
@Override public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { if (resourceModel.hasDefined(attribute.getName())) { writer.writeStartElement(attribute.getName()); writer.writeAttribute(Attribute.NAME.getLocalName(), resourceModel.get(attribute.getName()).asString()); writer.writeEndElement(); } } };
private ModelNode getResolvedModel(OperationContext context, ModelNode model) throws OperationFailedException { ModelNode resolved = new ModelNode(); for (AttributeDefinition attribute : attributes) { resolved.get(attribute.getName()).set(attribute.resolveModelAttribute(context, model)); } return resolved; }
@Override public HttpHandler createHttpHandler(Predicate predicate, ModelNode model, HttpHandler next) { String expression = model.get(TARGET.getName()).asString(); boolean redirect = model.get(REDIRECT.getName()).asBoolean(); if(predicate == null) { return create(next, expression, redirect); } else { return Handlers.predicate(predicate, create(next, expression, redirect), next); } }
@Override protected void validateUpdatedModel(final OperationContext context, final Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); if (!context.getProcessType().equals(ProcessType.HOST_CONTROLLER)) { final List<String> propertiesToReject = new LinkedList<String>(); for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName()) && model.get(attribute.getName()).equals(JacORBSubsystemDefinitions.DEFAULT_ENABLED_PROPERTY)) { propertiesToReject.add(attribute.getName()); } } for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName())) { propertiesToReject.add(attribute.getName()); } } if (!propertiesToReject.isEmpty()) { throw JacORBLogger.ROOT_LOGGER.cannotEmulateProperties(propertiesToReject); } } }
private void getAttributeValueOrDefault(AttributeDefinition def, OperationContext context) throws OperationFailedException { //TODO fails in the validator //final ModelNode result = def.resolveModelAttribute(context, context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel()); final ModelNode result = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel().get(def.getName()); context.getResult().set(result.isDefined() ? result : new ModelNode().setEmptyList()); } }
sasContextMetaData.setCallerPropagation(IIOPRootDefinition.CALLER_PROPAGATION.resolveModelAttribute(context, resourceModel).asString()); securityConfigMetaData.setSasContext(sasContextMetaData); asContextMetaData.setAuthMethod(IIOPRootDefinition.AUTH_METHOD.resolveModelAttribute(context, resourceModel).asString()); if (resourceModel.hasDefined(IIOPRootDefinition.REALM.getName())) { asContextMetaData.setRealm(IIOPRootDefinition.REALM.resolveModelAttribute(context, resourceModel).asString());
private static void validateSSLAttribute(final OperationContext context, final ModelNode resourceModel, final boolean sslConfigured, final boolean serverRequiresSsl, final AttributeDefinition attributeDefinition, final List<String> warnings) throws OperationFailedException { final ModelNode attributeNode = attributeDefinition.resolveModelAttribute(context, resourceModel); if(attributeNode.isDefined()){ final String attribute = attributeNode.asString(); if(sslConfigured) { if(attribute.equals(Constants.IOR_NONE)){ final String warning = IIOPLogger.ROOT_LOGGER.inconsistentSupportedTransportConfig(attributeDefinition.getName(), serverRequiresSsl ? Constants.IOR_REQUIRED : Constants.IOR_SUPPORTED); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } if (serverRequiresSsl && attribute.equals(Constants.IOR_SUPPORTED)) { final String warning = IIOPLogger.ROOT_LOGGER.inconsistentRequiredTransportConfig(Constants.SECURITY_SERVER_REQUIRES_SSL, attributeDefinition.getName()); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } else { if(!attribute.equals(Constants.IOR_NONE)){ final String warning = IIOPLogger.ROOT_LOGGER.inconsistentUnsupportedTransportConfig(attributeDefinition.getName()); IIOPLogger.ROOT_LOGGER.warn(warning); warnings.add(warning); } } } }
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceRegistry registry = context.getServiceRegistry(true); EJBSuspendHandlerService service = (EJBSuspendHandlerService) registry.getRequiredService(EJBSuspendHandlerService.SERVICE_NAME).getValue(); if (service!= null && this.gracefulTxnShutdownAttribute.getName().equals(attributeName)) { boolean enableGracefulTxnShutdown = this.gracefulTxnShutdownAttribute.resolveModelAttribute(context, model) .asBoolean(); service.enableGracefulTxnShutdown(enableGracefulTxnShutdown); } }
@Override public void marshallAsAttribute(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException { if (attribute.isMarshallable(resourceModel, marshallDefault)) { resourceModel = resourceModel.get(attribute.getName()); if (resourceModel.hasDefined(Constants.ALGORITHM)) { writer.writeAttribute(attribute.getName() + "-factory-" + Constants.ALGORITHM, resourceModel.get(Constants.ALGORITHM).asString()); } if (resourceModel.hasDefined(Constants.PROVIDER)) { writer.writeAttribute(attribute.getName() + "-factory-" + Constants.PROVIDER, resourceModel.get(Constants.PROVIDER).asString()); } } } }