Java Code Examples for org.jboss.as.controller.ModelVersion#create()
The following examples show how to use
org.jboss.as.controller.ModelVersion#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testFailedTransformersEAP700() throws Exception { final ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.EAP_7_0_0; final ModelVersion modelVersion = ModelVersion.create(3, 0, 0); // Test against current testEap7FailedTransformers(controllerVersion, modelVersion, readResource("/expressions.xml"), new FailedOperationTransformationConfig() .addFailedAttribute(SUBSYSTEM_ADDRESS.append("json-formatter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("xml-formatter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("socket-handler"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("syslog-handler"), new NewAttributesConfig(SyslogHandlerResourceDefinition.NAMED_FORMATTER)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("socket-handler"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("syslog-handler"), new NewAttributesConfig(SyslogHandlerResourceDefinition.NAMED_FORMATTER)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("filter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("filter"), FailedOperationTransformationConfig.REJECTED_RESOURCE)); }
Example 2
Source File: LoggingSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testFailedTransformersEAP720() throws Exception { final ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.EAP_7_2_0; final ModelVersion modelVersion = ModelVersion.create(7, 0, 0); // Test against current testEap7FailedTransformers(controllerVersion, modelVersion, readResource("/expressions.xml"), new FailedOperationTransformationConfig() .addFailedAttribute(SUBSYSTEM_ADDRESS.append("syslog-handler"), new NewAttributesConfig(SyslogHandlerResourceDefinition.NAMED_FORMATTER)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("syslog-handler"), new NewAttributesConfig(SyslogHandlerResourceDefinition.NAMED_FORMATTER)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("filter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("filter"), FailedOperationTransformationConfig.REJECTED_RESOURCE)); }
Example 3
Source File: OperationTransformationTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testAddSubsystem() throws Exception { final ModelVersion subsystem = ModelVersion.create(1, 2); final TransformerRegistry registry = TransformerRegistry.Factory.create(); TransformersSubRegistration sub = registry.registerSubsystemTransformers("test", subsystem, ResourceTransformer.DISCARD); sub.registerOperationTransformer("test", OPERATION_TRANSFORMER); final TransformationTarget host = create(registry, ModelVersion.create(1, 2, 3)); host.addSubsystemVersion("test", subsystem); final PathAddress profile = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.PROFILE, "test")); final PathAddress serverAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.HOST, "test"), PathElement.pathElement(ModelDescriptionConstants.RUNNING_SERVER, "test")); final PathAddress subsytemAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "test")); final OperationTransformer profileTransformer = host.resolveTransformer(new MockTransformationContext(), profile.append(subsytemAddress), "test"); Assert.assertEquals(profileTransformer, OPERATION_TRANSFORMER); final OperationTransformer serverTransformer = host.resolveTransformer(new MockTransformationContext(), serverAddress.append(subsytemAddress), "test"); Assert.assertEquals(serverTransformer, OPERATION_TRANSFORMER); }
Example 4
Source File: SecurityManagerSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT); ModelVersion version = ModelVersion.create(2, 0, 0); builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, controllerVersion, version) .addMavenResourceURL("org.jboss.eap:wildfly-security-manager:" + controllerVersion.getMavenGavVersion()); KernelServices mainServices = builder.build(); assertTrue(mainServices.isSuccessfulBoot()); KernelServices legacyServices = mainServices.getLegacyServices(version); assertNotNull(legacyServices); assertTrue(legacyServices.isSuccessfulBoot()); PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName())); ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version, builder.parseXmlResource("security-manager-reject.xml"), new FailedOperationTransformationConfig() .addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.DEPLOYMENT_PERMISSIONS)), new FailedOperationTransformationConfig.NewAttributesConfig(Constants.MAXIMUM_PERMISSIONS))); }
Example 5
Source File: LoggingSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testFailedTransformersEAP640() throws Exception { final ModelTestControllerVersion controllerVersion = ModelTestControllerVersion.EAP_6_4_0; final ModelVersion modelVersion = ModelVersion.create(1, 5, 0); final PathAddress loggingProfileAddress = SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE); // Test against current testEapFailedTransformers(controllerVersion, modelVersion, readResource("/expressions.xml"), new FailedOperationTransformationConfig() .addFailedAttribute(SUBSYSTEM_ADDRESS, new NewAttributesConfig(LoggingResourceDefinition.USE_DEPLOYMENT_LOGGING_CONFIG)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("console-handler"), new RejectExpressionsConfig(ConsoleHandlerResourceDefinition.TARGET)) .addFailedAttribute(loggingProfileAddress.append("console-handler"), new RejectExpressionsConfig(ConsoleHandlerResourceDefinition.TARGET)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("json-formatter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("xml-formatter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("socket-handler"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("syslog-handler"), new NewAttributesConfig(SyslogHandlerResourceDefinition.NAMED_FORMATTER)) .addFailedAttribute(loggingProfileAddress.append("socket-handler"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("syslog-handler"), new NewAttributesConfig(SyslogHandlerResourceDefinition.NAMED_FORMATTER)) .addFailedAttribute(SUBSYSTEM_ADDRESS.append("filter"), FailedOperationTransformationConfig.REJECTED_RESOURCE) .addFailedAttribute(SUBSYSTEM_ADDRESS.append(CommonAttributes.LOGGING_PROFILE).append("filter"), FailedOperationTransformationConfig.REJECTED_RESOURCE)); }
Example 6
Source File: ServerConfigResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void registerServerLifecycleOperations(final ManagementResourceRegistration resourceRegistration, final ServerInventory serverInventory) { // Lifecycle ops are deprecated on the server-config resource but not on server boolean serverConfig = resourceRegistration.getPathAddress().getLastElement().getKey().equals(SERVER_CONFIG); // Mark the lifecycle ops on the server-config resources as deprecated. // Some already were deprecated in version 7, so use a different deprecated version for those ModelVersion deprecatedVersion = serverConfig ? ModelVersion.create(9) : null; ModelVersion existingDeprecatedVersion = serverConfig ? ModelVersion.create(7) : null; resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(START, ModelType.STRING, deprecatedVersion, BLOCKING, START_MODE), new ServerStartHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(RESTART, ModelType.STRING, deprecatedVersion, BLOCKING, START_MODE), new ServerRestartHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(STOP, ModelType.STRING, deprecatedVersion, BLOCKING, TIMEOUT, SUSPEND_TIMEOUT), new ServerStopHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(RELOAD, ModelType.STRING, existingDeprecatedVersion, BLOCKING, START_MODE), new ServerReloadHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(SUSPEND, null, existingDeprecatedVersion, TIMEOUT, SUSPEND_TIMEOUT), new ServerSuspendHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(RESUME, null, existingDeprecatedVersion), new ServerResumeHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(DESTROY, null, deprecatedVersion), new ServerProcessHandlers.ServerDestroyHandler(serverInventory)); resourceRegistration.registerOperationHandler( getDomainServerLifecycleDefinition(KILL, null, deprecatedVersion), new ServerProcessHandlers.ServerKillHandler(serverInventory)); }
Example 7
Source File: ServerInventoryImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ManagedServer createManagedServer(final String serverName, final String authKey) { final String hostControllerName = domainController.getLocalHostInfo().getLocalHostName(); // final ManagedServerBootConfiguration configuration = combiner.createConfiguration(); final Map<PathAddress, ModelVersion> subsystems = TransformerRegistry.resolveVersions(extensionRegistry); final ModelVersion modelVersion = ModelVersion.create(Version.MANAGEMENT_MAJOR_VERSION, Version.MANAGEMENT_MINOR_VERSION, Version.MANAGEMENT_MICRO_VERSION); //We don't need any transformation between host and server final TransformationTarget target = TransformationTargetImpl.create(hostControllerName, extensionRegistry.getTransformerRegistry(), modelVersion, subsystems, TransformationTarget.TransformationTargetType.SERVER); return new ManagedServer(hostControllerName, serverName, authKey, processControllerClient, managementURI, target); }
Example 8
Source File: SubsystemInformation.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Gets full version of the subsystem * @return full {@link ModelVersion} */ default ModelVersion getManagementInterfaceVersion(){ return ModelVersion.create(getManagementInterfaceMajorVersion() != null ? getManagementInterfaceMajorVersion() : 0, getManagementInterfaceMinorVersion() != null ? getManagementInterfaceMinorVersion() : 0, getManagementInterfaceMicroVersion() != null ? getManagementInterfaceMicroVersion() : 0 ); }
Example 9
Source File: TransformerRegistry.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ModelVersion convert(final String version) { final String[] s = version.split("\\."); final int length = s.length; if(length > 3) { throw new IllegalStateException(); } int major = Integer.valueOf(s[0]); int minor = length > 1 ? Integer.valueOf(s[1]) : 0; int micro = length == 3 ? Integer.valueOf(s[2]) : 0; return ModelVersion.create(major, minor, micro); }
Example 10
Source File: TransformationTargetImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static TransformationTarget createLocal() { TransformerRegistry registry = new TransformerRegistry(); OperationTransformerRegistry r2 = registry.resolveHost(ModelVersion.create(0), new HashMap<PathAddress, ModelVersion>()); return new TransformationTargetImpl(null, registry, ModelVersion.create(0), new HashMap<PathAddress, ModelVersion>(), r2, TransformationTargetType.SERVER, Transformers.OperationExcludedTransformationRegistry.DEFAULT, null); }
Example 11
Source File: GlobalTransformerRegistry.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private OperationTransformerRegistry getRegistryUpdater(final ModelVersion version) { int micro = version.getMicro(); for (int i = micro; i >= 0; i--) { ModelVersion currentVersion = ModelVersion.create(version.getMajor(), version.getMinor(), i); OperationTransformerRegistry current = registryUpdater.get(this, currentVersion); if (current != null) { if(micro != i && this.getClass().desiredAssertionStatus()) { ControllerLogger.MGMT_OP_LOGGER.couldNotFindTransformerRegistryFallingBack(version, currentVersion); } return current; } } return null; }
Example 12
Source File: CamelExtension.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Override public void initialize(ExtensionContext context) { boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid(); ModelVersion modelVersion = ModelVersion.create(MANAGEMENT_API_MAJOR_VERSION, MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION); SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, modelVersion); subsystem.registerSubsystemModel(new CamelRootResource(registerRuntimeOnly)); subsystem.registerXMLElementWriter(CamelSubsystemWriter.INSTANCE); }
Example 13
Source File: TransformerSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception { ModelVersion oldVersion = ModelVersion.create(1, 0, 0); KernelServicesBuilder builder = createKernelServicesBuilder(null) .setSubsystemXml(getSubsystemXml()); builder.createLegacyKernelServicesBuilder(null, controllerVersion, oldVersion) .setExtensionClassName(VersionedExtension1.class.getName()) .addSimpleResourceURL(LEGACY_ARCHIVE.toString()) .skipReverseControllerCheck(); KernelServices mainServices = builder.build(); KernelServices legacyServices = mainServices.getLegacyServices(oldVersion); Assert.assertNotNull(legacyServices); ModelNode mainModel = mainServices.readWholeModel(); ModelNode mainSubsystem = mainModel.get(SUBSYSTEM, "test-subsystem"); Assert.assertEquals(3, mainSubsystem.keys().size()); Assert.assertEquals("This is only a test", mainSubsystem.get("test-attribute").asString()); Assert.assertTrue(mainSubsystem.hasDefined("new-element")); Assert.assertTrue(mainSubsystem.get("new-element").hasDefined("test")); Assert.assertTrue(mainSubsystem.hasDefined("renamed")); Assert.assertTrue(mainSubsystem.get("renamed").hasDefined("element")); ModelNode legacyModel = legacyServices.readWholeModel(); ModelNode legacySubsystem = legacyModel.get(SUBSYSTEM, "test-subsystem"); Assert.assertEquals(2, legacySubsystem.keys().size()); Assert.assertEquals("This is only a test", legacySubsystem.get("test-attribute").asString()); Assert.assertTrue(legacySubsystem.hasDefined("element")); Assert.assertTrue(legacySubsystem.get("element").hasDefined("renamed")); checkSubsystemModelTransformation(mainServices, oldVersion); PathAddress subsystemAddress = PathAddress.pathAddress(SUBSYSTEM, "test-subsystem"); ModelNode writeAttribute = Util.getWriteAttributeOperation(subsystemAddress, "test-attribute", "do reject"); OperationTransformer.TransformedOperation op = mainServices.executeInMainAndGetTheTransformedOperation(writeAttribute, oldVersion); Assert.assertFalse(op.rejectOperation(success())); //The model now has the 'magic' old value which gets put into the transformer attachment, which the reject transformer //will reject writeAttribute = Util.getWriteAttributeOperation(subsystemAddress, "test-attribute", "something else"); op = mainServices.executeInMainAndGetTheTransformedOperation(writeAttribute, oldVersion); Assert.assertTrue(op.rejectOperation(success())); legacyServices.shutdown(); mainServices.shutdown(); }
Example 14
Source File: TransformerAttachmentAndInspectModelSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testTransformers() throws Exception { ModelVersion oldVersion = ModelVersion.create(1, 0, 0); KernelServicesBuilder builder = createKernelServicesBuilder(null) .setSubsystemXml(getSubsystemXml()); builder.createLegacyKernelServicesBuilder(null, ModelTestControllerVersion.MASTER, oldVersion) .setExtensionClassName(OldExtension.class.getName()) .addSimpleResourceURL("target/legacy-archive.jar") .dontPersistXml()//don't test xml persistence as woodstox parser for legacy test will break it .skipReverseControllerCheck(); KernelServices mainServices = builder.build(); KernelServices legacyServices = mainServices.getLegacyServices(oldVersion); Assert.assertNotNull(legacyServices); ModelNode mainModel = mainServices.readWholeModel(); ModelNode legacyModel = legacyServices.readWholeModel(); checkModels(mainModel, legacyModel, "Hello", "one", "A", "two", "B"); //Check the resource transformation results in the same model as the one from the add ops Assert.assertEquals(legacyModel.get(SUBSYSTEM, "test-subsystem"), mainServices.readTransformedModel(oldVersion).get(SUBSYSTEM, "test-subsystem")); //Remove, change, and add things back to the normal state final PathAddress subsystemAddress = PathAddress.pathAddress(SUBSYSTEM, "test-subsystem"); ModelNode write1 = getMapRemoveOperation(subsystemAddress, "properties", "one"); transformAndExecuteInLegacyController(mainServices, oldVersion, write1); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "two", "B"); ModelNode write2 = getMapPutOperation(subsystemAddress, "properties", "two", "b"); transformAndExecuteInLegacyController(mainServices, oldVersion, write2); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "two", "b"); ModelNode write3 = getMapRemoveOperation(subsystemAddress, "properties", "two"); transformAndExecuteInLegacyController(mainServices, oldVersion, write3); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello"); ModelNode write4 = getMapPutOperation(subsystemAddress, "properties", "one", "A"); transformAndExecuteInLegacyController(mainServices, oldVersion, write4); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "one", "A"); ModelNode write5 = getMapPutOperation(subsystemAddress, "properties", "two", "B"); transformAndExecuteInLegacyController(mainServices, oldVersion, write5); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "one", "A", "two", "B"); //Now try to do the same with a composite ModelNode composite = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS); composite.get(STEPS).add(write1); composite.get(STEPS).add(write2); composite.get(STEPS).add(write3); transformAndExecuteInLegacyController(mainServices, oldVersion, composite); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello"); composite = Util.createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS); composite.get(STEPS).add(write4); composite.get(STEPS).add(write5); transformAndExecuteInLegacyController(mainServices, oldVersion, composite); checkModels(mainServices.readWholeModel(), legacyServices.readWholeModel(), "Hello", "one", "A", "two", "B"); legacyServices.shutdown(); mainServices.shutdown(); }