@Override
		public void initialize(ConfigurableApplicationContext applicationContext) {
			String adminPort = applicationContext.getEnvironment().resolvePlaceholders(ADMIN_PORT_PLACEHOLDER);
			ServerSocket socket = null;
			try {
				socket = new ServerSocket(Integer.parseInt(adminPort));
			}
			catch (IOException e) {
				throw new AdminPortNotAvailableException(adminPort);
			}
			finally {
				if (socket != null) {
					try {
						socket.close();
					}
					catch (IOException e) {
						// It is very unlikely to get an exception here.
					}
				}
			}
		}
{@link ApplicationContextInitializer} that checks if the admin port is already in use.

@author Ilayaperumal Gopinathan
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/server/admin/AdminServerApplication.java