public static InetAddress outboundSocketBindingGetResolvedDestinationAddress(OutboundSocketBinding serverBinding) throws UnknownHostException { try { return serverBinding.getResolvedDestinationAddress(); } catch (NoSuchMethodError _nsme) { // When using jboss-as we need to use the now deprecated getDestinationAddress return serverBinding.getDestinationAddress(); } }
/** * Creates a {@link Socket} represented by this {@link OutboundSocketBinding} and connects to the * destination * * @return * @throws IOException */ public Socket connect() throws IOException { final Socket socket = this.createSocket(); final InetAddress destinationAddress = this.getDestinationAddress(); final int destinationPort = this.getDestinationPort(); final SocketAddress destination = new InetSocketAddress(destinationAddress, destinationPort); socket.connect(destination); return socket; }
/** * Generates and returns the URI that corresponds to the local outbound connection. * If the URI has already been generated in a previous request, then it returns that back. * Else the URI is constructed out of the outbound socket binding's destination address and destination port. * * @return * @throws IOException * @throws URISyntaxException */ private synchronized URI getConnectionURI() throws IOException, URISyntaxException { if (this.connectionURI != null) { return this.connectionURI; } final OutboundSocketBinding destinationOutboundSocket = this.destinationOutboundSocketBindingInjectedValue.getValue(); final InetAddress destinationAddress = destinationOutboundSocket.getDestinationAddress(); final int port = destinationOutboundSocket.getDestinationPort(); this.connectionURI = new URI(LOCAL_URI_SCHEME + destinationAddress.getHostAddress() + ":" + port); return this.connectionURI; }
private InetSocketAddress getServerSocketAddress(ServerConfig server) throws StartException { final String ref = server.getOutgoingSocketBinding(); final OutboundSocketBinding binding = socketBindings.get(ref); if (ref == null) { throw MailMessages.MESSAGES.outboundSocketBindingNotAvailable(ref); } final InetAddress destinationAddress; try { destinationAddress = binding.getDestinationAddress(); } catch (UnknownHostException uhe) { throw MailMessages.MESSAGES.unknownOutboundSocketBindingDestination(uhe, ref); } return new InetSocketAddress(destinationAddress, binding.getDestinationPort()); }
/** * Generates and returns the URI that corresponds to the remote outbound connection. * If the URI has already been generated in a previous request, then it returns that back. * Else the URI is constructed out of the outbound socket binding's destination address and destination port. * * @return * @throws IOException * @throws URISyntaxException */ private synchronized URI getConnectionURI() throws IOException, URISyntaxException { if (this.connectionURI != null) { return this.connectionURI; } final OutboundSocketBinding destinationOutboundSocket = this.destinationOutboundSocketBindingInjectedValue.getValue(); final InetAddress destinationAddress = destinationOutboundSocket.getDestinationAddress(); final int port = destinationOutboundSocket.getDestinationPort(); this.connectionURI = new URI(REMOTE_URI_SCHEME + NetworkUtils.formatPossibleIpv6Address( destinationAddress.getHostAddress()) + ":" + port); return this.connectionURI; }