registerAnnotatedTypes

Finds the annotated classes in packages and registers each with this client.

Three annotations are looked for, all of them from the multiplatform pg-model module so that they can sit on classes shared with another platform: PgEnumType, PgCompositeType and DynamicallyMappable.

val db = OctaviusClient.fromDataSource(dataSource)
db.dynamicTypes.install()
val found = db.registerAnnotatedTypes("com.roma.domain", "com.roma.dto")
logger.info { "Octavius registered $found" }

This does the same thing as calling typeManager.registerEnum, registerAutoComposite and dynamicTypes.register by hand, and nothing the hand-written calls cannot do - the annotations carry everything those take, case conventions included. What it saves is naming thirty classes at startup and remembering to add the thirty-first.

A name the database has no type for is registered like any other and reported in ScanReport.unresolved: registering ahead of a type that does not exist yet is a working flow, so it is not refused, only said out loud.

Registration is global to the database this client is connected to, so this belongs at startup and once.

Return

What was found and registered.

Parameters

packages

The packages to scan, and their subpackages. At least one; scanning everything on the classpath is slow enough to be worth refusing.

Throws

INVALID_ARGUMENT where no package was named, or where an annotation sits on a class it cannot describe.


Finds the annotated classes in packages and registers each with this client.

Return

What was found and registered.

Parameters

packages

The packages to scan, and their subpackages. At least one.

classLoader

Where to look, for an application whose classes are not on the loader that loaded this one - an OSGi container, a plugin host. null uses the default.

Throws

INVALID_ARGUMENT where no package was named, or where an annotation sits on a class it cannot describe.