Skip to content

Commit

Permalink
Don't use deprecated apis & code cleanup
Browse files Browse the repository at this point in the history
 get rid of bunch of compiler warnings
  • Loading branch information
ctomc authored and bstansberry committed Jan 14, 2013
1 parent 45ad80a commit 3a81ca0
Show file tree
Hide file tree
Showing 89 changed files with 540 additions and 1,385 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*
* @author Tomaz Cerar
*/
@SuppressWarnings("unchecked")
public abstract class AbstractAttributeDefinitionBuilder<BUILDER extends AbstractAttributeDefinitionBuilder, ATTRIBUTE extends AttributeDefinition> {

protected final String name;
Expand Down Expand Up @@ -133,7 +134,7 @@ public BUILDER setValidator(ParameterValidator validator) {
* by the {@link org.jboss.as.controller.AttributeDefinition} and instead let operation handlers validate using more complex logic
* (e.g. checking for {@link #setAlternatives(String...) alternatives}.
*
* @param validateNull {@code true} if additional validation should be performed; {@false} otherwise
* @param validateNull {@code true} if additional validation should be performed; {@code false} otherwise
*/
public BUILDER setValidateNull(boolean validateNull) {
this.validateNull = validateNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private static int getBootStackSize() {
* @param prepareStep the prepare step to prepend to operation execution
* @param expressionResolver the expression resolver
*/
@Deprecated
protected AbstractControllerService(final ProcessType processType, final RunningModeControl runningModeControl,
final ConfigurationPersister configurationPersister,
final ControlledProcessState processState, final DescriptionProvider rootDescriptionProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@SuppressWarnings("deprecation")
abstract class AbstractOperationContext implements OperationContext {

static final ThreadLocal<Thread> controllingThread = new ThreadLocal<Thread>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@SuppressWarnings("deprecation")
final class OperationContextImpl extends AbstractOperationContext {

private static final Object NULL = new Object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*
* @author Brian Stansberry (c) 2011 Red Hat Inc.
*/
@SuppressWarnings("deprecation")
class ParallelBootOperationContext extends AbstractOperationContext {

private final OperationContext primaryContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
*
* @author <a href="mailto:tomaz.cerar@redhat.com">Tomaz Cerar</a> (c) 2012 Red Hat Inc.
*/
public class NonResolvingResourceDescriptionResolver implements ResourceDescriptionResolver {
public class NonResolvingResourceDescriptionResolver extends StandardResourceDescriptionResolver {
public NonResolvingResourceDescriptionResolver() {
super("", "", NonResolvingResourceDescriptionResolver.class.getClassLoader());
}

@Override
public ResourceBundle getResourceBundle(Locale locale) {
return new ResourceBundle() {
Expand Down Expand Up @@ -113,4 +117,5 @@ public String getOperationDeprecatedDescription(String operationName, Locale loc
public String getOperationParameterDeprecatedDescription(String operationName, String paramName, Locale locale, ResourceBundle bundle) {
return operationName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@
@Deprecated
public class CommonDescriptions {

/**
* default describe operation description,
* here just for binary compatibility with external extensions
* @param locale
* @return
*/
@Deprecated
public static ModelNode getSubsystemDescribeOperation(final Locale locale) {
final ResourceBundle bundle = getResourceBundle(locale);
final ModelNode root = new ModelNode();
root.get(OPERATION_NAME).set(ADD);
root.get(DESCRIPTION).set(bundle.getString("subsystem.describe"));
root.get(REPLY_PROPERTIES, TYPE).set(ModelType.LIST);
root.get(REPLY_PROPERTIES, VALUE_TYPE).set(ModelType.OBJECT);
return root;
}


public static ModelNode getDescriptionOnlyOperation(final ResourceBundle bundle, final String operationName, final String descriptionPrefix) {

final ModelNode node = new ModelNode();
Expand Down Expand Up @@ -130,10 +112,4 @@ public static ModelNode getNoArgSimpleListReplyOperation(final ResourceBundle bu
return result;
}

private static ResourceBundle getResourceBundle(Locale locale) {
if (locale == null) {
locale = Locale.getDefault();
}
return ResourceBundle.getBundle(ControllerResolver.RESOURCE_NAME, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.dmr.ModelNode;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
Expand All @@ -41,13 +42,6 @@ public class ExtensionAddHandler implements OperationStepHandler {

public static final String OPERATION_NAME = ADD;

public static ModelNode getAddExtensionOperation(ModelNode address) {
ModelNode op = new ModelNode();
op.get(OP).set(OPERATION_NAME);
op.get(OP_ADDR).set(address);
return op;
}

private final ExtensionRegistry extensionRegistry;
private final boolean parallelBoot;
private final boolean standalone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void performRemove(OperationContext context, ModelNode operation, Mode
super.performRemove(context, operation, model);
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
String module = address.getLastElement().getValue();
extensionRegistry.removeExtension(context.getRootResource(), module);
extensionRegistry.removeExtension(context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS), module);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Map<NetworkInterface, Set<InetAddress>> getAcceptableAddresses(final Map<
Map<NetworkInterface, Set<InetAddress>> result = new HashMap<NetworkInterface, Set<InetAddress>>();
for (Map.Entry<NetworkInterface, Set<InetAddress>> entry : candidates.entrySet()) {
NetworkInterface ni = entry.getKey();
HashSet addresses = null;
HashSet<InetAddress> addresses = null;
for (InetAddress address : entry.getValue()) {
InetAddress accepted = isAcceptable(ni, address);
if (accepted != null) {
Expand All @@ -87,22 +87,4 @@ public static Map<NetworkInterface, Set<InetAddress>> cloneCandidates(final Map<
}
return clone;
}

/**
* A little toString utility for NetworkInterface since its version seems to add the hardware address and this corrupts
* logging output.
*
* @param iface The interface to convert to string format.
* @return toString for NetworkInterface
*/
static String toString(NetworkInterface iface) {
StringBuilder sb = new StringBuilder("NetworkInterface(");
sb.append("name:");
sb.append(iface.getName());
sb.append("(");
sb.append(iface.getDisplayName());
sb.append("), addresses:");
sb.append(iface.getInterfaceAddresses());
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@
public class InterfaceAddHandler extends AbstractAddStepHandler {


@Deprecated
public static ModelNode getAddInterfaceOperation(ModelNode address, ModelNode criteria) {
ModelNode op = Util.getEmptyOperation(ADD, address);
for (final AttributeDefinition def : InterfaceDefinition.ROOT_ATTRIBUTES) {
if(criteria.hasDefined(def.getName())) {
op.get(def.getName()).set(criteria.get(def.getName()));
}
}
return op;
}

public static final InterfaceAddHandler NAMED_INSTANCE = new InterfaceAddHandler(false);
public static final InterfaceAddHandler SPECIFIED_INSTANCE = new InterfaceAddHandler(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ public class SocketBindingAddHandler extends AbstractAddStepHandler {

public static final String OPERATION_NAME = ADD;

public static ModelNode getOperation(ModelNode address, ModelNode socketBinding) {
ModelNode op = new ModelNode();
op.get(OP).set(OPERATION_NAME);
op.get(OP_ADDR).set(address);
public static ModelNode getOperation(PathAddress address, ModelNode socketBinding) {
ModelNode op = Util.createAddOperation(address);
if (socketBinding.get(INTERFACE).isDefined()) {
op.get(INTERFACE).set(socketBinding.get(INTERFACE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class WriteAttributeHandlers {

/** @deprecated use {@link AbstractWriteAttributeHandler} */
@Deprecated
@SuppressWarnings("deprecation")
public static class WriteAttributeOperationHandler implements OperationStepHandler {
public static WriteAttributeOperationHandler INSTANCE = new WriteAttributeOperationHandler();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
*
* @author Brian Stansberry
*/
@SuppressWarnings("deprecation")
public abstract class AbstractConfigurationPersister implements ExtensibleConfigurationPersister {

private final XMLElementWriter<ModelMarshallingContext> rootDeparser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@SuppressWarnings("deprecation")
abstract class AbstractResourceRegistration implements ManagementResourceRegistration {

private final String valueString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
*
* @author Kabir Khan
*/
@SuppressWarnings("deprecation")
final class AliasResourceRegistration extends AbstractResourceRegistration implements DescriptionProvider {

private final AliasEntry aliasEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.jboss.as.controller.registry.OperationEntry.EntryType;
import org.jboss.dmr.ModelNode;

@SuppressWarnings("deprecation")
final class ConcreteResourceRegistration extends AbstractResourceRegistration {

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public final class OperationEntry {
public enum EntryType {
PUBLIC, PRIVATE;
PUBLIC, PRIVATE
}

/** Flags to indicate special characteristics of an operation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@SuppressWarnings("deprecation")
final class ProxyControllerRegistration extends AbstractResourceRegistration implements DescriptionProvider {

private final ProxyController proxyController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -163,7 +162,7 @@ public boolean isFailed() {

@Override
public AsyncFuture<ModelNode> getFinalResult() {
return new CompletedResult(finalResult);
return new CompletedResult<ModelNode>(finalResult);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.controller.services.path.PathManager.Event;
import org.jboss.as.controller.services.path.PathManagerService.PathEventContextImpl;
Expand All @@ -46,10 +47,8 @@ public class PathAddHandler implements OperationStepHandler {

public static final String OPERATION_NAME = ADD;

public static ModelNode getAddPathOperation(ModelNode address, ModelNode path, ModelNode relativeTo) {
ModelNode op = new ModelNode();
op.get(OP).set(OPERATION_NAME);
op.get(OP_ADDR).set(address);
public static ModelNode getAddPathOperation(PathAddress address, ModelNode path, ModelNode relativeTo) {
ModelNode op = Util.createAddOperation(address);
if (path.isDefined()) {
op.get(PATH_SPECIFIED.getName()).set(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@
import java.util.concurrent.atomic.AtomicBoolean;

import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.controller.descriptions.NonResolvingResourceDescriptionResolver;
import org.jboss.as.controller.persistence.ConfigurationPersister;
import org.jboss.as.controller.persistence.NullConfigurationPersister;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;

/**
* A simple {@code Service<ModelController>} base class for use in unit tests.
*
* @author Brian Stansberry (c) 2012 Red Hat Inc.
*/
* A simple {@code Service<ModelController>} base class for use in unit tests.
*
* @author Brian Stansberry (c) 2012 Red Hat Inc.
*/
public abstract class TestModelControllerService extends AbstractControllerService {

private final ControlledProcessState processState;
Expand All @@ -52,7 +53,14 @@ protected TestModelControllerService() {
}

protected TestModelControllerService(final ConfigurationPersister configurationPersister, final ControlledProcessState processState) {
this(ProcessType.EMBEDDED_SERVER, configurationPersister, processState, DESC_PROVIDER);
this(ProcessType.EMBEDDED_SERVER, configurationPersister, processState,
ResourceBuilder.Factory.create(PathElement.pathElement("root"), new NonResolvingResourceDescriptionResolver()).build());
}

protected TestModelControllerService(final ProcessType processType, final ConfigurationPersister configurationPersister, final ControlledProcessState processState,
final ResourceDefinition rootDescriptionProvider) {
super(processType, new RunningModeControl(RunningMode.NORMAL), configurationPersister, processState, rootDescriptionProvider, null, ExpressionResolver.DEFAULT);
this.processState = processState;
}

protected TestModelControllerService(final ProcessType processType, final ConfigurationPersister configurationPersister, final ControlledProcessState processState,
Expand Down Expand Up @@ -82,7 +90,7 @@ public void start(StartContext context) throws StartException {
}

@Override
protected void bootThreadDone() {
protected void bootThreadDone() {
super.bootThreadDone();
latch.countDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
package org.jboss.as.controller.services.path;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CHILDREN;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MIN_OCCURS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MODEL_DESCRIPTION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATIONS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
Expand All @@ -43,14 +39,12 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import junit.framework.Assert;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.controller.operations.global.GlobalOperationHandlers;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
Expand Down Expand Up @@ -804,21 +798,6 @@ private ModelNode readResource() throws Exception {
return executeForResult(operation);
}

@Override
protected DescriptionProvider getRootDescriptionProvider() {
return new DescriptionProvider() {
@Override
public ModelNode getModelDescription(Locale locale) {
ModelNode node = new ModelNode();
node.get(DESCRIPTION).set("The root node of the test management API");
node.get(CHILDREN, PATH, DESCRIPTION).set("A list of paths");
node.get(CHILDREN, PATH, MIN_OCCURS).set(0);
node.get(CHILDREN, PATH, MODEL_DESCRIPTION);
return node;
}
};
}

@Override
protected void initModel(Resource rootResource, ManagementResourceRegistration registration) {
pathManagerService = new PathManagerService() {
Expand Down
Loading

0 comments on commit 3a81ca0

Please sign in to comment.