Last active
January 3, 2016 16:39
-
-
Save rinrinne/8491225 to your computer and use it in GitHub Desktop.
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
public static final class GerritController { | |
private static PluginImpl getActivePlugin() { | |
PluginImpl plugin = Jenkins.getInstance().getPlugin(PluginImpl.class); | |
if (plugin != null && plugin.isActive()) { | |
return plugin; | |
} | |
return null; | |
} | |
public static void postEvent(String event) { | |
PluginImpl plugin = getActivePlugin(); | |
if (plugin != null) { | |
plugin.getHandler().post(event); | |
} | |
} |
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
public class GerritControlTask inplements Runnable { | |
abstract void exec(); | |
@Override | |
protected void run() { | |
exec(); | |
} | |
} |
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
public final class GerritPostEventTask extends GerritControlTask { | |
private final String event; | |
public GerritPostEventTask(String event) { | |
this.event = event; | |
} | |
@Override | |
public void exec() { | |
GerritController.postEvent(event); | |
} | |
} |
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
public class PluginImpl extends Plugin { | |
private final ExecutorService controlService = Executors.newSingleThreadExecutor(); | |
public commitTask(ControlTask task) { | |
controlServie.submit(task); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment