Example usage for org.apache.commons.logging Log debug

List of usage examples for org.apache.commons.logging Log debug

Introduction

In this page you can find the example usage for org.apache.commons.logging Log debug.

Prototype

void debug(Object message);

Source Link

Document

Logs a message with debug log level.

Usage

From source file:hotbeans.support.AbstractHotBeanModuleRepository.java

/**
 * Checks for obsolete modules.//from  w w  w. j  a  v  a  2s.  com
 */
protected void checkForObsoleteModules() {
    Log logger = this.getLog();
    if (logger.isDebugEnabled())
        logger.debug("Checking for obsolete/inactive modules.");

    synchronized (this.lock) {
        String[] moduleNames = this.getHotBeanModuleNames();

        for (int n = 0; n < moduleNames.length; n++) {
            this.checkForObsoleteModules(moduleNames[n]);
        }
    }
}

From source file:hotbeans.support.AbstractHotBeanModuleRepository.java

/**
 * Registers a module revision./*from www  .  jav a  2  s  . c  o m*/
 */
protected void registerHotBeanModule(final HotBeanModule module) {
    Log logger = this.getLog();
    if (logger.isDebugEnabled())
        logger.debug("Registering module " + module.toString(false) + ".");

    synchronized (this.lock) {
        final String moduleName = module.getName();
        HotBeanModuleType hotBeanModuleType = this.getHotBeanModuleType(moduleName);
        if (hotBeanModuleType == null) {
            hotBeanModuleType = new HotBeanModuleType(moduleName);
            this.moduleRegistry.put(moduleName, hotBeanModuleType);
        }

        hotBeanModuleType.addModule(module); // Add as the last module revision
    }
}

From source file:hotbeans.support.AbstractHotBeanModuleRepository.java

/**
 * Unregisters a module revision, and possibly the whole module type.
 *///from   ww  w.  ja v  a2s  .  c om
protected void unregisterHotBeanModule(final HotBeanModule module) {
    Log logger = this.getLog();
    if (logger.isDebugEnabled())
        logger.debug("Unregistering module " + module.toString(false) + ".");

    synchronized (this.lock) {
        String moduleName = module.getName();
        HotBeanModuleType hotBeanModuleType = this.getHotBeanModuleType(moduleName);
        if (hotBeanModuleType != null) {
            hotBeanModuleType.removeModule(module);
            if (hotBeanModuleType.moduleCount() == 0)
                this.moduleRegistry.remove(moduleName); // If no revisions left
                                                        // - remove key
        }
    }
}

From source file:hotbeans.support.AbstractHotBeanModuleRepository.java

/**
 * Called to validate a HotBeanProxyFactory and module and bean references.
 *///from  w  ww . j  a  v  a  2s .  c  o m
public void validateHotBeanProxyFactory(final HotBeanProxyFactory hotBeanProxyFactory) {
    boolean hotModuleSwapped = false;
    HotBeanModule currentModule = hotBeanProxyFactory.getCurrentModule();

    Log logger = this.getLog();
    if (logger.isDebugEnabled())
        logger.debug("Validating " + hotBeanProxyFactory + " - current module: " + currentModule + ".");

    if ((currentModule != null) && !currentModule.isActive())
        currentModule = null; // If current module is
                              // inactive...

    if (currentModule == null) {
        currentModule = this.getHotBeanModule(hotBeanProxyFactory.getModuleName());
        hotModuleSwapped = true;
    }

    // Swap target
    if (hotModuleSwapped) {
        if (logger.isDebugEnabled())
            logger.debug("Swapping module of " + hotBeanProxyFactory + " - new current module: " + currentModule
                    + ".");

        Object hotBean = null;

        // Get bean from hot bean context
        if (currentModule != null)
            hotBean = currentModule.getHotBean(hotBeanProxyFactory.getBeanName());
        hotBeanProxyFactory.updateHotBeanModuleAndBean(currentModule, hotBean);
    }
}

