001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.context.event; 018 019import org.springframework.boot.SpringApplication; 020import org.springframework.context.ConfigurableApplicationContext; 021 022/** 023 * Event published as late as conceivably possible to indicate that the application is 024 * ready to service requests. The source of the event is the {@link SpringApplication} 025 * itself, but beware of modifying its internal state since all initialization steps will 026 * have been completed by then. 027 * 028 * @author Stephane Nicoll 029 * @since 1.3.0 030 * @see ApplicationFailedEvent 031 */ 032@SuppressWarnings("serial") 033public class ApplicationReadyEvent extends SpringApplicationEvent { 034 035 private final ConfigurableApplicationContext context; 036 037 /** 038 * Create a new {@link ApplicationReadyEvent} instance. 039 * @param application the current application 040 * @param args the arguments the application is running with 041 * @param context the context that was being created 042 */ 043 public ApplicationReadyEvent(SpringApplication application, String[] args, 044 ConfigurableApplicationContext context) { 045 super(application, args); 046 this.context = context; 047 } 048 049 /** 050 * Return the application context. 051 * @return the context 052 */ 053 public ConfigurableApplicationContext getApplicationContext() { 054 return this.context; 055 } 056 057}