Skip to content

Commit

Permalink
APPNG-2235 use @slf4j and parameter placeholders (#52)
Browse files Browse the repository at this point in the history
APPNG-2235 use Slf4j and parameter placeholders
  • Loading branch information
madness-inc authored Jan 29, 2019
1 parent 3cca98c commit b8b6050
Show file tree
Hide file tree
Showing 175 changed files with 1,387 additions and 1,337 deletions.
15 changes: 8 additions & 7 deletions appng-api/src/main/java/org/appng/api/RequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import org.appng.api.model.Properties;
import org.appng.api.model.Site;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.extern.slf4j.Slf4j;

/**
*
Expand All @@ -35,9 +35,9 @@
* @author Matthias Müller
*
*/
@Slf4j
public class RequestUtil {

private static Logger logger = LoggerFactory.getLogger(RequestUtil.class);
private static final String SERVER_LOCAL_NAME = "SERVER_LOCAL_NAME";

/**
Expand Down Expand Up @@ -138,7 +138,7 @@ public static PathInfo getPathInfo(Environment env, Site site, String servletPat
Properties platformProperties = env.getAttribute(Scope.PLATFORM, Platform.Environment.PLATFORM_CONFIG);
Properties activeSiteProperties = site.getProperties();

logger.trace("found site '" + site.getName() + "' for request '" + servletPath + "'");
LOGGER.trace("found site '{}' for request '{}'", site.getName(), servletPath);

String repoPath = platformProperties.getString(Platform.Property.REPOSITORY_PATH);
String extension = platformProperties.getString(Platform.Property.JSP_FILE_TYPE);
Expand Down Expand Up @@ -168,7 +168,8 @@ public static PathInfo getPathInfo(Environment env, Site site, String servletPat
* the {@link ServletRequest}
* @param env
* an {@link Environment}
* @return <ul>
* @return
* <ul>
* <li>the IP-address, if {@link VHostMode#IP_BASED} is used (see {@link ServletRequest#getLocalAddr()})
* <li>the value of the request-header {@code SERVER_LOCAL_NAME}, if present. This header has to be added by
* the webserver of choice (usually <a href="http://httpd.apache.org/">Apache httpd</a>), in case a
Expand All @@ -181,7 +182,7 @@ public static String getHostIdentifier(ServletRequest request, Environment env)
Properties platformProperties = env.getAttribute(Scope.PLATFORM, Platform.Environment.PLATFORM_CONFIG);
VHostMode vHostMode = VHostMode.valueOf(platformProperties.getString(Platform.Property.VHOST_MODE));
String hostIdentifier;
logger.trace("hostmode: " + vHostMode);
LOGGER.trace("hostmode: {}", vHostMode);
if (vHostMode.equals(VHostMode.IP_BASED)) {
hostIdentifier = request.getLocalAddr();
} else {
Expand All @@ -193,7 +194,7 @@ public static String getHostIdentifier(ServletRequest request, Environment env)
hostIdentifier = request.getServerName().toLowerCase();
}
}
logger.trace("hostIdentifier: " + hostIdentifier);
LOGGER.trace("hostIdentifier: {}", hostIdentifier);
return hostIdentifier;
}

Expand Down
8 changes: 4 additions & 4 deletions appng-api/src/main/java/org/appng/api/XPathProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
Expand All @@ -51,6 +49,8 @@
import org.w3c.dom.Text;
import org.xml.sax.SAXException;

import lombok.extern.slf4j.Slf4j;

/**
*
* An {@code XPathProcessor} is used the create a {@link Document} from an {@link URL} or {@link InputStream} and then
Expand All @@ -60,9 +60,9 @@
* @author Matthias Müller
*
*/
@Slf4j
public class XPathProcessor {

private static final Logger LOG = LoggerFactory.getLogger(XPathProcessor.class);
private final Document document;
private final XPath xpath;
private Transformer transformer;
Expand Down Expand Up @@ -185,7 +185,7 @@ public void getXml(Node node, OutputStream outputStream) {
try {
transformer.transform(new DOMSource(node), new StreamResult(outputStream));
} catch (TransformerException e) {
LOG.error("error during transformation", e);
LOGGER.error("error during transformation", e);
}
}

Expand Down
8 changes: 4 additions & 4 deletions appng-api/src/main/java/org/appng/api/auth/AuthTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.MessageDigestAlgorithms;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.extern.slf4j.Slf4j;

/**
* This class is used to get different types of digests.
*
* @author Matthias Herlitzius
*/
@Slf4j
public final class AuthTools {

private static final Logger log = LoggerFactory.getLogger(AuthTools.class);
private static final String STRING_FORMAT = "%1$032X";
private static final String SHA1PRNG = "SHA1PRNG";

Expand Down Expand Up @@ -85,7 +85,7 @@ private static byte[] getRandomSaltBytes(int length) {
salt = new byte[length];
random.nextBytes(salt);
} catch (NoSuchAlgorithmException e) {
log.error("error while generting random string.", e);
LOGGER.error("error while generting random string.", e);
}
return salt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.appng.api.Platform;
import org.appng.api.Scope;
import org.appng.api.model.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.extern.slf4j.Slf4j;

/**
* A utility class offering static helper methods to create and retrieve a {@link Sender} and to shutdown
Expand All @@ -37,10 +37,9 @@
* @see Sender
* @see Receiver
*/
@Slf4j
public class Messaging {

private static final Logger LOGGER = LoggerFactory.getLogger(Messaging.class);

/**
* Name of a system property used to identify the node
*/
Expand Down Expand Up @@ -97,7 +96,7 @@ public static String getNodeId(Environment env) {
nodeId);
System.setProperty(APPNG_NODE_ID, nodeId);
} catch (UnknownHostException e) {
LOGGER.warn("error setting system property " + APPNG_NODE_ID, e);
LOGGER.warn(String.format("error setting system property %s", APPNG_NODE_ID), e);
}
}
return nodeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.appng.api.model.Site;
import org.appng.api.support.SiteAwareObjectInputStream;
import org.appng.api.support.SiteClassLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.extern.slf4j.Slf4j;

/**
* Utility class helping to serialize/deserialize {@link Event}s to an {@link OutputStream}/ from an {@link InputStream}
Expand All @@ -41,9 +41,9 @@
*
* @see Event
*/
@Slf4j
public class Serializer {

private static final Logger LOGGER = LoggerFactory.getLogger(Serializer.class);
private Environment environment;
private String nodeId;

Expand Down
15 changes: 7 additions & 8 deletions appng-api/src/main/java/org/appng/api/model/SimpleProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.extern.slf4j.Slf4j;

/**
* Default {@link Property}-implementation
*
* @author Matthias Müller
*
*/
@Slf4j
public class SimpleProperty implements Property, Identifiable<String>, Comparable<Property> {

private static final Logger log = LoggerFactory.getLogger(SimpleProperty.class);

private String value;
private String defaultValue;
private String description;
Expand Down Expand Up @@ -153,7 +152,7 @@ public Integer getInteger() {
try {
return Integer.parseInt(getString());
} catch (NumberFormatException e) {
log.warn("could not convert property '" + getName() + "' to an Integer");
LOGGER.warn("could not convert property '{}' to an Integer", getName());
}
}
return null;
Expand All @@ -164,7 +163,7 @@ public Float getFloat() {
try {
return Float.parseFloat(getString());
} catch (NumberFormatException e) {
log.warn("could not convert property '" + getName() + "' to a Float");
LOGGER.warn("could not convert property '{}' to a Float", getName());
}
}
return null;
Expand All @@ -175,7 +174,7 @@ public Double getDouble() {
try {
return Double.parseDouble(getString());
} catch (NumberFormatException e) {
log.warn("could not convert property '" + getName() + "' to a Double");
LOGGER.warn("could not convert property '{}' to a Double", getName());
}
}
return null;
Expand All @@ -186,7 +185,7 @@ public Boolean getBoolean() {
try {
return "true".equalsIgnoreCase(getString()) || "1".equals(getString());
} catch (Exception e) {
log.warn("could not convert property '" + getName() + "' to a Boolean");
LOGGER.warn("could not convert property '{}' to a Boolean", getName());
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,23 @@
import org.appng.xml.platform.Pages;
import org.appng.xml.platform.Param;
import org.appng.xml.platform.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import lombok.extern.slf4j.Slf4j;

/**
*
* Default {@link ApplicationConfigProvider}-implementation.
*
* @author Matthias Müller
*/
@Slf4j
public class ApplicationConfigProviderImpl implements ApplicationConfigProvider {

private static final String RESOURCE_MAP_KEY_EVENT = "event:";
private static final String RESOURCE_MAP_KEY_PAGE = "page:";
private static final String RESOURCE_MAP_KEY_DATASOURCE = "datasource:";
private static final String RESOURCE_MAP_KEY_APPLICATION_ROOT_CONFIG = "applicationRootConfig";

private static final Logger log = LoggerFactory.getLogger(ApplicationConfigProviderImpl.class);

protected ActionMap actionMap;
protected DataSourceMap datasourceMap;
protected PageMap pageMap;
Expand Down Expand Up @@ -152,10 +151,10 @@ private synchronized void loadConfig(MarshallService marshallService) throws Inv
readData();
}
} catch (Exception e) {
log.error("error while reading configuration", e);
LOGGER.error("error while reading configuration", e);
}
long end = System.currentTimeMillis() - start;
log.debug("loading config for application " + applicationName + " took " + end + "ms");
long duration = System.currentTimeMillis() - start;
LOGGER.debug("loading config for application {} took {}ms", applicationName, duration);
}

private void readResources(MarshallService marshallService) throws IOException, InvalidConfigurationException {
Expand All @@ -171,7 +170,7 @@ private void readResources(MarshallService marshallService) throws IOException,
Object object = marshallService.unmarshall(inputStream);