-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Allow customization of the banner printer used by SpringBootApplication #42284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@vjh0107 Can you provide some more details about what you're trying to achieve. I'm having a bit of a hard time following the example code you've posted (probably because my Kotlin knowledge isn't that good). What is the aim of the |
@philwebb |
I'm afraid I'm still not totally following. Perhaps a sample application might help (ideally in Java). Are you saying you want to be able to plug in a different |
That’s right, I’ve already been using it that way, but when someone else uses the banner I already made (or it can be SpringBootBanner), there’s a problem where they can’t set the PrintStream. |
I wonder if you could use a decorator pattern to do this? I'm not too keen to introduce a new API just for this use-case. I'm thinking something like: public class BannerWrapper implements Banner {
// Fields
public BannerWrapper(Banner delegate, PrintStream out) {
this.delegate = delegate;
this.out = out;
}
public void printBanner(Environment environment, Class<?> sourceClass, PrintStream out) {
this.delegate.printBanner(environment, sourceClass, this.out);
}
} If that doesn't work, I'd really like to see a sample application so we totally understand the requirements. |
Sadly, the wrapper method doesn’t change only the printing method of the SpringBootBanner. https://github.com/vjh0107/spring-boot-pr-42284 ![]() I designed it so that there are no changes to the public API! |
Unfortunately there is new public API which increases the surface area of code we'd need to support. Looking at the sample, I'm afraid I don't see a use-case that will be popular enough for us to warrant the changes. If the decorator approach does not work, the other option you might consider is using the Thanks anyway for the suggestion. |
Hello! I’ve made changes to allow the customization of the banner printer.
The
Banner
class was originally intended for printing a banner programmatically, but I needed a way to customize it more flexibly.Here is the code before my contribution:
So, I changed the printer to be changeable. Now I can create a banner more programmatically!
I tried to follow the existing code style, but if any parts need to be revised, I would appreciate it if you could make corrections.
Thank you!