From source file:de.betterform.agent.web.servlet.XFormsRepeater.java

protected void doSubmissionReplaceAll(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    final Log LOG = LogFactory.getLog(XFormsRepeater.class);
    HttpSession session = request.getSession(false);
    WebProcessor webProcessor = WebUtil.getWebProcessor(request, response, session);
    if (session != null && webProcessor != null) {
        if (LOG.isDebugEnabled()) {
            Enumeration keys = session.getAttributeNames();
            if (keys.hasMoreElements()) {
                LOG.debug("--- existing keys in session --- ");
            }//from   w  w  w.  j a  v a  2s  .c  o m
            while (keys.hasMoreElements()) {
                String s = (String) keys.nextElement();
                LOG.debug("existing sessionkey: " + s + ":" + session.getAttribute(s));
            }
        }

        Map submissionResponse = webProcessor.checkForExitEvent().getContextInfo();
        if (submissionResponse != null) {

            if (LOG.isDebugEnabled()) {
                LOG.debug("handling submission/@replace='all'");
                Enumeration keys = session.getAttributeNames();
                if (keys.hasMoreElements()) {
                    LOG.debug("--- existing keys in http session  --- ");
                    while (keys.hasMoreElements()) {
                        String s = (String) keys.nextElement();
                        LOG.debug("existing sessionkey: " + s + ":" + session.getAttribute(s));
                    }
                } else {
                    LOG.debug("--- no keys left in http session  --- ");
                }
            }

            // copy header fields
            Map headerMap = (Map) submissionResponse.get("header");
            String name;
            String value;
            Iterator iterator = headerMap.keySet().iterator();
            while (iterator.hasNext()) {
                name = (String) iterator.next();
                if (name.equalsIgnoreCase("Transfer-Encoding")) {
                    // Some servers (e.g. WebSphere) may set a "Transfer-Encoding"
                    // with the value "chunked". This may confuse the client since
                    // XFormsServlet output is not encoded as "chunked", so this
                    // header is ignored.
                    continue;
                }

                value = (String) headerMap.get(name);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("added header: " + name + "=" + value);
                }

                response.setHeader(name, value);
            }

            // copy body stream
            InputStream bodyStream = (InputStream) submissionResponse.get("body");
            OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
            for (int b = bodyStream.read(); b > -1; b = bodyStream.read()) {
                outputStream.write(b);
            }

            // close streams
            bodyStream.close();
            outputStream.close();

            //kill XFormsSession
            WebUtil.removeSession(webProcessor.getKey());
            return;
        }
    }
    response.sendError(HttpServletResponse.SC_FORBIDDEN, "no submission response available");
}

From source file:hotbeans.support.AbstractHotBeanModuleRepository.java

/**
 * Checks for obsolete revisions of a specific module name.
 *//* ww w.  ja  va  2  s.  co  m*/
protected void checkForObsoleteModules(final String moduleName) {
    Log logger = this.getLog();
    if (logger.isDebugEnabled())
        logger.debug("Checking for obsolete/inactive module revisions for module " + moduleName + ".");

    synchronized (this.lock) {
        HotBeanModule currentModule = this.getHotBeanModule(moduleName); // Get current module for name
        HotBeanModule[] modules = this.getHotBeanModules(moduleName); // Get all revisions for module name
        HotBeanModuleType moduleType = this.getHotBeanModuleType(moduleName);
        boolean isRemoveType = moduleType.isRemoveType();

        for (int r = 0; r < modules.length; r++) {
            if (modules[r] != null) {
                synchronized (modules[r]) {
                    if (logger.isDebugEnabled())
                        logger.debug("Checking module revision " + modules[r] + " - usage count: "
                                + modules[r].getUsageCount());

                    if (modules[r].isActive() || modules[r].isInactive()) // Only check module if active or inactive (i.e
                                                                          // loaded)
                    {
                        boolean obsolete = !modules[r].equals(currentModule); // Module is obsolete if it isn't the
                                                                              // latest(current)

                        if (isRemoveType) {
                            if (logger.isDebugEnabled())
                                logger.debug("Unloading removed module " + modules[r].toString(false) + ".");
                            modules[r].unload();
                        } else if (obsolete && modules[r].isActive()) // If module is obsolete...
                        {
                            if (logger.isDebugEnabled())
                                logger.debug("Marking obsolete module " + modules[r].toString(false)
                                        + " as inactive.");
                            modules[r].inactivate(); // ...mark as inactive....
                        } else if (modules[r].isInactive() && !modules[r].inUse()) // ...and unload it during the next
                                                                                   // check (and when no longer in use)
                        {
                            if (logger.isDebugEnabled())
                                logger.debug("Unloading inactive module " + modules[r].toString(false) + ".");
                            modules[r].unload();
                        }
                    }

                    if (isRemoveType) // Unregister removed module
                    {
                        this.unregisterHotBeanModule(modules[r]);
                    }
                }
            }
        }
    }
}

