PL-7505 Do not use apache commons LogFactory

This commit is contained in:
Yuriy Artamonov 2016-07-08 18:50:09 +04:00
parent 385bd3c70b
commit 35146c9d12
16 changed files with 57 additions and 61 deletions

View File

@ -38,8 +38,8 @@ import net.miginfocom.layout.CC;
import net.miginfocom.layout.LC;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
@ -199,7 +199,7 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
if (!this.fields.isEmpty()) {
rows = rowsCount();
} else if (datasource != null) {
LogFactory.getLog(getClass()).warn("Field group does not have fields");
LoggerFactory.getLogger(DesktopFieldGroup.class).warn("Field group does not have fields");
}
assignAutoDebugId();

View File

@ -23,9 +23,9 @@ import com.haulmont.cuba.desktop.App;
import com.haulmont.cuba.desktop.ApplicationSession;
import com.haulmont.cuba.gui.settings.SettingsClient;
import com.haulmont.cuba.security.app.UserSettingService;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.util.Map;
@ -63,14 +63,14 @@ public class DesktopSettingsClient implements SettingsClient {
@Override
public void deleteSettings(String name) {
getCache().put(name, Optional.<String>absent());
getCache().put(name, Optional.absent());
userSettingService.deleteSettings(ClientType.DESKTOP, name);
}
protected Map<String, Optional<String>> getCache() {
ApplicationSession session = App.getInstance().getApplicationSession();
if (session == null) {
LogFactory.getLog(getClass()).warn("Application disconnected, used fake empty session");
LoggerFactory.getLogger(DesktopSettingsClient.class).warn("Application disconnected, used fake empty session");
return new ConcurrentHashMap<>();
}

View File

@ -28,8 +28,8 @@ import com.haulmont.cuba.security.global.UserSession;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang.text.StrBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
@ -40,16 +40,16 @@ import java.util.*;
@Component("cuba_ConfigStorageCommon")
public class ConfigStorageCommon {
private final Logger log = LoggerFactory.getLogger(ConfigStorageCommon.class);
@Inject
protected Configuration configuration;
@Inject
protected LoginService loginService;
protected final Log log = LogFactory.getLog(ConfigStorageCommon.class);
public String printAppProperties(String prefix) {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
for (String name : AppContext.getPropertyNames()) {
if (prefix == null || name.startsWith(prefix)) {
list.add(name + "=" + AppContext.getProperty(name));

View File

@ -17,7 +17,6 @@
package com.haulmont.cuba.core.sys.jmx;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jmx.support.MBeanRegistrationSupport;
@ -34,11 +33,10 @@ import java.util.Map;
* if it complies to MyObject -> MyObjectMBean naming scheme.
* <br/>
* Instead it uses {@link AnnotationMBeanInfoAssembler} to construct MBean descriptor for every bean.
*
*/
public class MBeanExporter extends org.springframework.jmx.export.MBeanExporter {
private Logger log = LoggerFactory.getLogger(MBeanExporter.class);
private final Logger log = LoggerFactory.getLogger(MBeanExporter.class);
public MBeanExporter() {
setAssembler(new AnnotationMBeanInfoAssembler());
@ -46,7 +44,7 @@ public class MBeanExporter extends org.springframework.jmx.export.MBeanExporter
try {
Field loggerField = MBeanRegistrationSupport.class.getDeclaredField("logger");
loggerField.setAccessible(true);
loggerField.set(this, LogFactory.getLog(org.springframework.jmx.export.MBeanExporter.class));
loggerField.set(this, LoggerFactory.getLogger(org.springframework.jmx.export.MBeanExporter.class));
} catch (NoSuchFieldException | IllegalAccessException ignore) {
}
}

View File

@ -40,7 +40,8 @@ import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.security.entity.EntityAttrAccess;
import com.haulmont.cuba.security.entity.EntityOp;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import java.util.*;
@ -601,9 +602,9 @@ public class BulkEditorWindow extends AbstractWindow {
Set<Entity> commited = dataSupplier.commit(new CommitContext(items));
LogFactory.getLog(getClass()).info(String.format(
"Applied bulk editing for %s entries of %s. Changed properties: %s",
commited.size(), metaClass, StringUtils.join(fields, ", ")));
Logger logger = LoggerFactory.getLogger(BulkEditorWindow.class);
logger.info("Applied bulk editing for {} entries of {}. Changed properties: {}",
commited.size(), metaClass, StringUtils.join(fields, ", "));
showNotification(formatMessage("bulk.successMessage", commited.size()), NotificationType.HUMANIZED);
close(COMMIT_ACTION_ID);

View File

@ -37,7 +37,7 @@ import com.haulmont.cuba.gui.data.DataSupplier;
import com.haulmont.cuba.gui.data.impl.DatasourceImplementation;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.util.Collection;
@ -238,7 +238,7 @@ public interface PickerField extends Field, Component.ActionsHolder {
WindowManager wm;
Window window = ComponentsHelper.getWindow(pickerField);
if (window == null) {
LogFactory.getLog(PickerField.class).warn("Please specify Frame for PickerField");
LoggerFactory.getLogger(PickerField.class).warn("Please specify Frame for PickerField");
wm = AppBeans.get(WindowManagerProvider.class).get();
} else {

View File

@ -27,7 +27,7 @@ import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.PropertyDatasource;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
@ -53,7 +53,7 @@ public class CollectionDsHelper {
"Specified transient property %s in view for datasource with persistent entity %s",
name, metaClass.getName());
LogFactory.getLog(CollectionDsHelper.class).warn(message);
LoggerFactory.getLogger(CollectionDsHelper.class).warn(message);
continue;
}
@ -76,9 +76,9 @@ public class CollectionDsHelper {
}
} else {
if (view != null) {
String message = String.format("Specified view %s for datasource with not persistent entity %s",
view.getName(), metaClass.getName());
LogFactory.getLog(CollectionDsHelper.class).warn(message);
LoggerFactory.getLogger(CollectionDsHelper.class).
warn("Specified view {} for datasource with not persistent entity {}",
view.getName(), metaClass.getName());
}
for (MetaProperty metaProperty : metaClass.getProperties()) {

View File

@ -36,8 +36,8 @@ import com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools;
import com.haulmont.cuba.gui.xml.DeclarativeFieldGenerator;
import com.haulmont.cuba.security.entity.EntityOp;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
import java.util.*;
@ -534,8 +534,8 @@ public class FieldGroupLoader extends AbstractComponentLoader<FieldGroup> {
loadEnable(resultComponent, field);
loadVisible(resultComponent, field);
} else {
LogFactory.getLog(FieldGroupLoader.class).warn(
"Missing component for custom field " + field.getId());
LoggerFactory.getLogger(FieldGroupLoader.class).warn(
"Missing component for custom field {}", field.getId());
}
}
}

View File

@ -23,8 +23,8 @@ import com.haulmont.cuba.gui.xml.layout.ComponentLoader;
import com.haulmont.cuba.gui.xml.layout.LayoutLoader;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
import java.util.*;
@ -187,7 +187,7 @@ public class GridLayoutLoader extends ContainerLoader<GridLayout> {
context.getFullFrameId(), "colspan", cspan);
}
if (cspan == 1) {
LogFactory.getLog(getClass()).warn("Do not use colspan=\"1\", it will have no effect");
LoggerFactory.getLogger(GridLayoutLoader.class).warn("Do not use colspan=\"1\", it will have no effect");
}
}
@ -198,7 +198,7 @@ public class GridLayoutLoader extends ContainerLoader<GridLayout> {
context.getFullFrameId(), "rowspan", rspan);
}
if (rspan == 1) {
LogFactory.getLog(getClass()).warn("Do not use rowspan=\"1\", it will have no effect");
LoggerFactory.getLogger(GridLayoutLoader.class).warn("Do not use rowspan=\"1\", it will have no effect");
}
}

View File

@ -19,7 +19,10 @@ package com.haulmont.cuba.web.gui.components;
import com.haulmont.cuba.gui.ComponentsHelper;
import com.haulmont.cuba.gui.TestIdManager;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.components.Accordion;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.Frame;
import com.haulmont.cuba.gui.components.Window;
import com.haulmont.cuba.gui.data.impl.DsContextImplementation;
import com.haulmont.cuba.gui.settings.Settings;
import com.haulmont.cuba.gui.xml.layout.ComponentLoader;
@ -28,8 +31,8 @@ import com.haulmont.cuba.web.AppWindow;
import com.haulmont.cuba.web.toolkit.ui.CubaAccordion;
import com.vaadin.ui.Layout;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -414,7 +417,7 @@ public class WebAccordion extends WebAbstractComponent<CubaAccordion> implements
if (window != null) {
((DsContextImplementation) window.getDsContext()).resumeSuspended();
} else {
LogFactory.getLog(WebAccordion.class).warn("Please specify Frame for Accordion");
LoggerFactory.getLogger(WebAccordion.class).warn("Please specify Frame for Accordion");
}
});
componentTabChangeListenerInitialized = true;

View File

@ -43,13 +43,14 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.lang.reflect.Field;
public class WebComponentsHelper {
@ -86,7 +87,7 @@ public class WebComponentsHelper {
return resource;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LogFactory.getLog(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon);
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon);
}
}
@ -95,7 +96,7 @@ public class WebComponentsHelper {
try {
return getFontIconResource(resURL);
} catch (NoSuchFieldException | IllegalAccessException e) {
LogFactory.getLog(WebComponentsHelper.class).warn("Unable to use font icon " + resURL);
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + resURL);
}
return null;
} else {
@ -484,7 +485,7 @@ public class WebComponentsHelper {
return resource;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LogFactory.getLog(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon);
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon {}", fontIcon);
}
}
return new VersionedThemeResource(iconName);

