Search in sources :

Example 6 with DbOomException

use of jodd.db.oom.DbOomException in project jodd by oblac.

the class AutomagicDbOomConfigurator method onEntry.

/**
	 * Scans all classes and registers only those annotated with {@link DbTable}.
	 * Because of performance purposes, classes are not dynamically loaded; instead, their
	 * file content is examined.
	 */
@Override
protected void onEntry(EntryData entryData) {
    String entryName = entryData.getName();
    InputStream inputStream = entryData.openInputStream();
    if (!isTypeSignatureInUse(inputStream, dbTableAnnotationBytes)) {
        return;
    }
    Class<?> beanClass;
    try {
        beanClass = loadClass(entryName);
    } catch (ClassNotFoundException cnfex) {
        throw new DbOomException("Entry class not found: " + entryName, cnfex);
    }
    if (beanClass == null) {
        return;
    }
    DbTable dbTable = beanClass.getAnnotation(DbTable.class);
    if (dbTable == null) {
        return;
    }
    if (registerAsEntities) {
        dbOomManager.registerEntity(beanClass);
    } else {
        dbOomManager.registerType(beanClass);
    }
}
Also used : DbOomException(jodd.db.oom.DbOomException) InputStream(java.io.InputStream) DbTable(jodd.db.oom.meta.DbTable)

Example 7 with DbOomException

use of jodd.db.oom.DbOomException in project jodd by oblac.

the class AutomagicDbOomConfigurator method configure.

/**
	 * Configures {@link DbOomManager} with specified class path.
	 * @see AutomagicDbOomConfigurator#configure(jodd.db.oom.DbOomManager)
	 */
public void configure(DbOomManager dbOomManager, File[] classpath) {
    this.dbOomManager = dbOomManager;
    rulesEntries.smartMode();
    elapsed = System.currentTimeMillis();
    try {
        scanPaths(classpath);
    } catch (Exception ex) {
        throw new DbOomException("Scan classpath error", ex);
    }
    elapsed = System.currentTimeMillis() - elapsed;
    if (log.isInfoEnabled()) {
        log.info("DbOomManager configured in " + elapsed + " ms. Total entities: " + dbOomManager.getTotalNames());
    }
}
Also used : DbOomException(jodd.db.oom.DbOomException) DbOomException(jodd.db.oom.DbOomException)

Aggregations

DbOomException (jodd.db.oom.DbOomException)7 DbEntityDescriptor (jodd.db.oom.DbEntityDescriptor)2 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DbQuery (jodd.db.DbQuery)1 DbOomManager (jodd.db.oom.DbOomManager)1 DbOomQuery (jodd.db.oom.DbOomQuery)1 DbSqlGenerator (jodd.db.oom.DbSqlGenerator)1 DbTable (jodd.db.oom.meta.DbTable)1 ParsedSql (jodd.db.oom.sqlgen.ParsedSql)1 SqlType (jodd.db.type.SqlType)1 MethodParameter (jodd.paramo.MethodParameter)1