public Object makeObject(Object key) throws Exception { UMOImmutableEndpoint ep = (UMOImmutableEndpoint) key; int port = ep.getEndpointURI().getPort(); InetAddress inetAddress = InetAddress.getByName(ep.getEndpointURI().getHost()); Socket socket = createSocket(port, inetAddress); socket.setReuseAddress(true); TcpConnector connector = (TcpConnector) ep.getConnector(); connector.configureSocket(TcpConnector.CLIENT, socket); return socket; }
public void passivateObject(Object key, Object object) throws Exception { UMOImmutableEndpoint ep = (UMOImmutableEndpoint) key; boolean keepSocketOpen = MapUtils.getBooleanValue( ep.getProperties(), TcpConnector.KEEP_SEND_SOCKET_OPEN_PROPERTY, ((TcpConnector) ep.getConnector()).isKeepSendSocketOpen()); Socket socket = (Socket) object; if (!keepSocketOpen) { try { if (socket != null) { socket.close(); } } catch (IOException e) { logger.debug("Failed to close socket after dispatch: " + e.getMessage()); } } }
public XmppMessageDispatcher(UMOImmutableEndpoint endpoint) { super(endpoint); this.connector = (XmppConnector) endpoint.getConnector(); }