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.SpringApplication;
020import org.springframework.context.ApplicationContext;
021import org.springframework.context.ConfigurableApplicationContext;
022
023/**
024 * Event published when a {@link SpringApplication} is starting up and the
025 * {@link ApplicationContext} is prepared and ApplicationContextInitializers have been
026 * called but before any bean definitions are loaded.
027 *
028 * @author Artsiom Yudovin
029 * @since 2.1.0
030 */
031@SuppressWarnings("serial")
032public class ApplicationContextInitializedEvent extends SpringApplicationEvent {
033
034        private final ConfigurableApplicationContext context;
035
036        /**
037         * Create a new {@link ApplicationContextInitializedEvent} instance.
038         * @param application the current application
039         * @param args the arguments the application is running with
040         * @param context the context that has been initialized
041         */
042        public ApplicationContextInitializedEvent(SpringApplication application,
043                        String[] args, 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}