@Test public void testSetPackages() throws Exception { MangoDaoScanner mc = new MangoDaoScanner(); List<String> packages = Lists.newArrayList("org.jfaster.mango", "", "org.jfaster"); mc.setPackages(packages); assertThat(mc.locationPatterns.get(0), is("classpath*:org/jfaster/mango*Dao.class")); assertThat(mc.locationPatterns.get(1), is("classpath*:org/jfaster/mango*DAO.class")); assertThat(mc.locationPatterns.get(2), is("classpath*:*Dao.class")); assertThat(mc.locationPatterns.get(3), is("classpath*:*DAO.class")); assertThat(mc.locationPatterns.get(4), is("classpath*:org/jfaster*Dao.class")); assertThat(mc.locationPatterns.get(5), is("classpath*:org/jfaster*DAO.class")); }
public void setPackages(List<String> packages) { for (String p : packages) { for (String daoEnd : DAO_ENDS) { String locationPattern = "classpath*:" + p.replaceAll("\\.", "/") + "*" + daoEnd + ".class"; logger.info("trnas package[" + p + "] to locationPattern[" + locationPattern + "]"); locationPatterns.add(locationPattern); } } }
MangoDaoScanner implements BeanFactoryPostProcessor { public void setPackages(List<String> packages) { for (String p : packages) { for (String daoEnd : DAO_ENDS) { String locationPattern = "classpath*:" + p.replaceAll("\\.", "/") + "*" + daoEnd + ".class"; logger.info("trnas package[" + p + "] to locationPattern[" + locationPattern + "]"); locationPatterns.add(locationPattern); } } } }
MangoDaoScanner implements BeanFactoryPostProcessor { public void setPackages(List<String> packages) { for (String p : packages) { for (String daoEnd : DAO_ENDS) { String locationPattern = "classpath*:" + p.replaceAll("\\.", "/") + "*" + daoEnd + ".class"; logger.info("trnas package[" + p + "] to locationPattern[" + locationPattern + "]"); locationPatterns.add(locationPattern); } } }  }
MangoDaoScanner implements BeanFactoryPostProcessor { public void setPackages(List<String> packages) { for (String p : packages) { for (String daoEnd : DAO_ENDS) { String locationPattern = "classpath*:" + p.replaceAll("\\.", "/") + "*" + daoEnd + ".class"; logger.info("trnas package[" + p + "] to locationPattern[" + locationPattern + "]"); locationPatterns.add(locationPattern); } } }  @Override void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory); void setPackages(List<String> packages); void setFactoryBeanClass(Class<?> factoryBeanClass); }
MangoDaoScanner implements BeanFactoryPostProcessor { public void setPackages(List<String> packages) { for (String p : packages) { for (String daoEnd : DAO_ENDS) { String locationPattern = "classpath*:" + p.replaceAll("\\.", "/") + "*" + daoEnd + ".class"; logger.info("trnas package[" + p + "] to locationPattern[" + locationPattern + "]"); locationPatterns.add(locationPattern); } } }  @Override void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory); void setPackages(List<String> packages); void setFactoryBeanClass(Class<?> factoryBeanClass);  }