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


Java ModelType类代码示例

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


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

示例1: getEnumRequirements

import org.jboss.dmr.ModelType; //导入依赖的package包/类
List<EnumRequirement> getEnumRequirements() {

        List<EnumRequirement> plans = new ArrayList<>();

        ResourceDescription desc = getDescription();

        desc.getAttributes().forEach(
                att -> {
                    ModelType modelType = ModelType.valueOf(att.getValue().get(TYPE).asString());
                    Optional<String> resolvedType = Types.resolveJavaTypeName(modelType, att.getValue());

                    if (resolvedType.isPresent() && !att.getValue().get(DEPRECATED).isDefined()) {
                        // attributes
                        // Determine if we should create an enum for strings that specify values
                        if (modelType == ModelType.STRING && att.getValue().hasDefined(ALLOWED)) {
                            // Create the enum name and enum source
                            EnumRequirement enumRequirement = new EnumRequirement(this, att);
                            plans.add(enumRequirement);
                        }
                    }
                }
        );

        return plans;
    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:26,代码来源:ClassPlan.java

示例2: from

import org.jboss.dmr.ModelType; //导入依赖的package包/类
public static ResourceDescription from(ModelNode response) {

        if(!response.get(OUTCOME).asString().equals(SUCCESS))
            throw new RuntimeException(response.get(FAILURE_DESCRIPTION).asString());

        ModelNode result = response.get(RESULT);
        if(ModelType.LIST == result.getType())
        {
            // wildcard addressing
            return new ResourceDescription(result.asList().get(0).get(RESULT));

        }
        else
        {
            // specific addressing
            return new ResourceDescription(result);
        }
    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:19,代码来源:ResourceDescription.java

示例3: toDmr

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void toDmr(ModelNode modelMode, String detypedName, List value) {

    if(value.isEmpty()) {
        modelMode.get(detypedName).setEmptyList();
    }
    else {
        value.forEach(
                v -> {
                    // model type  is derived from list item java type
                    ModelType listValueType = Types.resolveModelType(v.getClass());
                    addDmrValueTo(modelMode.get(detypedName), listValueType, v);
                }
        );
    }

}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:18,代码来源:ListTypeAdapter.java

示例4: fromDmr

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void fromDmr(Object entity, String javaName, ModelType dmrType, Class<?> propertyType, ModelNode dmrPayload) throws Exception {

    Method target = entity.getClass().getMethod(javaName, propertyType);
    List<ModelNode> items = dmrPayload.isDefined() ? dmrPayload.asList() : Collections.EMPTY_LIST;

    if(items.isEmpty()) {
        target.invoke(entity, Collections.EMPTY_LIST);
    }
    else
    {
        List list = new ArrayList(items.size());

        // java type is derived from list item dmr type
        ModelType listValueType = items.get(0).getType();
        for (ModelNode item : items) {
            addJavaValueTo(list, listValueType, item);
        }

        target.invoke(entity, list);
    }


}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:25,代码来源:ListTypeAdapter.java

示例5: deriveImageTag

import org.jboss.dmr.ModelType; //导入依赖的package包/类
default String deriveImageTag(String imageID, IImageStream srcIS) {
    // TODO port to ImageStream.java in openshift-restclient-java
    ModelNode imageStream = ((ImageStream) srcIS).getNode();
    ModelNode status = imageStream.get("status");
    ModelNode tags = status.get("tags");
    if (tags.getType() != ModelType.LIST)
        return null;
    List<ModelNode> tagWrappers = tags.asList();
    for (ModelNode tagWrapper : tagWrappers) {
        ModelNode tag = tagWrapper.get("tag");
        ModelNode items = tagWrapper.get("items");
        for (ModelNode itemWrapper : items.asList()) {
            ModelNode image = itemWrapper.get("image");
            if (image != null
                    && (image.asString().equals(imageID) || image
                            .asString().substring(7).equals(imageID))) {
                return tag.asString();
            }
        }
    }
    return null;
}
 
开发者ID:openshift,项目名称:jenkins-plugin,代码行数:23,代码来源:IOpenShiftImageTagger.java

示例6: extensionAddress

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Test
public void extensionAddress() {
    Address singleElementAddress = Address.extension("org.jboss.as.logging");
    ModelNode modelNode = singleElementAddress.toModelNode();

    assertTrue(modelNode.isDefined());
    assertEquals(ModelType.LIST, modelNode.getType());
    assertTrue(modelNode.hasDefined(0));
    assertFalse(modelNode.hasDefined(1));

    ModelNode firstElement = modelNode.get(0);
    assertEquals(ModelType.PROPERTY, firstElement.getType());
    assertEquals(Constants.EXTENSION, firstElement.asProperty().getName());
    assertEquals(ModelType.STRING, firstElement.asProperty().getValue().getType());
    assertEquals("org.jboss.as.logging", firstElement.asProperty().getValue().asString());

    assertEquals("/extension=org.jboss.as.logging", singleElementAddress.toString());
    assertEquals("org.jboss.as.logging", singleElementAddress.getLastPairValue());
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:20,代码来源:AddressTest.java

示例7: profileAddress

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Test
public void profileAddress() {
    Address singleElementAddress = Address.profile("default");
    ModelNode modelNode = singleElementAddress.toModelNode();

    assertTrue(modelNode.isDefined());
    assertEquals(ModelType.LIST, modelNode.getType());
    assertTrue(modelNode.hasDefined(0));
    assertFalse(modelNode.hasDefined(1));

    ModelNode firstElement = modelNode.get(0);
    assertEquals(ModelType.PROPERTY, firstElement.getType());
    assertEquals(Constants.PROFILE, firstElement.asProperty().getName());
    assertEquals(ModelType.STRING, firstElement.asProperty().getValue().getType());
    assertEquals("default", firstElement.asProperty().getValue().asString());

    assertEquals("/profile=default", singleElementAddress.toString());
    assertEquals("default", singleElementAddress.getLastPairValue());
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:20,代码来源:AddressTest.java

示例8: hostAddress

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Test
public void hostAddress() {
    Address singleElementAddress = Address.host("master");
    ModelNode modelNode = singleElementAddress.toModelNode();

    assertTrue(modelNode.isDefined());
    assertEquals(ModelType.LIST, modelNode.getType());
    assertTrue(modelNode.hasDefined(0));
    assertFalse(modelNode.hasDefined(1));

    ModelNode firstElement = modelNode.get(0);
    assertEquals(ModelType.PROPERTY, firstElement.getType());
    assertEquals(Constants.HOST, firstElement.asProperty().getName());
    assertEquals(ModelType.STRING, firstElement.asProperty().getValue().getType());
    assertEquals("master", firstElement.asProperty().getValue().asString());

    assertEquals("/host=master", singleElementAddress.toString());
    assertEquals("master", singleElementAddress.getLastPairValue());
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:20,代码来源:AddressTest.java

示例9: subsystemAddress

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Test
public void subsystemAddress() {
    Address singleElementAddress = Address.subsystem("foo");
    ModelNode modelNode = singleElementAddress.toModelNode();

    assertTrue(modelNode.isDefined());
    assertEquals(ModelType.LIST, modelNode.getType());
    assertTrue(modelNode.hasDefined(0));
    assertFalse(modelNode.hasDefined(1));

    ModelNode firstElement = modelNode.get(0);
    assertEquals(ModelType.PROPERTY, firstElement.getType());
    assertEquals(Constants.SUBSYSTEM, firstElement.asProperty().getName());
    assertEquals(ModelType.STRING, firstElement.asProperty().getValue().getType());
    assertEquals("foo", firstElement.asProperty().getValue().asString());

    assertEquals("/subsystem=foo", singleElementAddress.toString());
    assertEquals("foo", singleElementAddress.getLastPairValue());
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:20,代码来源:AddressTest.java

示例10: coreServiceAddress

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Test
public void coreServiceAddress() {
    Address singleElementAddress = Address.coreService("management");
    ModelNode modelNode = singleElementAddress.toModelNode();

    assertTrue(modelNode.isDefined());
    assertEquals(ModelType.LIST, modelNode.getType());
    assertTrue(modelNode.hasDefined(0));
    assertFalse(modelNode.hasDefined(1));

    ModelNode firstElement = modelNode.get(0);
    assertEquals(ModelType.PROPERTY, firstElement.getType());
    assertEquals(Constants.CORE_SERVICE, firstElement.asProperty().getName());
    assertEquals(ModelType.STRING, firstElement.asProperty().getValue().getType());
    assertEquals("management", firstElement.asProperty().getValue().asString());

    assertEquals("/core-service=management", singleElementAddress.toString());
    assertEquals("management", singleElementAddress.getLastPairValue());
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:20,代码来源:AddressTest.java

示例11: deploymentAddress

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Test
public void deploymentAddress() {
    Address singleElementAddress = Address.deployment("simple.war");
    ModelNode modelNode = singleElementAddress.toModelNode();

    assertTrue(modelNode.isDefined());
    assertEquals(ModelType.LIST, modelNode.getType());
    assertTrue(modelNode.hasDefined(0));
    assertFalse(modelNode.hasDefined(1));

    ModelNode firstElement = modelNode.get(0);
    assertEquals(ModelType.PROPERTY, firstElement.getType());
    assertEquals(Constants.DEPLOYMENT, firstElement.asProperty().getName());
    assertEquals(ModelType.STRING, firstElement.asProperty().getValue().getType());
    assertEquals("simple.war", firstElement.asProperty().getValue().asString());

    assertEquals("/deployment=simple.war", singleElementAddress.toString());
    assertEquals("simple.war", singleElementAddress.getLastPairValue());
}
 
开发者ID:wildfly-extras,项目名称:creaper,代码行数:20,代码来源:AddressTest.java

示例12: findNodeInList

import org.jboss.dmr.ModelType; //导入依赖的package包/类
/**
 * This tries to find specific node within a list of nodes. Given an address and a named node
 * at that address (the "haystack"), it is assumed that haystack is actually a list of other
 * nodes. This method looks in the haystack and tries to find the named needle. If it finds it,
 * that list item is returned. If it does not find the needle in the haystack, it returns null.
 *
 * For example, if you want to find a specific datasource in the list of datasources, you
 * can pass in the address for the datasource subsystem, and ask to look in the data-source
 * node list (the haystack) and return the named datasource (the needle).
 *
 * @param addr resource address
 * @param haystack the collection
 * @param needle the item to find in the collection
 * @return the found item or null if not found
 * @throws Exception if the lookup fails for some reason
 */
public ModelNode findNodeInList(Address addr, String haystack, String needle) throws Exception {
    final ModelNode queryNode = createRequest(READ_RESOURCE, addr);
    final ModelNode results = execute(queryNode);
    if (isSuccess(results)) {
        final ModelNode haystackNode = getResults(results).get(haystack);
        if (haystackNode.getType() != ModelType.UNDEFINED) {
            final List<ModelNode> haystackList = haystackNode.asList();
            for (ModelNode needleNode : haystackList) {
                if (needleNode.has(needle)) {
                    return needleNode;
                }
            }
        }
        return null;
    } else {
        throw new FailureException(results, "Failed to get data for [" + addr + "]");
    }
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:35,代码来源:JBossASClient.java

示例13: getResourceAdapterModuleName

import org.jboss.dmr.ModelType; //导入依赖的package包/类
private String getResourceAdapterModuleName(String rarName)
		throws AdminException {
	final List<String> props = new ArrayList<String>();
	cliCall("read-resource",
			new String[] { "subsystem", "resource-adapters", "resource-adapter", rarName},
			null, new ResultCallback() {
				@Override
				void onSuccess(ModelNode outcome, ModelNode result) throws AdminException {
		    		List<ModelNode> properties = outcome.get("result").asList();
		    		
	        		for (ModelNode prop:properties) {
	        			if (!prop.getType().equals(ModelType.PROPERTY)) {
	        				continue;
	        			}
	    				org.jboss.dmr.Property p = prop.asProperty();			        			
						if (p.getName().equals("module")) {
							props.add(p.getValue().asString());
						}
	        		}
				}
			});
	return props.get(0);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:24,代码来源:AdminFactory.java

示例14: onSuccess

import org.jboss.dmr.ModelType; //导入依赖的package包/类
@Override
public void onSuccess(ModelNode outcome, ModelNode result) throws AdminProcessingException {
  		List<ModelNode> props = outcome.get("result").asList();
     		for (ModelNode prop:props) {
     			if (prop.getType().equals(ModelType.PROPERTY)) {
     				org.jboss.dmr.Property p = prop.asProperty();
     				ModelType type = p.getValue().getType();
     				if (p.getValue().isDefined() && !type.equals(ModelType.LIST) && !type.equals(ModelType.OBJECT)) {
				if (p.getName().equals("driver-name")
						|| p.getName().equals("jndi-name")
						|| !excludeProperty(p.getName())) {
     						this.dsProperties.setProperty(p.getName(), p.getValue().asString());
     					}
     				}
     			}
     		}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:18,代码来源:AdminFactory.java

示例15: getAttributeDefinitions

import org.jboss.dmr.ModelType; //导入依赖的package包/类
public AttributeDefinition[] getAttributeDefinitions() {
	ObjectListAttributeDefinition properties = ObjectListAttributeDefinition.Builder.of(PROPERTIES, PropertyMetaDataMapper.INSTANCE.getAttributeDefinition()).build();
	ObjectListAttributeDefinition vdbimports = ObjectListAttributeDefinition.Builder.of(IMPORT_VDBS, VDBImportMapper.INSTANCE.getAttributeDefinition()).build();
	ObjectListAttributeDefinition models = ObjectListAttributeDefinition.Builder.of(MODELS, ModelMetadataMapper.INSTANCE.getAttributeDefinition()).build();
	ObjectListAttributeDefinition translators = ObjectListAttributeDefinition.Builder.of(OVERRIDE_TRANSLATORS, VDBTranslatorMetaDataMapper.INSTANCE.getAttributeDefinition()).build();
	ObjectListAttributeDefinition policies = ObjectListAttributeDefinition.Builder.of(DATA_POLICIES, DataPolicyMetadataMapper.INSTANCE.getAttributeDefinition()).build();
	
	return new AttributeDefinition[] {
			new SimpleAttributeDefinition(VDBNAME, ModelType.STRING, false),
			new SimpleAttributeDefinition(CONNECTIONTYPE, ModelType.INT, false),
			new SimpleAttributeDefinition(STATUS, ModelType.BOOLEAN, false),
			new SimpleAttributeDefinition(VERSION, ModelType.BOOLEAN, false),
			new SimpleAttributeDefinition(VDB_DESCRIPTION, ModelType.BOOLEAN, true),
			new SimpleAttributeDefinition(XML_DEPLOYMENT, ModelType.BOOLEAN, true),
			properties,
			vdbimports,
			models,
			translators,
			policies
		};
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:22,代码来源:VDBMetadataMapper.java


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