use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class WindowManager method openEditor.
public Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, Map<String, Object> params, Datasource parentDs) {
if (params == null) {
params = Collections.emptyMap();
}
checkCanOpenWindow(windowInfo, openType, params);
Integer hashCode = getHash(windowInfo, params);
String template = windowInfo.getTemplate();
if (openType.getOpenMode() != OpenMode.DIALOG) {
Window existingWindow = getWindow(hashCode);
if (existingWindow != null) {
params = createParametersMap(windowInfo, params);
String caption = loadCaption(existingWindow, params);
String description = loadDescription(existingWindow, params);
showWindow(existingWindow, caption, description, openType, false);
return (Window.Editor) existingWindow;
}
}
params = createParametersMap(windowInfo, params);
WindowParams.ITEM.set(params, item instanceof Datasource ? ((Datasource) item).getItem() : item);
Window window;
if (template != null) {
window = createWindow(windowInfo, openType, params, LayoutLoaderConfig.getEditorLoaders(), false);
} else {
Class windowClass = windowInfo.getScreenClass();
if (windowClass != null) {
window = createWindow(windowInfo, params);
if (!(window instanceof Window.Editor)) {
throw new IllegalStateException(String.format("Class %s does't implement Window.Editor interface", windowClass));
}
} else {
throw new IllegalStateException("Invalid WindowInfo: " + windowInfo);
}
}
((Window.Editor) window).setParentDs(parentDs);
StopWatch setItemWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.SET_ITEM, LoggerFactory.getLogger(UIPerformanceLogger.class));
((Window.Editor) window).setItem(item);
setItemWatch.stop();
String caption = loadCaption(window, params);
String description = loadDescription(window, params);
showWindow(window, caption, description, openType, false);
userActionsLog.trace("Editor {} was opened", windowInfo.getId());
return (Window.Editor) window;
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class WindowManager method createWindow.
protected Window createWindow(WindowInfo windowInfo, Map<String, Object> params) {
Window window;
try {
window = (Window) windowInfo.getScreenClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Unable to instantiate window class", e);
}
window.setId(windowInfo.getId());
window.setWindowManager(this);
init(window, params);
StopWatch uiPermissionsWatch = new Slf4JStopWatch(windowInfo.getId() + "#" + LifeCycle.UI_PERMISSIONS, LoggerFactory.getLogger(UIPerformanceLogger.class));
// apply ui permissions
WindowCreationHelper.applyUiPermissions(window);
uiPermissionsWatch.stop();
return window;
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class MenuCommand method execute.
public void execute() {
StopWatch sw = new Slf4JStopWatch("MenuItem." + item.getId());
command.run();
sw.stop();
}
use of org.perf4j.slf4j.Slf4JStopWatch 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.slf4j.Slf4JStopWatch 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();
}
Aggregations