Skip to content

Commit

Permalink
ParameterServiceProvider from core-common is not a subject of Service…
Browse files Browse the repository at this point in the history
…Finder.

Rather it is used when no other ParameterServiceProvider is found.

Signed-off-by: Jan Supol <jan.supol@oracle.com>
  • Loading branch information
jansupol committed Apr 11, 2019
1 parent d6b839b commit 37ddbaf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
41 changes: 29 additions & 12 deletions core-common/src/main/java/org/glassfish/jersey/model/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.glassfish.jersey.model;

import org.glassfish.jersey.internal.LocalizationMessages;
import org.glassfish.jersey.internal.ServiceFinder;
import org.glassfish.jersey.internal.guava.Lists;
import org.glassfish.jersey.internal.util.ReflectionHelper;
Expand Down Expand Up @@ -105,16 +106,24 @@ public enum Source {
UNKNOWN
}

private static final List<ParameterServiceProvider> PARAMETER_SERVICE_PROVIDERS = Collections
.unmodifiableList(Lists.newArrayList(ServiceFinder.find(ParameterServiceProvider.class)));
private static final List<ParamCreationFactory> PARAM_CREATION_FACTORIES = Collections.unmodifiableList(
PARAMETER_SERVICE_PROVIDERS.stream().map(a -> a.getParameterCreationFactory()).collect(Collectors.toList())
);

private static final Map<Class, ParamAnnotationHelper> ANNOTATION_HELPER_MAP = Collections.unmodifiableMap(
PARAMETER_SERVICE_PROVIDERS.stream().map(a -> a.getParameterAnnotationHelperMap())
.collect(WeakHashMap::new, Map::putAll, Map::putAll)
);
static {
final List<ParameterServiceProvider> FOUND_PARAMETER_SERVICE_PROVIDERS = Lists
.newArrayList(ServiceFinder.find(ParameterServiceProvider.class));
final List<ParameterServiceProvider> PARAMETER_SERVICE_PROVIDERS =
FOUND_PARAMETER_SERVICE_PROVIDERS.isEmpty()
? Collections.singletonList(new ParameterService())
: FOUND_PARAMETER_SERVICE_PROVIDERS;
PARAM_CREATION_FACTORIES = Collections.unmodifiableList(
PARAMETER_SERVICE_PROVIDERS.stream().map(a -> a.getParameterCreationFactory())
.collect(Collectors.toList())
);
ANNOTATION_HELPER_MAP = Collections.unmodifiableMap(
PARAMETER_SERVICE_PROVIDERS.stream().map(a -> a.getParameterAnnotationHelperMap())
.collect(WeakHashMap::new, Map::putAll, Map::putAll)
);
};
private static final List<ParamCreationFactory> PARAM_CREATION_FACTORIES;
private static final Map<Class, ParamAnnotationHelper> ANNOTATION_HELPER_MAP;

public interface ParamAnnotationHelper<T extends Annotation> {

Expand Down Expand Up @@ -307,7 +316,11 @@ private static <PARAMETER extends Parameter> PARAMETER createBeanParameter(Anno
defaultValue);
}
}
return null;

if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, LocalizationMessages.PARAM_CREATION_FACTORY_NOT_FOUND(parameterClass.getName()));
}
throw new IllegalStateException(LocalizationMessages.PARAM_CREATION_FACTORY_NOT_FOUND(parameterClass.getName()));
}

private static <PARAMETER extends Parameter> PARAMETER createParameter(Annotation[] markers, Annotation marker,
Expand All @@ -320,7 +333,11 @@ private static <PARAMETER extends Parameter> PARAMETER createParameter(Annotatio
defaultValue);
}
}
return null;

if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, LocalizationMessages.PARAM_CREATION_FACTORY_NOT_FOUND(parameterClass.getName()));
}
throw new IllegalStateException(LocalizationMessages.PARAM_CREATION_FACTORY_NOT_FOUND(parameterClass.getName()));
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ osgi.registry.error.opening.resource.stream=Unable to open an input stream for r
osgi.registry.error.processing.resource.stream=Unexpected error occurred while processing resource stream {0}.
output.stream.closed=The output stream has already been closed.
overriding.method.cannot.be.found=Method that overrides {0} cannot be found on class {1}.
param.creation.factory.not.found=No ParamCreationFactory found for Parameter source {0}.
param.null="{0}" parameter is null.
# {0} - value to string; {1} - type of value; {2} - desired value type/class
properties.helper.get.value.no.transform=There is no way how to transform value "{0}" [{1}] to type [{2}].
Expand Down

0 comments on commit 37ddbaf

Please sign in to comment.