From source file:com.dhcc.framework.web.context.DhccContextLoader.java

/**
 * Template method with default implementation (which may be overridden by a
 * subclass), to load or obtain an ApplicationContext instance which will be
 * used as the parent context of the root WebApplicationContext. If the
 * return value from the method is null, no parent context is set.
 * <p>The main reason to load a parent context here is to allow multiple root
 * web application contexts to all be children of a shared EAR context, or
 * alternately to also share the same parent context that is visible to
 * EJBs. For pure web applications, there is usually no need to worry about
 * having a parent context to the root web application context.
 * <p>The default implementation uses
 * {@link org.springframework.context.access.ContextSingletonBeanFactoryLocator},
 * configured via {@link #LOCATOR_FACTORY_SELECTOR_PARAM} and
 * {@link #LOCATOR_FACTORY_KEY_PARAM}, to load a parent context
 * which will be shared by all other users of ContextsingletonBeanFactoryLocator
 * which also use the same configuration parameters.
 * @param servletContext current servlet context
 * @return the parent application context, or {@code null} if none
 * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator
 *///from  w w  w .j a  v a  2 s.c o m
protected ApplicationContext loadParentContext(ServletContext servletContext) {
    ApplicationContext parentContext = null;
    String locatorFactorySelector = servletContext.getInitParameter(LOCATOR_FACTORY_SELECTOR_PARAM);
    String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM);

    if (parentContextKey != null) {
        // locatorFactorySelector may be null, indicating the default "classpath*:beanRefContext.xml"
        BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(locatorFactorySelector);
        Log logger = LogFactory.getLog(DhccContextLoader.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Getting parent context definition: using parent context key of '" + parentContextKey
                    + "' with BeanFactoryLocator");
        }
        this.parentContextRef = locator.useBeanFactory(parentContextKey);
        parentContext = (ApplicationContext) this.parentContextRef.getFactory();
    }

    return parentContext;
}

From source file:de.ingrid.iplug.csw.dsc.cache.impl.AbstractUpdateStrategy.java

/**
 * Fetch all records from a id list using the GetRecordById and put them in the cache
 * //from www  . ja  va 2 s.  co m
 * @param client The CSWClient to use
 * @param elementSetName The ElementSetName of the records to fetch
 * @param recordIds The list of ids
 * @param requestPause The time between two requests in milliseconds
 * @throws Exception
 */
protected void fetchRecords(CSWClient client, ElementSetName elementSetName, List<String> recordIds,
        int requestPause) throws Exception {

    CSWFactory factory = client.getFactory();
    Cache cache = this.getExecutionContext().getCache();
    Log log = this.getLog();

    CSWQuery query = factory.createQuery();
    query.setElementSetName(elementSetName);

    int cnt = 1;
    int max = recordIds.size();
    Iterator<String> it = recordIds.iterator();
    while (it.hasNext()) {
        String id = it.next();
        query.setId(id);
        CSWRecord record = null;
        try {
            record = client.getRecordById(query);
            if (log.isDebugEnabled())
                log.debug("Fetched record: " + id + " " + record.getElementSetName() + " (" + cnt + "/" + max
                        + ")");
            cache.putRecord(record);
        } catch (Exception e) {
            log.error("Error fetching record '" + query.getId() + "'! Removing record from cache.", e);
            cache.removeRecord(query.getId());
            recordIds.remove(id);
        }
        cnt++;
        Thread.sleep(requestPause);
    }
}

