Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1da9fc
commit 0560be4
Showing
5 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* This file is part of jTransfo, a library for converting to and from transfer objects. | ||
* Copyright (c) PROGS bvba, Belgium | ||
* | ||
* The program is available in open source according to the Apache License, Version 2.0. | ||
* For full licensing details, see LICENSE.txt in the project root. | ||
*/ | ||
|
||
package org.jtransfo; | ||
|
||
import org.zeroturnaround.javarebel.ClassEventListener; | ||
import org.zeroturnaround.javarebel.ClassResourceSource; | ||
import org.zeroturnaround.javarebel.LoggerFactory; | ||
import org.zeroturnaround.javarebel.Plugin; | ||
import org.zeroturnaround.javarebel.ReloaderFactory; | ||
|
||
/** | ||
* Jrebel plugin, assure jTransfo does not keep working with 'old' class definitions. | ||
*/ | ||
public class JTransfoJrebelPlugin implements Plugin { | ||
|
||
private JTransfoImpl jTransfo; | ||
|
||
/** | ||
* Set instance for which this plugin (instance) applies. | ||
* | ||
* @param instance jTransfo registry instance | ||
*/ | ||
public void setInstance(JTransfoImpl instance) { | ||
jTransfo = instance; | ||
} | ||
|
||
@Override | ||
public void preinit() { | ||
registerListener(); | ||
} | ||
|
||
private void registerListener() { | ||
// Set up the reload listener | ||
ReloaderFactory.getInstance().addClassReloadListener( | ||
new ClassEventListener() { | ||
public void onClassEvent(int eventType, Class klass) { | ||
try { | ||
if (klass.isAnnotationPresent(DomainClass.class) || | ||
klass.isAnnotationPresent(DomainClassDelegate.class)) { | ||
jTransfo.clearCaches(); | ||
} | ||
} catch (Exception e) { | ||
LoggerFactory.getInstance().error(e); | ||
System.out.println(e); | ||
} | ||
} | ||
|
||
public int priority() { | ||
return 0; | ||
} | ||
} | ||
); | ||
} | ||
|
||
@Override | ||
public boolean checkDependencies(ClassLoader classLoader, ClassResourceSource classResourceSource) { | ||
return classResourceSource.getClassResource("org.jtransfo.JTransfoImpl") != null; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return "JTransfoJrebelPlugin"; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "JRebel Plugin for jTransfo"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Assure jTransfo notices changes in mapped classes - clear cache."; | ||
} | ||
|
||
@Override | ||
public String getAuthor() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getWebsite() { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters