Skip to content

Conversation

@wendigo
Copy link
Contributor

@wendigo wendigo commented Dec 9, 2025

This is useful for scenarios when class was renamed and we want to use a fixed string for backward compatibility.

@wendigo
Copy link
Contributor Author

wendigo commented Dec 9, 2025

cc @martint

@wendigo wendigo force-pushed the serafin/object-name-generator branch from 9664e44 to 2743958 Compare December 9, 2025 14:39
Comment on lines 29 to 54
default String generatedNameOf(String packageName, String className)
{
return generatedNameOf(packageName, ImmutableMap.of("name", className));
}

default String generatedNameOf(String packageName, String className, String name)
{
return generatedNameOf(packageName, ImmutableMap.of("type", className, "name", name));
}

default String generatedNameOf(Class<?> type, Map<String, String> properties)
{
return generatedNameOf(type.getPackage().getName(), properties);
}

String generatedNameOf(String domain, Map<String, String> properties);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no callers for these methods. How do you intend for these to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To generate a name for the class that was renamed and we want to keep backward compatibility providing previous name by hand

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface is meant to be used by the mbean exporter, not for users to call directly.

Copy link
Contributor Author

@wendigo wendigo Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come?

newExporter(binder).export(DispatchManager.class).as(generator -> generator.generatedNameOf(QueryManager.class));

generator is of type ObjectNameGenerator

Copy link
Contributor Author

@wendigo wendigo Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to be able to do:

newExporter(binder).export(DispatchManager.class).as(generator -> generator.generatedNameOf("io.trino.execution", "QueryManager"));

to avoid a need to keep a class around just to get a package name and simple name from it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martint PTAL

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. However, that's a pattern of usage I've been wanting to change. There's really no need to pass an object around when the caller can generate the names directly. Let me take a closer look at this PR to see if there's a better way to make it fit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let me know. Right now in Trino we are renaming beans to ensure backward compatibility of metrics

This is useful for scenarios when class was renamed and we want to use a fixed string
for backward compatibility.

Added tests for ObjectNameGenerator usage
@wendigo wendigo force-pushed the serafin/object-name-generator branch from 5ee510c to f8034a7 Compare December 9, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants