- name: repository/custom-rules
  description: This ruleset looks for the class-loading element in a jboss-web.xml file, which is no longer valid in JBoss EAP 6
  violations:
    corporate-config-01000:
      description: Legacy configuration with io.konveyor.demo.config.ApplicationConfiguration
      category: mandatory
      labels:
      - configuration
      - konveyor.io/source=traditional-corporate-framework
      - konveyor.io/target=cloud-corporate-framework
      incidents:
      - uri: file:///shared/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java
        message: "The legacy ApplicationConfiguration class is being used in this application. This is discouraged by the migration\n guidelines, and should be replaced by a more standard approach using Spring's @PropertySource annotation and Environment class:\n\n\n ```java\n @PropertySource(\"classpath:persistence.properties\")\n public class PersistenceConfig \n }}\n ```\n\n\n\n This allows externalizing the configuration in Kubernetes by injecting it as a ConfigMap or a Secret in the lib directory from the\n container running the Tomcat instance."
        codeSnip: "33          em.setDataSource(dataSource());\n34          em.setPackagesToScan(\"io.konveyor.demo.ordermanagement.model\");\n35          em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());\n36          em.setJpaProperties(additionalProperties());\n37  \n38          return em;\n39      }\n40      \n41      @Bean\n42      public DataSource dataSource() {\n43      \tApplicationConfiguration config = new ApplicationConfiguration();\n44          final DriverManagerDataSource dataSource = new DriverManagerDataSource();\n45          dataSource.setDriverClassName(config.getProperty(\"jdbc.driverClassName\"));\n46          dataSource.setUrl(config.getProperty(\"jdbc.url\"));\n47          dataSource.setUsername(config.getProperty(\"jdbc.user\"));\n48          dataSource.setPassword(config.getProperty(\"jdbc.password\"));\n49  \n50          return dataSource;\n51      }\n52  \n53      @Bean"
        lineNumber: 43
        variables:
          file: file:///shared/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java
          kind: Variable
          name: config
          package: io.konveyor.demo.ordermanagement.config
      - uri: file:///shared/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java
        message: "The legacy ApplicationConfiguration class is being used in this application. This is discouraged by the migration\n guidelines, and should be replaced by a more standard approach using Spring's @PropertySource annotation and Environment class:\n\n\n ```java\n @PropertySource(\"classpath:persistence.properties\")\n public class PersistenceConfig \n }}\n ```\n\n\n\n This allows externalizing the configuration in Kubernetes by injecting it as a ConfigMap or a Secret in the lib directory from the\n container running the Tomcat instance."
        codeSnip: "56          transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());\n57          return transactionManager;\n58      }\n59  \n60      @Bean\n61      public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {\n62          return new PersistenceExceptionTranslationPostProcessor();\n63      }\n64  \n65      final Properties additionalProperties() {\n66      \tApplicationConfiguration config = new ApplicationConfiguration();\n67          final Properties hibernateProperties = new Properties();\n68          hibernateProperties.setProperty(\"hibernate.hbm2ddl.auto\", config.getProperty(\"hibernate.hbm2ddl.auto\"));\n69          hibernateProperties.setProperty(\"hibernate.dialect\", config.getProperty(\"hibernate.dialect\"));\n70          hibernateProperties.setProperty(\"hibernate.cache.use_second_level_cache\", \"false\");\n71  \n72          return hibernateProperties;\n73      }\n74  }\n"
        lineNumber: 66
        variables:
          file: file:///shared/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java
          kind: Variable
          name: config
          package: io.konveyor.demo.ordermanagement.config
      links:
      - url: https://www.baeldung.com/properties-with-spring
        title: Baeldung - Properties with Spring and Spring Boot
      - url: https://mkyong.com/spring/spring-propertysources-example/
        title: Mkyong - Spring @PropertySource example
      - url: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html
        title: Spring Documentation - PropertySource javadoc
      effort: 1
  unmatched:
  - JBoss5-web-class-loading_001
  - JBoss5-web-class-loading_002
  - Test1-002-00001
  - java-internals-custom-getFont
  - java-internals-custom-getPeer
  - javax-package-00001
  - javax-package-custom-target-00001
