Skip to content

Commit

Permalink
AS7-5112 - log if deprecated attributes are used
Browse files Browse the repository at this point in the history
  • Loading branch information
ctomc authored and bstansberry committed Oct 1, 2012
1 parent 42b7377 commit 724818c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Expand Up @@ -210,6 +210,9 @@ public ModelNode validateOperation(final ModelNode operationObject) throws Opera
* @throws OperationFailedException if the value is not valid
*/
public final void validateAndSet(ModelNode operationObject, final ModelNode model) throws OperationFailedException {
if (isDeprecated()){
ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName());
}
final ModelNode newValue = correctValue(operationObject.get(name), model.get(name));
if (!newValue.equals(operationObject.get(name))) {
operationObject.get(name).set(newValue);
Expand Down
Expand Up @@ -27,17 +27,15 @@

import java.io.Closeable;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Set;

import javax.xml.stream.XMLStreamWriter;

import org.jboss.dmr.ModelNode;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.Logger;
import org.jboss.logging.Logger.Level;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;

Expand Down Expand Up @@ -76,6 +74,11 @@ public interface ControllerLogger extends BasicLogger {
*/
ControllerLogger SERVER_MANAGEMENT_LOGGER = Logger.getMessageLogger(ControllerLogger.class, "org.jboss.server.management");

/**
* A logger for logging deprecated resources usage
*/
ControllerLogger DEPRECATED_LOGGER = Logger.getMessageLogger(ControllerLogger.class, ControllerLogger.class.getPackage().getName() + ".management-deprecated");

/**
* Logs a warning message indicating the address, represented by the {@code address} parameter, could not be
* resolved, so cannot match it to any InetAddress.
Expand Down Expand Up @@ -388,4 +391,8 @@ public interface ControllerLogger extends BasicLogger {
@LogMessage(level = Level.WARN)
@Message(id = 14626, value = "Operation was interrupted before stability could be reached")
void interruptedWaitingStability();

@LogMessage(level = Level.INFO)
@Message(id = 14627, value = "Attribute %s is deprecated, and it might be removed in future version!")
void attributeDeprecated(String name);
}
Expand Up @@ -268,6 +268,9 @@ public void marshallAsAttribute(final ModelNode resourceModel, final XMLStreamWr
* @throws javax.xml.stream.XMLStreamException if {@code writer} throws an exception
*/
public void marshallAsAttribute(final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException {
if (isDeprecated()) {
ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName());
}
attributeMarshaller.marshallAsAttribute(this,resourceModel,marshallDefault,writer);
}

Expand All @@ -277,11 +280,16 @@ public void marshallAsAttribute(final ModelNode resourceModel, final boolean mar
* This implementation marshalls the attribute value as text content of the element.
*/
public void marshallAsElement(final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException {
if (isDeprecated()) {
ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName());
}
attributeMarshaller.marshallAsElement(this,resourceModel,marshallDefault,writer);
}

private ModelNode parse(final String value) throws OperationFailedException {

if (isDeprecated()) {
ControllerLogger.DEPRECATED_LOGGER.attributeDeprecated(getName());
}
final String trimmed = value == null ? null : value.trim();
ModelNode node;
if (trimmed != null ) {
Expand Down

0 comments on commit 724818c

Please sign in to comment.