Interface BeanMetaInitializer
BeanMeta construction hooks.
The bean-modeling layer in commons.bean can construct a BeanMeta from a Class plus a
BeanConfigContext alone, but the full marshalling-side construction path also needs to:
- Read
@Marshalled/@BeanTypeannotations to detect bean registration, dictionary names, and the type-property name. - Build a
BeanRegistryfor polymorphic dispatch (bean-level and per-property). - Walk the parent class/interface hierarchy to find an inherited dictionary name.
These operations require the marshalling-side MarshallingContext, so they are exposed here as SPI
methods that take the marshalling context as an opaque Object. The marshalling-side implementation
in MarshalledBeanMetaInitializer narrows the argument internally; the bean-modeling layer never
imports the marshalling-side types.
The default NOOP implementation is wired on the commons-side path and returns conservative defaults
(no marshalling-side help available). @BeanType reads remain functional via the configured
BeanConfigContext.getAnnotationProvider().
Thread safety
Thread safety depends on implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BeanMetaInitializerSingleton commons-side default — no marshalling-side knowledge. -
Method Summary
Modifier and TypeMethodDescriptionbuildBeanFilter(BeanInfo<?> cm) Builds the marshalling-sideBeanFilterfor the supplied class, reading@Marshalledand@BeanTypeannotations.buildBeanRegistry(Object marshallingContext, BeanFilter beanFilter, ClassInfo classInfo, BeanConfigContext config) Builds the bean-levelBeanRegistryLookupfor the supplied class.buildPropertyBeanRegistry(Object marshallingContext, BeanRegistryLookup parent, List<ClassInfo> dictionaryClasses) Builds the per-propertyBeanRegistryLookupchained on top of the bean-level registry.findMarshalledTypeName(BeanConfigContext config, ClassInfo classInfo) Returns the marshalling-side@Marshalled(typeName)value for the bean, ornull if not set.findTypeNameInParents(Object marshallingContext, ClassInfo classInfo, Class<?> rawClass) Walks the parent classes/interfaces ofclassInfoand returns the first dictionary-name mapping forrawClassfound in any parent's registry, ornull if none.booleanhasBeanRegistrationAnnotation(BeanConfigContext config, ClassInfo classInfo) Returnstrue if the supplied class has a "registered as bean" annotation (e.g.resolveTypePropertyName(BeanConfigContext config, ClassInfo classInfo) Returns the marshalling-side@Marshalled(typePropertyName)value for the bean, ornull if not set.
-
Field Details
-
NOOP
Singleton commons-side default — no marshalling-side knowledge.Returns conservative defaults: no bean dictionary, no inherited type-names, no
@Marshalledreads.hasBeanRegistrationAnnotation(BeanConfigContext, ClassInfo)still reads@BeanTypevia the suppliedannotation provider.
-
-
Method Details
-
hasBeanRegistrationAnnotation
Returnstrue if the supplied class has a "registered as bean" annotation (e.g.@Marshalledor@BeanType). Used to relax constructor-visibility / serializable / class-visibility checks during bean detection.- Parameters:
config- The bean-modeling configuration.classInfo- The bean's class info.- Returns:
true if the class has a registration annotation.
-
resolveTypePropertyName
Returns the marshalling-side@Marshalled(typePropertyName)value for the bean, ornull if not set. Callers fall back toBeanConfigContext.getBeanTypePropertyName()when this returnsnull .- Parameters:
config- The bean-modeling configuration.classInfo- The bean's class info.- Returns:
- The resolved type property name, or
null .
-
findMarshalledTypeName
Returns the marshalling-side@Marshalled(typeName)value for the bean, ornull if not set.- Parameters:
config- The bean-modeling configuration.classInfo- The bean's class info.- Returns:
- The marshalled type name, or
null .
-
buildBeanRegistry
BeanRegistryLookup buildBeanRegistry(Object marshallingContext, BeanFilter beanFilter, ClassInfo classInfo, BeanConfigContext config) Builds the bean-levelBeanRegistryLookupfor the supplied class. Returnsnull on the commons-side path (no marshalling context).- Parameters:
marshallingContext- The marshalling-side context (as an opaqueObject). Can benull . The effect is implementation-dependent — seeorg.apache.juneau.marshall.MarshalledBeanMetaInitializer, the sole concrete implementer of this SPI.beanFilter- The bean filter applied to this bean meta. Can benull . The effect is implementation-dependent — seeorg.apache.juneau.marshall.MarshalledBeanMetaInitializer.classInfo- The class info of the bean. Must not benull .config- The bean-modeling configuration. Must not benull .- Returns:
- The bean-level registry, or
null .
-
buildPropertyBeanRegistry
BeanRegistryLookup buildPropertyBeanRegistry(Object marshallingContext, BeanRegistryLookup parent, List<ClassInfo> dictionaryClasses) Builds the per-propertyBeanRegistryLookupchained on top of the bean-level registry.- Parameters:
marshallingContext- The marshalling-side context. Must not benull on the marshalling path.parent- The bean-level registry (chained behind the per-property one). May benull .dictionaryClasses- The per-property dictionary class infos. Must not benull .- Returns:
- The per-property registry, or
null when there is no marshalling context.
-
findTypeNameInParents
Walks the parent classes/interfaces ofclassInfoand returns the first dictionary-name mapping forrawClassfound in any parent's registry, ornull if none.- Parameters:
marshallingContext- The marshalling-side context. Can benull . The effect is implementation-dependent — seeorg.apache.juneau.marshall.MarshalledBeanMetaInitializer.classInfo- The bean's class info.rawClass- The raw class to look up.- Returns:
- The dictionary name found in a parent's registry, or
null .
-
buildBeanFilter
Builds the marshalling-sideBeanFilterfor the supplied class, reading@Marshalledand@BeanTypeannotations. Returnsnull on the commons-side path (no marshalling-side filter construction is available).- Parameters:
cm- The bean type info.- Returns:
- The bean filter, or
null .
-