Interface BeanMetaInitializer


public interface BeanMetaInitializer
Bean-modeling SPI seam that exposes marshalling-aware 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 / @BeanType annotations to detect bean registration, dictionary names, and the type-property name.
  • Build a BeanRegistry for 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.
See Also:
  • Field Details

  • Method Details

    • hasBeanRegistrationAnnotation

      Returns true if the supplied class has a "registered as bean" annotation (e.g. @Marshalled or @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, or null if not set. Callers fall back to BeanConfigContext.getBeanTypePropertyName() when this returns null.
      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, or null 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-level BeanRegistryLookup for the supplied class. Returns null on the commons-side path (no marshalling context).
      Parameters:
      marshallingContext - The marshalling-side context (as an opaque Object). Can be null. The effect is implementation-dependent — see org.apache.juneau.marshall.MarshalledBeanMetaInitializer, the sole concrete implementer of this SPI.
      beanFilter - The bean filter applied to this bean meta. Can be null. The effect is implementation-dependent — see org.apache.juneau.marshall.MarshalledBeanMetaInitializer.
      classInfo - The class info of the bean. Must not be null.
      config - The bean-modeling configuration. Must not be null.
      Returns:
      The bean-level registry, or null.
    • buildPropertyBeanRegistry

      BeanRegistryLookup buildPropertyBeanRegistry(Object marshallingContext, BeanRegistryLookup parent, List<ClassInfo> dictionaryClasses)
      Builds the per-property BeanRegistryLookup chained on top of the bean-level registry.
      Parameters:
      marshallingContext - The marshalling-side context. Must not be null on the marshalling path.
      parent - The bean-level registry (chained behind the per-property one). May be null.
      dictionaryClasses - The per-property dictionary class infos. Must not be null.
      Returns:
      The per-property registry, or null when there is no marshalling context.
    • findTypeNameInParents

      String findTypeNameInParents(Object marshallingContext, ClassInfo classInfo, Class<?> rawClass)
      Walks the parent classes/interfaces of classInfo and returns the first dictionary-name mapping for rawClass found in any parent's registry, or null if none.
      Parameters:
      marshallingContext - The marshalling-side context. Can be null. The effect is implementation-dependent — see org.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-side BeanFilter for the supplied class, reading @Marshalled and @BeanType annotations. Returns null on the commons-side path (no marshalling-side filter construction is available).
      Parameters:
      cm - The bean type info.
      Returns:
      The bean filter, or null.