001/* 002 * JGrapes Event Driven Framework 003 * Copyright (C) 2016-2018 Michael N. Lipp 004 * 005 * This program is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Affero General Public License as published by 007 * the Free Software Foundation; either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, but 011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 013 * for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License along 016 * with this program; if not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jgrapes.net.events; 020 021import java.net.SocketAddress; 022import org.jgrapes.core.Channel; 023import org.jgrapes.core.Components; 024import org.jgrapes.io.events.Opened; 025 026/** 027 * Signals that a server has bound to a socket address and 028 * is ready to accept connections. 029 */ 030public class Ready extends Opened<Void> { 031 032 private final SocketAddress listenAddress; 033 034 /** 035 * Creates a new event. 036 * 037 * @param socketAddress the socket address 038 */ 039 public Ready(SocketAddress socketAddress) { 040 this.listenAddress = socketAddress; 041 } 042 043 /** 044 * The address that the server has bound to. 045 * 046 * @return the address 047 */ 048 public SocketAddress listenAddress() { 049 return listenAddress; 050 } 051 052 /* 053 * (non-Javadoc) 054 * 055 * @see java.lang.Object#toString() 056 */ 057 @Override 058 public String toString() { 059 StringBuilder builder = new StringBuilder(); 060 builder.append(Components.objectName(this)) 061 .append(" [") 062 .append(listenAddress) 063 .append(", "); 064 if (channels().length > 0) { 065 builder.append("channels="); 066 builder.append(Channel.toString(channels())); 067 } 068 builder.append(']'); 069 return builder.toString(); 070 } 071}