use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class JcaWorkManagerDefinition method registerSubModels.
static void registerSubModels(ManagementResourceRegistration resourceRegistration, boolean runtimeOnly) {
final BoundedQueueThreadPoolAdd shortRunningThreadPoolAdd = new BoundedQueueThreadPoolAdd(false, ThreadsServices.STANDARD_THREAD_FACTORY_RESOLVER, ThreadsServices.STANDARD_HANDOFF_EXECUTOR_RESOLVER, ThreadsServices.EXECUTOR.append(WORKMANAGER_SHORT_RUNNING)) {
@Override
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
context.addStep(new OperationStepHandler() {
public void execute(OperationContext oc, ModelNode op) throws OperationFailedException {
checkThreadPool(oc, op, WORKMANAGER_SHORT_RUNNING);
}
}, MODEL);
}
};
resourceRegistration.registerSubModel(new JCAThreadPoolResourceDefinition(false, runtimeOnly, WORKMANAGER_SHORT_RUNNING, ThreadsServices.EXECUTOR.append(WORKMANAGER_SHORT_RUNNING), CommonAttributes.BOUNDED_QUEUE_THREAD_POOL, shortRunningThreadPoolAdd, ReloadRequiredRemoveStepHandler.INSTANCE));
final BoundedQueueThreadPoolAdd longRunningThreadPoolAdd = new BoundedQueueThreadPoolAdd(false, ThreadsServices.STANDARD_THREAD_FACTORY_RESOLVER, ThreadsServices.STANDARD_HANDOFF_EXECUTOR_RESOLVER, ThreadsServices.EXECUTOR.append(WORKMANAGER_LONG_RUNNING)) {
@Override
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
super.populateModel(context, operation, resource);
context.addStep(new OperationStepHandler() {
public void execute(OperationContext oc, ModelNode op) throws OperationFailedException {
checkThreadPool(oc, op, WORKMANAGER_LONG_RUNNING);
}
}, MODEL);
}
};
resourceRegistration.registerSubModel(new JCAThreadPoolResourceDefinition(false, runtimeOnly, WORKMANAGER_LONG_RUNNING, ThreadsServices.EXECUTOR.append(WORKMANAGER_LONG_RUNNING), CommonAttributes.BOUNDED_QUEUE_THREAD_POOL, longRunningThreadPoolAdd, new BoundedQueueThreadPoolRemove(longRunningThreadPoolAdd)));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class AOConfigPropertyAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException {
final String configPropertyValue = CONFIG_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString();
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String archiveName = path.getElement(path.size() - 3).getValue();
final String aoName = path.getElement(path.size() - 2).getValue();
final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue();
ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, aoName, configPropertyName);
ServiceName aoServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, aoName);
final ServiceTarget serviceTarget = context.getServiceTarget();
final AOConfigPropertiesService service = new AOConfigPropertiesService(configPropertyName, configPropertyValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(aoServiceName, ModifiableAdminObject.class, service.getAOInjector()).install();
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class AdminObjectAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String raName = context.getCurrentAddress().getParent().getLastElement().getValue();
final String archiveOrModuleName;
ModelNode raModel = context.readResourceFromRoot(path.subAddress(0, path.size() - 1)).getModel();
final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, raModel).asBoolean();
if (!raModel.hasDefined(ARCHIVE.getName()) && !raModel.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
}
if (raModel.get(ARCHIVE.getName()).isDefined()) {
archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString();
} else {
archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString();
}
final String poolName = PathAddress.pathAddress(address).getLastElement().getValue();
final ModifiableAdminObject adminObjectValue;
try {
adminObjectValue = RaOperationUtil.buildAdminObjects(context, operation, poolName);
} catch (ValidateException e) {
throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("AdminObject", operation, e.getLocalizedMessage())));
}
ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName, poolName);
ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
final ServiceTarget serviceTarget = context.getServiceTarget();
final AdminObjectService service = new AdminObjectService(adminObjectValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(raServiceName, ModifiableResourceAdapter.class, service.getRaInjector()).install();
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
Activation raxml = (Activation) RaxmlController.getValue();
ServiceName deploymentServiceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, raName);
String bootStrapCtxName = DEFAULT_NAME;
if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
bootStrapCtxName = raxml.getBootstrapContext();
}
AdminObjectStatisticsService adminObjectStatisticsService = new AdminObjectStatisticsService(context.getResourceRegistrationForUpdate(), poolName, statsEnabled);
ServiceBuilder statsServiceBuilder = serviceTarget.addService(serviceName.append(ConnectorServices.STATISTICS_SUFFIX), adminObjectStatisticsService);
statsServiceBuilder.addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName), adminObjectStatisticsService.getBootstrapContextInjector()).addDependency(deploymentServiceName, adminObjectStatisticsService.getResourceAdapterDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peAO = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
final Resource aoResource = new IronJacamarResource.IronJacamarRuntimeResource();
resource.registerChild(peAO, aoResource);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class CommonIronJacamarParser method parseConnectionDefinitions_4_0.
/**
* parse a single connection-definition tag
*
* @param reader the reader
* @throws javax.xml.stream.XMLStreamException
* XMLStreamException
* @throws ParserException ParserException
* @throws org.jboss.jca.common.api.validator.ValidateException
* ValidateException
*/
protected void parseConnectionDefinitions_4_0(final XMLExtendedStreamReader reader, final Map<String, ModelNode> map, final Map<String, HashMap<String, ModelNode>> configMap, final boolean isXa) throws XMLStreamException, ParserException, ValidateException {
final ModelNode connectionDefinitionNode = new ModelNode();
connectionDefinitionNode.get(OP).set(ADD);
String poolName = null;
String jndiName = null;
int attributeSize = reader.getAttributeCount();
boolean poolDefined = Boolean.FALSE;
for (int i = 0; i < attributeSize; i++) {
ConnectionDefinition.Attribute attribute = ConnectionDefinition.Attribute.forName(reader.getAttributeLocalName(i));
String value = reader.getAttributeValue(i);
switch(attribute) {
case ENABLED:
{
ENABLED.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case CONNECTABLE:
{
CONNECTABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case TRACKING:
{
TRACKING.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case JNDI_NAME:
{
jndiName = value;
JNDINAME.parseAndSetParameter(jndiName, connectionDefinitionNode, reader);
break;
}
case POOL_NAME:
{
poolName = value;
break;
}
case USE_JAVA_CONTEXT:
{
USE_JAVA_CONTEXT.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case USE_CCM:
{
USE_CCM.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case SHARABLE:
{
SHARABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case ENLISTMENT:
{
ENLISTMENT.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case CLASS_NAME:
{
CLASS_NAME.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case MCP:
{
MCP.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
}
case ENLISTMENT_TRACE:
ENLISTMENT_TRACE.parseAndSetParameter(value, connectionDefinitionNode, reader);
break;
default:
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
if (poolName == null || poolName.trim().equals("")) {
if (jndiName != null && jndiName.trim().length() != 0) {
if (jndiName.contains("/")) {
poolName = jndiName.substring(jndiName.lastIndexOf("/") + 1);
} else {
poolName = jndiName.substring(jndiName.lastIndexOf(":") + 1);
}
} else {
throw ParseUtils.missingRequired(reader, EnumSet.of(ConnectionDefinition.Attribute.JNDI_NAME));
}
}
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (Activation.Tag.forName(reader.getLocalName()) == Activation.Tag.CONNECTION_DEFINITION) {
map.put(poolName, connectionDefinitionNode);
return;
} else {
if (ConnectionDefinition.Tag.forName(reader.getLocalName()) == ConnectionDefinition.Tag.UNKNOWN) {
throw ParseUtils.unexpectedEndElement(reader);
}
}
break;
}
case START_ELEMENT:
{
switch(ConnectionDefinition.Tag.forName(reader.getLocalName())) {
case CONFIG_PROPERTY:
{
if (!configMap.containsKey(poolName)) {
configMap.put(poolName, new HashMap<String, ModelNode>(0));
}
parseConfigProperties(reader, configMap.get(poolName));
break;
}
case SECURITY:
{
parseSecuritySettings(reader, connectionDefinitionNode);
break;
}
case TIMEOUT:
{
parseTimeOut(reader, isXa, connectionDefinitionNode);
break;
}
case VALIDATION:
{
parseValidation(reader, connectionDefinitionNode);
break;
}
case XA_POOL:
{
if (!isXa) {
throw ParseUtils.unexpectedElement(reader);
}
if (poolDefined) {
throw new ParserException(bundle.multiplePools());
}
parseXaPool(reader, connectionDefinitionNode);
poolDefined = true;
break;
}
case POOL:
{
if (isXa) {
throw ParseUtils.unexpectedElement(reader);
}
if (poolDefined) {
throw new ParserException(bundle.multiplePools());
}
parsePool(reader, connectionDefinitionNode);
poolDefined = true;
break;
}
case RECOVERY:
{
parseRecovery(reader, connectionDefinitionNode);
break;
}
default:
throw ParseUtils.unexpectedElement(reader);
}
break;
}
}
}
throw ParseUtils.unexpectedEndElement(reader);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class AbstractComplexSubsystemTestCase method getModel.
public ModelNode getModel(String resourceFileName, boolean checkMarshalledXML, String archiveName) throws Exception {
String xml = readResource(resourceFileName);
KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(xml).build();
ModelNode model = services.readWholeModel();
// Marshal the xml to see that it is the same as before
String marshalled = services.getPersistedSubsystemXml();
if (checkMarshalledXML)
Assert.assertEquals(normalizeXML(xml), normalizeXML(marshalled));
services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT).setSubsystemXml(marshalled).build();
// Check that the model looks the same
ModelNode modelReloaded = services.readWholeModel();
compare(model, modelReloaded);
assertRemoveSubsystemResources(services);
return model;
}
Aggregations