Permalink
Browse files

integrated reloading agent with GrailsPluginManager reload events mec…

…hanism, controllers now reloading again (although new controllers/actions created whilst container is running aren't, still researching that)
  • Loading branch information...
graemerocher committed Mar 9, 2011
1 parent f7837a6 commit ea7c286e0c4024ed84ce7e99a28aff1839011453
View
@@ -197,10 +197,7 @@ task clean << {
delete(buildDir)
}
-task install(dependsOn:[populateDependencies])
-
-
-install.doLast {
+task installResources << {
copy {
from('src/resources/tests')
into('lib')
@@ -218,7 +215,7 @@ install.doLast {
// the fileMode property above should take care of the chmod work, but
// it doesn't per http://jira.codehaus.org/browse/GRADLE-971
ant.chmod(dir: 'bin', perm: '755', includes: '*')
-
+
copy {
from("src/resources/conf")
into "conf"
@@ -231,4 +228,5 @@ install.doLast {
}
+task install(dependsOn:[populateDependencies, installResources])
task assemble(dependsOn:zipDist)
View
@@ -1,8 +1,18 @@
+configurations {
+ agent.extendsFrom compile
+}
dependencies {
runtime 'oro:oro:2.0.8'
+ agent files(fileTree(dir:"$projectDir/lib" as File))
compile project(":grails-bootstrap"), project(":grails-spring")
}
+sourceSets {
+ main {
+ compileClasspath = files(configurations.agent)
+ }
+}
+
compileGroovy.doFirst {
delete("${buildDir}/classes/main/META-INF")
ant.mkdir(dir:sourceSets.main.classesDir)
Binary file not shown.
@@ -0,0 +1,44 @@
+/* Copyright 2011 SpringSource
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.codehaus.groovy.grails.cli.agent;
+
+import com.springsource.loaded.Plugins;
+import com.springsource.loaded.ReloadEventProcessorPlugin;
+import org.codehaus.groovy.grails.plugins.GrailsPluginManager;
+import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
+
+/**
+ *
+ * Reloading agent plugin for use with the GrailsPluginManager
+ *
+ * @author Graeme Rocher
+ * @since 1.4
+ */
+public class GrailsPluginManagerReloadPlugin implements ReloadEventProcessorPlugin {
+
+ @Override
+ public void reloadEvent(String typename, Class<?> aClass, String encodedTimestamp) {
+ GrailsPluginManager pluginManager = PluginManagerHolder.getPluginManager();
+ if(pluginManager != null) {
+ pluginManager.informOfClassChange(aClass);
+ }
+ }
+
+
+ public static void register() {
+ Plugins.registerGlobalPlugin(new GrailsPluginManagerReloadPlugin());
+ }
+}
@@ -98,6 +98,9 @@ public GrailsRuntimeConfigurator(GrailsApplication application, ApplicationConte
pluginManager = pluginManager != null ? pluginManager : PluginManagerHolder.getPluginManager();
} catch (BeansException e) {
// ignore
+ }
+ if(pluginManager == null) {
+ pluginManager = PluginManagerHolder.getPluginManager();
}
if(pluginManager == null) {
pluginManager = new DefaultGrailsPluginManager("**/plugins/*/**GrailsPlugin.groovy", application);
@@ -192,6 +192,10 @@ target(loadPlugins:"Loads Grails' plugins") {
pluginManager.doArtefactConfiguration()
grailsApp.initialise()
+
+ if(org.springframework.util.ClassUtils.isPresent("com.springsource.loaded.Plugins", rootLoader)) {
+ org.codehaus.groovy.grails.cli.agent.GrailsPluginManagerReloadPlugin.register()
+ }
event("PluginLoadEnd", [pluginManager])
}
}
@@ -234,7 +234,7 @@ startGrails() {
else
GRAILS_OPTS="-server -Xmx512M -XX:MaxPermSize=192m -Dfile.encoding=UTF-8"
fi
- JAVA_OPTS="$GRAILS_OPTS $JAVA_OPTS -javaagent:$GRAILS_HOME/bin/springloaded-0.7.1.jar -noverify -Dspringloaded=limit=false;plugins=com.springsource.loaded.SystemPropertyConfiguredIsReloadableTypePlugin"
+ JAVA_OPTS="$GRAILS_OPTS $JAVA_OPTS -javaagent:$GRAILS_HOME/bin/springloaded-0.7.2.jar -noverify -Dspringloaded=limit=false;plugins=com.springsource.loaded.SystemPropertyConfiguredIsReloadableTypePlugin"
# Start the Profiler or the JVM
if $useprofiler; then
runProfiler

0 comments on commit ea7c286

Please sign in to comment.