Skip to content

Commit

Permalink
AS7-677 Add a <cached-connection-manager debug="false" error="false"/…
Browse files Browse the repository at this point in the history
…> configuration element to the <connector> subsystem.
  • Loading branch information
maeste authored and kabir committed May 5, 2011
1 parent d2a0573 commit 69ce113
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 45 deletions.
Expand Up @@ -22,10 +22,14 @@ public class CcmService implements Service<CachedConnectionManager> {

private CachedConnectionManager value;

private final boolean debug;
private final boolean error;

/** create an instance **/
public CcmService() {
public CcmService(final boolean debug, final boolean error) {
super();

this.debug = debug;
this.error = error;
}

@Override
Expand All @@ -36,6 +40,8 @@ public CachedConnectionManager getValue() throws IllegalStateException, IllegalA
@Override
public void start(StartContext context) throws StartException {
value = new CachedConnectionManagerImpl(transactionIntegration.getValue().getTransactionManager());
value.setDebug(debug);
value.setError(error);
log.debugf("started CcmService %s", context.getController().getName());

}
Expand Down
Expand Up @@ -14,19 +14,21 @@ public enum Attribute {
ENABLED("enabled"),
/**
* fail-on-error attribute
*
*/
FAIL_ON_ERROR("fail-on-error"),

/**
* fail-on-warn attribute
*
*/
FAIL_ON_WARN("fail-on-warn"),

SHORT_RUNNING_THREAD_POOL("short-running-thread-pool"),

LONG_RUNNING_THREAD_POOL("long-running-thread-pool");
LONG_RUNNING_THREAD_POOL("long-running-thread-pool"),

DEBUG("debug"),

ERROR("error");

private final String name;

Expand All @@ -36,7 +38,6 @@ public enum Attribute {

/**
* Get the local name of this element.
*
* @return the local name
*/
public String getLocalName() {
Expand Down
Expand Up @@ -21,7 +21,7 @@
*/
package org.jboss.as.connector.subsystems.connector;

import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_ENABLED;
import static org.jboss.as.connector.subsystems.connector.Constants.*;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_ERROR;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_WARN;
import static org.jboss.as.connector.subsystems.connector.Constants.BEAN_VALIDATION_ENABLED;
Expand Down Expand Up @@ -92,7 +92,8 @@ public void initialize(final ExtensionContext context) {
final ModelNodeRegistration subsystem = registration.registerSubsystemModel(SUBSYSTEM);
subsystem.registerOperationHandler(ADD, ConnectorSubsystemAdd.INSTANCE, SUBSYSTEM_ADD_DESC, false);
subsystem.registerOperationHandler(REMOVE, ConnectorSubSystemRemove.INSTANCE, SUBSYSTEM_REMOVE_DESC, false);
subsystem.registerOperationHandler(DESCRIBE, ConnectorSubsystemDescribeHandler.INSTANCE, ConnectorSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
subsystem.registerOperationHandler(DESCRIBE, ConnectorSubsystemDescribeHandler.INSTANCE,
ConnectorSubsystemDescribeHandler.INSTANCE, false, OperationEntry.EntryType.PRIVATE);
}

@Override
Expand Down Expand Up @@ -124,6 +125,7 @@ public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingCon
writeArchiveValidation(writer, node);
writeBeanValidation(writer, node);
writeDefaultWorkManager(writer, node);
writeCachedConnectionManager(writer, node);
writer.writeEndElement();
}

Expand All @@ -149,6 +151,16 @@ private void writeBeanValidation(XMLExtendedStreamWriter writer, ModelNode node)
}
}

private void writeCachedConnectionManager(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (has(node, CACHED_CONNECTION_MANAGER_DEBUG) || has(node, CACHED_CONNECTION_MANAGER_ERROR)) {
writer.writeEmptyElement(Element.CACHED_CONNECTION_MANAGER.getLocalName());
if (has(node, CACHED_CONNECTION_MANAGER_DEBUG))
writeAttribute(writer, Attribute.DEBUG, node.require(CACHED_CONNECTION_MANAGER_DEBUG));
if (has(node, CACHED_CONNECTION_MANAGER_ERROR))
writeAttribute(writer, Attribute.ERROR, node.require(CACHED_CONNECTION_MANAGER_ERROR));
}
}

private void writeDefaultWorkManager(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (hasAnyOf(node, DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL, DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL)) {
writer.writeEmptyElement(Element.DEFAULT_WORKMANAGER.getLocalName());
Expand Down Expand Up @@ -215,6 +227,10 @@ public void readElement(final XMLExtendedStreamReader reader, final List<ModelNo
break;

}
case CACHED_CONNECTION_MANAGER: {
parseCcm(reader, subsystem);
break;
}
default:
throw unexpectedElement(reader);
}
Expand Down Expand Up @@ -291,23 +307,38 @@ private void parseDefaultWorkManager(final XMLExtendedStreamReader reader, final
private void parseBeanValidation(final XMLExtendedStreamReader reader, final ModelNode node) throws XMLStreamException {
final boolean enabled = readBooleanAttributeElement(reader, Attribute.ENABLED.getLocalName());
node.get(BEAN_VALIDATION_ENABLED).set(enabled);
// Don't add a requireNoContent here as readBooleanAttributeElement already performs that check.
// Don't add a requireNoContent here as readBooleanAttributeElement
// already performs that check.
}
}

private void parseCcm(final XMLExtendedStreamReader reader, final ModelNode node) throws XMLStreamException {

final boolean debug = Boolean.parseBoolean(reader.getAttributeValue("", Attribute.DEBUG.getLocalName()));
final boolean error = Boolean.parseBoolean(reader.getAttributeValue("", Attribute.ERROR.getLocalName()));

node.get(CACHED_CONNECTION_MANAGER_DEBUG).set(debug);
node.get(CACHED_CONNECTION_MANAGER_ERROR).set(error);

requireNoContent(reader);
}
}

private static class ConnectorSubsystemDescribeHandler implements ModelQueryOperationHandler, DescriptionProvider {
static final ConnectorSubsystemDescribeHandler INSTANCE = new ConnectorSubsystemDescribeHandler();

@Override
public OperationResult execute(final OperationContext context, final ModelNode operation, final ResultHandler resultHandler) {
public OperationResult execute(final OperationContext context, final ModelNode operation,
final ResultHandler resultHandler) {
final ModelNode add = createEmptyAddOperation();
final ModelNode model = context.getSubModel();

if (model.hasDefined(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL)) {
add.get(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL).set(model.get(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL));
add.get(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL).set(
model.get(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL));
}
if (model.hasDefined(DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL)) {
add.get(DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL).set(model.get(DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL));
add.get(DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL).set(
model.get(DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL));
}
if (model.hasDefined(BEAN_VALIDATION_ENABLED)) {
add.get(BEAN_VALIDATION_ENABLED).set(model.get(BEAN_VALIDATION_ENABLED));
Expand All @@ -321,6 +352,12 @@ public OperationResult execute(final OperationContext context, final ModelNode o
if (model.hasDefined(ARCHIVE_VALIDATION_FAIL_ON_WARN)) {
add.get(ARCHIVE_VALIDATION_FAIL_ON_WARN).set(model.get(ARCHIVE_VALIDATION_FAIL_ON_WARN));
}
if (model.hasDefined(CACHED_CONNECTION_MANAGER_DEBUG)) {
add.get(CACHED_CONNECTION_MANAGER_DEBUG).set(model.get(CACHED_CONNECTION_MANAGER_DEBUG));
}
if (model.hasDefined(CACHED_CONNECTION_MANAGER_ERROR)) {
add.get(CACHED_CONNECTION_MANAGER_ERROR).set(model.get(CACHED_CONNECTION_MANAGER_ERROR));
}

ModelNode result = new ModelNode();
result.add(add);
Expand Down
Expand Up @@ -21,7 +21,7 @@
*/
package org.jboss.as.connector.subsystems.connector;

import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_ENABLED;
import static org.jboss.as.connector.subsystems.connector.Constants.*;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_ERROR;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_WARN;
import static org.jboss.as.connector.subsystems.connector.Constants.BEAN_VALIDATION_ENABLED;
Expand Down Expand Up @@ -63,7 +63,8 @@ public OperationResult execute(final OperationContext context, final ModelNode o
if (context.getRuntimeContext() != null) {
context.getRuntimeContext().setRuntimeTask(new RuntimeTask() {
public void execute(RuntimeTaskContext context) throws OperationFailedException {
final ServiceController<?> controller = context.getServiceRegistry().getService(ConnectorServices.CONNECTOR_CONFIG_SERVICE);
final ServiceController<?> controller = context.getServiceRegistry().getService(
ConnectorServices.CONNECTOR_CONFIG_SERVICE);
if (controller != null) {
controller.setMode(ServiceController.Mode.REMOVE);
}
Expand Down Expand Up @@ -99,6 +100,12 @@ public void execute(RuntimeTaskContext context) throws OperationFailedException
compensating.get(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL).set(
model.get(DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL));
}
if (model.has(CACHED_CONNECTION_MANAGER_DEBUG)) {
compensating.get(CACHED_CONNECTION_MANAGER_DEBUG).set(model.get(CACHED_CONNECTION_MANAGER_DEBUG));
}
if (model.has(CACHED_CONNECTION_MANAGER_ERROR)) {
compensating.get(CACHED_CONNECTION_MANAGER_ERROR).set(model.get(CACHED_CONNECTION_MANAGER_ERROR));
}
return new BasicOperationResult(compensating);
}
}
Expand Up @@ -22,7 +22,7 @@

package org.jboss.as.connector.subsystems.connector;

import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_ENABLED;
import static org.jboss.as.connector.subsystems.connector.Constants.*;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_ERROR;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_WARN;
import static org.jboss.as.connector.subsystems.connector.Constants.BEAN_VALIDATION_ENABLED;
Expand Down Expand Up @@ -89,6 +89,8 @@ public OperationResult execute(final OperationContext context, final ModelNode o
.parseBooleanParameter(operation, ARCHIVE_VALIDATION_ENABLED, false);
final boolean failOnError = ParamsUtils.parseBooleanParameter(operation, ARCHIVE_VALIDATION_FAIL_ON_ERROR, true);
final boolean failOnWarn = ParamsUtils.parseBooleanParameter(operation, ARCHIVE_VALIDATION_FAIL_ON_WARN, false);
final boolean ccmDebug = ParamsUtils.parseBooleanParameter(operation, CACHED_CONNECTION_MANAGER_DEBUG, false);
final boolean ccmError = ParamsUtils.parseBooleanParameter(operation, CACHED_CONNECTION_MANAGER_ERROR, false);

// Apply to the model
final ModelNode model = context.getSubModel();
Expand All @@ -113,6 +115,12 @@ public OperationResult execute(final OperationContext context, final ModelNode o
if (ParamsUtils.has(operation, ARCHIVE_VALIDATION_FAIL_ON_WARN)) {
model.get(ARCHIVE_VALIDATION_FAIL_ON_WARN).set(failOnWarn);
}
if (ParamsUtils.has(operation, CACHED_CONNECTION_MANAGER_DEBUG)) {
model.get(CACHED_CONNECTION_MANAGER_DEBUG).set(ccmDebug);
}
if (ParamsUtils.has(operation, CACHED_CONNECTION_MANAGER_ERROR)) {
model.get(CACHED_CONNECTION_MANAGER_ERROR).set(ccmError);
}

if (context instanceof BootOperationContext) {
final BootOperationContext bootContext = BootOperationContext.class.cast(context);
Expand All @@ -139,7 +147,7 @@ public void execute(RuntimeTaskContext context) throws OperationFailedException
.addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionLocalDelegate.class,
tiService.getTldInjector()).setInitialMode(Mode.ACTIVE).install();

CcmService ccmService = new CcmService();
CcmService ccmService = new CcmService(ccmDebug, ccmError);
serviceTarget
.addService(ConnectorServices.CCM_SERVICE, ccmService)
.addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class,
Expand Down
Expand Up @@ -21,7 +21,7 @@
*/
package org.jboss.as.connector.subsystems.connector;

import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_ENABLED;
import static org.jboss.as.connector.subsystems.connector.Constants.*;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_ERROR;
import static org.jboss.as.connector.subsystems.connector.Constants.ARCHIVE_VALIDATION_FAIL_ON_WARN;
import static org.jboss.as.connector.subsystems.connector.Constants.BEAN_VALIDATION_ENABLED;
Expand Down Expand Up @@ -96,6 +96,16 @@ public ModelNode getModelDescription(final Locale locale) {
subsystem.get(ATTRIBUTES, ARCHIVE_VALIDATION_FAIL_ON_WARN, TYPE).set(ModelType.BOOLEAN);
subsystem.get(ATTRIBUTES, ARCHIVE_VALIDATION_FAIL_ON_WARN, REQUIRED).set(false);

subsystem.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_DEBUG, DESCRIPTION).set(
bundle.getString("cached-connection-manager.debug"));
subsystem.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_DEBUG, TYPE).set(ModelType.BOOLEAN);
subsystem.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_DEBUG, REQUIRED).set(false);

subsystem.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_ERROR, DESCRIPTION).set(
bundle.getString("cached-connection-manager.error"));
subsystem.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_ERROR, TYPE).set(ModelType.BOOLEAN);
subsystem.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_ERROR, REQUIRED).set(false);

return subsystem;
}
};
Expand Down Expand Up @@ -145,6 +155,16 @@ public ModelNode getModelDescription(final Locale locale) {
operation.get(REQUEST_PROPERTIES, DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL, TYPE).set(ModelType.STRING);
operation.get(REQUEST_PROPERTIES, DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL, REQUIRED).set(false);

operation.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_DEBUG, DESCRIPTION).set(
bundle.getString("cached-connection-manager.debug"));
operation.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_DEBUG, TYPE).set(ModelType.BOOLEAN);
operation.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_DEBUG, REQUIRED).set(false);

operation.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_ERROR, DESCRIPTION).set(
bundle.getString("cached-connection-manager.error"));
operation.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_ERROR, TYPE).set(ModelType.BOOLEAN);
operation.get(ATTRIBUTES, CACHED_CONNECTION_MANAGER_ERROR, REQUIRED).set(false);

return operation;
}
};
Expand Down
Expand Up @@ -33,5 +33,7 @@ class Constants {
static final String BEAN_VALIDATION_ENABLED = "bean-validation-enabled";
static final String DEFAULT_WORKMANAGER_SHORT_RUNNING_THREAD_POOL = "default-workmanager-short-running-thread-pool";
static final String DEFAULT_WORKMANAGER_LONG_RUNNING_THREAD_POOL = "default-workmanager-long-running-thread-pool";
static final String CACHED_CONNECTION_MANAGER_DEBUG = "cached-connection-manager-debug";
static final String CACHED_CONNECTION_MANAGER_ERROR = "cached-connection-manager-error";

}
Expand Up @@ -40,7 +40,10 @@ public enum Element {
BEAN_VALIDATION("bean-validation"),

/** default-workmanager element **/
DEFAULT_WORKMANAGER("default-workmanager");
DEFAULT_WORKMANAGER("default-workmanager"),

/** cached-connection-manager element **/
CACHED_CONNECTION_MANAGER("cached-connection-manager");

private final String name;

Expand All @@ -50,7 +53,6 @@ public enum Element {

/**
* Get the local name of this element.
*
* @return the local name
*/
public String getLocalName() {
Expand Down
Expand Up @@ -8,6 +8,8 @@ bean-validation.enabled=Specify whether bean validation is enabled
default-workmanager=Configurations for thread pools used by default workmanager
default-workmanager.short-running-thread-pool=Specify the name of short running thread pool
default-workmanager.long-running-thread-pool=Specify the name of long running thread pool
cached-connection-manager.debug=enable/disable debug information logging for cached connection manager
cached-connection-manager.error=enable/disable error information logging for cached connection manager
connector.add=Adds connector
connector.archive-validation.add=Adds archive validation
connector.archive-validation.enabled=Enabling the validation
Expand Down

0 comments on commit 69ce113

Please sign in to comment.