/** * Checks is the db type aleady registered. the name compares ignore case. */ public static boolean exists(String name){ return tryGet(name) != null; }
/** * Returns all the registered {@link DbPlatform} objects. */ public static Iterable<DbPlatform> all(){ return currentPlatforms().values(); }
for(DbPlatform platform : DbPlatforms.all()){ if((db = platform.tryCreateDbInstance(name,ds,connection,dm)) != null){ break;
/** * Returns the {@link DbPlatform} matched the given db type name. * * <p> * The type name is case sensitive. * * @throws ObjectNotFoundException if the given type name not exists. */ public static DbPlatform get(String name) throws ObjectNotFoundException { DbPlatform p = tryGet(name); if(null == p){ throw new ObjectNotFoundException("No db platform '" + name + "' exists"); } return p; }
/** * Returns the {@link DbPlatform} matched the given db type name. * * <p> * Returns <code>null</code> if the given db type name not found. * * <p> * The type name is case sensitive. */ public static DbPlatform tryGet(String name) throws ObjectNotFoundException { if(null == name){ return null; } return currentPlatforms().get(name.toLowerCase()); }
protected String resolveDbType(Resource r) { String filename = r.getFilename(); if(null != filename){ String filenameWithoutExt = Paths.getFileNameWithoutExtension(filename); int lastIndexOfUnderscore = filenameWithoutExt.lastIndexOf('_'); if(lastIndexOfUnderscore > 0){ String dbType = filenameWithoutExt.substring(lastIndexOfUnderscore + 1); if(DbPlatforms.tryGet(dbType) != null){ return dbType; } } } return null; } }
private static Map<String,DbPlatform> currentPlatforms(){ return currentPlatforms(AppContext.current()); }