| 
001 /*002  * Copyright 2008-2015 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 package griffon.core;
 017
 018 import griffon.core.addon.AddonManager;
 019 import griffon.core.artifact.ArtifactManager;
 020 import griffon.core.controller.ActionManager;
 021 import griffon.core.env.ApplicationPhase;
 022 import griffon.core.event.EventRouter;
 023 import griffon.core.i18n.MessageSource;
 024 import griffon.core.injection.Injector;
 025 import griffon.core.mvc.MVCGroupManager;
 026 import griffon.core.resources.ResourceHandler;
 027 import griffon.core.resources.ResourceInjector;
 028 import griffon.core.resources.ResourceResolver;
 029 import griffon.core.threading.UIThreadManager;
 030 import griffon.core.view.WindowManager;
 031 import org.slf4j.Logger;
 032
 033 import javax.annotation.Nonnull;
 034 import javax.annotation.Nullable;
 035 import java.util.Locale;
 036 import java.util.Map;
 037
 038 /**
 039  * Defines the basic contract of a Griffon application.<p>
 040  *
 041  * @author Danno Ferrin
 042  * @author Andres Almiray
 043  * @since 0.0.0
 044  */
 045 public interface GriffonApplication extends Observable {
 046     String PROPERTY_LOCALE = "locale";
 047     String PROPERTY_PHASE = "phase";
 048
 049     @Nonnull
 050     Object createApplicationContainer(@Nonnull Map<String, Object> attributes);
 051
 052     @Nonnull
 053     ApplicationClassLoader getApplicationClassLoader();
 054
 055     @Nonnull
 056     Configuration getConfiguration();
 057
 058     @Nonnull
 059     UIThreadManager getUIThreadManager();
 060
 061     @Nonnull
 062     EventRouter getEventRouter();
 063
 064     @Nonnull
 065     ArtifactManager getArtifactManager();
 066
 067     @Nonnull
 068     ActionManager getActionManager();
 069
 070     @Nonnull
 071     AddonManager getAddonManager();
 072
 073     @Nonnull
 074     MVCGroupManager getMvcGroupManager();
 075
 076     @Nonnull
 077     MessageSource getMessageSource();
 078
 079     @Nonnull
 080     ResourceResolver getResourceResolver();
 081
 082     @Nonnull
 083     ResourceHandler getResourceHandler();
 084
 085     @Nonnull
 086     ResourceInjector getResourceInjector();
 087
 088     @Nonnull
 089     Injector<?> getInjector();
 090
 091     @Nonnull
 092     Context getContext();
 093
 094     @Nonnull
 095     <W> WindowManager<W> getWindowManager();
 096
 097     // --== Lifecycle ==--
 098
 099     /**
 100      * Executes the 'Initialize' life cycle phase.
 101      */
 102     void initialize();
 103
 104     /**
 105      * Executes the 'Startup' life cycle phase.
 106      */
 107     void startup();
 108
 109     /**
 110      * Executes the 'Ready' life cycle phase.
 111      */
 112     void ready();
 113
 114     /**
 115      * Executes the 'Shutdown' life cycle phase.
 116      *
 117      * @return false if the shutdown sequence was aborted
 118      */
 119     boolean shutdown();
 120
 121     /**
 122      * Queries any available ShutdownHandlers.
 123      *
 124      * @return true if the shutdown sequence can proceed, false otherwise
 125      */
 126     boolean canShutdown();
 127
 128     /**
 129      * Registers a ShutdownHandler on this application
 130      *
 131      * @param handler the shutdown handler to be registered; null and/or
 132      *                duplicated values should be ignored
 133      */
 134     void addShutdownHandler(@Nonnull ShutdownHandler handler);
 135
 136     /**
 137      * Removes a ShutdownHandler from this application
 138      *
 139      * @param handler the shutdown handler to be removed; null and/or
 140      *                duplicated values should be ignored
 141      */
 142     void removeShutdownHandler(@Nonnull ShutdownHandler handler);
 143
 144     // --== Properties ==--
 145
 146     /**
 147      * Gets the application locale.
 148      *
 149      * @return the current Locale used by the application. Never returns null.
 150      */
 151     @Nonnull
 152     Locale getLocale();
 153
 154     /**
 155      * Sets the application locale.<p>
 156      * This is a bound property.
 157      *
 158      * @param locale the Locale value to use
 159      */
 160     void setLocale(@Nonnull Locale locale);
 161
 162     /**
 163      * Sets the application locale.<p>
 164      * This is a bound property.
 165      *
 166      * @param locale a literal representation of a Locale
 167      */
 168     void setLocaleAsString(@Nullable String locale);
 169
 170     /**
 171      * Returns the current phase.
 172      *
 173      * @return returns the current ApplicationPhase. Never returns null.
 174      */
 175     @Nonnull
 176     ApplicationPhase getPhase();
 177
 178     /**
 179      * Returns the arguments set on the command line (if any).<p>
 180      *
 181      * @return an array of command line arguments. Never returns null.
 182      */
 183     @Nonnull
 184     String[] getStartupArgs();
 185
 186     /**
 187      * Returns a Logger instance suitable for this application.
 188      *
 189      * @return a Logger instance.
 190      */
 191     @Nonnull
 192     Logger getLog();
 193 }
 |