本文整理汇总了Java中hudson.remoting.Callable类的典型用法代码示例。如果您正苦于以下问题:Java Callable类的具体用法?Java Callable怎么用?Java Callable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Callable类属于hudson.remoting包,在下文中一共展示了Callable类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyCallable
import hudson.remoting.Callable; //导入依赖的package包/类
public static Callable<?, ?> getPropertyCallable ( final Object prop )
throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
Class<?> reqClass = Class.forName("hudson.remoting.RemoteInvocationHandler$RPCRequest");
Constructor<?> reqCons = reqClass.getDeclaredConstructor(int.class, Method.class, Object[].class);
reqCons.setAccessible(true);
Object getJarLoader = reqCons
.newInstance(1, Class.forName("hudson.remoting.IChannel").getMethod("getProperty", Object.class), new Object[] {
prop
});
return (Callable<?, ?>) getJarLoader;
}
示例2: executeWithGitSSH
import hudson.remoting.Callable; //导入依赖的package包/类
public static boolean executeWithGitSSH(BuildContext context, SSHUserPrivateKey creds, EnvVars envVars, Callable<Boolean, Exception> callable) throws Exception {
context.listener.getLogger().println("using GIT_SSH to set credentials " + creds.getDescription());
FilePath key = createSshKeyFile(context.build.getWorkspace(), creds);
FilePath ssh = null;
FilePath pass = null;;
try {
if (context.launcher.isUnix()) {
ssh = createUnixGitSSH(context.build.getWorkspace(), key, creds.getUsername());
pass = createUnixSshAskpass(context.build.getWorkspace(), creds);
} else {
ssh = createWindowsGitSSH(context.build.getWorkspace(), key, creds.getUsername(), envVars);
pass = createWindowsSshAskpass(context.build.getWorkspace(), creds);
}
envVars.put("GIT_SSH", ssh.getRemote());
envVars.put("SSH_ASKPASS", pass.getRemote());
if (!envVars.containsKey("DISPLAY")) {
envVars.put("DISPLAY", ":");
}
return callable.call();
} finally {
tryDelete(key, context.listener);
tryDelete(ssh, context.listener);
tryDelete(pass, context.listener);
}
}
示例3: runGit
import hudson.remoting.Callable; //导入依赖的package包/类
public static boolean runGit(final BuildContext context, final List<String> args, final EnvVars envVars, boolean withAuth) throws Exception, BuildInterruptedException {
Callable<Boolean, Exception> gitRunner = new Callable<Boolean, Exception>() {
@Override
public Boolean call() throws Exception {
final String gitExe;
if (JenkinsHelper.isNodeWindows(context)) {
gitExe = "git.exe";
} else {
gitExe = "git";
}
// prepend 'git' to the command line args
args.add(0, gitExe);
return JenkinsHelper.execute(context, args, envVars);
}
};
if (withAuth) {
// find the credentials.
SSHUserPrivateKey theCreds = GitSSHKeyHelper.getSSHCredentials(context, envVars);
if (theCreds == null) {
context.listener.getLogger().println("No SSH credentials found");
return false;
}
return GitSSHKeyHelper.executeWithGitSSH(context, theCreds, envVars, gitRunner);
} else {
return gitRunner.call();
}
}
示例4: caller
import hudson.remoting.Callable; //导入依赖的package包/类
public static Boolean caller(DockerCLI cli, Callable<Boolean, Throwable> callable) throws Throwable {
LOG.trace("Calling callable '{}'.", callable);
assertThat(cli.getChannel(), notNullValue());
Boolean call = cli.getChannel().call(callable);
assertThat(call, is(true));
return call;
}
示例5: getExecutable
import hudson.remoting.Callable; //导入依赖的package包/类
/**
* Get executable path of this Drush installation on the given target system.
*/
public String getExecutable(Launcher launcher) throws IOException, InterruptedException {
return launcher.getChannel().call(new Callable<String,IOException>() {
public String call() throws IOException {
File exe = getExeFile();
return exe.exists() ? exe.getPath() : null;
}
});
}
示例6: initiateDownloadsAtWorkspace
import hudson.remoting.Callable; //导入依赖的package包/类
private void initiateDownloadsAtWorkspace(
final GoogleRobotCredentials credentials,
final Run run, final List<StorageObjectId> objects,
final FilePath localDir, final TaskListener listener,
final String version, final String resolvedPrefix)
throws IOException, InterruptedException {
try {
// Use remotable credential to access the storage service from the
// remote machine.
final GoogleRobotCredentials remoteCredentials =
checkNotNull(credentials).forRemote(module.getRequirement());
localDir.act(
new Callable<Void, IOException>() {
@Override
public Void call() throws IOException {
performDownloads(remoteCredentials, localDir, objects, listener,
version, resolvedPrefix);
return (Void) null;
}
@Override
public void checkRoles(RoleChecker checker)
throws SecurityException {
// We know by definition that this is the correct role;
// the callable exists only in this method context.
}
});
} catch (GeneralSecurityException e) {
throw new IOException(
Messages.AbstractUpload_RemoteCredentialError(), e);
}
}
示例7: getExecutable
import hudson.remoting.Callable; //导入依赖的package包/类
public String getExecutable(Launcher launcher) throws InterruptedException, IOException {
return launcher.getChannel().call(new Callable<String, IOException>() {
public String call() throws IOException {
File exe = getExeFile();
if (exe.exists()) {
return exe.getPath();
}
return null;
}
});
}
示例8: getExecutable
import hudson.remoting.Callable; //导入依赖的package包/类
public String getExecutable(Launcher launcher) throws IOException, InterruptedException
{
return launcher.getChannel().call(new Callable<String,IOException>()
{
@Override
public String call() throws IOException
{
File fauxpasFile = new File(getHome(), "fauxpas");
return fauxpasFile.exists() ? fauxpasFile.getPath() : null;
}
});
}
示例9: getExecutable
import hudson.remoting.Callable; //导入依赖的package包/类
public String getExecutable(Launcher launcher) throws IOException,
InterruptedException {
return launcher.getChannel().call(
new Callable<String, IOException>() {
private static final long serialVersionUID = 1L;
public String call() throws IOException {
File exe = getExeFile();
if (exe.exists())
return exe.getPath();
return null;
}
});
}
示例10: getExecutable
import hudson.remoting.Callable; //导入依赖的package包/类
/**
* Gets the executable path of this groovy installation on the given target system.
*/
public String getExecutable(final Launcher launcher, final VirtualChannel channel) throws IOException, InterruptedException {
return channel.call(new Callable<String, IOException>() {
@Override
public String call() throws IOException {
final File exe = getExePath("scala", launcher.isUnix());
if(exe.exists()) {
return exe.getPath();
}
return null;
}
});
}
示例11: get
import hudson.remoting.Callable; //导入依赖的package包/类
public static <V, T extends java.lang.Throwable> V get(Node node, WeakHashMap<Node, V> cache, /*MasterToSlave*/Callable<V,T> operation, String name, V defaultIfNull)
throws IOException {
V result = get(node, cache, operation, name);
return result == null ? defaultIfNull : result;
}