001/* 002 * Copyright 2012-2018 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.ApplicationRunner; 020import org.springframework.boot.CommandLineRunner; 021import org.springframework.boot.SpringApplication; 022import org.springframework.context.ConfigurableApplicationContext; 023 024/** 025 * Event published once the application context has been refreshed but before any 026 * {@link ApplicationRunner application} and {@link CommandLineRunner command line} 027 * runners have been called. 028 * 029 * @author Andy Wilkinson 030 * @since 2.0.0 031 */ 032@SuppressWarnings("serial") 033public class ApplicationStartedEvent extends SpringApplicationEvent { 034 035 private final ConfigurableApplicationContext context; 036 037 /** 038 * Create a new {@link ApplicationStartedEvent} 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 ApplicationStartedEvent(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}