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

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

Introduction

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

Prototype

void info(Object message);

Source Link

Document

Logs a message with info log level.

Usage

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

/**
 * Process a fetched search result (collect ids and cache records)
 * //from www  .j a v a  2  s . c  o  m
 * @param result The search result
 * @param doCache Determines wether to cache the record or not
 * @return The list of ids of the fetched records
 * @throws Exception
 */
private List<String> processResult(CSWSearchResult result, boolean doCache) throws Exception {

    Cache cache = this.getExecutionContext().getCache();
    Log log = this.getLog();

    List<String> fetchedRecordIds = new ArrayList<String>();
    for (CSWRecord record : result.getRecordList()) {
        String id = record.getId();

        if (log.isInfoEnabled())
            log.info("Fetched record: " + id + " " + record.getElementSetName());
        if (fetchedRecordIds.contains(id)) {
            log.warn("Duplicated id: " + id + ". Overriding previous entry.");
        }
        fetchedRecordIds.add(id);

        // cache only if requested
        if (doCache)
            cache.putRecord(record);
    }
    if (log.isInfoEnabled())
        log.info("Fetched " + fetchedRecordIds.size() + " of " + result.getNumberOfRecordsTotal()
                + " [starting from " + result.getQuery().getStartPosition() + "]");
    return fetchedRecordIds;
}

From source file:name.livitski.tools.persista.schema.example.CustomerCRUDTest.java

@Test
public void testUpdateDelete() {
    assertNotNull("stored object must have a positive id, got null", storedRecordId);
    final Log log = log();
    final EntityManager db = getEntityManager();
    final EntityTransaction txn = db.getTransaction();
    txn.begin();//from ww w .j a  va 2  s  .co  m
    Customer customer = db.find(Customer.class, storedRecordId);
    assertNotNull("cannot find record of type " + Customer.class + " with id=" + storedRecordId, customer);
    customer.setName(UPDATED_NAME);
    customer.setAddress(UPDATED_ADDRESS);
    customer.setPhone(UPDATED_PHONE);
    customer.setEmail(UPDATED_EMAIL);
    txn.commit();
    log.info("Updated customer record with id=" + storedRecordId);
    expected = new String[] { UPDATED_NAME, UPDATED_ADDRESS, UPDATED_PHONE, UPDATED_EMAIL };
    testRead();
    txn.begin();
    db.refresh(customer);
    db.remove(customer);
    txn.commit();
    log.info("Deleted customer record with id=" + storedRecordId);
    customer = db.find(Customer.class, storedRecordId);
    assertNull("record of type " + Customer.class + " with id=" + storedRecordId + " was not deleted",
            customer);
    storedRecordId = null;
}

From source file:com.moss.error_reporting.server.ErrorReportServer.java

public ErrorReportServer(ServerConfiguration config) {

    final Log log = LogFactory.getLog(this.getClass());

    try {/*from ww  w .j av a2s.c o m*/
        Server jetty = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(config.bindPort());
        connector.setHost(config.bindAddress());
        jetty.addConnector(connector);

        boolean initialize = false;
        if (!config.storageDir().exists() || config.storageDir().listFiles().length == 0) {
            initialize = true;
        }

        log.info("Using storage dir: " + config.storageDir().getAbsolutePath());

        DataStore data = new DataStore(config.storageDir(), initialize);
        ReportingServiceImpl impl = new ReportingServiceImpl(data,
                new Notifier(config.smtpServer(), config.fromAddress(), config.emailReceipients()));

        final String path = "/Reporting";
        final SwitchingContentHandler handler = new SwitchingContentHandler(path);
        final boolean jaxwsEnabled = Boolean
                .parseBoolean(System.getProperty("shell.rpc.jaxws.enabled", "true"));

        if (jaxwsEnabled) {

            if (log.isDebugEnabled()) {
                log.debug(
                        "Constructing JAXWS http content handler RPC impl " + impl.getClass().getSimpleName());
            }

            try {
                ContentHandler jaxwsHandler = new JAXWSContentHandler(impl);
                handler.addHandler(jaxwsHandler);
            } catch (Exception ex) {
                throw new RuntimeException("Failed to create JAXWS service for " + impl.getClass().getName(),
                        ex);
            }
        }

        if (log.isDebugEnabled()) {
            log.debug("Constructing Hessian http content handler for RPC impl "
                    + impl.getClass().getSimpleName());
        }

        ContentHandler hessianHandler = new HessianContentHandler(ReportingService.class, impl);
        handler.addHandler(hessianHandler);

        jetty.addHandler(handler);
        jetty.start();

        System.out.println("\n\nSERVER READY FOR ACTION\n\n");
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Unexpected Error.  Shutting Down.");
        System.exit(1);
    }
}

