use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class AbstractViewRepository method replaceOverridden.
protected void replaceOverridden(View replacementView) {
StopWatch replaceTiming = new Slf4JStopWatch("ViewRepository.replaceOverridden");
HashSet<View> checked = new HashSet<>();
for (View view : getAllInitialized()) {
if (!checked.contains(view)) {
replaceOverridden(view, replacementView, checked);
}
}
replaceTiming.stop();
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class AbstractViewRepository method init.
protected void init() {
StopWatch initTiming = new Slf4JStopWatch("ViewRepository.init." + getClass().getSimpleName());
storage.clear();
readFileNames.clear();
String configName = AppContext.getProperty("cuba.viewsConfig");
if (!StringUtils.isBlank(configName)) {
Element rootElem = DocumentHelper.createDocument().addElement("views");
StrTokenizer tokenizer = new StrTokenizer(configName);
for (String fileName : tokenizer.getTokenArray()) {
addFile(rootElem, fileName);
}
checkDuplicates(rootElem);
for (Element viewElem : Dom4j.elements(rootElem, "view")) {
deployView(rootElem, viewElem, new HashSet<>());
}
}
initTiming.stop();
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class JavaClassLoader method loadClass.
@Override
public Class loadClass(final String fullClassName, boolean resolve) throws ClassNotFoundException {
String containerClassName = StringUtils.substringBefore(fullClassName, "$");
StopWatch loadingWatch = new Slf4JStopWatch("LoadClass");
try {
lock(containerClassName);
Class clazz;
if (!sourceProvider.getSourceFile(containerClassName).exists()) {
clazz = super.loadClass(fullClassName, resolve);
return clazz;
}
CompilationScope compilationScope = new CompilationScope(this, containerClassName);
if (!compilationScope.compilationNeeded()) {
TimestampClass timestampClass = getTimestampClass(fullClassName);
if (timestampClass == null) {
throw new ClassNotFoundException(fullClassName);
}
return timestampClass.clazz;
}
String src;
try {
src = sourceProvider.getSourceString(containerClassName);
} catch (IOException e) {
throw new ClassNotFoundException("Could not load java sources for class " + containerClassName);
}
try {
log.debug("Compiling " + containerClassName);
final DiagnosticCollector<JavaFileObject> errs = new DiagnosticCollector<>();
SourcesAndDependencies sourcesAndDependencies = new SourcesAndDependencies(rootDir, this);
sourcesAndDependencies.putSource(containerClassName, src);
sourcesAndDependencies.collectDependencies(containerClassName);
Map<String, CharSequence> sourcesForCompilation = sourcesAndDependencies.collectSourcesForCompilation(containerClassName);
@SuppressWarnings("unchecked") Map<String, Class> compiledClasses = createCompiler().compile(sourcesForCompilation, errs);
Map<String, TimestampClass> compiledTimestampClasses = wrapCompiledClasses(compiledClasses);
compiled.putAll(compiledTimestampClasses);
linkDependencies(compiledTimestampClasses, sourcesAndDependencies.dependencies);
clazz = compiledClasses.get(fullClassName);
springBeanLoader.updateContext(compiledClasses.values());
return clazz;
} catch (Exception e) {
proxyClassLoader.restoreRemoved();
throw new RuntimeException(e);
} finally {
proxyClassLoader.cleanupRemoved();
}
} finally {
unlock(containerClassName);
loadingWatch.stop();
}
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class DesktopTableCellEditor method getCellComponent.
protected Component getCellComponent(int row) {
Entity item = desktopAbstractTable.getTableModel().getItem(row);
StopWatch sw = new Slf4JStopWatch("TableColumnGenerator." + desktopAbstractTable.getId());
@SuppressWarnings("unchecked") com.haulmont.cuba.gui.components.Component component = columnGenerator.generateCell(item);
sw.stop();
Component comp;
if (component == null) {
comp = new JLabel("");
} else if (component instanceof Table.PlainTextCell) {
comp = new JLabel(((Table.PlainTextCell) component).getText());
} else {
if (component instanceof BelongToFrame) {
BelongToFrame belongToFrame = (BelongToFrame) component;
if (belongToFrame.getFrame() == null) {
belongToFrame.setFrame(desktopAbstractTable.getFrame());
}
}
component.setParent(desktopAbstractTable);
JComponent jComposition = DesktopComponentsHelper.getComposition(component);
jComposition.putClientProperty(CELL_EDITOR_TABLE, desktopAbstractTable.getComponent());
jComposition.putClientProperty(CELL_COMPONENT, component);
comp = jComposition;
}
cache.put(row, comp);
return comp;
}
use of org.perf4j.slf4j.Slf4JStopWatch in project cuba by cuba-platform.
the class DesktopAbstractTable method packRows.
/**
* Sets the height of each row into the preferred height of the tallest cell in that row.
*/
public void packRows() {
if (!contentRepaintEnabled) {
return;
}
impl.setRowHeight(defaultRowHeight);
for (Column column : columnsOrder) {
if (column.isEditable()) {
impl.setRowHeight(defaultEditableRowHeight);
break;
}
}
if (allColumnsAreInline()) {
return;
}
int preferredRowHeight = -1;
boolean equalsRowHeight = true;
StopWatch sw = new Slf4JStopWatch("DAT packRows " + id);
for (int r = 0; r < impl.getRowCount(); r++) {
int h = getPreferredRowHeight(r);
if (preferredRowHeight == -1) {
preferredRowHeight = h;
} else if (preferredRowHeight != h) {
equalsRowHeight = false;
}
if (impl.getRowHeight(r) != h) {
impl.setRowHeight(r, h);
}
}
if (equalsRowHeight && preferredRowHeight > 0) {
impl.setRowHeight(preferredRowHeight);
}
sw.stop();
}
Aggregations