I have an enum ContentType and it has a method like ContentType.getName() which can evaluate to regText OR session. So, how do I do the below where I can instantiate the bean based on the return value of this method. Also, I only want to do this in XML config and not annotations.
<property name="contentCaptureRegEx" ref="${ContentType.getName()}">
</property>
<bean id="regText" class="java.util.regex.Pattern" factory-method="compile" lazy-init="true">
<constructor-arg value="xyz" /></bean>
<bean id="session" class="java.util.regex.Pattern" factory-method="compile" lazy-init="true">
<constructor-arg value="abc" /></bean>
I would suggest a static factory method since the pattern regexes are already using that pattern. Just eliminate them and add:
which you can wire as:
And then you can ref that bean anywhere as: