/** * Return the service loader using the classLoader defined in ClassLoadConfig. */ public <T> ServiceLoader<T> serviceLoad(Class<T> spiService) { return ServiceLoader.load(spiService, classLoadConfig.getClassLoader()); }
/** * Return the list of ClassPathScanner services using serverConfig service loader. */ public static List<ClassPathScanner> find(ServerConfig serverConfig) { List<ClassPathScanner> scanners = new ArrayList<>(); ServiceLoader<ClassPathScannerFactory> scannerLoader = serverConfig.serviceLoad(ClassPathScannerFactory.class); for (ClassPathScannerFactory factory : scannerLoader) { ClassPathScanner scanner = factory.createScanner(serverConfig.getClassLoadConfig().getClassLoader()); scanners.add(scanner); } return scanners; } }
private void readXmlMapping() { try { ClassLoader classLoader = serverConfig.getClassLoadConfig().getClassLoader(); Enumeration<URL> resources = classLoader.getResources("ebean.xml"); List<XmEbean> mappings = new ArrayList<>(); while (resources.hasMoreElements()) { URL url = resources.nextElement(); InputStream is = url.openStream(); mappings.add(XmlMappingReader.read(is)); is.close(); } for (XmEbean mapping : mappings) { List<XmEntity> entityDeploy = mapping.getEntity(); for (XmEntity deploy : entityDeploy) { readEntityMapping(classLoader, deploy); } } } catch (IOException e) { throw new RuntimeException("Error reading ebean.xml", e); } }
/** * Run the DB migration against the DataSource. */ public DataSource runDbMigration(DataSource dataSource) { if (migrationConfig.isRunMigration()) { MigrationRunner runner = migrationConfig.createRunner(getClassLoadConfig().getClassLoader()); runner.run(dataSource); } return dataSource; }
private BootupClassPathSearch(ServerConfig serverConfig) { // find packages defined in META-INF/ebean.mf resources Set<String> mfPackages = ManifestReader.readManifests(serverConfig.getClassLoadConfig().getClassLoader(), EBEAN_MF); this.packages = DistillPackages.distill(serverConfig.getPackages(), mfPackages); this.scanners = ClassPathScanners.find(serverConfig); }