sob., 25 lut 2023 o 12:47 Bogoljub Pavičić
<276ee31...@proton.me.invalid> napisał(a):
>
> Hi,
>
> is it possible to produce beans using a factory method with struts2 default 
> ioc container?
> I want to inject an ObjectMapper but I want to configure the bean before 
> inserting it in the container (similar to spring's @Bean method inside a 
> @Configuration class)
>
> @Bean
> public ObjectMapper objectMapper() {
>
> return new ObjectMapper(new JavaTimeModule());
>
> }

It's a bit more complicated in Struts, you must implement
"ContainerProvider" or "ConfigurationProvider" interface, than
register the provider:
https://struts.apache.org/core-developers/configuration-provider-and-configuration

then use register() to add your beans
https://github.com/apache/struts/blob/master/core/src/main/java/com/opensymphony/xwork2/config/ContainerProvider.java#L58

> the <bean> tag of struts.xml invokes only the empty constructor without 
> giving any arguments

Not really, you can use @Inject to inject required dependencies


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to