Class DiscriminatorLookup

java.lang.Object
dev.morphia.mapping.DiscriminatorLookup

public final class DiscriminatorLookup extends Object
Patched shadow of dev.morphia.mapping.DiscriminatorLookup from morphia-core.

This class replaces Morphia's DiscriminatorLookup on the classpath via the standard JVM classpath-order rule: because mongo-dao.jar is listed before morphia-core.jar in the application classpath, the JVM loads this version instead of Morphia's.

The only behavioral change from the Morphia 2.4.x original is in getClassForName(java.lang.String): the original uses Class.forName(name, true, this.classLoader) where this.classLoader is the thread context classloader captured at construction time (i.e. the platform/application classloader, which cannot see element-specific classes).

Our replacement tries the current thread context classloader first, then falls back to the captured classloader. This allows element-owned @Entity classes to be resolved when the TCCL has been set to the element's isolated classloader — either by ClassLoaderSwitchHandler during HTTP request dispatch, or by JakartaRsLoader during element startup (Jersey initialization).

All other behaviour — including the discriminatorClassMap cache, duplicate-discriminator detection, and searchPackages(java.lang.String) fallback — is identical to the Morphia original.

  • Constructor Details

    • DiscriminatorLookup

      public DiscriminatorLookup()
  • Method Details

    • addModel

      public void addModel(dev.morphia.mapping.codec.pojo.EntityModel entityModel)
    • lookup

      public Class<?> lookup(String discriminator)