List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:hotbeans.support.FileSystemHotBeanModuleRepository.java
/** * Adds (installs) a new hot bean module. *///from w w w.j ava 2s.com public HotBeanModuleInfo addHotBeanModule(final InputStream moduleFile) { Log logger = this.getLog(); if (logger.isInfoEnabled()) logger.info("Attempting to add module."); HotBeanModuleInfo hotBeanModuleInfo = this.updateModuleInternal(null, moduleFile, true); if (logger.isInfoEnabled()) logger.info("Done adding module - " + hotBeanModuleInfo + "."); if (hotBeanModuleInfo != null) return hotBeanModuleInfo.getClone(); else return hotBeanModuleInfo; }
From source file:hotbeans.support.FileSystemHotBeanModuleRepository.java
/** * Updates an existing hot beans module with a new revision. *///w ww. j a v a 2s . c om public HotBeanModuleInfo updateHotBeanModule(final String moduleName, final InputStream moduleFile) { Log logger = this.getLog(); if (logger.isInfoEnabled()) logger.info("Attempting to update module '" + moduleName + "'."); HotBeanModuleInfo hotBeanModuleInfo = this.updateModuleInternal(moduleName, moduleFile, false); if (logger.isInfoEnabled()) logger.info("Done updating module - " + hotBeanModuleInfo + "."); if (hotBeanModuleInfo != null) return hotBeanModuleInfo.getClone(); else return hotBeanModuleInfo; }
From source file:com.amazon.carbonado.repo.indexed.IndexedStorage.java
@SuppressWarnings("unchecked") private void removeIndex(StorableIndex index) throws RepositoryException { Log log = LogFactory.getLog(IndexedStorage.class); if (log.isInfoEnabled()) { StringBuilder b = new StringBuilder(); b.append("Removing index on "); b.append(getStorableType().getName()); b.append(": "); try {//from w w w .j av a 2 s . c o m index.appendTo(b); } catch (java.io.IOException e) { // Not gonna happen. } log.info(b.toString()); } Class<? extends Storable> indexEntryClass = IndexEntryGenerator.getIndexAccess(index).getReferenceClass(); Storage<?> indexEntryStorage; try { indexEntryStorage = mRepository.getIndexEntryStorageFor(indexEntryClass); } catch (Exception e) { // Assume it doesn't exist. unregisterIndex(index); return; } { // Doesn't completely remove the index, but it should free up space. double desiredSpeed = mRepository.getIndexRepairThrottle(); Throttle throttle = desiredSpeed < 1.0 ? new Throttle(BUILD_THROTTLE_WINDOW) : null; if (throttle == null) { indexEntryStorage.truncate(); } else { long totalDropped = 0; while (true) { Transaction txn = mRepository.getWrappedRepository() .enterTopTransaction(IsolationLevel.READ_COMMITTED); txn.setForUpdate(true); try { Cursor<? extends Storable> cursor = indexEntryStorage.query().fetch(); if (!cursor.hasNext()) { break; } int count = 0; final long savedTotal = totalDropped; boolean anyFailure = false; try { while (count++ < BUILD_BATCH_SIZE && cursor.hasNext()) { if (cursor.next().tryDelete()) { totalDropped++; } else { anyFailure = true; } } } finally { cursor.close(); } txn.commit(); if (log.isInfoEnabled()) { log.info("Removed " + totalDropped + " index entries"); } if (anyFailure && totalDropped <= savedTotal) { log.warn("No indexes removed in last batch. " + "Aborting index removal cleanup"); break; } } catch (FetchException e) { throw e.toPersistException(); } finally { txn.exit(); } try { throttle.throttle(desiredSpeed, BUILD_THROTTLE_SLEEP_PRECISION); } catch (InterruptedException e) { throw new RepositoryException("Index removal interrupted"); } } } } unregisterIndex(index); }
From source file:hotbeans.support.FileSystemHotBeanModuleRepository.java
/** * Registers an unloaded (history) module. *//*w w w . j a v a 2s. c o m*/ protected void registerHistoryModule(final String moduleName, final long revision) throws Exception { Log logger = this.getLog(); if (logger.isInfoEnabled()) logger.info("Registering unloaded module '" + moduleName + "', revision " + revision + "."); File moduleDirectory = new File(this.moduleRepositoryDirectory, moduleName); File moduleFile = new File(moduleDirectory, revision + MODULE_FILE_SUFFIX); Manifest manifest = ModuleManifestUtils.readManifest(moduleFile); // Get version from mainfest String version = ModuleManifestUtils.getVersion(manifest); if ((version == null) || (version.trim().length() == 0)) version = "n/a"; // Get description from mainfest String description = ModuleManifestUtils.getDescription(manifest); HotBeanModuleInfo hotBeanModuleInfo = new HotBeanModuleInfo(moduleName, description, revision, version, moduleFile.lastModified()); HotBeanModule hotBeanModue = super.createHotBeanModule(hotBeanModuleInfo); // Register HotBeanModule super.registerHotBeanModule(hotBeanModue); if (logger.isInfoEnabled()) logger.info("Unloaded module '" + moduleName + "', revision " + revision + " registered."); }
From source file:hotbeans.support.FileSystemHotBeanModuleRepository.java
/** * Removes all revisions of a hot bean module. *///from www .j ava 2 s .com public void removeHotBeanModule(final String moduleName) { Log logger = this.getLog(); if (logger.isInfoEnabled()) logger.info("Removing module '" + moduleName + "'."); synchronized (super.getLock()) { RepositoryFileLock fileLock = null; try { HotBeanModuleType moduleType = super.getHotBeanModuleType(moduleName); if (moduleType != null) { // Mark current module revision as as deleted to indicate that the module should be deleted moduleType.setRemoveType(true); fileLock = this.obtainRepositoryFileLock(false); // Obtain lock File moduleDirectory = new File(this.moduleRepositoryDirectory, moduleName); FileDeletor.delete(moduleDirectory); this.checkForObsoleteModules(moduleName); // Perform a check on the module at once, to make sure it is // removed } } catch (Exception e) { logger.error("Error deleting module '" + moduleName + " - " + e + "'!", e); throw new HotBeansException("Error deleting module '" + moduleName + " - " + e + "'!"); } finally { this.releaseRepositoryFileLock(fileLock); fileLock = null; } } }
From source file:net.sf.nmedit.nomad.core.Nomad.java
private void shutDownPlugin() { Log log = LogFactory.getLog(getClass()); log.info("Shutting down " + pluginInstance); try {// w w w .j a v a 2 s . co m Boot.stopApplication(pluginInstance); } catch (Exception e) { // log.warn(e); e.printStackTrace(); } }
From source file:de.tudarmstadt.ukp.clarin.webanno.crowdflower.CrowdClient.java
/** * Orders the job given by its jobid. Pay is per assigment, which is by default 5 units. * * @param job as CrowdJob//from w w w . j a va 2 s. com * @param channels : a vector of channels, in which the job should be made available * @param units : number of units to order * @param payPerAssigment : pay in (dollar) cents for each assignments * @return JsonNode that Crowdflower returns */ JsonNode orderJob(CrowdJob job, Vector<String> channels, int units, int payPerAssigment) { Log LOG = LogFactory.getLog(getClass()); RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter()); restTemplate.getMessageConverters().add(new FormHttpMessageConverter()); MultiValueMap<String, String> argumentMap = new LinkedMultiValueMap<String, String>(); argumentMap.add(debitKey, String.valueOf(units)); for (String channel : channels) { argumentMap.add(channelKey + "[]", channel); } updateVariable(job, jobPaymentKey, String.valueOf(payPerAssigment)); LOG.info("Order Job: #" + job.getId() + " with " + units + " judgments for " + payPerAssigment + " cents (dollar) per assigment."); JsonNode result = restTemplate.postForObject(orderJobURL, argumentMap, JsonNode.class, job.getId(), apiKey); return result; }
From source file:com.tecapro.inventory.common.util.LogUtil.java
/** * /*from w w w . j av a 2 s. c om*/ * End log output * * @param log * @param clazz * @param method * @param time */ @SuppressWarnings("resource") public void endLog(Log log, String clazz, String method, InfoValue info, long time) { long totalMemory = Runtime.getRuntime().totalMemory(); long freeMemory = Runtime.getRuntime().freeMemory(); Integer level = LOG_LEVEL.get(Thread.currentThread()); if (level != null) { level -= 1; } else { level = 0; } if (level == 0) { LOG_LEVEL.remove(Thread.currentThread()); } else { LOG_LEVEL.put(Thread.currentThread(), level); } Formatter formatter = new Formatter(new StringBuffer()); log.info(returnLogString(clazz, method, info, LogPrefix.END, new StringBuffer().append(totalMemory - freeMemory).append(",").append(totalMemory).append(",") .append(formatter.format("%.3f", (System.nanoTime() - time) / 1000000.0D)).append("ms") .toString())); }
From source file:gov.nih.nci.cabig.caaers.tools.logging.CaaersLoggingAspect.java
@Around("execution(public * gov.nih.nci.cabig.caaers.api.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.api.impl.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.dao..*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.domain.repository.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.domain.repository.ajax.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.service..*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.validation..*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.workflow..*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.rules.business.service.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.rules.runtime.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.web.ae.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.web.study.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.web.admin.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.web.rule.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.web.participant.*.*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.tools.Excel*.*(..))") public Object log(ProceedingJoinPoint call) throws Throwable { Log logger = (call.getTarget() == null) ? LogFactory.getLog(CaaersLoggingAspect.class) : LogFactory.getLog(call.getTarget().getClass()); //just proceed to call if Info is not enabled. if (logger == null || !logger.isInfoEnabled()) return call.proceed(); boolean traceEnabled = logger.isTraceEnabled(); String userName = ""; if (traceEnabled) { userName = "[" + getUserLoginName() + "] - "; log(logger, true, call, null, 0, userName); }/*from w w w. j a v a2 s . co m*/ long startTime = System.currentTimeMillis(); //proceed with the call Object point = call.proceed(); long endTime = System.currentTimeMillis(); long executionTime = (endTime - startTime); if (executionTime > 500) { logger.info(userName + "More than 500ms [ " + call.toShortString() + " executionTime : " + executionTime + "]"); } if (traceEnabled) { log(logger, false, call, point, executionTime, userName); } return point; }
From source file:hotbeans.support.FileSystemHotBeanModuleRepository.java
/** * Loads a module.//from w ww . j a v a 2 s .c o m */ protected HotBeanModuleInfo loadModule(final String moduleName, final long revision) throws Exception { Log logger = this.getLog(); if (logger.isInfoEnabled()) logger.info("Loading module '" + moduleName + "', revision " + revision + "."); File moduleDirectory = new File(this.moduleRepositoryDirectory, moduleName); File moduleFile = new File(moduleDirectory, revision + MODULE_FILE_SUFFIX); File tempDir = new File(this.temporaryDirectory, moduleName + "." + revision); Manifest manifest = ModuleManifestUtils.readManifest(moduleFile); // Get version from mainfest String version = ModuleManifestUtils.getVersion(manifest); if ((version == null) || (version.trim().length() == 0)) version = "n/a"; // Get description from mainfest String description = ModuleManifestUtils.getDescription(manifest); HotBeanModuleInfo hotBeanModuleInfo = new HotBeanModuleInfo(moduleName, description, revision, version, moduleFile.lastModified()); HotBeanModuleLoader hotBeanModuleLoader = null; HotBeanContext hotBeanContext = null; String errorReason = null; HotBeanModule hotBeanModule = null; try { // Create loader hotBeanModuleLoader = super.createHotBeanModuleLoader(moduleFile, tempDir); // Create context hotBeanContext = super.createHotBeanContext(this, manifest, hotBeanModuleLoader.getClassLoader()); if ((hotBeanContext instanceof ConfigurableApplicationContext) && (this.parentApplicationContext != null)) { if (logger.isInfoEnabled()) logger.info("Setting parent Spring ApplicationContext for HotBeanContext(" + hotBeanContext + ") of module '" + moduleName + "', revision " + revision + "."); ((ConfigurableApplicationContext) hotBeanContext).setParent(this.parentApplicationContext); } // Initialize context hotBeanContext.init(); // Create module hotBeanModule = super.createHotBeanModule(hotBeanModuleInfo, hotBeanModuleLoader, hotBeanContext); // Init loader hotBeanModuleLoader.init(hotBeanModule); } catch (Exception e) { hotBeanModuleLoader = null; hotBeanContext = null; hotBeanModule = null; errorReason = e.getMessage(); logger.error( "Error loading module '" + moduleName + "', revision " + revision + " - " + errorReason + "!", e); } if (hotBeanModule == null) { hotBeanModule = super.createHotBeanModule(hotBeanModuleInfo); hotBeanModule.setError(errorReason); } // Register HotBeanModule super.registerHotBeanModule(hotBeanModule); if ((hotBeanContext != null) && logger.isInfoEnabled()) logger.info("Module '" + moduleName + "', revision " + revision + " loaded."); return hotBeanModuleInfo; }