From source file:it.caladyon.akka.commonslog.CommonsLoggingLogger.java

@Override
public void onReceive(Object message) throws Exception {
    if (message instanceof InitializeLogger) {
        loggerLog.info(message);//from  w  ww.  j  a  va  2s.  c  om
        getSender().tell(Logging.loggerInitialized(), getSelf());
    } else if (message instanceof Error) {
        Log log = LogFactory.getLog(((Error) message).logClass());
        if (((Error) message).cause() == null) {
            log.error(composeMessage((LogEvent) message));
        } else {
            log.error(composeMessage((LogEvent) message), ((Error) message).cause());
        }
    } else if (message instanceof Warning) {
        Log log = LogFactory.getLog(((Warning) message).logClass());
        log.warn(composeMessage((LogEvent) message));
    } else if (message instanceof Info) {
        Log log = LogFactory.getLog(((Info) message).logClass());
        if (log.isInfoEnabled()) {
            log.info(composeMessage((LogEvent) message));
        }
    } else if (message instanceof Debug) {
        Log log = LogFactory.getLog(((Debug) message).logClass());
        if (log.isDebugEnabled()) {
            log.debug(composeMessage((LogEvent) message));
        }
    }
}

From source file:com.chinamobile.bcbsp.comm.io.util.MemoryAllocator.java

/**
 * Utilized in computation recycle./*  w ww.j a  v  a  2  s  . c  o  m*/
 * Make sure that graph data is ready for Item Ratio Computation.
 * @param superstep
 */
public void setupOnEachSuperstep(int superstep, Log LOG) {
    if (superstep > 0) {
        return;
    }
    // Note Combine And None-Combine. Bucked-To-Be-Processing Bytes Are
    // Different.
    int maxBucketCount = MetaDataOfGraph.VERTEX_NUM_PERBUCKET[MetaDataOfGraph.BCBSP_MAX_BUCKET_INDEX];
    // Accurate Evaluation.
    long messageObjesSize = maxBucketCount * (8 + 4 + MetaDataOfMessage.BYTESIZE_PER_MESSAGE);
    // Note Contain The Incomed Bucket Message For Memory Deployment.
    long leftBytes = this.remainAdjusted - messageObjesSize;
    if (leftBytes <= 0) {
        LOG.info("[ShutDown]Memory Space Is Too Small " + "Except The One To Hold The Bucketed Message");
        System.exit(-1);
    } else if (leftBytes <= this.remainAdjusted / 5) {
        LOG.info("Memory Space For Local Computing Is " + "A Little Small [Less Than 1/5Total]");
    }
    long sendMessageCacheBytes = leftBytes / 8;
    leftBytes = leftBytes - sendMessageCacheBytes;
    // Note Graph Data Is In Memory One Bucket One Time.
    // Note Set Up The Ceil Bucket Cache Threshold(Bytes).
    // Note IO Buffer Unit Is 10000 To 10000(Bytes)[65535]
    int unitSizeThreshold = 65535;
    // Note Graph Is Vertex And Edges.
    long graphIOBytes = (long) unitSizeThreshold * MetaDataOfGraph.BCBSP_DISKGRAPH_HASHNUMBER * 2;
    // Note
    long revMessageIOBytes = (long) unitSizeThreshold * MetaDataOfMessage.PARTITIONBUCKET_NUMBER;
    // Note
    leftBytes -= (graphIOBytes + revMessageIOBytes + sendMessageCacheBytes);
    if (leftBytes <= 0) {
        LOG.info("[ShutDown]Memory Space Is Too Small " + "To Cache The Bucketed Message");
        System.exit(-1);
    } else if (leftBytes <= this.remainAdjusted / 10) {
        LOG.info("Memory Space For Local Computing Is" + " A Little Small [Less Than 1/10Total]");
    }
    MetaDataOfGraph.BCBSP_GRAPH_LOAD_READSIZE = unitSizeThreshold;
    MetaDataOfGraph.BCBSP_GRAPH_LOAD_WRITESIZE = unitSizeThreshold;
    MetaDataOfMessage.MESSAGE_IO_BYYES = unitSizeThreshold;
    MetaDataOfMessage.MESSAGE_SEND_BUFFER_THRESHOLD = (int) (sendMessageCacheBytes
            / MetaDataOfMessage.PARTITIONBUCKET_NUMBER);
    MetaDataOfMessage.MESSAGE_RECEIVED_BUFFER_THRESHOLD = (int) (leftBytes
            / MetaDataOfMessage.PARTITIONBUCKET_NUMBER / 2);
    LOG.info("Memory Deploy **********************************************");
    LOG.info("Memory Processed Message Bucket Bytes   *************** " + messageObjesSize);
    LOG.info("Memory Message Send Cache Bytes         **************** " + sendMessageCacheBytes
            + "***** SizePerUnit: " + MetaDataOfMessage.MESSAGE_SEND_BUFFER_THRESHOLD);
    LOG.info("Memory Graph Data IO Bytes              **************** " + graphIOBytes);
    LOG.info("Memory Message Data IO Bytes            **************** " + revMessageIOBytes);
    LOG.info("Memory Message Rev Cached Bytes         **************** " + leftBytes + "****SizePerUnit: "
            + MetaDataOfMessage.MESSAGE_RECEIVED_BUFFER_THRESHOLD);
}

