Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Risingwavelabs Risingwave DynClasses

From Leeroopedia


Property Value
File java/connector-node/risingwave-sink-iceberg/src/main/java/org/apache/iceberg/common/DynClasses.java
Language Java
Lines 118
Category Utility
Package org.apache.iceberg.common
Origin Ported from Apache Iceberg project

Overview

DynClasses is a utility class providing a builder pattern for dynamically loading Java classes by name at runtime. Ported from the Apache Iceberg project, it supports trying multiple class names in sequence and returning the first one that can be successfully loaded via Class.forName(). This is used to resolve Iceberg catalog implementation classes without compile-time dependencies, enabling the RisingWave connector to work with different Iceberg catalog backends.

Code Reference

Source Location

java/connector-node/risingwave-sink-iceberg/src/main/java/org/apache/iceberg/common/DynClasses.java

Signature

public class DynClasses {
    private DynClasses() {}
    public static Builder builder();

    public static class Builder {
        public Builder loader(ClassLoader newLoader);
        public Builder impl(String className);
        public Builder orNull();
        public <S> Class<? extends S> buildChecked() throws ClassNotFoundException;
        public <S> Class<? extends S> build();
    }
}

Imports

import org.apache.iceberg.relocated.com.google.common.base.Joiner;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import java.util.Set;

I/O Contract

Builder Methods

Method Description
loader(ClassLoader) Sets the ClassLoader for class lookup (currently a no-op in this implementation; uses default Class.forName())
impl(String className) Attempts to load the specified class by name. If a class has already been found, this is a no-op. On ClassNotFoundException, silently continues.
orNull() Configures the builder to return null instead of throwing an exception if no class is found.
buildChecked() Returns the first successfully loaded class. Throws ClassNotFoundException with all tried class names if none was found and orNull() was not called.
build() Returns the first successfully loaded class. Throws RuntimeException with all tried class names if none was found and orNull() was not called.

State

The builder maintains:

  • foundClass: The first successfully loaded Class<?>, or null if none found.
  • nullOk: Whether to return null on failure (set by orNull()).
  • classNames: An ordered set of all attempted class names (used for error messages).

Usage Examples

// Try loading one of several possible class implementations
Class<?> catalogClass = DynClasses.builder()
    .impl("org.apache.iceberg.aws.glue.GlueCatalog")
    .impl("org.apache.iceberg.hive.HiveCatalog")
    .buildChecked();

// Allow null result if no implementation is found
Class<?> optionalClass = DynClasses.builder()
    .impl("com.example.OptionalFeature")
    .orNull()
    .build();
// optionalClass may be null

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment