当前位置: 首页>>代码示例>>Java>>正文


Java SimpleAttributeDefinitionBuilder类代码示例

本文整理汇总了Java中org.jboss.as.controller.SimpleAttributeDefinitionBuilder的典型用法代码示例。如果您正苦于以下问题:Java SimpleAttributeDefinitionBuilder类的具体用法?Java SimpleAttributeDefinitionBuilder怎么用?Java SimpleAttributeDefinitionBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleAttributeDefinitionBuilder类属于org.jboss.as.controller包,在下文中一共展示了SimpleAttributeDefinitionBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LegacyResourceDefinition

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
public LegacyResourceDefinition(ModelNode modelDescription) {
    this.description = modelDescription.get(ModelDescriptionConstants.MODEL_DESCRIPTION);
    ModelNode attributes = description.has(ModelDescriptionConstants.ATTRIBUTES) ? description.get(ModelDescriptionConstants.ATTRIBUTES) : new ModelNode();
    address = PathAddress.pathAddress(modelDescription.get(ModelDescriptionConstants.ADDRESS));

    if (attributes.isDefined()) {
        for (Property property : attributes.asPropertyList()) {
            String name = property.getName();
            SimpleAttributeDefinition def = SimpleAttributeDefinitionBuilder.create(name, property.getValue()).build();
            this.attributes.put(name, new AttributeAccess(
                    AttributeAccess.AccessType.READ_ONLY, AttributeAccess.Storage.CONFIGURATION, null, null, def)
            );
        }
    }
    ModelNode children = modelDescription.get(ModelDescriptionConstants.CHILDREN);
    if (!children.isDefined()) {
        return;
    }
    for (ModelNode child : children.asList()) {
        this.children.add(new LegacyResourceDefinition(child));
    }
    description.remove(ModelDescriptionConstants.CHILDREN);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:LegacyResourceDefinition.java

示例2: registerChildren

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Override
public void registerChildren(ManagementResourceRegistration profileSub1Reg) {
    super.registerChildren(profileSub1Reg);
    ResourceDefinition profileSub1RegType1Def = ResourceBuilder.Factory.create(PathElement.pathElement("type1", "*"),
            new NonResolvingResourceDescriptionResolver())
            .addReadOnlyAttribute(createAttribute("name", ModelType.STRING))
            .addReadOnlyAttribute(createAttribute("value", ModelType.INT))
            .build();
    profileSub1Reg.registerSubModel(profileSub1RegType1Def);

    ResourceDefinition profileSub1RegType2Def = ResourceBuilder.Factory.create(PathElement.pathElement("type2", "other"),
            new NonResolvingResourceDescriptionResolver())
            .addReadOnlyAttribute(createAttribute("name", ModelType.STRING))
            .addReadOnlyAttribute(SimpleAttributeDefinitionBuilder.create("default", ModelType.STRING).setRequired(false).setDefaultValue(new ModelNode("Default string")).build())
            .build();
    profileSub1Reg.registerSubModel(profileSub1RegType2Def);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:Subsystem1RootResource.java

示例3: createAttribute

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
public static AttributeDefinition createAttribute(String name, ModelType type, String groupName, boolean runtimeOnly, boolean alias, boolean allowNull) {
    SimpleAttributeDefinitionBuilder attribute = SimpleAttributeDefinitionBuilder.create(name, type);
    if (runtimeOnly) {
        attribute.setStorageRuntime();
    }
    if(groupName != null && ! groupName.isEmpty()) {
        attribute.setAttributeGroup(groupName);
    }
    if(alias) {
        attribute.addFlag(AttributeAccess.Flag.ALIAS);
    }
    attribute.setAllowExpression(true);
    if (allowNull) {
        attribute.setRequired(false);
    }
    return attribute.build();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:TestUtils.java

示例4: testValidArgs

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
/**
 * Tests that a valid operation passes validation
 */
@Test
public void testValidArgs() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.LONG)
                    .setRequired(true)
                    .setValidator(new LongRangeValidator(0L, 2L))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(1);
    KernelServices services = createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
            .setBootOperations(Collections.singletonList(operation))
            .build();

    services.validateOperation(operation);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:ValidateOperationsTestCase.java

示例5: testMissingRequiredParam

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testMissingRequiredParam() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.LONG)
                    .setRequired(true)
                    .build()
    );
    ModelNode operation = createAddOperation();
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(Collections.singletonList(operation))
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:ValidateOperationsTestCase.java

示例6: testMissingRequiredParam2

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testMissingRequiredParam2() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.LONG)
                    .build()
    );
    ModelNode operation = createAddOperation();
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(Collections.singletonList(operation))
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ValidateOperationsTestCase.java

示例7: testWrongParamType

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testWrongParamType() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.LONG)
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set("Hello");
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(Collections.singletonList(operation))
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:ValidateOperationsTestCase.java

示例8: testBigDecimalRangeTooSmall

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testBigDecimalRangeTooSmall() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.BIG_DECIMAL)
                    .setValidator(new BigDecimalRangeValidator(10, Integer.MAX_VALUE))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(new BigDecimal("5"));
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(Collections.singletonList(operation))
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例9: testBigDecimalRangeTooLarge

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testBigDecimalRangeTooLarge() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.BIG_DECIMAL)
                    .setValidator(new BigDecimalRangeValidator(Integer.MIN_VALUE, 10))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(new BigDecimal("15"));
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(Collections.singletonList(operation))
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例10: testIntRangeTooSmall

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testIntRangeTooSmall() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.INT)
                    .setValidator(new IntRangeValidator(10))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(5);
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(operation)
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例11: testIntRangeTooLarge

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testIntRangeTooLarge() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.INT)
                    .setValidator(new IntRangeValidator(Integer.MIN_VALUE, 10))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(15);
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(operation)
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例12: testStringTooShort

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testStringTooShort() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.STRING)
                    .setValidator(new StringLengthValidator(3))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set("Yo");
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(operation)
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例13: testStringTooLong

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testStringTooLong() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.STRING)
                    .setValidator(new StringLengthValidator(0, 1))
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set("Yo");
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(operation)
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例14: testBytesTooShort

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testBytesTooShort() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.BYTES)
                    .setMinSize(3)
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(new byte[] {1, 2});
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(operation)
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        // ok
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java

示例15: testBytesTooLong

import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; //导入依赖的package包/类
@Test
public void testBytesTooLong() throws Exception {
    getMainExtension().setAddAttributes(
            SimpleAttributeDefinitionBuilder.create("test", ModelType.BYTES)
                    .setMaxSize(1)
                    .build()
    );
    ModelNode operation = createAddOperation();
    operation.get("test").set(new byte[] {1, 2});
    try {
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
                .setBootOperations(operation)
                .build();
        Assert.fail("Not valid");
    } catch (Exception expected) {
        //
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ValidateOperationsTestCase.java


注:本文中的org.jboss.as.controller.SimpleAttributeDefinitionBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。