Example usage for java.net InetSocketAddress getPort

List of usage examples for java.net InetSocketAddress getPort

Introduction

In this page you can find the example usage for java.net InetSocketAddress getPort.

Prototype

public final int getPort() 

Source Link

Document

Gets the port number.

Usage

From source file:com.wealdtech.jackson.modules.InetSocketAddressSerializer.java

@Override
public void serialize(final InetSocketAddress value, final JsonGenerator jgen,
        final SerializerProvider provider) throws IOException {
    jgen.writeString(value.getHostName() + ":" + value.getPort());
}

From source file:asia.stampy.common.gateway.HostPort.java

/**
 * Instantiates a new host port./*from   www . j  a  va 2 s  .  c om*/
 * 
 * @param address
 *          the address
 */
public HostPort(InetSocketAddress address) {
    this.host = address.getAddress().getHostAddress();
    this.port = address.getPort();
}

From source file:org.opennms.minion.stests.utils.HibernateDaoFactory.java

public HibernateDaoFactory(InetSocketAddress pgsqlAddr) {
    PGSimpleDataSource dataSource = new PGSimpleDataSource();
    dataSource.setPortNumber(pgsqlAddr.getPort());
    dataSource.setUser("postgres");
    dataSource.setPassword("postgres");
    dataSource.setServerName(pgsqlAddr.getAddress().getHostAddress());
    dataSource.setDatabaseName("opennms");

    AnnotationSessionFactoryBean sfb = new AnnotationSessionFactoryBean();
    sfb.setDataSource(dataSource);/* ww w  .  ja  va  2s  .c o  m*/
    sfb.setPackagesToScan("org.opennms.netmgt.model");
    try {
        sfb.afterPropertiesSet();
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
    m_sessionFactory = sfb.getObject();
    m_hibernateTemplate = new HibernateTemplate(m_sessionFactory);
}

From source file:com.nl.util.redis.config.JedisClusterConfig.java

/**
 * Returns nodes./*from ww w. j  ava2s.  co m*/
 * @return list of node information
 */
public Set<HostAndPort> getNodes() {
    Set<HostAndPort> ret = new HashSet<>();
    for (InetSocketAddress node : nodes) {
        ret.add(new HostAndPort(node.getHostName(), node.getPort()));
    }
    return ret;
}

From source file:com.datatorrent.stram.client.StramClientUtils.java

public static String getSocketConnectString(InetSocketAddress socketAddress) {
    String host;//  w  ww.  j a  v  a  2s  .  c o  m
    InetAddress address = socketAddress.getAddress();
    if (address == null) {
        host = socketAddress.getHostString();
    } else if (address.isAnyLocalAddress() || address.isLoopbackAddress()) {
        host = address.getCanonicalHostName();
    } else {
        host = address.getHostName();
    }
    return host + ":" + socketAddress.getPort();
}

From source file:org.wso2.carbon.inbound.endpoint.protocol.hl7.core.MultiIOHandler.java

@Override
public void inputReady(IOSession session) {

    InetSocketAddress isa = (InetSocketAddress) session.getRemoteAddress();
    MLLPSourceHandler handler = handlers.get(isa.getPort());
    handler.inputReady(session);/*from  w  w w .  ja  v a2 s. c  o  m*/

}

From source file:org.wso2.carbon.inbound.endpoint.protocol.hl7.core.MultiIOHandler.java

@Override
public void outputReady(IOSession session) {

    InetSocketAddress isa = (InetSocketAddress) session.getRemoteAddress();
    MLLPSourceHandler handler = handlers.get(isa.getPort());
    handler.outputReady(session);/*from w ww  . j  a va 2 s . c o  m*/

}

From source file:com.urswolfer.intellij.plugin.gerrit.rest.ProxyHttpClientBuilderExtension.java

@Override
public CredentialsProvider extendCredentialProvider(HttpClientBuilder httpClientBuilder,
        CredentialsProvider credentialsProvider, GerritAuthData authData) {
    HttpConfigurable proxySettings = HttpConfigurable.getInstance();
    IdeaWideProxySelector ideaWideProxySelector = new IdeaWideProxySelector(proxySettings);

    // This will always return at least one proxy, which can be the "NO_PROXY" instance.
    List<Proxy> proxies = ideaWideProxySelector.select(URI.create(authData.getHost()));

    // Find the first real proxy with an address type we support.
    for (Proxy proxy : proxies) {
        SocketAddress socketAddress = proxy.address();

        if (HttpConfigurable.isRealProxy(proxy) && socketAddress instanceof InetSocketAddress) {
            InetSocketAddress address = (InetSocketAddress) socketAddress;
            HttpHost proxyHttpHost = new HttpHost(address.getHostName(), address.getPort());
            httpClientBuilder.setProxy(proxyHttpHost);

            // Here we use the single username/password that we got from IDEA's settings. It feels kinda strange
            // to use these credential but it's probably what the user expects.
            if (proxySettings.PROXY_AUTHENTICATION) {
                AuthScope authScope = new AuthScope(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
                UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
                        proxySettings.PROXY_LOGIN, proxySettings.getPlainProxyPassword());
                credentialsProvider.setCredentials(authScope, credentials);
                break;
            }//w ww.  java 2 s .c o m
        }
    }
    return credentialsProvider;
}

From source file:org.elasticsearch.client.RestClientBuilderIntegTests.java

private RestClient buildRestClient() {
    InetSocketAddress address = httpsServer.getAddress();
    return RestClient.builder(new HttpHost(address.getHostString(), address.getPort(), "https")).build();
}

From source file:org.apache.geode.distributed.internal.membership.gms.membership.HostAddress.java

public HostAddress(InetSocketAddress loc, String locStr) {
    this.socketInetAddress = loc;
    this.hostname = locStr;
    this.port = loc.getPort();
    this.isIpString = InetAddressValidator.getInstance().isValid(locStr);
}