use of org.perf4j.StopWatch in project cuba by cuba-platform.
the class CollectionDatasourceImpl method loadData.
/**
* Load data from middleware into {@link #data} field.
* <p>In case of error sets {@link #dataLoadError} field to the exception object.</p>
* @param params datasource parameters, as described in {@link CollectionDatasource#refresh(java.util.Map)}
*/
protected void loadData(Map<String, Object> params) {
Security security = AppBeans.get(Security.NAME);
if (!security.isEntityOpPermitted(metaClass, EntityOp.READ)) {
return;
}
String tag = getLoggingTag("CDS");
StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
if (needLoading()) {
LoadContext context = beforeLoadData(params);
if (context == null) {
return;
}
try {
final Collection<T> entities = dataSupplier.loadList(context);
afterLoadData(params, context, entities);
} catch (Throwable e) {
dataLoadError = e;
}
}
sw.stop();
}
use of org.perf4j.StopWatch in project cuba by cuba-platform.
the class ValueCollectionDatasourceImpl method loadData.
@Override
protected void loadData(Map<String, Object> params) {
String tag = getLoggingTag("VDS");
StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
delegate.loadData(params);
sw.stop();
}
use of org.perf4j.StopWatch in project cuba by cuba-platform.
the class AbstractMessages method searchFiles.
protected String searchFiles(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
StopWatch stopWatch = new Slf4JStopWatch("Messages.searchFiles");
try {
String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale);
String msg = strCache.get(cacheKey);
if (msg != null)
return msg;
log.trace("searchFiles: {}", cacheKey);
String packPath = confDir + "/" + pack.replaceAll("\\.", "/");
while (packPath != null && !packPath.equals(confDir)) {
Properties properties = loadPropertiesFromFile(packPath, locale, truncatedLocale);
if (properties != PROPERTIES_NOT_FOUND) {
msg = getMessageFromProperties(pack, key, locale, truncatedLocale, properties, passedPacks);
if (msg != null)
return msg;
}
// not found, keep searching
int pos = packPath.lastIndexOf("/");
if (pos < 0)
packPath = null;
else
packPath = packPath.substring(0, pos);
}
return null;
} finally {
stopWatch.stop();
}
}
use of org.perf4j.StopWatch in project cuba by cuba-platform.
the class AbstractMessages method searchClasspath.
protected String searchClasspath(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
StopWatch stopWatch = new Slf4JStopWatch("Messages.searchClasspath");
try {
String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale);
String msg = strCache.get(cacheKey);
if (msg != null)
return msg;
log.trace("searchClasspath: {}", cacheKey);
String packPath = "/" + pack.replaceAll("\\.", "/");
while (packPath != null) {
Properties properties = loadPropertiesFromResource(packPath, locale, truncatedLocale);
if (properties != PROPERTIES_NOT_FOUND) {
msg = getMessageFromProperties(pack, key, locale, truncatedLocale, properties, passedPacks);
if (msg != null)
return msg;
}
// not found, keep searching
int pos = packPath.lastIndexOf("/");
if (pos < 0)
packPath = null;
else
packPath = packPath.substring(0, pos);
}
return null;
} finally {
stopWatch.stop();
}
}
use of org.perf4j.StopWatch in project cuba by cuba-platform.
the class MetadataLoader method replaceExtendedMetaClasses.
protected void replaceExtendedMetaClasses() {
StopWatch sw = new Slf4JStopWatch("Metadata.replaceExtendedMetaClasses");
for (MetaModel model : session.getModels()) {
MetaModelImpl modelImpl = (MetaModelImpl) model;
List<Pair<MetaClass, MetaClass>> replaceMap = new ArrayList<>();
for (MetaClass metaClass : modelImpl.getClasses()) {
MetaClass effectiveMetaClass = session.getClass(extendedEntities.getEffectiveClass(metaClass));
if (effectiveMetaClass != metaClass) {
replaceMap.add(new Pair<>(metaClass, effectiveMetaClass));
}
for (MetaProperty metaProperty : metaClass.getOwnProperties()) {
MetaPropertyImpl propertyImpl = (MetaPropertyImpl) metaProperty;
// replace domain
Class effectiveDomainClass = extendedEntities.getEffectiveClass(metaProperty.getDomain());
MetaClass effectiveDomainMeta = session.getClass(effectiveDomainClass);
if (metaProperty.getDomain() != effectiveDomainMeta) {
propertyImpl.setDomain(effectiveDomainMeta);
}
if (metaProperty.getRange().isClass()) {
// replace range class
ClassRange range = (ClassRange) metaProperty.getRange();
Class effectiveRangeClass = extendedEntities.getEffectiveClass(range.asClass());
MetaClass effectiveRangeMeta = session.getClass(effectiveRangeClass);
if (effectiveRangeMeta != range.asClass()) {
ClassRange newRange = new ClassRange(effectiveRangeMeta);
newRange.setCardinality(range.getCardinality());
newRange.setOrdered(range.isOrdered());
((MetaPropertyImpl) metaProperty).setRange(newRange);
}
}
}
}
for (Pair<MetaClass, MetaClass> replace : replaceMap) {
MetaClass replacedMetaClass = replace.getFirst();
extendedEntities.registerReplacedMetaClass(replacedMetaClass);
MetaClassImpl effectiveMetaClass = (MetaClassImpl) replace.getSecond();
modelImpl.registerClass(replacedMetaClass.getName(), replacedMetaClass.getJavaClass(), effectiveMetaClass);
}
}
sw.stop();
}
Aggregations