0

How to write this part of annotation based configuration in XML?

@Bean
public EventRepository eventRepository() throws Exception {
    return new SolrRepositoryFactory(eventTemplate())
        .getRepository(EventRepository.class, new EventRepositoryImpl(eventTemplate()));
}

Full code of this config:

@Configuration
public class SolrContext {

    @Bean
    public SolrServerFactory solrServerFactory() {
        return new MulticoreSolrServerFactory(new HttpSolrServer("solr.host"));
    }

    @Bean
    public SolrTemplate eventTemplate() throws Exception {
        SolrTemplate solrTemplate = new SolrTemplate(solrServerFactory());
        solrTemplate.setSolrCore("events");
        return solrTemplate;
    }

    @Bean
    public EventRepository eventRepository() throws Exception {
        return new SolrRepositoryFactory(eventTemplate())
            .getRepository(EventRepository.class, new EventRepositoryImpl(eventTemplate()));
    }
} 

I got this example from that answer.

Community
  • 1
  • 1
Ilya Zharkov
  • 319
  • 1
  • 4
  • 11
  • And why don't you use the xml configuration from the same question you just posted? – Andrei Stefan Aug 19 '14 at 08:41
  • @AndreiStefan, I have project configured only with XML and I want to store this config in one place. It's a matter of preference. – Ilya Zharkov Aug 19 '14 at 08:50
  • Right, in the SO question you referenced, the person who asked the question has already provided some xml configuration. Have you tried that xml configuration? – Andrei Stefan Aug 19 '14 at 08:53
  • And why do you want to change your configuration to XML? – geoand Aug 19 '14 at 10:01
  • @AndreiStefan, if you have read that question you might see that this code isn't working. – Ilya Zharkov Aug 19 '14 at 10:32
  • @geoand, please stop talking about using annotations or XML. My question was not about that. – Ilya Zharkov Aug 19 '14 at 10:34
  • 1
    @IlyaZharkov How was your question not about that? Are you kidding me? I am simply asking what your reason is for wanting to convert from Java Configuration to XML configuration. What wont the Java configuration do for you? – geoand Aug 19 '14 at 10:38
  • @geoand I had already wrote about matter of preference. I like XML based config. Project had already configured with XML. And I just want to know can I convert this config to XML or not. – Ilya Zharkov Aug 19 '14 at 10:48
  • I haven't tried it, but it looks fairly standard stuff. You should be able to use `bean`, `contructor-arg` and `property` to convert it – geoand Aug 19 '14 at 10:51
  • @IlyaZharkov if you would have read that question that poster wanted something different: accessing two/multiple repos and he already had a configuration for just one. I'm curious if you tried anything in your attempt to have that configuration translated to xml. Try something first and if you encounter problems, show us what you tried and why is not working. – Andrei Stefan Aug 19 '14 at 10:53

0 Answers0