32
32
@ Singleton
33
33
@ Named ("errorMapperProxyDecorator" )
34
34
public class ErrorMapperProxyDecorator implements JaxrsProxyDecorator {
35
- //----------------------------------------------------------------------------------------------------------------------
35
+ //----------------------------------------------------------------------------------------------------------------------
36
36
// Fields
37
37
//----------------------------------------------------------------------------------------------------------------------
38
+
38
39
private static final Logger LOGGER = LoggerFactory .getLogger (ErrorMapperProxyDecorator .class );
39
40
private static final String STRATEGY = "strategy" ;
40
41
private final ErrorMapperService errorMapperService ;
42
+ private final String defaultStrategy ;
41
43
42
44
//----------------------------------------------------------------------------------------------------------------------
43
45
// Constructors
44
46
//----------------------------------------------------------------------------------------------------------------------
45
47
46
48
@ Inject
47
49
public ErrorMapperProxyDecorator (ErrorMapperService errorMapperService ) {
50
+ this (errorMapperService , ErrorMapperUtils .DEFAULT_STRATEGY );
51
+ }
52
+
53
+ public ErrorMapperProxyDecorator (ErrorMapperService errorMapperService , String defaultStrategy ) {
48
54
this .errorMapperService = errorMapperService ;
55
+ this .defaultStrategy = defaultStrategy ;
49
56
}
50
57
51
58
//----------------------------------------------------------------------------------------------------------------------
@@ -54,7 +61,7 @@ public ErrorMapperProxyDecorator(ErrorMapperService errorMapperService) {
54
61
55
62
@ Override
56
63
public void decorate (JaxrsServiceDescriptor descriptor , Config config ) {
57
- final String strategy = config .value (STRATEGY ).orElse (ErrorMapperUtils . DEFAULT_STRATEGY );
64
+ final String strategy = config .value (STRATEGY ).orElse (defaultStrategy );
58
65
LOGGER .debug ("Using \" {}\" error response strategy for {} JAX-RS proxy." , strategy , descriptor .serviceInterface ().getSimpleName ());
59
66
descriptor .addProvider (new ErrorMapperResponseExceptionMapper (errorMapperService , strategy ));
60
67
}
0 commit comments