extension point for FilePath.act interception

This commit is contained in:
Nicolas De Loof committed 2012-09-06 15:04:27 +02:00
1 parent 597ea1e6a2
commit 5c80e9476f
1 file changed
+16 -1
+16 -1
View File
@@ -27,6 +27,8 @@ package hudson;
import hudson.Launcher.LocalLauncher;
import hudson.Launcher.RemoteLauncher;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import jenkins.model.Jenkins;
import hudson.model.TaskListener;
import hudson.model.AbstractProject;
@@ -828,7 +830,13 @@ public final class FilePath implements Serializable {
if(channel!=null) {
// run this on a remote system
try {
return channel.call(new FileCallableWrapper<T>(callable,cl));
DelegatingCallable<T,IOException> wrapper = new FileCallableWrapper<T>(callable, cl);
ExtensionList<AroundInvokeFactory> factories = Jenkins.getInstance().getExtensionList(AroundInvokeFactory.class);
for (AroundInvokeFactory factory : factories) {
wrapper = factory.wrap(wrapper);
}
return channel.call(wrapper);
} catch (TunneledInterruptedException e) {
throw (InterruptedException)new InterruptedException().initCause(e);
} catch (AbortException e) {
@@ -843,6 +851,12 @@ public final class FilePath implements Serializable {
}
}
public static abstract class AroundInvokeFactory extends AbstractDescribableImpl<AroundInvokeFactory> implements ExtensionPoint {
public abstract <T> DelegatingCallable<T,IOException> wrap(DelegatingCallable<T,IOException> callable);
}
/**
* Executes some program on the machine that this {@link FilePath} exists,
* so that one can perform local file operations.
@@ -2197,6 +2211,7 @@ public final class FilePath implements Serializable {
public T call() throws IOException {
try {
Channel.current().
return callable.invoke(new File(remote), Channel.current());
} catch (InterruptedException e) {
throw new TunneledInterruptedException(e);