001 /*
002 * Copyright 2008-2014 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 <W> WindowManager<W> getWindowManager();
093
094 // --== Lifecycle ==--
095
096 /**
097 * Executes the 'Initialize' life cycle phase.
098 */
099 void initialize();
100
101 /**
102 * Executes the 'Startup' life cycle phase.
103 */
104 void startup();
105
106 /**
107 * Executes the 'Ready' life cycle phase.
108 */
109 void ready();
110
111 /**
112 * Executes the 'Shutdown' life cycle phase.
113 *
114 * @return false if the shutdown sequence was aborted
115 */
116 boolean shutdown();
117
118 /**
119 * Queries any available ShutdownHandlers.
120 *
121 * @return true if the shutdown sequence can proceed, false otherwise
122 */
123 boolean canShutdown();
124
125 /**
126 * Registers a ShutdownHandler on this application
127 *
128 * @param handler the shutdown handler to be registered; null and/or
129 * duplicated values should be ignored
130 */
131 void addShutdownHandler(@Nonnull ShutdownHandler handler);
132
133 /**
134 * Removes a ShutdownHandler from this application
135 *
136 * @param handler the shutdown handler to be removed; null and/or
137 * duplicated values should be ignored
138 */
139 void removeShutdownHandler(@Nonnull ShutdownHandler handler);
140
141 // --== Properties ==--
142
143 /**
144 * Gets the application locale.
145 *
146 * @return the current Locale used by the application. Never returns null.
147 */
148 @Nonnull
149 Locale getLocale();
150
151 /**
152 * Sets the application locale.<p>
153 * This is a bound property.
154 *
155 * @param locale the Locale value to use
156 */
157 void setLocale(@Nonnull Locale locale);
158
159 /**
160 * Sets the application locale.<p>
161 * This is a bound property.
162 *
163 * @param locale a literal representation of a Locale
164 */
165 void setLocaleAsString(@Nullable String locale);
166
167 /**
168 * Returns the current phase.
169 *
170 * @return returns the current ApplicationPhase. Never returns null.
171 */
172 @Nonnull
173 ApplicationPhase getPhase();
174
175 /**
176 * Returns the arguments set on the command line (if any).<p>
177 *
178 * @return an array of command line arguments. Never returns null.
179 */
180 @Nonnull
181 String[] getStartupArgs();
182
183 /**
184 * Returns a Logger instance suitable for this application.
185 *
186 * @return a Logger instance.
187 */
188 @Nonnull
189 Logger getLog();
190 }
|