@@ -99,6 +99,7 @@ public class DefaultGrailsApplication extends GroovyObjectSupport implements Gra
9999 private static final String CONFIG_BINDING_GRAILS_HOME = "grailsHome" ;
100100 private static final String CONFIG_BINDING_APP_NAME = "appName" ;
101101 private static final String CONFIG_BINDING_APP_VERSION = "appVersion" ;
102+ private static final String META_GRAILS_WAR_DEPLOYED = "grails.war.deployed" ;
102103
103104 /**
104105 * Creates a new empty Grails application
@@ -124,7 +125,7 @@ public DefaultGrailsApplication(final Class[] classes, GroovyClassLoader classLo
124125 }
125126 this .allClasses = classes ;
126127 this .cl = classLoader ;
127- loadMetadata ();
128+ this . applicationMeta = loadMetadata ();
128129 }
129130
130131
@@ -143,7 +144,7 @@ public DefaultGrailsApplication(GrailsResourceLoader resourceLoader) {
143144 this .resourceLoader = resourceLoader ;
144145
145146 try {
146- loadMetadata ();
147+ this . applicationMeta = loadMetadata ();
147148 loadGrailsApplicationFromResources (resourceLoader .getResources ());
148149 } catch (IOException e ) {
149150 throw new GrailsConfigurationException ("I/O exception loading Grails: " + e .getMessage (), e );
@@ -206,7 +207,7 @@ private void loadGrailsApplicationFromResources(Resource[] resources) throws IOE
206207 }
207208 }
208209
209- private void loadMetadata () {
210+ protected Map loadMetadata () {
210211 final Properties meta = new Properties ();
211212 Resource r = new ClassPathResource (PROJECT_META_FILE );
212213 try {
@@ -218,7 +219,7 @@ private void loadMetadata() {
218219 if (System .getProperty (GrailsApplication .ENVIRONMENT ) != null ) {
219220 meta .setProperty (GrailsApplication .ENVIRONMENT , System .getProperty (GrailsApplication .ENVIRONMENT ));
220221 }
221- applicationMeta = Collections .unmodifiableMap (meta );
222+ return Collections .unmodifiableMap (meta );
222223 }
223224
224225 /**
@@ -872,6 +873,17 @@ public void addArtefact(Class artefact) {
872873 }
873874 }
874875
876+ public boolean isWarDeployed () {
877+ Map metadata = getMetadata ();
878+ if (metadata != null ) {
879+ Object val = metadata .get (META_GRAILS_WAR_DEPLOYED );
880+ if (val != null && val .equals ("true" )) {
881+ return true ;
882+ }
883+ }
884+ return false ;
885+ }
886+
875887 public void setBeanClassLoader (ClassLoader classLoader ) {
876888 this .beanClassLoader = classLoader ;
877889 }
0 commit comments