From source file:com.boylesoftware.web.AbstractWebApplication.java

/**
 * Initialize the web-application. Called by the framework just before the
 * application is made available in the container.
 *
 * @throws UnavailableException If application cannot be initialized.
 * Throwing the exception makes the application fail to start.
 *///from w  w  w . ja v a  2 s. c  o m
void onRouterInit() throws UnavailableException {

    // get the log
    final Log log = LogFactory.getLog(AbstractWebApplication.class);
    log.debug("initializing the web-application");

    // initialize the application
    boolean success = false;
    try {

        // create configuration
        log.debug("creating configuration");
        this.configure(this.configProperties);

        // get the authenticator
        final ServletContext sc = this.servletContext;
        log.debug("creating authenticator");
        this.services.setAuthenticationService(this.getAuthenticationService(sc, this));

        // get validator factory
        log.debug("creating validator factory");
        this.services.setValidatorFactory(this.getValidatorFactory(sc, this));

        // get user locale finder
        log.debug("creating user locale finder");
        this.services.setUserLocaleFinder(this.getUserLocaleFinder(sc, this));

        // create entity manager factory
        log.debug("creating persistence manager factory");
        this.services.setEntityManagerFactory(this.getEntityManagerFactory(sc, this));

        // get JavaMail session from the JNDI
        log.debug("attempting to find JavaMail session in the JNDI");
        try {
            final InitialContext jndi = new InitialContext();
            try {
                this.services
                        .setMailSession((Session) jndi.lookup(this.getConfigProperty(MAIL_SESSION_JNDI_NAME,
                                String.class, ApplicationServices.DEFAULT_MAIL_SESSION_JNDI_NAME)));
            } catch (final NameNotFoundException e) {
                log.debug("no JavaMail session in the JNDI, JavaMail will" + " be unavailable", e);
            }
        } catch (final NamingException e) {
            log.error("Error accessing JNDI.", e);
        }

        // get the router configuration
        log.debug("creating routes configuration");
        this.routerConfiguration = this.getRouterConfiguration(sc, this, this.services);

        // initialize custom application
        log.debug("initializing custom application");
        this.init();

        // get the executor service
        log.debug("creating request processing executor service");
        this.executors = this.getExecutorService(sc, this);

        // done
        log.debug("initialized successfully");
        success = true;

    } finally {
        if (!success) {
            log.debug("initialization error");
            this.cleanup();
        }
    }
}

From source file:com.flexive.shared.exceptions.FxApplicationException.java

/**
 * Log a message at a given level (or error if no level given)
 *
 * @param log     Log to use/*from   w ww  . j ava2s  .  co  m*/
 * @param message message to LOG
 * @param level   log4j level to apply
 */
private void logMessage(Log log, String message, LogLevel level) {
    this.messageLogged = true;
    if (FxContext.get() != null && FxContext.get().isTestDivision())
        return; //dont log exception traces during automated tests
    final Throwable cause = getCause() != null ? getCause() : this;
    if (level == null)
        log.error(message, cause);
    else {
        switch (level) {
        case DEBUG:
            if (log.isDebugEnabled())
                log.debug(message);
            break;
        case ERROR:
            if (log.isErrorEnabled())
                log.error(message, cause);
            break;
        case FATAL:
            if (log.isFatalEnabled())
                log.fatal(message, cause);
            break;
        case INFO:
            if (log.isInfoEnabled())
                log.info(message);
            break;
        //                case Level.WARN_INT:
        default:
            if (log.isWarnEnabled())
                log.warn(message);
        }
    }
}