Search in sources :

Example 1 with UncheckedException

use of jodd.exception.UncheckedException in project jodd by oblac.

the class JtxManagerTest method testReadOnly.

// ---------------------------------------------------------------- ro
@Test
public void testReadOnly() {
    JtxTransactionManager manager = createManager();
    JtxTransaction jtx = manager.requestTransaction(new JtxTransactionMode().propagationRequired().readOnly(true));
    WorkSession work = jtx.requestResource(WorkSession.class);
    WorkSession work2 = jtx.requestResource(WorkSession.class);
    assertSame(work2, work);
    try {
        work.writeValue("new value");
        fail();
    } catch (UncheckedException ignored) {
    }
    jtx.commit();
    manager.close();
}
Also used : UncheckedException(jodd.exception.UncheckedException) WorkSession(jodd.jtx.data.WorkSession) Test(org.junit.Test)

Example 2 with UncheckedException

use of jodd.exception.UncheckedException in project jodd by oblac.

the class LagartoFormSuiteBase method startTomcat.

/**
	 * Starts Tomcat.
	 */
protected static void startTomcat(String webXmlFileName) {
    if (server != null) {
        return;
    }
    server = new TomcatTestServer(webXmlFileName);
    try {
        server.start();
        System.out.println("Tomcat test server started");
    } catch (Exception e) {
        throw new UncheckedException(e);
    }
}
Also used : UncheckedException(jodd.exception.UncheckedException) UncheckedException(jodd.exception.UncheckedException)

Example 3 with UncheckedException

use of jodd.exception.UncheckedException in project jodd by oblac.

the class Jodd method updateModuleInstance.

/**
	 * Updates modules instances by creating new modules.
	 * When new module is created, {@link JoddModule#start()}
	 * will be called only once.
	 */
private static void updateModuleInstance(int moduleId) {
    Object module = MODULES[moduleId];
    if (module == null) {
        return;
    }
    if (module instanceof Class) {
        Class type = (Class) module;
        try {
            module = type.newInstance();
            MODULES[moduleId] = module;
            if (module instanceof JoddModule) {
                ((JoddModule) module).start();
            }
        } catch (Exception ex) {
            MODULES[moduleId] = null;
            throw new UncheckedException(ex);
        }
    }
}
Also used : UncheckedException(jodd.exception.UncheckedException) UncheckedException(jodd.exception.UncheckedException)

Example 4 with UncheckedException

use of jodd.exception.UncheckedException in project jodd by oblac.

the class JoySuite method startTomcat.

/**
	 * Starts Tomcat.
	 */
public static void startTomcat() {
    if (server != null) {
        return;
    }
    server = new JoyTomcatTestServer();
    try {
        server.start();
        System.out.println("Tomcat test server started");
    } catch (Exception e) {
        throw new UncheckedException(e);
    }
}
Also used : UncheckedException(jodd.exception.UncheckedException) UncheckedException(jodd.exception.UncheckedException)

Example 5 with UncheckedException

use of jodd.exception.UncheckedException in project jodd by oblac.

the class Jodd method initAllModules.

/**
	 * Loads all modules on the classpath by using classloader
	 * of this class.
	 */
public static void initAllModules() {
    if (initAllModules) {
        return;
    }
    initAllModules = true;
    final Field[] fields = Jodd.class.getFields();
    final ClassLoader classLoader = Jodd.class.getClassLoader();
    for (Field field : fields) {
        int index;
        try {
            index = ((Integer) field.get(null)).intValue();
        } catch (IllegalAccessException iaex) {
            throw new UncheckedException(iaex);
        }
        String moduleName = field.getName();
        String packageName = moduleName.toLowerCase();
        while (true) {
            int ndx = packageName.indexOf('_');
            if (ndx == -1) {
                break;
            }
            packageName = packageName.substring(0, ndx) + packageName.substring(ndx + 1);
        }
        moduleName = moduleName.substring(0, 1).toUpperCase() + moduleName.substring(1, moduleName.length()).toLowerCase();
        while (true) {
            int ndx = moduleName.indexOf('_');
            if (ndx == -1) {
                break;
            }
            moduleName = moduleName.substring(0, ndx) + moduleName.substring(ndx + 1, ndx + 2).toUpperCase() + moduleName.substring(ndx + 2);
        }
        String moduleClass = "jodd." + packageName + ".Jodd" + moduleName;
        NAMES[index] = moduleClass;
        try {
            MODULES[index] = classLoader.loadClass(moduleClass);
        } catch (ClassNotFoundException cnfex) {
        // ignore
        }
    }
    for (int i = 0; i < MODULES.length; i++) {
        updateModuleInstance(i);
    }
}
Also used : Field(java.lang.reflect.Field) UncheckedException(jodd.exception.UncheckedException)

Aggregations

UncheckedException (jodd.exception.UncheckedException)7 Field (java.lang.reflect.Field)1 CoreConnectionPool (jodd.db.pool.CoreConnectionPool)1 WorkSession (jodd.jtx.data.WorkSession)1 Logger (jodd.log.Logger)1 NOPLogger (jodd.log.impl.NOPLogger)1 NOPLoggerFactory (jodd.log.impl.NOPLoggerFactory)1 Test (org.junit.Test)1