use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class FoldersServiceBean method loadAppFolders.
@Override
public List<AppFolder> loadAppFolders() {
log.debug("Loading AppFolders");
StopWatch stopWatch = new Slf4JStopWatch("AppFolders");
stopWatch.start();
List<AppFolder> resultList;
try (Transaction tx = persistence.createTransaction()) {
String metaClassName = metadata.getExtendedEntities().getEffectiveMetaClass(AppFolder.class).getName();
TypedQuery<AppFolder> q = persistence.getEntityManager().createQuery("select f from " + metaClassName + " f order by f.sortOrder, f.name", AppFolder.class);
resultList = q.getResultList();
// fetch parent folder
resultList.forEach(Folder::getParent);
tx.commit();
} finally {
stopWatch.stop();
}
if (CollectionUtils.isNotEmpty(resultList)) {
Binding binding = new Binding();
binding.setVariable("persistence", persistence);
binding.setVariable("metadata", metadata);
binding.setVariable("userSession", userSessionSource.getUserSession());
Iterator<AppFolder> iterator = resultList.iterator();
while (iterator.hasNext()) {
AppFolder folder = iterator.next();
try (Transaction tx = persistence.createTransaction()) {
boolean evaluatedVisibilityScript = true;
try {
if (!StringUtils.isBlank(folder.getVisibilityScript())) {
binding.setVariable("folder", folder);
Boolean visible = runScript(folder.getVisibilityScript(), binding);
if (BooleanUtils.isFalse(visible)) {
iterator.remove();
continue;
}
}
} catch (Exception e) {
log.warn("Unable to evaluate AppFolder visibility script for folder: id: {} name: {}", folder.getId(), folder.getName(), e);
// because EclipseLink Query marks transaction as rollback-only on JPQL syntax errors
evaluatedVisibilityScript = false;
}
boolean evaluatedQuantityScript = loadFolderQuantity(binding, folder);
if (evaluatedVisibilityScript && evaluatedQuantityScript) {
tx.commit();
}
}
}
}
return resultList;
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class FoldersServiceBean method reloadAppFolders.
@Override
public List<AppFolder> reloadAppFolders(List<AppFolder> folders) {
log.debug("Reloading AppFolders {}", folders);
StopWatch stopWatch = new Slf4JStopWatch("AppFolders");
stopWatch.start();
try {
if (!folders.isEmpty()) {
Binding binding = new Binding();
binding.setVariable("persistence", persistence);
binding.setVariable("metadata", metadata);
binding.setProperty("userSession", userSessionSource.getUserSession());
for (AppFolder folder : folders) {
Transaction tx = persistence.createTransaction();
try {
if (loadFolderQuantity(binding, folder)) {
tx.commit();
}
} finally {
tx.end();
}
}
}
return folders;
} finally {
stopWatch.stop();
}
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class WindowManager method afterShowWindow.
protected void afterShowWindow(Window window) {
if (!WindowParams.DISABLE_APPLY_SETTINGS.getBool(window.getContext())) {
window.applySettings(getSettingsImpl(window.getId()));
}
if (!WindowParams.DISABLE_RESUME_SUSPENDED.getBool(window.getContext())) {
((DsContextImplementation) window.getDsContext()).resumeSuspended();
}
if (window instanceof AbstractWindow) {
AbstractWindow abstractWindow = (AbstractWindow) window;
if (abstractWindow.isAttributeAccessControlEnabled()) {
AttributeAccessSupport attributeAccessSupport = AppBeans.get(AttributeAccessSupport.NAME);
attributeAccessSupport.applyAttributeAccess(abstractWindow, false);
}
StopWatch readyStopWatch = new Slf4JStopWatch(window.getId() + "#" + LifeCycle.READY, LoggerFactory.getLogger(UIPerformanceLogger.class));
abstractWindow.ready();
readyStopWatch.stop();
}
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class WindowManager method init.
protected void init(Window window, Map<String, Object> params) {
if (window instanceof AbstractWindow) {
StopWatch initStopWatch = new Slf4JStopWatch(window.getId() + "#" + LifeCycle.INIT, LoggerFactory.getLogger(UIPerformanceLogger.class));
((AbstractWindow) window).init(params);
initStopWatch.stop();
}
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class WindowManager method initWrapperFrame.
protected void initWrapperFrame(Window wrappingWindow, ComponentLoaderContext context, Element element, Map<String, Object> params) {
if (wrappingWindow instanceof AbstractWindow) {
Element companionsElem = element.element("companions");
if (companionsElem != null) {
StopWatch companionStopWatch = new Slf4JStopWatch(wrappingWindow.getId() + "#" + LifeCycle.COMPANION, LoggerFactory.getLogger(UIPerformanceLogger.class));
initCompanion(companionsElem, (AbstractWindow) wrappingWindow);
companionStopWatch.stop();
}
}
StopWatch injectStopWatch = new Slf4JStopWatch(wrappingWindow.getId() + "#" + LifeCycle.INJECTION, LoggerFactory.getLogger(UIPerformanceLogger.class));
ControllerDependencyInjector dependencyInjector = AppBeans.getPrototype(ControllerDependencyInjector.NAME, wrappingWindow, params);
dependencyInjector.inject();
injectStopWatch.stop();
context.executeInjectTasks();
context.executePostWrapTasks();
init(wrappingWindow, params);
context.executeInitTasks();
}
Aggregations