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.ApplicationContext; 021import org.springframework.context.ConfigurableApplicationContext; 022import org.springframework.core.env.Environment; 023 024/** 025 * Event published as when a {@link SpringApplication} is starting up and the 026 * {@link ApplicationContext} is fully prepared but not refreshed. The bean definitions 027 * will be loaded and the {@link Environment} is ready for use at this stage. 028 * 029 * @author Dave Syer 030 */ 031@SuppressWarnings("serial") 032public class ApplicationPreparedEvent extends SpringApplicationEvent { 033 034 private final ConfigurableApplicationContext context; 035 036 /** 037 * Create a new {@link ApplicationPreparedEvent} instance. 038 * @param application the current application 039 * @param args the arguments the application is running with 040 * @param context the ApplicationContext about to be refreshed 041 */ 042 public ApplicationPreparedEvent(SpringApplication application, String[] args, 043 ConfigurableApplicationContext context) { 044 super(application, args); 045 this.context = context; 046 } 047 048 /** 049 * Return the application context. 050 * @return the context 051 */ 052 public ConfigurableApplicationContext getApplicationContext() { 053 return this.context; 054 } 055 056}