Search code examples
xmlspring-bootmigrationjackrabbit

Change configuration of xml to spring boot


I am migrating a project which used xml for mapping to spring boot (.java file)

How should I go about it? Below is the jackrabbit xml configuration...

<bean id="repository" class="org.springframework.jndi.JndiObjectFactoryBean">
   <property name="jndiName" value="java:comp/env/jcr/myRepository"/>
</bean>

<bean id="jcrSessionFactory" class="org.springmodules.jcr.JcrSessionFactory">
    <property name="repository" ref="repository" />
    <property name="credentials">
      <bean class="javax.jcr.SimpleCredentials">
        <constructor-arg index="0" value="admin" />
        <!-- create the credentials using a bean factory -->
        <constructor-arg index="1">
          <bean factory-bean="password" factory-method="toCharArray" />
        </constructor-arg>
      </bean>
    </property>
</bean>

  <!-- create the password to return it as a char[] -->
  <bean id="password" class="java.lang.String">
    <constructor-arg index="0" value="admin" />
  </bean>

  <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
    <property name="sessionFactory" ref="jcrSessionFactory" />
    <property name="allowCreate" value="true" />
  </bean>

<Resource name="jcr/myRepository"
  auth="Container"
  type="javax.jcr.Repository"
  factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
  configFilePath="D:/DMSRepo/repositoryFactlive.xml"
  repHomeDir="D:/DMSRepo/factlivetrialVersion2/repo"/> 

Solution

  • First you should create a configuration class file using @Configuration and import your .xml file using @ImportResource like this:-

    @Configuration
    @ImportResource("classpath:dmsRepository.xml")
    public class JackRabbitRepository {
    
    }
    

    Then you have to keep your resource content in server.xml file coz it won't work in your current xml. After this your configuration of JackRabbit is done. Then do what you want to do in DMS.