Skip to content

Commit

Permalink
Fix #264: Models marked for serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 24, 2024
1 parent 5f99b7e commit 6d5278c
Showing 1 changed file with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,12 @@ void registerForReflection(PrimeFacesRecorder recorder, BuildProducer<Reflective
org.primefaces.util.SecurityUtils.class.getName(),
PropertyDescriptorResolver.DefaultResolver.class.getName()));

// All models
List<String> models = collectClassesInPackage(combinedIndex, "org.primefaces.model");
models.remove(CommonsUploadedFile.class.getName());
classNames.addAll(models);

// components that need special treatment
classNames.add(org.primefaces.component.fileupload.NativeFileUploadDecoder.class.getName());
classNames.add(org.primefaces.application.exceptionhandler.ExceptionInfo.class.getName());
classNames.add(org.primefaces.component.organigram.OrganigramHelper.class.getName());
classNames.addAll(collectImplementors(combinedIndex, PropertyDescriptorResolver.class.getName()));

// Chart XDev models
classNames.addAll(collectClassesInPackage(combinedIndex, "software.xdev.chartjs.model"));

// Exporters
classNames.addAll(collectImplementors(combinedIndex, org.primefaces.component.export.Exporter.class.getName()));
classNames.addAll(collectImplementors(combinedIndex, org.primefaces.component.export.ExporterOptions.class.getName()));
Expand All @@ -158,6 +150,23 @@ void registerForReflection(PrimeFacesRecorder recorder, BuildProducer<Reflective
ReflectiveClassBuildItem.builder(org.primefaces.config.PrimeEnvironment.class.getName()).build());
}

@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void registerForSerialization(PrimeFacesRecorder recorder, BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndex) {
// All models
final List<String> models = collectClassesInPackage(combinedIndex, "org.primefaces.model");
models.remove(CommonsUploadedFile.class.getName());
final List<String> classNames = new ArrayList<>(models);

// Chart XDev models
classNames.addAll(collectClassesInPackage(combinedIndex, "software.xdev.chartjs.model"));

// serialization reflection
reflectiveClass.produce(
ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods().fields().serialization().build());
}

// TODO: Remove after MyFaces 4.0.3
@BuildStep
void temporaryMyFacesStuff(BuildProducer<AdditionalBeanBuildItem> additionalBean,
Expand All @@ -175,9 +184,20 @@ void temporaryMyFacesStuff(BuildProducer<AdditionalBeanBuildItem> additionalBean

// TODO: remove in MyFaces 4.0.3
reflectiveClass.produce(ReflectiveClassBuildItem
.builder("org.apache.myfaces.view.facelets.component.RepeatStatus", "org.apache.myfaces.push.EndpointImpl")
.methods(true).fields(true).build());

.builder("org.apache.myfaces.view.facelets.component.RepeatStatus",
"org.apache.myfaces.push.EndpointImpl",
"jakarta.faces.component._AttachedStateWrapper",
"jakarta.faces.component._DeltaStateHelper",
"jakarta.faces.component._DeltaStateHelper$InternalMap",
"jakarta.faces.context._MyFacesExternalContextHelper",
"jakarta.faces.component._AttachedDeltaWrapper",
"java.util.Collections$EmptySet",
java.lang.StringBuilder.class.getName(),
jakarta.el.Expression.class.getName(),
jakarta.el.ValueExpression.class.getName(),
jakarta.faces.view.Location.class.getName(),
org.apache.myfaces.view.facelets.tag.faces.FaceletState.class.getName())
.methods().fields().serialization().build());
}

@BuildStep
Expand Down

0 comments on commit 6d5278c

Please sign in to comment.