From source file:net.sf.nmedit.nomad.core.NomadPlugin.java

private void logOsInfo(Log log) {
    String properties[] = { "java.version", "java.vendor", "java.vendor.url", "java.home",
            "java.vm.specification.version", "java.vm.specification.vendor", "java.vm.specification.name",
            "java.vm.version", "java.vm.vendor", "java.vm.name", "java.specification.version",
            "java.specification.vendor", "java.specification.name", "java.class.version", "java.class.path",
            "java.library.path", "java.io.tmpdir", "java.compiler", "java.ext.dirs", "os.name", "os.arch",
            "os.version", "file.separator", "path.separator", "line.separator", "user.name", "user.home",
            "user.dir" };

    try {//from  w w w.  j a va 2s.  c o  m
        log.info("\t[System Properties]");
        for (String key : properties) {
            String value = System.getProperty(key);
            log.info("\t" + key + "=" + value);
        }
        log.info("\t[/System Properties]");
    } catch (SecurityException e) {
        log.error("logOsInfo(Log)", e);
    }
}

From source file:hotbeans.support.AbstractHotBeanModuleRepository.java

/**
 * Destroys this AbstractHotBeanModuleRepository. Subclasses may override this method, but should call the super
 * class implementation.// w w  w.ja va 2 s .c  o  m
 */
public void destroy() throws Exception {
    Log logger = this.getLog();

    synchronized (this.lock) {
        String[] moduleNames = this.getHotBeanModuleNames();
        if (logger.isInfoEnabled())
            logger.info("Destroying " + this.getName() + " (" + ((moduleNames != null) ? moduleNames.length : 0)
                    + " modules).");
        HotBeanModuleType moduleType;
        HotBeanModule[] modules;
        for (int i = 0; i < moduleNames.length; i++) {
            if (logger.isDebugEnabled())
                logger.debug("Unloading revisions of module " + moduleNames[i] + ".");

            moduleType = this.getHotBeanModuleType(moduleNames[i]);
            if (moduleType != null) {
                modules = moduleType.getModules();
                for (int j = 0; j < modules.length; j++) {
                    if (logger.isDebugEnabled())
                        logger.debug("Checking" + modules[i] + ".");

                    if (modules[j].isActive() || modules[j].isInactive()) {
                        if (logger.isDebugEnabled())
                            logger.debug("Unloading " + modules[j] + ".");
                        modules[j].unload();
                    }
                    this.unregisterHotBeanModule(modules[j]);
                }
            }
        }
    }
}

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

