use of org.springsource.loaded.ReloadEventProcessorPlugin in project spring-loaded by spring-projects.
the class PluginTests method testPluginRerunStaticInitializerRequest2.
@Test
public void testPluginRerunStaticInitializerRequest2() throws Exception {
binLoader = new TestClassloaderWithRewriting("metaNotExist", true);
String t = "clinit.One";
ReloadEventProcessorPlugin repp = new ReloadEventProcessorPlugin() {
public void reloadEvent(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("Plugin: reloadEvent(" + typename + "," + clazz.getName() + "," + encodedTimestamp + ")");
}
public boolean shouldRerunStaticInitializer(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("Plugin: rerun request for " + typename);
// if this were false, the result below would be 5!
return true;
}
};
try {
Plugins.registerGlobalPlugin(repp);
TypeRegistry r = getTypeRegistry(t);
ReloadableType rtype = r.addType(t, loadBytesForClass(t));
captureOn();
rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
String output = captureOff();
System.out.println(output);
assertContains("Reloading: Loading new version of clinit.One [2]", output);
assertUniqueContains("Plugin: reloadEvent(clinit.One,clinit.One,2)", output);
assertContains("Reloading: Loading new version of clinit.One [2]", output);
assertUniqueContains("Plugin: rerun request for clinit.One", output);
result = runUnguarded(rtype.getClazz(), "run");
assertEquals("7", result.returnValue);
} finally {
Plugins.unregisterGlobalPlugin(repp);
}
}
use of org.springsource.loaded.ReloadEventProcessorPlugin in project spring-loaded by spring-projects.
the class PluginTests method testPluginRerunStaticInitializerRequest.
@Test
public void testPluginRerunStaticInitializerRequest() throws Exception {
binLoader = new TestClassloaderWithRewriting("metaNotExist", true);
String t = "simple.Basic";
ReloadEventProcessorPlugin repp = new ReloadEventProcessorPlugin() {
public void reloadEvent(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("Plugin: reloadEvent(" + typename + "," + clazz.getName() + "," + encodedTimestamp + ")");
}
public boolean shouldRerunStaticInitializer(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("Plugin: rerun request for " + typename);
return false;
}
};
try {
Plugins.registerGlobalPlugin(repp);
TypeRegistry r = getTypeRegistry(t);
ReloadableType rtype = r.addType(t, loadBytesForClass(t));
captureOn();
rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
String output = captureOff();
System.out.println(output);
assertContains("Reloading: Loading new version of simple.Basic [2]", output);
assertUniqueContains("Plugin: reloadEvent(simple.Basic,simple.Basic,2)", output);
assertContains("Reloading: Loading new version of simple.Basic [2]", output);
assertUniqueContains("Plugin: rerun request for simple.Basic", output);
result = runUnguarded(rtype.getClazz(), "run");
assertEquals("goodbye", result.returnValue);
} finally {
Plugins.unregisterGlobalPlugin(repp);
}
}
use of org.springsource.loaded.ReloadEventProcessorPlugin in project spring-loaded by spring-projects.
the class PluginTests method testGlobalPluginRegistration.
// registering a global plugin
@Test
public void testGlobalPluginRegistration() throws Exception {
binLoader = new TestClassloaderWithRewriting("metaNotExist", true);
String t = "simple.Basic";
ReloadEventProcessorPlugin repp = new ReloadEventProcessorPlugin() {
public void reloadEvent(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("Plugin: reloadEvent(" + typename + "," + clazz.getName() + "," + encodedTimestamp + ")");
}
public boolean shouldRerunStaticInitializer(String typename, Class<?> clazz, String encodedTimestamp) {
return false;
}
};
try {
Plugins.registerGlobalPlugin(repp);
TypeRegistry r = getTypeRegistry(t);
ReloadableType rtype = r.addType(t, loadBytesForClass(t));
captureOn();
rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
String output = captureOff();
System.out.println(output);
assertContains("Reloading: Loading new version of simple.Basic [2]", output);
assertUniqueContains("Plugin: reloadEvent(simple.Basic,simple.Basic,2)", output);
result = runUnguarded(rtype.getClazz(), "run");
assertEquals("goodbye", result.returnValue);
} finally {
Plugins.unregisterGlobalPlugin(repp);
}
}
Aggregations