Converting Java-based configuration to Spring XML-based

I am trying to convert a Birt application executed in java annotation to XML, but "I am having difficulty changing this part to xml

@Bean   
public BirtViewResolver birtViewResolver() throws Exception {
    BirtViewResolver bvr = new BirtViewResolver();
    bvr.setBirtEngine(this.engine().getObject());
    bvr.setViewClass(HtmlSingleFormatBirtView.class);
    bvr.setDataSource(this.birtDataServiceConfiguration.dataSource());
    bvr.setReportsDirectory("Reports");
    bvr.setOrder(2);
    return bvr;
}

I tried this but couldn't figure out how to set birtEngine, viewClass and the dataSource part

<beans:bean id="birtViewResolver" class="org.eclipse.birt.spring.core.BirtViewResolver">
        <beans:property name="birtEngine" value="?" />
        <beans:property name="viewClass" value="?" />
        <beans:property name="dataSource" value="?" />
        <beans:property name="reportsDirectory" value="Reports" />
        <beans:property name="order" value="2" />
    </beans:bean>

Thank you in advance

+4
source share
1 answer

Considering this

bvr.setBirtEngine(this.engine().getObject());

I am going to assume that engine()- this is another method @Beanthat returns an object FactoryBean. In XML, you would get it as

<bean name="engine" class="com.example.EngineFactoryBean" />

For

bvr.setViewClass(HtmlSingleFormatBirtView.class);

Spring XML Class .

bvr.setDataSource(this.birtDataServiceConfiguration.dataSource());

, birtDataServiceConfiguration @Configuration, @Autowired dataSource() @Bean, .

XML

<!-- Assuming you converted that config to XML as well -->
<import resource="classpath:birtDataServiceConfiguration.xml" /> 
<beans:bean id="birtViewResolver" class="org.eclipse.birt.spring.core.BirtViewResolver">
    <beans:property name="birtEngine" ref="engine" />
    <!-- You would have to give the class' fully qualified name -->
    <beans:property name="viewClass" value="com.example.fully.qualified.HtmlSingleFormatBirtView" />
    <!-- Assuming that imported config had a bean declared with the name 'dataSource' -->
    <beans:property name="dataSource" ref="dataSource" />
    <beans:property name="reportsDirectory" value="Reports" />
    <beans:property name="order" value="2" />
</beans:bean>
+4

All Articles