public SocketBindingGroup getSocketBindingGroup(String name) { for (SocketBindingGroup each : this.socketBindingGroups) { if (each.name().equals(name)) { return each; } } return null; }
private void configureSocketBindingGroup(SocketBindingGroup group, List<ModelNode> list) { if ( hasSocketBindingGroup( list ) ) { return; } ModelNode node = new ModelNode(); PathAddress address = PathAddress.pathAddress("socket-binding-group", group.name()); node.get(OP).set(ADD); node.get(OP_ADDR).set(address.toModelNode()); node.get(DEFAULT_INTERFACE).set(group.defaultInterface()); node.get(PORT_OFFSET).set(new ValueExpression(group.portOffsetExpression())); list.add(node); configureSocketBindings(address, group, list); }
public void marshal(List<ModelNode> list) { for (SocketBindingGroup group : this.socketBindingGroups) { PathAddress address = PathAddress.pathAddress("socket-binding-group", group.name()); ModelNode node = new ModelNode(); node.get(OP).set(ADD); node.get(OP_ADDR).set(address.toModelNode()); node.get(DEFAULT_INTERFACE).set(group.defaultInterface()); node.get(PORT_OFFSET).set(new ValueExpression(group.portOffsetExpression())); LinkedList<ModelNode> subList = new LinkedList<>(); subList.add(node); for (SocketBinding binding : group.socketBindings()) { configureSocketBinding(address, binding, subList); } for (OutboundSocketBinding binding : group.outboundSocketBindings()) { configureSocketBinding(address, binding, subList); } if (!isAlreadyConfigured(subList, list)) { list.addAll(subList); } } }
public void marshal(List<ModelNode> list) { for (SocketBindingGroup group : this.socketBindingGroups) { PathAddress address = PathAddress.pathAddress("socket-binding-group", group.name()); ModelNode node = new ModelNode(); node.get(OP).set(ADD); node.get(OP_ADDR).set(address.toModelNode()); node.get(DEFAULT_INTERFACE).set(group.defaultInterface()); node.get(PORT_OFFSET).set(new ValueExpression(group.portOffsetExpression())); LinkedList<ModelNode> subList = new LinkedList<>(); subList.add(node); for (SocketBinding binding : group.socketBindings()) { configureSocketBinding(address, binding, subList); } for (OutboundSocketBinding binding : group.outboundSocketBindings()) { configureSocketBinding(address, binding, subList); } if (!isAlreadyConfigured(subList, list)) { list.addAll(subList); } } }
protected void fixSocketBindings(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()).append("socket-bindings"); List<SimpleKey> names = this.configView.simpleSubkeys(key); names.stream() .map(e -> e.name()) .map(name -> group.socketBindings() .stream() .filter(e -> e.name().equals(name)) .findFirst() .orElseGet(() -> { SocketBinding binding = new SocketBinding(name); group.socketBinding(binding); return binding; })) .forEach(e -> { applyConfiguration(key, e); }); }
protected void fixSocketBindings(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()).append("socket-bindings"); List<SimpleKey> names = this.configView.simpleSubkeys(key); names.stream() .map(e -> e.name()) .map(name -> group.socketBindings() .stream() .filter(e -> e.name().equals(name)) .findFirst() .orElseGet(() -> { SocketBinding binding = new SocketBinding(name); group.socketBinding(binding); return binding; })) .forEach(e -> { applyConfiguration(key, e); }); }
protected void fixSocketBindings(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()).append("socket-bindings"); List<SimpleKey> names = this.configView.simpleSubkeys(key); names.stream() .map(e -> e.name()) .map(name -> group.socketBindings() .stream() .filter(e -> e.name().equals(name)) .findFirst() .orElseGet(() -> { SocketBinding binding = new SocketBinding(name); group.socketBinding(binding); return binding; })) .forEach(e -> { applyConfiguration(key, e); }); }
public void marshal(List<ModelNode> list) { for (SocketBindingGroup group : this.socketBindingGroups) { PathAddress address = PathAddress.pathAddress("socket-binding-group", group.name()); ModelNode node = new ModelNode(); node.get(OP).set(ADD); node.get(OP_ADDR).set(address.toModelNode()); node.get(DEFAULT_INTERFACE).set(group.defaultInterface()); node.get(PORT_OFFSET).set(new ValueExpression(group.portOffsetExpression())); LinkedList<ModelNode> subList = new LinkedList<>(); subList.add(node); for (SocketBinding binding : group.socketBindings()) { configureSocketBinding(address, binding, subList); } for (OutboundSocketBinding binding : group.outboundSocketBindings()) { configureSocketBinding(address, binding, subList); } if (!isAlreadyConfigured(subList, list)) { list.addAll(subList); } } }
protected void fixOutboundSocketBindings(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()).append("outbound-socket-bindings"); List<SimpleKey> names = this.configView.simpleSubkeys(key); names.stream() .map(e -> e.name()) .map(name -> group.outboundSocketBindings() .stream() .filter(e -> e.name().equals(name)) .findFirst() .orElseGet(() -> { OutboundSocketBinding binding = new OutboundSocketBinding(name); group.outboundSocketBinding(binding); return binding; })) .forEach(e -> { applyConfiguration(key, e); }); }
protected void fixOutboundSocketBindings(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()).append("outbound-socket-bindings"); List<SimpleKey> names = this.configView.simpleSubkeys(key); names.stream() .map(e -> e.name()) .map(name -> group.outboundSocketBindings() .stream() .filter(e -> e.name().equals(name)) .findFirst() .orElseGet(() -> { OutboundSocketBinding binding = new OutboundSocketBinding(name); group.outboundSocketBinding(binding); return binding; })) .forEach(e -> { applyConfiguration(key, e); }); }
protected void fixOutboundSocketBindings(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()).append("outbound-socket-bindings"); List<SimpleKey> names = this.configView.simpleSubkeys(key); names.stream() .map(e -> e.name()) .map(name -> group.outboundSocketBindings() .stream() .filter(e -> e.name().equals(name)) .findFirst() .orElseGet(() -> { OutboundSocketBinding binding = new OutboundSocketBinding(name); group.outboundSocketBinding(binding); return binding; })) .forEach(e -> { applyConfiguration(key, e); }); }
@Override protected void applyConfiguration(SocketBindingGroup instance) { ConfigKey key = ROOT.append(instance.name()); applyConfiguration(key.append("port-offset"), (offset) -> { instance.portOffset(offset.toString()); }); applyConfiguration(key.append("default-interface"), (offset) -> { instance.portOffset(offset.toString()); }); }
@Override protected void applyConfiguration(SocketBindingGroup instance) { ConfigKey key = ROOT.append(instance.name()); applyConfiguration(key.append("port-offset"), (offset) -> { instance.portOffset(offset.toString()); }); applyConfiguration(key.append("default-interface"), (offset) -> { instance.portOffset(offset.toString()); }); }
@Override protected void applyConfiguration(SocketBindingGroup instance) { ConfigKey key = ROOT.append(instance.name()); applyConfiguration(key.append("port-offset"), (offset) -> { instance.portOffset(offset.toString()); }); applyConfiguration(key.append("default-interface"), (offset) -> { instance.portOffset(offset.toString()); }); }
return (SocketBindingGroup) beanManager.getReference(e, SocketBindingGroup.class, ctx); }) .filter(group -> group.name().equals(each.socketBindingGroup())) .findFirst() .ifPresent((group) -> group.socketBinding(each.socketBinding()));
@SuppressWarnings("unused") void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception { try (AutoCloseable handle = Performance.time("OutboundSocketBindingExtension.afterBeanDiscovery")) { for (OutboundSocketBindingRequest each : this.bindings) { Supplier<Customizer> customizerSupplier = () -> (Customizer) () -> { Set<Bean<?>> groups = beanManager.getBeans(SocketBindingGroup.class, Any.Literal.INSTANCE); groups.stream() .map((Bean<?> e) -> { CreationalContext<?> ctx = beanManager.createCreationalContext(e); return (SocketBindingGroup) beanManager.getReference(e, SocketBindingGroup.class, ctx); }) .filter(group -> group.name().equals(each.socketBindingGroup())) .findFirst() .ifPresent((group) -> group.outboundSocketBinding(each.outboundSocketBinding())); }; CommonBean<Customizer> customizerBean = CommonBeanBuilder.newBuilder(Customizer.class) .beanClass(OutboundSocketBindingExtension.class) .scope(Singleton.class) .addQualifier(Pre.Literal.INSTANCE) .addQualifier(Any.Literal.INSTANCE) .createSupplier(customizerSupplier) .addType(Customizer.class) .addType(Object.class).build(); abd.addBean(customizerBean); } } } }
@SuppressWarnings("unused") void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager beanManager) throws Exception { try (AutoCloseable handle = Performance.time("OutboundSocketBindingExtension.afterBeanDiscovery")) { for (OutboundSocketBindingRequest each : this.bindings) { Supplier<Customizer> customizerSupplier = () -> (Customizer) () -> { Set<Bean<?>> groups = beanManager.getBeans(SocketBindingGroup.class, AnyLiteral.INSTANCE); groups.stream() .map((Bean<?> e) -> { CreationalContext<?> ctx = beanManager.createCreationalContext(e); return (SocketBindingGroup) beanManager.getReference(e, SocketBindingGroup.class, ctx); }) .filter(group -> group.name().equals(each.socketBindingGroup())) .findFirst() .ifPresent((group) -> group.outboundSocketBinding(each.outboundSocketBinding())); }; CommonBean<Customizer> customizerBean = CommonBeanBuilder.newBuilder(Customizer.class) .beanClass(OutboundSocketBindingExtension.class) .scope(Singleton.class) .addQualifier(Pre.Literal.INSTANCE) .addQualifier(AnyLiteral.INSTANCE) .createSupplier(customizerSupplier) .addType(Customizer.class) .addType(Object.class).build(); abd.addBean(customizerBean); } } } }
protected void fixGroup(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()); int offset = this.configView.resolve(SWARM.append("port", "offset")).as(Integer.class).withDefault(0).getValue(); group.portOffset(offset); applyConfiguration(key.append("port-offset"), (portOffset) -> { group.portOffset(portOffset.toString()); }); applyConfiguration(key.append("default-interface"), (defaultInterface) -> { group.defaultInterface(defaultInterface.toString()); }); }
protected void fixGroup(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()); int offset = this.configView.resolve(SWARM.append("port", "offset")).as(Integer.class).withDefault(0).getValue(); group.portOffset(offset); applyConfiguration(key.append("port-offset"), (portOffset) -> { group.portOffset(portOffset.toString()); }); applyConfiguration(key.append("default-interface"), (defaultInterface) -> { group.defaultInterface(defaultInterface.toString()); }); }
protected void fixGroup(SocketBindingGroup group) { ConfigKey key = ROOT.append(group.name()); int offset = this.configView.resolve(SWARM.append("port", "offset")).as(Integer.class).withDefault(0).getValue(); group.portOffset(offset); applyConfiguration(key.append("port-offset"), (portOffset) -> { group.portOffset(portOffset.toString()); }); applyConfiguration(key.append("default-interface"), (defaultInterface) -> { group.defaultInterface(defaultInterface.toString()); }); }