@Override protected OutboundSocketBinding createOutboundSocketBinding() { // unlike the RemoteDestinationOutboundSocketBindingService, we resolve the destination address // here itself (instead of doing it lazily in the OutboundSocketBinding) is because we already // inject a SocketBinding reference which is local to the server instance and is expected to have // already resolved the (local) address (via the NetworkInterfaceBinding). final InetAddress destinationAddress = this.getDestinationAddress(); final int destinationPort = this.getDestinationPort(); return new OutboundSocketBinding(this.outboundSocketName, this.socketBindingManagerInjectedValue.getValue(), destinationAddress, destinationPort, this.sourceInterfaceInjectedValue.getOptionalValue(), this.sourcePort, this.fixedSourcePort); }
public static ServiceController<OutboundSocketBinding> installOutboundSocketBindingService(final OperationContext context, final ModelNode model, final String outboundSocketName) throws OperationFailedException, UnknownHostException { final ServiceTarget serviceTarget = context.getServiceTarget(); final String socketBindingRef = LocalDestinationOutboundSocketBindingResourceDefinition.SOCKET_BINDING_REF.resolveModelAttribute(context, model).asString(); // (optional) source interface final ModelNode sourceInterfaceModelNode = OutboundSocketBindingResourceDefinition.SOURCE_INTERFACE.resolveModelAttribute(context, model); final String sourceInterfaceName = sourceInterfaceModelNode.isDefined() ? sourceInterfaceModelNode.asString() : null; // (optional) source port final ModelNode sourcePortModelNode = OutboundSocketBindingResourceDefinition.SOURCE_PORT.resolveModelAttribute(context, model); final Integer sourcePort = sourcePortModelNode.isDefined() ? sourcePortModelNode.asInt() : null; // (optional) fixedSourcePort final ModelNode fixedSourcePortModelNode = OutboundSocketBindingResourceDefinition.FIXED_SOURCE_PORT.resolveModelAttribute(context, model); final boolean fixedSourcePort = fixedSourcePortModelNode.isDefined() ? fixedSourcePortModelNode.asBoolean() : false; // create the service final LocalDestinationOutboundSocketBindingService outboundSocketBindingService = new LocalDestinationOutboundSocketBindingService(outboundSocketName, sourcePort, fixedSourcePort); final ServiceBuilder<OutboundSocketBinding> serviceBuilder = serviceTarget.addService(OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketName), outboundSocketBindingService); // add dependency on the SocketBinding service corresponding to the socket binding ref serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(socketBindingRef), SocketBinding.class, outboundSocketBindingService.getLocalDestinationSocketBindingInjector()); // if a source interface has been specified then add a dependency on it if (sourceInterfaceName != null) { serviceBuilder.addDependency(NetworkInterfaceService.JBOSS_NETWORK_INTERFACE.append(sourceInterfaceName), NetworkInterfaceBinding.class, outboundSocketBindingService.getSourceNetworkInterfaceBindingInjector()); } // add a dependency on the socket binding manager serviceBuilder.addDependency(SocketBindingManager.SOCKET_BINDING_MANAGER, SocketBindingManager.class, outboundSocketBindingService.getSocketBindingManagerInjector()); // install the service return serviceBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND).install(); } }
public static ServiceController<OutboundSocketBinding> installOutboundSocketBindingService(final OperationContext context, final ModelNode model, final String outboundSocketName) throws OperationFailedException, UnknownHostException { final ServiceTarget serviceTarget = context.getServiceTarget(); final String socketBindingRef = LocalDestinationOutboundSocketBindingResourceDefinition.SOCKET_BINDING_REF.resolveModelAttribute(context, model).asString(); // (optional) source interface final ModelNode sourceInterfaceModelNode = OutboundSocketBindingResourceDefinition.SOURCE_INTERFACE.resolveModelAttribute(context, model); final String sourceInterfaceName = sourceInterfaceModelNode.isDefined() ? sourceInterfaceModelNode.asString() : null; // (optional) source port final ModelNode sourcePortModelNode = OutboundSocketBindingResourceDefinition.SOURCE_PORT.resolveModelAttribute(context, model); final Integer sourcePort = sourcePortModelNode.isDefined() ? sourcePortModelNode.asInt() : null; // (optional) fixedSourcePort final ModelNode fixedSourcePortModelNode = OutboundSocketBindingResourceDefinition.FIXED_SOURCE_PORT.resolveModelAttribute(context, model); final boolean fixedSourcePort = fixedSourcePortModelNode.isDefined() ? fixedSourcePortModelNode.asBoolean() : false; // create the service final LocalDestinationOutboundSocketBindingService outboundSocketBindingService = new LocalDestinationOutboundSocketBindingService(outboundSocketName, sourcePort, fixedSourcePort); final ServiceBuilder<OutboundSocketBinding> serviceBuilder = serviceTarget.addService(OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketName), outboundSocketBindingService); // add dependency on the SocketBinding service corresponding to the socket binding ref serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(socketBindingRef), SocketBinding.class, outboundSocketBindingService.getLocalDestinationSocketBindingInjector()); // if a source interface has been specified then add a dependency on it if (sourceInterfaceName != null) { serviceBuilder.addDependency(NetworkInterfaceService.JBOSS_NETWORK_INTERFACE.append(sourceInterfaceName), NetworkInterfaceBinding.class, outboundSocketBindingService.getSourceNetworkInterfaceBindingInjector()); } // add a dependency on the socket binding manager serviceBuilder.addDependency(SocketBindingManager.SOCKET_BINDING_MANAGER, SocketBindingManager.class, outboundSocketBindingService.getSocketBindingManagerInjector()); // install the service return serviceBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND).install(); } }
static void installOutboundSocketBindingService(final OperationContext context, final ModelNode model) throws OperationFailedException { final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget(); // socket name final String outboundSocketName = context.getCurrentAddressValue(); final String socketBindingRef = LocalDestinationOutboundSocketBindingResourceDefinition.SOCKET_BINDING_REF.resolveModelAttribute(context, model).asString(); // (optional) source interface final String sourceInterfaceName = OutboundSocketBindingResourceDefinition.SOURCE_INTERFACE.resolveModelAttribute(context, model).asStringOrNull(); // (optional) source port final Integer sourcePort = OutboundSocketBindingResourceDefinition.SOURCE_PORT.resolveModelAttribute(context, model).asIntOrNull(); // (optional but defaulted) fixedSourcePort final boolean fixedSourcePort = OutboundSocketBindingResourceDefinition.FIXED_SOURCE_PORT.resolveModelAttribute(context, model).asBoolean(); // create the service final LocalDestinationOutboundSocketBindingService outboundSocketBindingService = new LocalDestinationOutboundSocketBindingService(outboundSocketName, sourcePort, fixedSourcePort); final CapabilityServiceBuilder<OutboundSocketBinding> serviceBuilder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY, outboundSocketBindingService); // if a source interface has been specified then add a dependency on it if (sourceInterfaceName != null) { serviceBuilder.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, outboundSocketBindingService.getSourceNetworkInterfaceBindingInjector(), sourceInterfaceName); } serviceBuilder.addCapabilityRequirement(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, outboundSocketBindingService.getLocalDestinationSocketBindingInjector(), socketBindingRef) .addCapabilityRequirement("org.wildfly.management.socket-binding-manager", SocketBindingManager.class, outboundSocketBindingService.getSocketBindingManagerInjector()) .setInitialMode(ServiceController.Mode.ON_DEMAND) .addAliases(OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketName)) .install(); } }
@Override protected OutboundSocketBinding createOutboundSocketBinding() { // unlike the RemoteDestinationOutboundSocketBindingService, we resolve the destination address // here itself (instead of doing it lazily in the OutboundSocketBinding) is because we already // inject a SocketBinding reference which is local to the server instance and is expected to have // already resolved the (local) address (via the NetworkInterfaceBinding). final InetAddress destinationAddress = this.getDestinationAddress(); final int destinationPort = this.getDestinationPort(); return new OutboundSocketBinding(this.outboundSocketName, this.socketBindingManagerInjectedValue.getValue(), destinationAddress, destinationPort, this.sourceInterfaceInjectedValue.getOptionalValue(), this.sourcePort, this.fixedSourcePort); }
static void installOutboundSocketBindingService(final OperationContext context, final ModelNode model) throws OperationFailedException { final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget(); // socket name final String outboundSocketName = context.getCurrentAddressValue(); final String socketBindingRef = LocalDestinationOutboundSocketBindingResourceDefinition.SOCKET_BINDING_REF.resolveModelAttribute(context, model).asString(); // (optional) source interface final String sourceInterfaceName = OutboundSocketBindingResourceDefinition.SOURCE_INTERFACE.resolveModelAttribute(context, model).asStringOrNull(); // (optional) source port final Integer sourcePort = OutboundSocketBindingResourceDefinition.SOURCE_PORT.resolveModelAttribute(context, model).asIntOrNull(); // (optional but defaulted) fixedSourcePort final boolean fixedSourcePort = OutboundSocketBindingResourceDefinition.FIXED_SOURCE_PORT.resolveModelAttribute(context, model).asBoolean(); // create the service final LocalDestinationOutboundSocketBindingService outboundSocketBindingService = new LocalDestinationOutboundSocketBindingService(outboundSocketName, sourcePort, fixedSourcePort); final CapabilityServiceBuilder<OutboundSocketBinding> serviceBuilder = serviceTarget.addCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY, outboundSocketBindingService); // if a source interface has been specified then add a dependency on it if (sourceInterfaceName != null) { serviceBuilder.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, outboundSocketBindingService.getSourceNetworkInterfaceBindingInjector(), sourceInterfaceName); } serviceBuilder.addCapabilityRequirement(SOCKET_BINDING_CAPABILITY_NAME, SocketBinding.class, outboundSocketBindingService.getLocalDestinationSocketBindingInjector(), socketBindingRef) .addCapabilityRequirement("org.wildfly.management.socket-binding-manager", SocketBindingManager.class, outboundSocketBindingService.getSocketBindingManagerInjector()) .setInitialMode(ServiceController.Mode.ON_DEMAND) .addAliases(OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketName)) .install(); } }
@Override protected OutboundSocketBinding createOutboundSocketBinding() { // unlike the RemoteDestinationOutboundSocketBindingService, we resolve the destination address // here itself (instead of doing it lazily in the OutboundSocketBinding) is because we already // inject a SocketBinding reference which is local to the server instance and is expected to have // already resolved the (local) address (via the NetworkInterfaceBinding). final InetAddress destinationAddress = this.getDestinationAddress(); final int destinationPort = this.getDestinationPort(); return new OutboundSocketBinding(this.outboundSocketName, this.socketBindingManagerInjectedValue.getValue(), destinationAddress, destinationPort, this.sourceInterfaceInjectedValue.getOptionalValue(), this.sourcePort, this.fixedSourcePort); }
@Override protected OutboundSocketBinding createOutboundSocketBinding() { // unlike the RemoteDestinationOutboundSocketBindingService, we resolve the destination address // here itself (instead of doing it lazily in the OutboundSocketBinding) is because we already // inject a SocketBinding reference which is local to the server instance and is expected to have // already resolved the (local) address (via the NetworkInterfaceBinding). final InetAddress destinationAddress = this.getDestinationAddress(); final int destinationPort = this.getDestinationPort(); return new OutboundSocketBinding(this.outboundSocketName, this.socketBindingManagerInjectedValue.getValue(), destinationAddress, destinationPort, this.sourceInterfaceInjectedValue.getOptionalValue(), this.sourcePort, this.fixedSourcePort); }