本文整理汇总了Java中org.jboss.as.controller.persistence.SubsystemMarshallingContext类的典型用法代码示例。如果您正苦于以下问题:Java SubsystemMarshallingContext类的具体用法?Java SubsystemMarshallingContext怎么用?Java SubsystemMarshallingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubsystemMarshallingContext类属于org.jboss.as.controller.persistence包,在下文中一共展示了SubsystemMarshallingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modelToXml
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
public String modelToXml(String subsystemName, String childType, XMLElementWriter<SubsystemMarshallingContext> parser) throws Exception {
final ModelNode address = new ModelNode();
address.add("subsystem", subsystemName);
address.protect();
final ModelNode operation = new ModelNode();
operation.get(OP).set("read-children-resources");
operation.get("child-type").set(childType);
operation.get(RECURSIVE).set(true);
operation.get(OP_ADDR).set(address);
final ModelNode result = executeOperation(operation);
Assert.assertNotNull(result);
ModelNode dsNode = new ModelNode();
dsNode.get(childType).set(result);
StringWriter strWriter = new StringWriter();
XMLExtendedStreamWriter writer = XMLExtendedStreamWriterFactory.create(XMLOutputFactory.newInstance()
.createXMLStreamWriter(strWriter));
parser.writeContent(writer, new SubsystemMarshallingContext(dsNode, writer));
writer.flush();
return strWriter.toString();
}
示例2: writeProfile
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
private void writeProfile(final XMLExtendedStreamWriter writer, final String profileName, final ModelNode profileNode, final ModelMarshallingContext context) throws XMLStreamException {
writer.writeStartElement(Element.PROFILE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), profileName);
ProfileResourceDefinition.INCLUDES.getMarshaller().marshallAsAttribute(ProfileResourceDefinition.INCLUDES, profileNode, false, writer);
if (profileNode.hasDefined(SUBSYSTEM)) {
final Set<String> subsystemNames = profileNode.get(SUBSYSTEM).keys();
if (subsystemNames.size() > 0) {
String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
for (String subsystemName : subsystemNames) {
try {
ModelNode subsystem = profileNode.get(SUBSYSTEM, subsystemName);
XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(subsystemName);
if (subsystemWriter != null) { // FIXME -- remove when extensions are doing the registration
subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
}
} finally {
writer.setDefaultNamespace(defaultNamespace);
}
}
}
}
writer.writeEndElement();
}
示例3: wrapPossibleHost
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
private ModelMarshallingContext wrapPossibleHost(final ModelMarshallingContext context) {
if (type == TestModelType.HOST) {
return new ModelMarshallingContext() {
@Override
public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String subsystemName) {
return context.getSubsystemWriter(subsystemName);
}
@Override
public ModelNode getModelNode() {
return context.getModelNode().get(ModelDescriptionConstants.HOST, "master");
}
};
}
return context;
}
示例4: sanitizeContext
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
private ModelMarshallingContext sanitizeContext(final ModelMarshallingContext context) {
if (writeSanitizers == null) {
return context;
}
ModelNode model = context.getModelNode();
for (ModelWriteSanitizer sanitizer : writeSanitizers) {
model = sanitizer.sanitize(model);
}
final ModelNode theModel = model;
return new ModelMarshallingContext() {
@Override
public XMLElementWriter<SubsystemMarshallingContext> getSubsystemWriter(String subsystemName) {
return context.getSubsystemWriter(subsystemName);
}
@Override
public ModelNode getModelNode() {
return theModel;
}
};
}
示例5: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
@Override
public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context) throws XMLStreamException {
String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
try {
ModelNode subsystems = context.getModelNode().get(SUBSYSTEM);
if (subsystems.has(mainSubsystemName)) {
ModelNode subsystem = subsystems.get(mainSubsystemName);
//We might have been removed
XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(mainSubsystemName);
if (subsystemWriter != null) {
subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
}
}else{
writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
}
}catch (Throwable t){
Assert.fail("could not marshal subsystem xml: "+t.getMessage()+":\n"+ Arrays.toString(t.getStackTrace()).replaceAll(", ","\n"));
} finally {
writer.setDefaultNamespace(defaultNamespace);
}
writer.writeEndDocument();
}
示例6: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode node = context.getModelNode();
if (node.hasDefined(ModelConstants.CONTEXT)) {
ModelNode properties = node.get(ModelConstants.CONTEXT);
for (String key : new TreeSet<String>(properties.keys())) {
String val = properties.get(key).get(ModelConstants.VALUE).asString();
writer.writeStartElement(Element.CAMEL_CONTEXT.getLocalName());
writer.writeAttribute(Attribute.ID.getLocalName(), key);
writer.writeCharacters(val);
writer.writeEndElement();
}
}
writer.writeEndElement();
}
示例7: writeJobExecutorContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
private void writeJobExecutorContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
ModelNode node = context.getModelNode();
ModelNode jobExecutorNode = node.get(Element.JOB_EXECUTOR.getLocalName());
if (jobExecutorNode.isDefined()) {
writer.writeStartElement(Element.JOB_EXECUTOR.getLocalName());
Property property = jobExecutorNode.asProperty();
writeElement(Element.THREAD_POOL_NAME, writer, property.getValue());
writeJobAcquisitionsContent(writer, context, property.getValue());
// end job-executor
writer.writeEndElement();
}
}
示例8: writeJobAcquisitionsContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
private void writeJobAcquisitionsContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context, ModelNode parentNode) throws XMLStreamException {
writer.writeStartElement(Element.JOB_AQUISITIONS.getLocalName());
ModelNode jobAcquisitionConfigurations = parentNode.get(Element.JOB_AQUISITIONS.getLocalName());
if (jobAcquisitionConfigurations.isDefined()) {
for (Property property : jobAcquisitionConfigurations.asPropertyList()) {
// write each child element to xml
writer.writeStartElement(Element.JOB_AQUISITION.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
ModelNode entry = property.getValue();
writeElement(Element.ACQUISITION_STRATEGY, writer, entry);
writeProperties(writer, entry);
writer.writeEndElement();
}
}
// end job-acquisitions
writer.writeEndElement();
}
示例9: writeJobExecutorContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
protected void writeJobExecutorContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
ModelNode node = context.getModelNode();
ModelNode jobExecutorNode = node.get(Element.JOB_EXECUTOR.getLocalName());
if (jobExecutorNode.isDefined()) {
writer.writeStartElement(Element.JOB_EXECUTOR.getLocalName());
for (Property property : jobExecutorNode.asPropertyList()) {
ModelNode propertyValue = property.getValue();
for (AttributeDefinition jobExecutorAttribute : SubsystemAttributeDefinitons.JOB_EXECUTOR_ATTRIBUTES) {
if (jobExecutorAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
((SimpleAttributeDefinition) jobExecutorAttribute).marshallAsAttribute(propertyValue, writer);
} else {
jobExecutorAttribute.marshallAsElement(propertyValue, writer);
}
}
writeJobAcquisitionsContent(writer, context, propertyValue);
}
// end job-executor
writer.writeEndElement();
}
}
示例10: writeJobAcquisitionsContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
protected void writeJobAcquisitionsContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context, ModelNode parentNode) throws XMLStreamException {
writer.writeStartElement(Element.JOB_AQUISITIONS.getLocalName());
ModelNode jobAcquisitionConfigurations = parentNode.get(Element.JOB_AQUISITIONS.getLocalName());
if (jobAcquisitionConfigurations.isDefined()) {
for (Property property : jobAcquisitionConfigurations.asPropertyList()) {
// write each child element to xml
writer.writeStartElement(Element.JOB_AQUISITION.getLocalName());
for (AttributeDefinition jobAcquisitionAttribute : SubsystemAttributeDefinitons.JOB_ACQUISITION_ATTRIBUTES) {
if (jobAcquisitionAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
((SimpleAttributeDefinition) jobAcquisitionAttribute).marshallAsAttribute(property.getValue(), writer);
} else {
jobAcquisitionAttribute.marshallAsElement(property.getValue(), writer);
}
}
writer.writeEndElement();
}
}
// end job-acquisitions
writer.writeEndElement();
}
示例11: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
final ModelNode node = context.getModelNode();
final ModelNode mbean = node.get(SmppMbeanDefinition.MBEAN);
for (Property mbeanProp : mbean.asPropertyList()) {
writer.writeStartElement(SmppMbeanDefinition.MBEAN);
final ModelNode mbeanEntry = mbeanProp.getValue();
SmppMbeanDefinition.NAME_ATTR.marshallAsAttribute(mbeanEntry, true, writer);
SmppMbeanDefinition.TYPE_ATTR.marshallAsAttribute(mbeanEntry, true, writer);
final ModelNode property = mbeanEntry.get(SmppMbeanPropertyDefinition.PROPERTY);
if (property != null && property.isDefined()) {
for (Property propertyProp : property.asPropertyList()) {
writer.writeStartElement(SmppMbeanPropertyDefinition.PROPERTY);
final ModelNode propertyEntry = propertyProp.getValue();
SmppMbeanPropertyDefinition.NAME_ATTR.marshallAsAttribute(propertyEntry, true, writer);
SmppMbeanPropertyDefinition.TYPE_ATTR.marshallAsAttribute(propertyEntry, true, writer);
SmppMbeanPropertyDefinition.VALUE_ATTR.marshallAsAttribute(propertyEntry, true, writer);
writer.writeEndElement();
}
}
writer.writeEndElement();
}
writer.writeEndElement();
}
示例12: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context)
throws XMLStreamException {
ModelNode node = context.getModelNode();
// <subsystem>
context.startSubsystemElement(NestSubsystemExtension.NAMESPACE, false);
writer.writeAttribute(NEST_ENABLED_ATTR, node.get(NEST_ENABLED_ATTR).asString());
// our config elements
writeElement(writer, node, NEST_NAME_ELEMENT);
// <custom-configuration>
writer.writeStartElement(CUSTOM_CONFIG_ELEMENT);
ModelNode configNode = node.get(CUSTOM_CONFIG_ELEMENT);
if (configNode != null && configNode.isDefined()) {
for (Property property : configNode.asPropertyList()) {
// <propery>
writer.writeStartElement(PROPERTY_ELEMENT);
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
writer.writeAttribute(Attribute.VALUE.getLocalName(), property.getValue().asString());
// </property>
writer.writeEndElement();
}
}
// </custom-configuration>
writer.writeEndElement();
// </subsystem>
writer.writeEndElement();
}
示例13: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(OpenShiftSubsystemExtension.NAMESPACE, false);
ModelNode node = context.getModelNode();
if(node.hasDefined(Constants.MAX_LINE_LENGTH)) {
OpenShiftSubsystemDefinition.MAX_LINE_LENGTH.marshallAsElement(node, writer);
}
ModelNode metricsGroups = node.get(Constants.METRICS_GROUP);
writeMetricsGroups(writer, metricsGroups);
writer.writeEndElement();
}
示例14: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
throws XMLStreamException {
context.startSubsystemElement(OrderedChildResourceExtension.NAMESPACE, false);
final ModelNode node = context.getModelNode();
if (node.hasDefined("child")) {
for (Property prop : node.get("child").asPropertyList()) {
writer.writeStartElement("child");
writer.writeAttribute("name", prop.getName());
writer.writeEndElement();
}
}
writer.writeEndElement();
}
示例15: writeContent
import org.jboss.as.controller.persistence.SubsystemMarshallingContext; //导入依赖的package包/类
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode model = context.getModelNode();
// Marshall attributes
for (AttributeDefinition attribute : LoggingResourceDefinition.ATTRIBUTES) {
attribute.marshallAsElement(model, false, writer);
}
writeContent(writer, model);
if (model.hasDefined(LOGGING_PROFILE)) {
final List<Property> profiles = model.get(LOGGING_PROFILE).asPropertyList();
if (!profiles.isEmpty()) {
writer.writeStartElement(LOGGING_PROFILES);
for (Property profile : profiles) {
final String name = profile.getName();
writer.writeStartElement(LOGGING_PROFILE);
writer.writeAttribute(Attribute.NAME.getLocalName(), name);
writeContent(writer, profile.getValue());
writer.writeEndElement();
}
writer.writeEndElement();
}
}
writer.writeEndElement();
}