Skip to content
Permalink
Browse files

[FIXED JENKINS-19454] - Added DecoratedLauncher implementation to the…

… core.

This launcher Allows subclasses to only implement methods they want to override.
Originally, this launcher has been implemented in Custom Tools Plugin, but there are many duplicates in other plugins => it would be useful to have it in Jenkins core.

Resolves https://issues.jenkins-ci.org/browse/JENKINS-19454

Signed-off-by: Oleg Nenashev <nenashev@synopsys.com>
(cherry picked from commit a865a52)
  • Loading branch information
oleg-nenashev authored and olivergondza committed Nov 13, 2013
1 parent db26457 commit 56f1ee4f81f81086036e1c4be4ea4e4b3b1de484
Showing with 82 additions and 0 deletions.
  1. +82 −0 core/src/main/java/hudson/Launcher.java
@@ -977,6 +977,88 @@ public OutputStream getStdin() {
}
}
}

/**
* A launcher which delegates to a provided inner launcher.
* Allows subclasses to only implement methods they want to override.
* Originally, this launcher has been implemented in
* <a href="https://wiki.jenkins-ci.org/display/JENKINS/Custom+Tools+Plugin">
* Custom Tools Plugin</a>.
*
* @author rcampbell
* @author Oleg Nenashev, Synopsys Inc.
* @since TODO: define version
*/
public static class DecoratedLauncher extends Launcher {

private Launcher inner = null;

public DecoratedLauncher(Launcher inner) {
super(inner);
this.inner = inner;
}

@Override
public Proc launch(ProcStarter starter) throws IOException {
return inner.launch(starter);
}

@Override
public Channel launchChannel(String[] cmd, OutputStream out,
FilePath workDir, Map<String, String> envVars) throws IOException,
InterruptedException {
return inner.launchChannel(cmd, out, workDir, envVars);
}

@Override
public void kill(Map<String, String> modelEnvVars) throws IOException,
InterruptedException {
inner.kill(modelEnvVars);
}

@Override
public boolean isUnix() {
return inner.isUnix();
}

@Override
public Proc launch(String[] cmd, boolean[] mask, String[] env, InputStream in, OutputStream out, FilePath workDir) throws IOException {
return inner.launch(cmd, mask, env, in, out, workDir);
}

@Override
public Computer getComputer() {
return inner.getComputer();
}

@Override
public TaskListener getListener() {
return inner.getListener();
}

@Override
public String toString() {
return super.toString() + "; decorates " + inner.toString();
}

@Override
public VirtualChannel getChannel() {
return inner.getChannel();
}

@Override
public Proc launch(String[] cmd, String[] env, InputStream in, OutputStream out, FilePath workDir) throws IOException {
return inner.launch(cmd, env, in, out, workDir);
}

/**
* Gets nested launcher.
* @return Inner launcher
*/
public Launcher getInner() {
return inner;
}
}

public static class IOTriplet implements Serializable {
InputStream stdout,stderr;

3 comments on commit 56f1ee4

@oleg-nenashev

This comment has been minimized.

Copy link
Member Author

@oleg-nenashev oleg-nenashev replied Jul 3, 2014

@olivergondza
I'm quite aware of this class back-porting.
I suppose it is required for JENKINS-20559 only

@olivergondza

This comment has been minimized.

Copy link
Member

@olivergondza olivergondza replied Jul 3, 2014

I will @Restrict new public api members such as this one once I am done backporting. I prefer this than backporting fix without its test. Or is there a problem I do not see?

@oleg-nenashev

This comment has been minimized.

Copy link
Member Author

@oleg-nenashev oleg-nenashev replied Jul 3, 2014

No, there's no other problems
Thanks for the backporting

Please sign in to comment.
You can’t perform that action at this time.