/**
 * Initialize Spring's web application context for the given servlet context,
 * using the application context provided at construction time, or creating a new one
 * according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and
 * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params.
 * @param servletContext current servlet context
 * @return the new WebApplicationContext
 * @see #ContextLoader(WebApplicationContext)
 * @see #CONTEXT_CLASS_PARAM/* www .j  a v  a  2s.  co m*/
 * @see #CONFIG_LOCATION_PARAM
 */
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) {
    if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) {
        throw new IllegalStateException(
                "Cannot initialize context because there is already a root application context present - "
                        + "check whether you have multiple ContextLoader* definitions in your web.xml!");
    }

    Log logger = LogFactory.getLog(DhccContextLoader.class);
    servletContext.log("Initializing Spring root WebApplicationContext");
    if (logger.isInfoEnabled()) {
        logger.info("Root WebApplicationContext: initialization started");
    }
    long startTime = System.currentTimeMillis();

    try {
        // Store context in local instance variable, to guarantee that
        // it is available on ServletContext shutdown.
        if (this.context == null) {
            this.context = createWebApplicationContext(servletContext);
        }
        if (this.context instanceof ConfigurableWebApplicationContext) {
            ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context;
            if (!cwac.isActive()) {
                // The context has not yet been refreshed -> provide services such as
                // setting the parent context, setting the application context id, etc
                if (cwac.getParent() == null) {
                    // The context instance was injected without an explicit parent ->
                    // determine parent for root web application context, if any.
                    ApplicationContext parent = loadParentContext(servletContext);
                    cwac.setParent(parent);
                }
                configureAndRefreshWebApplicationContext(cwac, servletContext);
            }
        }
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);

        ClassLoader ccl = Thread.currentThread().getContextClassLoader();
        if (ccl == DhccContextLoader.class.getClassLoader()) {
            currentContext = this.context;
        } else if (ccl != null) {
            currentContextPerThread.put(ccl, this.context);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Published root WebApplicationContext as ServletContext attribute with name ["
                    + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
        }
        if (logger.isInfoEnabled()) {
            long elapsedTime = System.currentTimeMillis() - startTime;
            logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms");
        }

        return this.context;
    } catch (RuntimeException ex) {
        logger.error("Context initialization failed", ex);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex);
        throw ex;
    } catch (Error err) {
        logger.error("Context initialization failed", err);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err);
        throw err;
    }
}

From source file:com.curl.orb.servlet.InstanceManagementServlet.java

@Override
public void init() {
    synchronized (initializedLock) {
        if (!initializedLock.isFirstTime())
            return;
        Log log = LogFactory.getLog(getClass());

        // Set to environment
        String environment = getServletContext().getInitParameter(ENVIRONMENT);
        if (environment != null) {
            if (environment.equalsIgnoreCase(Environment.PRODUCTION.toString()))
                InstanceManagementServlet.environment = Environment.PRODUCTION;
            else if (environment.equalsIgnoreCase(Environment.TEST.toString()))
                InstanceManagementServlet.environment = Environment.TEST;
            else if (environment.equalsIgnoreCase(Environment.DEVELOPMENT.toString()))
                InstanceManagementServlet.environment = Environment.DEVELOPMENT;
        }//from  ww  w .j  a  va 2s  . com
        log.info("Environment [" + environment + "]");

        // Load ApplicationContext
        AbstractApplicationContext applicationContext = (ApplicationContextFactory
                .getInstance(getServletContext())).getApplicationContext();
        log.info("Loaded ApplicationContext [" + applicationContext + "]");

        // Load jars/classes files
        try {
            if (!(Environment.TEST.contain(InstanceManagementServlet.environment))
                    || InstanceManagementServlet.environment == null) {
                ClassPathLoader loader = ClassPathLoader
                        .getInstance(getServletContext().getInitParameter(GENERATOR_FILTER));
                String fileType = getServletContext().getInitParameter(GENERATOR_LOAD_FILETYPE);
                if (fileType == null || fileType.equalsIgnoreCase("both")) {
                    loader.addClassProperties(getServletContext().getRealPath("/WEB-INF/lib"));
                    loader.addClassProperties(getServletContext().getRealPath("/WEB-INF/classes"));
                } else if (fileType.equalsIgnoreCase("class")) {
                    loader.addClassProperties(getServletContext().getRealPath("/WEB-INF/classes"));
                } else if (fileType.equalsIgnoreCase("jar")) {
                    loader.addClassProperties(getServletContext().getRealPath("/WEB-INF/lib"));
                }
                // System.getProperty("java.class.path")
                log.info("Loaded java libraries to generate Curl code.");
            }
        } catch (GeneratorException e) {
            log.warn(e);
        }
    }
}

From source file:com.chinamobile.bcbsp.bspcontroller.Counters.java

/**
 * Logs the current counter values./*from  w w w .  jav  a  2  s .co m*/
 * @param log
 *        The log to use.
 */
public void log(Log log) {
    log.info("Counters: " + size());
    for (Group group : this) {
        log.info("  " + group.getDisplayName());
        for (Counter counter : group) {
            log.info(counter.getDisplayName() + "=" + counter.getCounter());
            countersmap.put(new Text(counter.getDisplayName()), new LongWritable(counter.getCounter()));
        }
    }
}