View File

@ -34,8 +34,8 @@ import com.haulmont.cuba.web.toolkit.ui.CubaFieldGroupLayout;
import com.haulmont.cuba.web.toolkit.ui.CubaFieldWrapper;
import com.vaadin.ui.AbstractComponent;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
import java.util.*;
@ -377,7 +377,7 @@ public class WebFieldGroup extends WebAbstractComponent<CubaFieldGroup> implemen
if (!this.fields.isEmpty()) {
component.setRows(rowsCount());
} else if (datasource != null) {
LogFactory.getLog(getClass()).warn("Field group does not have fields");
LoggerFactory.getLogger(WebFieldGroup.class).warn("Field group does not have fields");
}
assignAutoDebugId();

View File

@ -20,9 +20,6 @@ import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.ComponentsHelper;
import com.haulmont.cuba.gui.TestIdManager;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.TabSheet;
import com.haulmont.cuba.gui.components.Window;
import com.haulmont.cuba.gui.data.impl.DsContextImplementation;
import com.haulmont.cuba.gui.settings.Settings;
import com.haulmont.cuba.gui.xml.layout.ComponentLoader;
@ -30,10 +27,10 @@ import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.web.AppUI;
import com.haulmont.cuba.web.AppWindow;
import com.haulmont.cuba.web.toolkit.ui.CubaTabSheet;
import com.vaadin.ui.*;
import com.vaadin.ui.Layout;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -451,7 +448,7 @@ public class WebTabSheet extends WebAbstractComponent<CubaTabSheet> implements T
if (window != null) {
((DsContextImplementation) window.getDsContext()).resumeSuspended();
} else {
LogFactory.getLog(WebTabSheet.class).warn("Please specify Frame for TabSheet");
LoggerFactory.getLogger(WebTabSheet.class).warn("Please specify Frame for TabSheet");
}
});
componentTabChangeListenerInitialized = true;

