当前位置: 首页>>代码示例>>Java>>正文


Java FileCallable类代码示例

本文整理汇总了Java中hudson.FilePath.FileCallable的典型用法代码示例。如果您正苦于以下问题:Java FileCallable类的具体用法?Java FileCallable怎么用?Java FileCallable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileCallable类属于hudson.FilePath包,在下文中一共展示了FileCallable类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFillFilenameLoadSessionItems

import hudson.FilePath.FileCallable; //导入依赖的package包/类
/**
 * List model to choose the ZAP session to use. It's called on the remote machine (if present)
 * to load all session files in the build's workspace.
 * 
 * @return a {@link ListBoxModel}. It can be empty if the workspace doesn't contain any ZAP sessions.
 * @throws InterruptedException 
 * @throws IOException 
 */
public ListBoxModel doFillFilenameLoadSessionItems() throws IOException, InterruptedException {
	ListBoxModel items = new ListBoxModel();
	
	// No workspace before the first build, so workspace is null
	if(workspace != null) {
		Collection<String> sessionsInString = workspace.act(new FileCallable<Collection<String>>() {
			private static final long serialVersionUID = 1328740269013881941L;
	
			public Collection<String> invoke(File f, VirtualChannel channel) {
				
				// List all files with FILE_SESSION_EXTENSION on the machine where the workspace is located
				Collection<File> colFiles = FileUtils.listFiles(f,
						FileFilterUtils.suffixFileFilter(FILE_SESSION_EXTENSION),
						TrueFileFilter.INSTANCE);
				
				Collection<String> colString = new ArrayList<String>();
				
				// "Transform" File into String
				for (File file : colFiles) {
					colString.add(file.getAbsolutePath());
					// The following line is to remove the full path to the workspace,
					// keep just the relative path to the session
					//colString.add(file.getAbsolutePath().replace(workspace.getRemote() + File.separatorChar, ""));
				}
				return colString;
			}
	
			@Override
			public void checkRoles(RoleChecker checker) throws SecurityException {
				// Nothing to do
			}
		});
	
		items.add(""); // To not load a session, add a blank choice
		
		for (String s : sessionsInString) {
			items.add(s);
		}
	}
	
	return items;
}
 
开发者ID:jenkinsci,项目名称:zaproxy-plugin,代码行数:51,代码来源:ZAProxy.java


注:本文中的hudson.FilePath.FileCallable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。