Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
c3df857c
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3df857c
编写于
3月 11, 2014
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replaced job field with asJob().
上级
71a29a7b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
20 deletion
+19
-20
core/src/main/java/hudson/model/AbstractProject.java
core/src/main/java/hudson/model/AbstractProject.java
+5
-1
core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
+14
-19
未找到文件。
core/src/main/java/hudson/model/AbstractProject.java
浏览文件 @
c3df857c
...
...
@@ -275,7 +275,11 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
private
LazyBuildMixIn
<
P
,
R
>
createBuildMixIn
()
{
return
new
LazyBuildMixIn
<
P
,
R
>(
this
)
{
return
new
LazyBuildMixIn
<
P
,
R
>()
{
@SuppressWarnings
(
"unchecked"
)
// untypable
@Override
protected
P
asJob
()
{
return
(
P
)
AbstractProject
.
this
;
}
@Override
protected
Class
<
R
>
getBuildClass
()
{
return
AbstractProject
.
this
.
getBuildClass
();
}
...
...
core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
浏览文件 @
c3df857c
...
...
@@ -29,7 +29,7 @@ import hudson.model.AbstractItem;
import
hudson.model.Item
;
import
hudson.model.ItemGroup
;
import
hudson.model.Job
;
import
hudson.model.Queue
.Task
;
import
hudson.model.Queue
;
import
hudson.model.Run
;
import
hudson.model.RunMap
;
import
hudson.model.listeners.ItemListener
;
...
...
@@ -53,12 +53,11 @@ import org.kohsuke.accmod.restrictions.DoNotUse;
* <p>Should be kept in a {@code transient} field in the job.
* @since TODO
*/
public
abstract
class
LazyBuildMixIn
<
P
extends
Job
<
P
,
R
>,
R
extends
Run
<
P
,
R
>>
{
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
abstract
class
LazyBuildMixIn
<
P
extends
Job
<
P
,
R
>
&
Queue
.
Task
&
LazyBuildMixIn
.
LazyLoadingJob
,
R
extends
Run
<
P
,
R
>>
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
LazyBuildMixIn
.
class
.
getName
());
private
final
Job
<
P
,
R
>
job
;
@SuppressWarnings
(
"deprecation"
)
// [JENKINS-15156] builds accessed before onLoad or onCreatedFromScratch called
private
@Nonnull
RunMap
<
R
>
builds
=
new
RunMap
<
R
>();
...
...
@@ -66,15 +65,12 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
private
long
lastBuildStartTime
;
/**
* Initializes this mixin
based on a job
.
* Initializes this mixin.
* Call this from a constructor and {@link AbstractItem#onLoad} to make sure it is always initialized.
* @param job the owning job (should be of type {@code P} and assignable to {@link Task} and {@link LazyLoadingJob})
*/
public
LazyBuildMixIn
(
Job
<
P
,
R
>
job
)
{
Task
.
class
.
cast
(
job
);
LazyLoadingJob
.
class
.
cast
(
job
);
this
.
job
=
job
;
}
protected
LazyBuildMixIn
()
{}
protected
abstract
P
asJob
();
/**
* Gets the raw model.
...
...
@@ -89,7 +85,7 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
* Same as {@link #getRunMap} but suitable for {@link Job#_getRuns}.
*/
public
final
RunMap
<
R
>
_getRuns
()
{
assert
builds
.
baseDirInitialized
()
:
"neither onCreatedFromScratch nor onLoad called on "
+
job
+
" yet"
;
assert
builds
.
baseDirInitialized
()
:
"neither onCreatedFromScratch nor onLoad called on "
+
asJob
()
+
" yet"
;
return
builds
;
}
...
...
@@ -117,7 +113,7 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
LOGGER
.
log
(
Level
.
WARNING
,
"failed to look up "
+
name
+
" in "
+
parent
,
x
);
current
=
null
;
}
if
(
current
!=
null
&&
current
.
getClass
()
==
job
.
getClass
())
{
if
(
current
!=
null
&&
current
.
getClass
()
==
asJob
()
.
getClass
())
{
currentBuilds
=
(
RunMap
<
R
>)
((
LazyLoadingJob
)
current
).
getLazyBuildMixIn
().
builds
;
}
}
...
...
@@ -133,7 +129,7 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
}
private
RunMap
<
R
>
createBuildRunMap
()
{
return
new
RunMap
<
R
>(
job
.
getBuildDir
(),
new
RunMap
.
Constructor
<
R
>()
{
return
new
RunMap
<
R
>(
asJob
()
.
getBuildDir
(),
new
RunMap
.
Constructor
<
R
>()
{
@Override
public
R
create
(
File
dir
)
throws
IOException
{
return
loadBuild
(
dir
);
}
...
...
@@ -154,7 +150,7 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
*/
public
R
loadBuild
(
File
dir
)
throws
IOException
{
try
{
return
getBuildClass
().
getConstructor
(
job
.
getClass
(),
File
.
class
).
newInstance
(
job
,
dir
);
return
getBuildClass
().
getConstructor
(
asJob
().
getClass
(),
File
.
class
).
newInstance
(
asJob
()
,
dir
);
}
catch
(
InstantiationException
e
)
{
throw
new
Error
(
e
);
}
catch
(
IllegalAccessException
e
)
{
...
...
@@ -185,7 +181,7 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
}
lastBuildStartTime
=
System
.
currentTimeMillis
();
try
{
R
lastBuild
=
getBuildClass
().
getConstructor
(
job
.
getClass
()).
newInstance
(
job
);
R
lastBuild
=
getBuildClass
().
getConstructor
(
asJob
().
getClass
()).
newInstance
(
asJob
()
);
builds
.
put
(
lastBuild
);
return
lastBuild
;
}
catch
(
InstantiationException
e
)
{
...
...
@@ -218,7 +214,7 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
*/
public
final
void
removeRun
(
R
run
)
{
if
(!
builds
.
remove
(
run
))
{
LOGGER
.
log
(
Level
.
WARNING
,
"{0} did not contain {1} to begin with"
,
new
Object
[]
{
job
,
run
});
LOGGER
.
log
(
Level
.
WARNING
,
"{0} did not contain {1} to begin with"
,
new
Object
[]
{
asJob
()
,
run
});
}
}
...
...
@@ -267,9 +263,8 @@ public abstract class LazyBuildMixIn<P extends Job<P,R>,R extends Run<P,R>> {
/**
* Suitable for {@link Job#createHistoryWidget}.
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
final
HistoryWidget
createHistoryWidget
()
{
return
new
BuildHistoryWidget
(
(
Task
)
job
,
builds
,
Job
.
HISTORY_ADAPTER
);
return
new
BuildHistoryWidget
(
asJob
()
,
builds
,
Job
.
HISTORY_ADAPTER
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录