|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -317,15 +317,19 @@ public HandlerMethod createWithValidateFlags() {
|
317 | 317 | }
|
318 | 318 |
|
319 | 319 | /**
|
320 |
| - * If the provided instance contains a bean name rather than an object instance, |
321 |
| - * the bean name is resolved before a {@link HandlerMethod} is created and returned. |
| 320 | + * If the {@link #getBean() handler} is a bean name rather than the actual |
| 321 | + * handler instance, resolve the bean name through Spring configuration |
| 322 | + * (e.g. for prototype beans), and return a new {@link HandlerMethod} |
| 323 | + * instance with the resolved handler. |
| 324 | + * <p>If the {@link #getBean() handler} is not String, return the same instance. |
322 | 325 | */
|
323 | 326 | public HandlerMethod createWithResolvedBean() {
|
324 |
| - Object handler = this.bean; |
325 |
| - if (this.bean instanceof String beanName) { |
326 |
| - Assert.state(this.beanFactory != null, "Cannot resolve bean name without BeanFactory"); |
327 |
| - handler = this.beanFactory.getBean(beanName); |
| 327 | + if (!(this.bean instanceof String beanName)) { |
| 328 | + return this; |
328 | 329 | }
|
| 330 | + |
| 331 | + Assert.state(this.beanFactory != null, "Cannot resolve bean name without BeanFactory"); |
| 332 | + Object handler = this.beanFactory.getBean(beanName); |
329 | 333 | Assert.notNull(handler, "No handler instance");
|
330 | 334 | return new HandlerMethod(this, handler, false);
|
331 | 335 | }
|
|
0 commit comments