/** * Create a new socket. * * @return A <code>Socket</code>. */ private Socket newSocket() throws NetworkException, UnknownHostException { if (protocol.isSecure()) { return networkImpl.newSecureSocket(id, proxy, address); } else { return networkImpl.newSocket(id, proxy); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((network == null) ? 0 : network.hashCode()); return result; }
/** * Connect via a proxy. * * @throws SocketException * @throws IOException */ private void connectViaProxy() throws NetworkException, SocketException, IOException { socket = newSocket(); if (Boolean.FALSE == protocol.isSecure()) { /* secure sockets must already be connected */ socket.connect(networkImpl.lookupSocketAddress(address), getConnectTimeout()); } }
@Override public void expected(Object o) { assertTrue(o instanceof PersonNetwork); PersonNetwork other = (PersonNetwork) o; AssertUtil.assertEquals("homeNetwork", homeNetwork, other.isHomeNetwork()); if (network != null) { network.expected(other.getNetwork()); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PersonNetwork other = (PersonNetwork) obj; if (network == null) { if (other.network != null) return false; } else if (!network.equals(other.network)) return false; return true; }
/** * Create NetworkConnectionImpl. * * @param networkImpl A <code>NetworkImpl</code>. * @param logger A <code>Log4JWrapper</code>. * @param protocol A <code>NetworkProtocol</code>. * @param address A <code>NetworkAddress</code>. * @param proxies A <code>List<NetworkProxy></code>. */ NetworkConnectionImpl( final NetworkImpl networkImpl, final Log4JWrapper logger, final NetworkProtocol protocol, final NetworkAddress address, final List<NetworkProxy> proxies) { super(); this.id = networkImpl.nextId(this); this.logger = logger; this.networkImpl = networkImpl; this.protocol = protocol; this.address = address; this.proxies = proxies; }
/** * Set socket options pulled from the network configuration. * * @throws SocketException */ private void setSocketOptions() throws SocketException { final NetworkConfiguration configuration = networkImpl.getConfiguration(); final Integer soLinger = configuration.getSoLinger(protocol, address, proxy, this); final boolean linger = -1 < soLinger ? true : false; logger.logDebug("{0} - linger:{1}", getId(), linger); logger.logDebug("{0} - soLinger:{1}", getId(), soLinger); final Integer soTimeout = configuration.getSoTimeout(protocol, address, proxy, this); logger.logDebug("{0} - soTimeout:{1}", getId(), soTimeout); final Boolean tcpNoDelay = configuration.getTcpNoDelay(protocol, address, proxy, this); logger.logDebug("{0} - tcpNoDelay:{1}", getId(), tcpNoDelay); socket.setSoLinger(linger, linger ? soLinger : -1); socket.setSoTimeout(soTimeout); socket.setTcpNoDelay(tcpNoDelay); }
public static PersonNetwork parseNetworkMember(JSONObject jsonObject) { Boolean homeNetwork = (Boolean) jsonObject.get("homeNetwork"); PersonNetwork networkMember = new PersonNetwork(homeNetwork, NetworkImpl.parseNetwork(jsonObject)); return networkMember; }
public PersonNetwork(Boolean homeNetwork, NetworkImpl network) { super(); this.homeNetwork = homeNetwork; this.network = network; this.networkId = network.getId(); }
@Override public Boolean isPaidNetwork() { return network.isPaidNetwork(); }
@Override public String getSubscriptionLevel() { return network.getSubscriptionLevel(); }
@Override public List<Quota> getQuotas() { return network.getQuotas(); }
@Override public String getCreatedAt() { return network.getCreatedAt(); }
@Override public Boolean getIsEnabled() { return network.getIsEnabled(); }
/** * Obtain the network configuration. * * @return A <code>NetworkConfiguration</code>. */ private NetworkConfiguration getConfiguration() { return networkImpl.getConfiguration(); }