Skip to content

Commit

Permalink
MYFACES-4688: 5.0 Quarkus reflection/serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 24, 2024
1 parent d633d9a commit 91d79be
Showing 1 changed file with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,8 @@ void buildRecommendedInitParams(BuildProducer<ServletInitParamBuildItem> initPar
{
// user config
Config config = ConfigProvider.getConfig();

Optional<String> projectStage = resolveProjectStage(config);
initParam.produce(new ServletInitParamBuildItem(ProjectStage.PROJECT_STAGE_PARAM_NAME, projectStage.get()));
String projectStage = resolveProjectStage(config);
initParam.produce(new ServletInitParamBuildItem(ProjectStage.PROJECT_STAGE_PARAM_NAME, projectStage));
}

@BuildStep
Expand All @@ -361,7 +360,7 @@ void buildAnnotationProviderIntegration(MyFacesRecorder recorder, CombinedIndexB
}
}

private Optional<String> resolveProjectStage(Config config)
private String resolveProjectStage(Config config)
{
Optional<String> projectStage = config.getOptionalValue(ProjectStage.PROJECT_STAGE_PARAM_NAME,
String.class);
Expand All @@ -377,7 +376,7 @@ else if (ConfigUtils.getProfiles().contains(LaunchMode.TEST.getDefaultProfile())
projectStage = Optional.of(ProjectStage.SystemTest.name());
}
}
return projectStage;
return projectStage.orElse(ProjectStage.Production.name());
}

@BuildStep
Expand Down Expand Up @@ -495,12 +494,6 @@ void registerForLimitedReflection(MyFacesRecorder recorder,
classNames.addAll(collectSubclasses(combinedIndex, factory));
}

classNames.addAll(Arrays.asList(
"jakarta.faces.component._DeltaStateHelper",
"jakarta.faces.component._DeltaStateHelper$InternalMap",
"jakarta.validation.groups.Default",
"jakarta.validation.Validation"));

List<Class<?>> classes = new ArrayList<>(Arrays.asList(ApplicationImplEventManager.class,
DefaultWebConfigProviderFactory.class,
ErrorPageWriter.class,
Expand Down Expand Up @@ -534,11 +527,12 @@ void registerForMethodReflection(MyFacesRecorder recorder, BuildProducer<Reflect
classNames.addAll(collectImplementors(combinedIndex, java.time.temporal.TemporalAccessor.class.getName()));
classNames.addAll(collectImplementors(combinedIndex, java.util.Map.Entry.class.getName()));
classNames.addAll(collectSubclasses(combinedIndex, java.lang.Number.class.getName()));
classNames.add(java.util.Date.class.getName());
classNames.add(java.util.Calendar.class.getName());
classNames.add(java.lang.Iterable.class.getName());
classNames.add(java.lang.Throwable.class.getName());
classNames.add(java.lang.String.class.getName());
classNames.add(java.lang.StringBuffer.class.getName());
classNames.add(java.lang.Throwable.class.getName());
classNames.add(java.util.Calendar.class.getName());
classNames.add(java.util.Date.class.getName());

classNames.addAll(collectSubclasses(combinedIndex, TagHandler.class.getName()));
classNames.addAll(collectSubclasses(combinedIndex, ConverterHandler.class.getName()));
Expand Down Expand Up @@ -582,9 +576,18 @@ void registerForMethodReflection(MyFacesRecorder recorder, BuildProducer<Reflect
void registerForFieldReflection(MyFacesRecorder recorder,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass)
{
List<String> classNames = new ArrayList<>();
classNames.add("jakarta.faces.component._AttachedStateWrapper");
classNames.add("jakarta.faces.component._DeltaStateHelper");
classNames.add("jakarta.faces.component._DeltaStateHelper$InternalMap");
classNames.add("jakarta.faces.context._MyFacesExternalContextHelper");
classNames.add("jakarta.validation.Validation");
classNames.add("jakarta.validation.groups.Default");

classNames.add(org.apache.myfaces.view.facelets.tag.faces.FaceletState.class.getName());
reflectiveClass.produce(
ReflectiveClassBuildItem.builder("jakarta.faces.context._MyFacesExternalContextHelper")
.methods(true).fields(true).build());
ReflectiveClassBuildItem.builder(
classNames.toArray(new String[0])).methods().fields().serialization().build());
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
Expand Down Expand Up @@ -787,7 +790,7 @@ else if (ai.target().asMethod().returnType().kind() == Type.Kind.PARAMETERIZED_T
types.removeIf(Objects::isNull);

// collect all public types from getters and fields
List<ClassInfo> temp = new ArrayList();
List<ClassInfo> temp = new ArrayList<>();
types.forEach(ci -> collectPublicTypes(ci, temp, combinedIndex));
types.addAll(temp);

Expand Down

0 comments on commit 91d79be

Please sign in to comment.