Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
a82a47a8
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
未验证
提交
a82a47a8
编写于
12月 14, 2017
作者:
J
Jesse Glick
提交者:
GitHub
12月 14, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3191 from jglick/ServiceLoader
Deprecating Service in favor of ServiceLoader
上级
67476c79
b6088dc4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
18 deletion
+25
-18
core/src/main/java/hudson/PluginManager.java
core/src/main/java/hudson/PluginManager.java
+3
-1
core/src/main/java/hudson/init/InitStrategy.java
core/src/main/java/hudson/init/InitStrategy.java
+8
-6
core/src/main/java/hudson/util/Service.java
core/src/main/java/hudson/util/Service.java
+3
-3
core/src/main/java/jenkins/InitReactorRunner.java
core/src/main/java/jenkins/InitReactorRunner.java
+3
-2
core/src/main/java/jenkins/security/ConfidentialStore.java
core/src/main/java/jenkins/security/ConfidentialStore.java
+8
-6
未找到文件。
core/src/main/java/hudson/PluginManager.java
浏览文件 @
a82a47a8
...
...
@@ -120,7 +120,6 @@ import java.util.HashSet;
import
java.util.Iterator
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.ListIterator
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeMap
;
...
...
@@ -144,6 +143,7 @@ import hudson.util.FormValidation;
import
java.io.ByteArrayInputStream
;
import
java.net.JarURLConnection
;
import
java.net.URLConnection
;
import
java.util.ServiceLoader
;
import
java.util.jar.JarEntry
;
import
static
java
.
util
.
logging
.
Level
.
FINE
;
...
...
@@ -1195,7 +1195,9 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
/**
* Discover all the service provider implementations of the given class,
* via <tt>META-INF/services</tt>.
* @deprecated Use {@link ServiceLoader} instead, or (more commonly) {@link ExtensionList}.
*/
@Deprecated
public
<
T
>
Collection
<
Class
<?
extends
T
>>
discover
(
Class
<
T
>
spi
)
{
Set
<
Class
<?
extends
T
>>
result
=
new
HashSet
<
Class
<?
extends
T
>>();
...
...
core/src/main/java/hudson/init/InitStrategy.java
浏览文件 @
a82a47a8
...
...
@@ -17,7 +17,8 @@ import hudson.PluginManager;
import
jenkins.util.SystemProperties
;
import
hudson.util.DirScanner
;
import
hudson.util.FileVisitor
;
import
hudson.util.Service
;
import
java.util.Iterator
;
import
java.util.ServiceLoader
;
/**
* Strategy pattern of the various key decision making during the Jenkins initialization.
...
...
@@ -113,11 +114,12 @@ public class InitStrategy {
* Obtains the instance to be used.
*/
public
static
InitStrategy
get
(
ClassLoader
cl
)
throws
IOException
{
List
<
InitStrategy
>
r
=
Service
.
loadInstances
(
cl
,
InitStrategy
.
class
);
if
(
r
.
isEmpty
())
return
new
InitStrategy
();
// default
InitStrategy
s
=
r
.
get
(
0
);
LOGGER
.
fine
(
"Using "
+
s
+
" as InitStrategy"
);
Iterator
<
InitStrategy
>
it
=
ServiceLoader
.
load
(
InitStrategy
.
class
,
cl
).
iterator
();
if
(!
it
.
hasNext
())
{
return
new
InitStrategy
();
// default
}
InitStrategy
s
=
it
.
next
();
LOGGER
.
log
(
Level
.
FINE
,
"Using {0} as InitStrategy"
,
s
);
return
s
;
}
...
...
core/src/main/java/hudson/util/Service.java
浏览文件 @
a82a47a8
...
...
@@ -31,6 +31,7 @@ import java.util.Collection;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.ServiceLoader
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
static
java
.
util
.
logging
.
Level
.
WARNING
;
...
...
@@ -39,11 +40,10 @@ import static java.util.logging.Level.WARNING;
* Load classes by looking up <tt>META-INF/services</tt>.
*
* @author Kohsuke Kawaguchi
* @deprecated use {@link ServiceLoader} instead.
*/
@Deprecated
public
class
Service
{
/**
* Poorman's clone of JDK6 ServiceLoader.
*/
public
static
<
T
>
List
<
T
>
loadInstances
(
ClassLoader
classLoader
,
Class
<
T
>
type
)
throws
IOException
{
List
<
T
>
result
=
new
ArrayList
<
T
>();
...
...
core/src/main/java/jenkins/InitReactorRunner.java
浏览文件 @
a82a47a8
package
jenkins
;
import
com.google.common.collect.Lists
;
import
jenkins.util.SystemProperties
;
import
hudson.init.InitMilestone
;
import
hudson.init.InitReactorListener
;
import
hudson.util.DaemonThreadFactory
;
import
hudson.util.NamingThreadFactory
;
import
hudson.util.Service
;
import
jenkins.model.Configuration
;
import
jenkins.model.Jenkins
;
import
org.jvnet.hudson.reactor.Milestone
;
...
...
@@ -16,6 +16,7 @@ import org.jvnet.hudson.reactor.Task;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.ServiceLoader
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
...
@@ -59,7 +60,7 @@ public class InitReactorRunner {
* As such there's no way for plugins to participate into this process.
*/
private
ReactorListener
buildReactorListener
()
throws
IOException
{
List
<
ReactorListener
>
r
=
(
List
)
Service
.
loadInstances
(
Thread
.
currentThread
().
getContextClassLoader
(),
InitReactorListener
.
class
);
List
<
ReactorListener
>
r
=
Lists
.
newArrayList
(
ServiceLoader
.
load
(
InitReactorListener
.
class
,
Thread
.
currentThread
().
getContextClassLoader
())
);
r
.
add
(
new
ReactorListener
()
{
final
Level
level
=
Level
.
parse
(
Configuration
.
getStringConfigParameter
(
"initLogLevel"
,
"FINE"
)
);
public
void
onTaskStarted
(
Task
t
)
{
...
...
core/src/main/java/jenkins/security/ConfidentialStore.java
浏览文件 @
a82a47a8
...
...
@@ -4,7 +4,6 @@ import hudson.Extension;
import
hudson.Lookup
;
import
hudson.init.InitMilestone
;
import
hudson.util.Secret
;
import
hudson.util.Service
;
import
jenkins.model.Jenkins
;
import
org.kohsuke.MetaInfServices
;
...
...
@@ -12,7 +11,9 @@ import javax.annotation.CheckForNull;
import
javax.annotation.Nonnull
;
import
java.io.IOException
;
import
java.security.SecureRandom
;
import
java.util.List
;
import
java.util.Iterator
;
import
java.util.ServiceConfigurationError
;
import
java.util.ServiceLoader
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -68,10 +69,11 @@ public abstract class ConfidentialStore {
ConfidentialStore
cs
=
lookup
.
get
(
ConfidentialStore
.
class
);
if
(
cs
==
null
)
{
try
{
List
<
ConfidentialStore
>
r
=
(
List
)
Service
.
loadInstances
(
ConfidentialStore
.
class
.
getClassLoader
(),
ConfidentialStore
.
class
);
if
(!
r
.
isEmpty
())
cs
=
r
.
get
(
0
);
}
catch
(
IOException
e
)
{
Iterator
<
ConfidentialStore
>
it
=
ServiceLoader
.
load
(
ConfidentialStore
.
class
,
ConfidentialStore
.
class
.
getClassLoader
()).
iterator
();
if
(
it
.
hasNext
())
{
cs
=
it
.
next
();
}
}
catch
(
ServiceConfigurationError
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to list up ConfidentialStore implementations"
,
e
);
// fall through
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录