Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
279f12d0
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,发现更多精彩内容 >>
提交
279f12d0
编写于
4月 26, 2015
作者:
T
tfennelly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call ExtensionListListener.onChange for add and remove (as well as refresh).
上级
cad0fdab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
20 deletion
+24
-20
core/src/main/java/hudson/ExtensionList.java
core/src/main/java/hudson/ExtensionList.java
+13
-7
core/src/main/java/hudson/ExtensionListListener.java
core/src/main/java/hudson/ExtensionListListener.java
+5
-5
test/src/test/java/hudson/ExtensionListListenerTest.java
test/src/test/java/hudson/ExtensionListListenerTest.java
+6
-8
未找到文件。
core/src/main/java/hudson/ExtensionList.java
浏览文件 @
279f12d0
...
...
@@ -199,6 +199,7 @@ public class ExtensionList<T> extends AbstractList<T> {
List
<
ExtensionComponent
<
T
>>
r
=
new
ArrayList
<
ExtensionComponent
<
T
>>(
extensions
);
removed
|=
removeComponent
(
r
,
o
);
extensions
=
sort
(
r
);
fireOnChangeListeners
();
}
return
removed
;
}
...
...
@@ -235,6 +236,7 @@ public class ExtensionList<T> extends AbstractList<T> {
List
<
ExtensionComponent
<
T
>>
r
=
new
ArrayList
<
ExtensionComponent
<
T
>>(
extensions
);
r
.
add
(
new
ExtensionComponent
<
T
>(
t
));
extensions
=
sort
(
r
);
fireOnChangeListeners
();
}
return
true
;
}
...
...
@@ -293,13 +295,17 @@ public class ExtensionList<T> extends AbstractList<T> {
List
<
ExtensionComponent
<
T
>>
l
=
Lists
.
newArrayList
(
extensions
);
l
.
addAll
(
found
);
extensions
=
sort
(
l
);
for
(
ExtensionListListener
listener
:
listeners
)
{
try
{
listener
.
onRefresh
();
}
catch
(
Exception
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Error firing ExtensionListListener.onRefresh()."
,
e
);
}
}
fireOnChangeListeners
();
}
}
}
private
void
fireOnChangeListeners
()
{
for
(
ExtensionListListener
listener
:
listeners
)
{
try
{
listener
.
onChange
();
}
catch
(
Exception
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Error firing ExtensionListListener.onChange()."
,
e
);
}
}
}
...
...
core/src/main/java/hudson/ExtensionListListener.java
浏览文件 @
279f12d0
...
...
@@ -31,11 +31,11 @@ package hudson;
public
abstract
class
ExtensionListListener
{
/**
* {@link ExtensionList}
has been refresh
ed.
* {@link ExtensionList}
contents has chang
ed.
* <p>
* This would be called when a
dynamically loaded plugin introduces a new
*
{@link ExtensionPoint} implementation that adds an entry to the {@link ExtensionList}
* being listened to.
* This would be called when a
n entry gets added to or removed from the list for any reason e.g.
*
when a dynamically loaded plugin introduces a new {@link ExtensionPoint} implementation
*
that adds an entry to the {@link ExtensionList}
being listened to.
*/
public
abstract
void
on
Refresh
();
public
abstract
void
on
Change
();
}
test/src/test/java/hudson/ExtensionListListenerTest.java
浏览文件 @
279f12d0
...
...
@@ -29,8 +29,6 @@ import org.junit.Rule;
import
org.junit.Test
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
java.io.IOException
;
/**
* @author <a href="mailto:tom.fennelly@gmail.com">tom.fennelly@gmail.com</a>
*/
...
...
@@ -40,7 +38,7 @@ public class ExtensionListListenerTest {
public
JenkinsRule
r
=
PluginManagerUtil
.
newJenkinsRule
();
@Test
public
void
test_on
Refresh
()
throws
Exception
{
public
void
test_on
Change
()
throws
Exception
{
ExtensionList
<
TransientActionFactory
>
extensionList
=
ExtensionList
.
lookup
(
TransientActionFactory
.
class
);
// force ExtensionList.ensureLoaded, otherwise the refresh will be ignored because
...
...
@@ -52,17 +50,17 @@ public class ExtensionListListenerTest {
extensionList
.
addListener
(
listListener
);
// magiext.hpi has a TransientActionFactory @Extension impl in it. The loading of that
// plugin should trigger on
Refresh
in the MyExtensionListListener instance.
// plugin should trigger on
Change
in the MyExtensionListListener instance.
PluginManagerUtil
.
dynamicLoad
(
"magicext.hpi"
,
r
.
jenkins
);
Assert
.
assert
True
(
listListener
.
refreshed
);
Assert
.
assert
Equals
(
1
,
listListener
.
onChangeCallCount
);
}
private
class
MyExtensionListListener
extends
ExtensionListListener
{
private
boolean
refreshed
=
false
;
private
int
onChangeCallCount
=
0
;
@Override
public
void
on
Refresh
()
{
refreshed
=
true
;
public
void
on
Change
()
{
onChangeCallCount
++
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录