Search in sources :

Example 1 with ConnectionBrokerManager

use of com.dexels.navajo.adapter.sqlmap.ConnectionBrokerManager in project navajo by Dexels.

the class SQLMap method setReload.

/**
 * @param reload
 */
@Deprecated
public void setReload(String datasourceName) throws MappableException, UserException {
    if (Version.osgiActive()) {
        // this method makes no sense in OSGi
        return;
    }
    // synchronized ( semaphore ) {
    if (debug) {
        Access.writeToConsole(myAccess, "SQLMAP setReload(" + datasourceName + ") called!\n");
    }
    try {
        synchronized (semaphore) {
            if (!initialized || !datasourceName.equals("")) {
                if (configFile == null) {
                    configFile = navajoConfig.readConfig("sqlmap.xml");
                    // SQLMap!!!
                    if (fixedBroker == null && datasourceName.equals("")) {
                        // Only
                        // re-create
                        // entire
                        // HashMap
                        // at
                        // initialization!
                        fixedBroker = new ConnectionBrokerManager();
                    }
                    if (datasourceName.equals("")) {
                        // Get other data sources.
                        if (configFile != null) {
                            List<Message> all = configFile.getMessages("/datasources/.*");
                            for (int i = 0; i < all.size(); i++) {
                                Message body = all.get(i);
                                createDataSource(body, navajoConfig);
                            }
                        } else {
                            logger.debug("No config file set. Normal in multitenant.");
                        }
                    } else {
                        createDataSource(configFile.getMessage("/datasources/" + datasourceName), navajoConfig);
                    }
                    this.checkDefaultDatasource();
                }
                initialized = true;
            }
        }
        rowCount = 0;
    } catch (NavajoException ne) {
        ne.printStackTrace(Access.getConsoleWriter(myAccess));
        AuditLog.log("SQLMap", ne.getMessage(), ne, Level.SEVERE, (myAccess != null ? myAccess.accessID : "unknown access"));
        throw new MappableException(ne.getMessage(), ne);
    } catch (java.io.IOException fnfe) {
        fnfe.printStackTrace(Access.getConsoleWriter(myAccess));
        AuditLog.log("SQLMap", fnfe.getMessage(), fnfe, Level.SEVERE, (myAccess != null ? myAccess.accessID : "unknown access"));
        throw new MappableException("Could not load configuration file for SQLMap object: " + fnfe.getMessage(), fnfe);
    } catch (Throwable t) {
        t.printStackTrace(Access.getConsoleWriter(myAccess));
        AuditLog.log("SQLMap", t.getMessage(), Level.SEVERE, (myAccess != null ? myAccess.accessID : ""));
        throw new MappableException(t.getMessage(), t);
    }
// }
}
Also used : MappableException(com.dexels.navajo.script.api.MappableException) Message(com.dexels.navajo.document.Message) ConnectionBrokerManager(com.dexels.navajo.adapter.sqlmap.ConnectionBrokerManager) NavajoException(com.dexels.navajo.document.NavajoException)

Aggregations

ConnectionBrokerManager (com.dexels.navajo.adapter.sqlmap.ConnectionBrokerManager)1 Message (com.dexels.navajo.document.Message)1 NavajoException (com.dexels.navajo.document.NavajoException)1 MappableException (com.dexels.navajo.script.api.MappableException)1