use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class EeLegacySubsystemTestCase method testSubsystem.
@Test
public void testSubsystem() throws Exception {
KernelServices services = standardSubsystemTest("subsystem_1_2.xml", false);
ModelNode model = services.readWholeModel();
ModelNode subsystem = model.require(SUBSYSTEM).require(EeExtension.SUBSYSTEM_NAME);
ModelNode globalModules = subsystem.require(GLOBAL_MODULES);
assertEquals("org.jboss.logging", globalModules.require(0).require(NAME).asString());
assertEquals("main", globalModules.require(0).require(SLOT).asString());
assertEquals("org.apache.log4j", globalModules.require(1).require(NAME).asString());
assertTrue(globalModules.require(1).require(ANNOTATIONS).asBoolean());
assertTrue(globalModules.require(1).require(META_INF).asBoolean());
assertFalse(globalModules.require(1).require(SERVICES).asBoolean());
assertFalse(subsystem.require(ANNOTATION_PROPERTY_REPLACEMENT).asBoolean());
assertTrue(subsystem.require(EAR_SUBDEPLOYMENTS_ISOLATED).asBoolean());
assertTrue(subsystem.require(JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT).asBoolean());
assertFalse(subsystem.require(SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT).asBoolean());
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class EeOperationsTestCase method testManagedExecutorFailureOperations.
@Test
public void testManagedExecutorFailureOperations() throws Exception {
// Boot the container
final KernelServices kernelServices = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(getSubsystemXml()).build();
// Default address
final ModelNode address = Operations.createAddress(ClientConstants.SUBSYSTEM, EeExtension.SUBSYSTEM_NAME, "managed-executor-service", "default");
// Create a composite operation that should fail; note that if the queue-length is undefined, 0 or Integer.MAX_VALUE the
// core-threads must be greater than 0
ModelNode op = Operations.createWriteAttributeOperation(address, "core-threads", 0);
ModelNode result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", Integer.MAX_VALUE)).addStep(Operations.createWriteAttributeOperation(address, "core-threads", 0)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", 0)).addStep(Operations.createWriteAttributeOperation(address, "core-threads", 0)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
// The max-threads must be greater than or equal to the core-threads
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "core-threads", 4)).addStep(Operations.createWriteAttributeOperation(address, "max-threads", 1)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
// Test a failure at the runtime-stage
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "queue-length", "${test.queue-length:10}")).addStep(Operations.createWriteAttributeOperation(address, "core-threads", "${test.core-threads:500}")).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
// The max-threads must be greater than or equal to the core-threads
final int calculatedMaxThreads = (ProcessorInfo.availableProcessors() * 2);
op = CompositeOperationBuilder.create().addStep(Operations.createWriteAttributeOperation(address, "core-threads", calculatedMaxThreads)).addStep(Operations.createWriteAttributeOperation(address, "max-threads", calculatedMaxThreads - 1)).build().getOperation();
result = kernelServices.executeOperation(op);
Assert.assertFalse(Operations.isSuccessfulOutcome(result));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class EeSubsystemTestCase method testTransformers800.
//@Test don't test as we dont have test controller
public void testTransformers800() throws Exception {
final ModelVersion legacyModelVersion = ModelVersion.create(3, 0, 0);
final ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.WILDFLY_8_2_0_FINAL;
KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
// Add legacy subsystems
builder.createLegacyKernelServicesBuilder(null, controllerVersion, legacyModelVersion).addMavenResourceURL("org.wildfly:wildfly-ee:" + controllerVersion.getMavenGavVersion());
KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(legacyModelVersion);
Assert.assertTrue(mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
List<ModelNode> bootOps = builder.parseXmlResource("subsystem-wf8-transformer.xml");
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, legacyModelVersion, bootOps, new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, ManagedExecutorServiceResourceDefinition.INSTANCE.getPathElement()), new RejectUndefinedAttribute(new ModelNode(Integer.MAX_VALUE), ManagedExecutorServiceResourceDefinition.CORE_THREADS_AD.getName())).addFailedAttribute(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM, ManagedScheduledExecutorServiceResourceDefinition.INSTANCE.getPathElement()), new RejectUndefinedAttribute(new ModelNode(Integer.MAX_VALUE), ManagedScheduledExecutorServiceResourceDefinition.CORE_THREADS_AD.getName())));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class DefaultBindingsAdd method performBoottime.
@Override
protected void performBoottime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
ModelNode model = resource.getModel();
if (model.hasDefined(DefaultBindingsResourceDefinition.CONTEXT_SERVICE)) {
final String contextService = DefaultBindingsResourceDefinition.CONTEXT_SERVICE_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setContextService(contextService);
}
if (model.hasDefined(DefaultBindingsResourceDefinition.DATASOURCE)) {
final String dataSource = DefaultBindingsResourceDefinition.DATASOURCE_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setDataSource(dataSource);
}
if (model.hasDefined(DefaultBindingsResourceDefinition.JMS_CONNECTION_FACTORY)) {
final String jmsConnectionFactory = DefaultBindingsResourceDefinition.JMS_CONNECTION_FACTORY_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setJmsConnectionFactory(jmsConnectionFactory);
}
if (model.hasDefined(DefaultBindingsResourceDefinition.MANAGED_EXECUTOR_SERVICE)) {
final String managedExecutorService = DefaultBindingsResourceDefinition.MANAGED_EXECUTOR_SERVICE_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setManagedExecutorService(managedExecutorService);
}
if (model.hasDefined(DefaultBindingsResourceDefinition.MANAGED_SCHEDULED_EXECUTOR_SERVICE)) {
final String managedScheduledExecutorService = DefaultBindingsResourceDefinition.MANAGED_SCHEDULED_EXECUTOR_SERVICE_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setManagedScheduledExecutorService(managedScheduledExecutorService);
}
if (model.hasDefined(DefaultBindingsResourceDefinition.MANAGED_THREAD_FACTORY)) {
final String managedThreadFactory = DefaultBindingsResourceDefinition.MANAGED_THREAD_FACTORY_AD.resolveModelAttribute(context, model).asString();
defaultBindingsConfigurationProcessor.setManagedThreadFactory(managedThreadFactory);
}
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(EeExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EE_DEFAULT_BINDINGS_CONFIG, defaultBindingsConfigurationProcessor);
}
}, OperationContext.Stage.RUNTIME);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class EEJndiViewExtension method execute.
public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
final ModelNode applicationsNode = context.getResult().get("applications");
final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
for (final Resource.ResourceEntry entry : deploymentResource) {
final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
if (deploymentUnitServiceController != null) {
final ModelNode deploymentNode = applicationsNode.get(entry.getName());
final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
final String appName = cleanName(deploymentUnit.getName());
final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
if (appContextController != null) {
final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
try {
context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
} catch (NamingException e) {
throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
}
}
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
if (roots != null)
for (ResourceRoot root : roots) {
if (SubDeploymentMarker.isSubDeployment(root)) {
final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
if (subDeploymentController != null) {
final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
} else {
handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
}
Aggregations