View File

@ -19,14 +19,11 @@ package com.haulmont.cuba.web.gui.components.mainwindow;
import com.haulmont.cuba.gui.components.mainwindow.NewWindowButton;
import com.haulmont.cuba.web.gui.components.WebAbstractComponent;
import com.haulmont.cuba.web.gui.components.WebButton;
import com.haulmont.cuba.web.gui.components.WebComponentsHelper;
import com.haulmont.cuba.web.toolkit.ui.CubaButton;
import com.vaadin.server.BrowserWindowOpener;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.Page;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
import java.net.URL;
@ -44,7 +41,7 @@ public class WebNewWindowButton extends WebAbstractComponent<CubaButton> impleme
try {
pageUrl = Page.getCurrent().getLocation().toURL();
} catch (MalformedURLException ignored) {
LogFactory.getLog(getClass()).warn("Couldn't get URL of current Page");
LoggerFactory.getLogger(WebNewWindowButton.class).warn("Couldn't get URL of current Page");
return;
}

View File

@ -22,11 +22,10 @@ import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.xml.layout.ComponentLoader;
import com.haulmont.cuba.gui.xml.layout.LayoutLoaderConfig;
import com.haulmont.cuba.web.gui.WebComponentsFactory;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import java.io.IOException;
@ -38,12 +37,11 @@ import java.util.List;
/**
* Class registers external components that are supplied in separate jars or defined in 'cuba-ui-component.xml'
* descriptor of 'web' module.
*
*/
@org.springframework.stereotype.Component("cuba_ExternalUIComponentsManager")
public class ExternalUIComponentsManager {
protected static final Log log = LogFactory.getLog(ExternalUIComponentsManager.class);
private final Logger log = LoggerFactory.getLogger(ExternalUIComponentsManager.class);
@PostConstruct
public void postConstruct() {
@ -85,13 +83,14 @@ public class ExternalUIComponentsManager {
if (Component.class.isAssignableFrom(componentClass)) {
WebComponentsFactory.registerComponent(name, (Class<? extends Component>) componentClass);
} else {
log.warn("Component " + componentClassName + " is not a subclass of com.haulmont.cuba.gui.components.Component");
log.warn("Component {} is not a subclass of com.haulmont.cuba.gui.components.Component", componentClassName);
}
if (ComponentLoader.class.isAssignableFrom(componentLoaderClass)) {
LayoutLoaderConfig.registerLoader(name, (Class<? extends ComponentLoader>) componentLoaderClass);
} else {
log.warn("Component loader " + componentLoaderClassName + " is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader");
log.warn("Component loader {} is not a subclass of com.haulmont.cuba.gui.xml.layout.ComponentLoader",
componentLoaderClassName);
}
}
}

View File

@ -25,7 +25,7 @@ import com.vaadin.server.ErrorMessage;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomField;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
@ -174,7 +174,7 @@ public class CubaResizableTextAreaWrapper extends CustomField {
if (getState(false).resizable
&& (textArea.getRows() > 0 && textArea.getColumns() > 0
|| isPercentageSize())) {
LogFactory.getLog(getClass()).warn(
LoggerFactory.getLogger(CubaResizableTextAreaWrapper.class).warn(
"TextArea with fixed rows and cols or percentage size can not be resizable");
getState().resizable = false;
}