private void addSocketBindings(List<ModelNode> updates, int portOffSet, String bindingRef, String defaultInterface) { final Set<String> processed = new HashSet<String>(); final Map<String, ModelNode> groups = new LinkedHashMap<String, ModelNode>(); if (domainModel.hasDefined(SOCKET_BINDING_GROUP)) { for (Property prop : domainModel.get(SOCKET_BINDING_GROUP).asPropertyList()) { ModelNode node = prop.getValue().clone(); if (portOffSet > 0) { node.get(PORT_OFFSET).set(portOffSet); } groups.put(prop.getName(), node); } } final ModelNode group = groups.get(bindingRef); if (group == null) { throw HostControllerLogger.ROOT_LOGGER.undefinedSocketBindingGroup(bindingRef); } final PathAddress groupAddress = PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, bindingRef)); final ModelNode groupAdd = BindingGroupAddHandler.getOperation(groupAddress, group); groupAdd.get(PORT_OFFSET).set(portOffSet); if(defaultInterface != null) { groupAdd.get(DEFAULT_INTERFACE).set(defaultInterface); } updates.add(groupAdd); mergeBindingGroups(updates, groups, bindingRef, group, processed); }
/** * {@inheritDoc} */ @Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); populateModel(operation, model); SocketBindingGroupResourceDefinition.PORT_OFFSET.validateAndSet(operation, model); // Validate only a single socket binding group final PathAddress mine = PathAddress.pathAddress(operation.require(OP_ADDR)); context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Set<ResourceEntry> children = root.getChildren(SOCKET_BINDING_GROUP); if (children.size() > 1) { for (ResourceEntry entry : children) { if (!entry.getName().equals(mine.getLastElement().getValue())) { throw ServerMessages.MESSAGES.cannotAddMoreThanOneSocketBindingGroupForServer( mine, PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, entry.getName()))); } } } context.stepCompleted(); } }, OperationContext.Stage.MODEL); SocketBindingGroupResourceDefinition.validateDefaultInterfaceReference(context, model); }
/** * {@inheritDoc} */ @Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); populateModel(operation, model); SocketBindingGroupResourceDefinition.PORT_OFFSET.validateAndSet(operation, model); // Validate only a single socket binding group final PathAddress mine = PathAddress.pathAddress(operation.require(OP_ADDR)); context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Set<ResourceEntry> children = root.getChildren(SOCKET_BINDING_GROUP); if (children.size() > 1) { for (ResourceEntry entry : children) { if (!entry.getName().equals(mine.getLastElement().getValue())) { throw ServerMessages.MESSAGES.cannotAddMoreThanOneSocketBindingGroupForServer( mine, PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, entry.getName()))); } } } context.stepCompleted(); } }, OperationContext.Stage.MODEL); SocketBindingGroupResourceDefinition.validateDefaultInterfaceReference(context, model); }
private void addSocketBindings(List<ModelNode> updates, int portOffSet, String bindingRef) { final Set<String> processed = new HashSet<String>(); final Map<String, ModelNode> groups = new LinkedHashMap<String, ModelNode>(); if (domainModel.hasDefined(SOCKET_BINDING_GROUP)) { for (Property prop : domainModel.get(SOCKET_BINDING_GROUP).asPropertyList()) { ModelNode node = prop.getValue().clone(); if (portOffSet > 0) { node.get(PORT_OFFSET).set(portOffSet); } groups.put(prop.getName(), node); } } final ModelNode group = groups.get(bindingRef); if (group == null) { throw MESSAGES.undefinedSocketBindingGroup(bindingRef); } final PathAddress groupAddress = PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, bindingRef)); final ModelNode groupAdd = BindingGroupAddHandler.getOperation(groupAddress, group); groupAdd.get(PORT_OFFSET).set(portOffSet); updates.add(groupAdd); mergeBindingGroups(updates, groups, bindingRef, group, processed); }
private void addSocketBindings(List<ModelNode> updates, int portOffSet, String bindingRef, String defaultInterface) { final Set<String> processed = new HashSet<String>(); final Map<String, ModelNode> groups = new LinkedHashMap<String, ModelNode>(); if (domainModel.hasDefined(SOCKET_BINDING_GROUP)) { for (Property prop : domainModel.get(SOCKET_BINDING_GROUP).asPropertyList()) { ModelNode node = prop.getValue().clone(); if (portOffSet > 0) { node.get(PORT_OFFSET).set(portOffSet); } groups.put(prop.getName(), node); } } final ModelNode group = groups.get(bindingRef); if (group == null) { throw HostControllerLogger.ROOT_LOGGER.undefinedSocketBindingGroup(bindingRef); } final PathAddress groupAddress = PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, bindingRef)); final ModelNode groupAdd = BindingGroupAddHandler.getOperation(groupAddress, group); groupAdd.get(PORT_OFFSET).set(portOffSet); if(defaultInterface != null) { groupAdd.get(DEFAULT_INTERFACE).set(defaultInterface); } updates.add(groupAdd); mergeBindingGroups(updates, groups, bindingRef, group, processed); }