Skip to content

Commit

Permalink
feat!: Configured jax-rs controllers, filters and exception-mappers a…
Browse files Browse the repository at this point in the history
…s singletons

Refs: #DEV-11808
  • Loading branch information
nirikash committed Jun 25, 2024
1 parent 5d8e957 commit 2455d05
Showing 1 changed file with 45 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,63 @@ public Set<Class<?>> getClasses() {

@NotNull
protected Set<Class<?>> getExceptionMappers() {
return new HashSet<>();
}

@NotNull
protected Set<Class<?>> getFilters() {
return new HashSet<>();
}

@NotNull
protected Set<Class<?>> getControllerClasses() {
return new HashSet<>();
}

@Override
@NotNull
public Set<Object> getSingletons() {
Set<Object> singletons = new HashSet<>();
singletons.addAll(getExceptionMapperSingletons());
singletons.addAll(getFilterSingletons());
singletons.addAll(getControllerSingletons());
return singletons;
}

@NotNull
protected Set<Object> getExceptionMapperSingletons() {
return new HashSet<>(Arrays.asList(
BadRequestExceptionMapper.class,
ForbiddenExceptionMapper.class,
IllegalArgumentExceptionMapper.class,
InternalServerErrorExceptionMapper.class,
NotFoundExceptionMapper.class,
ObjectNotFoundExceptionMapper.class,
UncaughtExceptionMapper.class
new BadRequestExceptionMapper(),
new ForbiddenExceptionMapper(),
new IllegalArgumentExceptionMapper(),
new InternalServerErrorExceptionMapper(),
new NotFoundExceptionMapper(),
new ObjectNotFoundExceptionMapper(),
new UncaughtExceptionMapper()
));
}

@NotNull
protected Set<Class<?>> getFilters() {
protected Set<Object> getFilterSingletons() {
return new HashSet<>(Arrays.asList(
AuthenticationFilter.class,
CorsFilter.class,
LogoutFilter.class
new AuthenticationFilter(),
new CorsFilter(),
new LogoutFilter()
));
}

@NotNull
protected Set<Class<?>> getControllerClasses() {
HashSet<Class<?>> controllerClasses = new HashSet<>(Arrays.asList(
ExtensionInfoApiController.class,
ExtensionInfoInternalController.class,
SwaggerController.class,
SwaggerDefinitionController.class
protected Set<Object> getControllerSingletons() {
HashSet<Object> controllerSingletons = new HashSet<>(Arrays.asList(
new ExtensionInfoApiController(),
new ExtensionInfoInternalController(),
new SwaggerController(),
new SwaggerDefinitionController()
));
if (!NamedSettingsRegistry.INSTANCE.getAll().isEmpty()) {
controllerClasses.add(NamedSettingsRegistry.INSTANCE.isScopeAgnostic() ? NamedSettingsApiScopeAgnosticController.class : NamedSettingsApiController.class);
controllerClasses.add(NamedSettingsInternalController.class);
controllerSingletons.add(NamedSettingsRegistry.INSTANCE.isScopeAgnostic() ? new NamedSettingsApiScopeAgnosticController() : new NamedSettingsApiController());
controllerSingletons.add(new NamedSettingsInternalController());
}
return controllerClasses;
return controllerSingletons;
}
}

0 comments on commit 2455d05

Please sign in to comment.