You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2018/01/25 13:41:40 UTC
[cxf] branch master updated: [CXF-7609] Minor updates
This is an automated email from the ASF dual-hosted git repository.
sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new 6a3f97e [CXF-7609] Minor updates
6a3f97e is described below
commit 6a3f97e9f0d02eef72bf10c266d444ec3af78bf5
Author: Sergey Beryozkin <sb...@gmail.com>
AuthorDate: Thu Jan 25 13:41:22 2018 +0000
[CXF-7609] Minor updates
---
.../org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java | 15 ++++-----------
.../java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java | 19 ++++++-------------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
index b96bfef..90d860a 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
@@ -22,10 +22,11 @@ package org.apache.cxf.jaxrs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
+import java.util.function.Function;
+import java.util.stream.Collectors;
import javax.ws.rs.Path;
import javax.xml.namespace.QName;
@@ -129,11 +130,7 @@ public class JAXRSServiceFactoryBean extends AbstractServiceFactoryBean {
}
public List<Class<?>> getResourceClasses() {
- List<Class<?>> resourceClasses = new ArrayList<Class<?>>();
- for (ClassResourceInfo cri : classResourceInfos) {
- resourceClasses.add(cri.getResourceClass());
- }
- return resourceClasses;
+ return classResourceInfos.stream().map(ClassResourceInfo::getResourceClass).collect(Collectors.toList());
}
public List<ClassResourceInfo> getClassResourceInfo() {
@@ -197,11 +194,7 @@ public class JAXRSServiceFactoryBean extends AbstractServiceFactoryBean {
}
private Map<String, UserResource> userResourcesAsMap(List<UserResource> resources) {
- Map<String, UserResource> map = new HashMap<>();
- for (UserResource ur : resources) {
- map.put(ur.getName(), ur);
- }
- return map;
+ return resources.stream().collect(Collectors.toMap(UserResource::getName, Function.identity()));
}
protected ClassResourceInfo createResourceInfo(Class<?> cls, boolean isRoot) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 7812f76..a09bbff 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -298,12 +298,9 @@ public final class JAXRSUtils {
public static Map<ClassResourceInfo, MultivaluedMap<String, String>> selectResourceClass(
List<ClassResourceInfo> resources, String path, Message message) {
- boolean isFineLevelLoggable = LOG.isLoggable(Level.FINE);
- if (isFineLevelLoggable) {
- LOG.fine(new org.apache.cxf.common.i18n.Message("START_CRI_MATCH",
+ LOG.fine(() -> new org.apache.cxf.common.i18n.Message("START_CRI_MATCH",
BUNDLE,
path).toString());
- }
if (resources.size() == 1) {
MultivaluedMap<String, String> values = new MetadataMap<String, String>();
return resources.get(0).getURITemplate().match(path, values)
@@ -318,15 +315,13 @@ public final class JAXRSUtils {
MultivaluedMap<String, String> map = new MetadataMap<String, String>();
if (cri.getURITemplate().match(path, map)) {
candidateList.put(cri, map);
- if (isFineLevelLoggable) {
- LOG.fine(new org.apache.cxf.common.i18n.Message("CRI_SELECTED_POSSIBLY",
+ LOG.fine(() -> new org.apache.cxf.common.i18n.Message("CRI_SELECTED_POSSIBLY",
BUNDLE,
cri.getServiceClass().getName(),
path,
cri.getURITemplate().getValue()).toString());
- }
- } else if (isFineLevelLoggable) {
- LOG.fine(new org.apache.cxf.common.i18n.Message("CRI_NO_MATCH",
+ } else {
+ LOG.fine(() -> new org.apache.cxf.common.i18n.Message("CRI_NO_MATCH",
BUNDLE,
path,
cri.getServiceClass().getName()).toString());
@@ -348,12 +343,10 @@ public final class JAXRSUtils {
} else {
break;
}
- if (isFineLevelLoggable) {
- LOG.fine(new org.apache.cxf.common.i18n.Message("CRI_SELECTED",
+ LOG.fine(() -> new org.apache.cxf.common.i18n.Message("CRI_SELECTED",
BUNDLE,
cri.getServiceClass().getName(),
path, cri.getURITemplate().getValue()).toString());
- }
}
return cris;
}
@@ -546,7 +539,7 @@ public final class JAXRSUtils {
final boolean checkDistance) {
List<MediaType> all = intersectMimeTypes(acceptTypes, producesTypes, true, checkDistance);
if (all.size() > 1) {
- Collections.sort(all, new Comparator<MediaType>() {
+ all.sort(new Comparator<MediaType>() {
public int compare(MediaType mt1, MediaType mt2) {
int result = compareMediaTypes(mt1, mt2, null);
--
To stop receiving notification emails like this one, please contact
sergeyb@apache.org.