Java Code Examples for org.jboss.dmr.ModelNode#writeString()
The following examples show how to use
org.jboss.dmr.ModelNode#writeString() .
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: AbstractITest.java From hawkular-agent with Apache License 2.0 | 6 votes |
public static void writeNode(Class<?> caller, ModelNode node, String nodeFileName) throws UnsupportedEncodingException, FileNotFoundException { URL callerUrl = caller.getResource(caller.getSimpleName() + ".class"); if (!callerUrl.getProtocol().equals("file")) { throw new IllegalStateException(AbstractITest.class.getName() + ".store() works only if the caller's class file is loaded using a file:// URL."); } String callerUrlPath = callerUrl.getPath(); String nodePath = callerUrlPath.replaceAll("\\.class$", "." + nodeFileName); nodePath = nodePath.replace("/target/test-classes/", "/src/test/resources/"); System.out.println("Storing a node to [" + nodePath + "]"); File outputFile = new File(nodePath); if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } try (PrintWriter out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "utf-8"))) { node.writeString(out, false); } }
Example 2
Source File: SubsystemDescriptionDump.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void dumpManagementResourceRegistration(final ImmutableManagementResourceRegistration profileRegistration, final ExtensionRegistry registry, final String path) throws OperationFailedException{ try { for (PathElement pe : profileRegistration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { ImmutableManagementResourceRegistration registration = profileRegistration.getSubModel(PathAddress.pathAddress(pe)); String subsystem = pe.getValue(); SubsystemInformation info = registry.getSubsystemInfo(subsystem); ModelNode desc = readFullModelDescription(PathAddress.pathAddress(pe), registration); String name = subsystem + "-" + info.getManagementInterfaceMajorVersion() + "." + info.getManagementInterfaceMinorVersion() +"."+info.getManagementInterfaceMicroVersion()+ ".dmr"; PrintWriter pw = new PrintWriter(Files.newBufferedWriter(Paths.get(path,name), StandardCharsets.UTF_8)); desc.writeString(pw, false); pw.close(); } } catch (IOException e) { throw new OperationFailedException("could not save,", e); } }
Example 3
Source File: SyncModelServerStateTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
void addRolloutPlan(ModelNode dmr) throws Exception { File systemTmpDir = new File(System.getProperty("java.io.tmpdir")); File tempDir = new File(systemTmpDir, "test" + System.currentTimeMillis()); tempDir.mkdir(); File file = new File(tempDir, "content"); this.vf = VFS.getChild(file.toURI()); try (final PrintWriter out = new PrintWriter(Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8))){ dmr.writeString(out, true); } }
Example 4
Source File: Util.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Build a compact representation of the ModelNode. * @param node The model * @return A single line containing the multi lines ModelNode.toString() content. */ public static String compactToString(ModelNode node) { Objects.requireNonNull(node); final StringWriter stringWriter = new StringWriter(); final PrintWriter writer = new PrintWriter(stringWriter, true); node.writeString(writer, true); return stringWriter.toString(); }
Example 5
Source File: TransformationUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Dumps the target subsystem resource description to DMR format, needed by TransformerRegistry for non-standard subsystems * * @param kernelServices the kernel services for the started controller * @param modelVersion the target subsystem model version * @param mainSubsystemName name of subsystem * @param dmrFile file where to write description */ private static void generateLegacySubsystemResourceRegistrationDmr(KernelServices kernelServices, ModelVersion modelVersion, String mainSubsystemName, Path dmrFile) throws IOException { KernelServices legacy = kernelServices.getLegacyServices(modelVersion); //Generate the org.jboss.as.controller.transform.subsystem-version.dmr file - just use the format used by TransformerRegistry for now PathAddress pathAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, mainSubsystemName)); ModelNode desc = ((KernelServicesInternal) legacy).readFullModelDescription(pathAddress.toModelNode()); try (PrintWriter pw = new PrintWriter(Files.newBufferedWriter(dmrFile, StandardCharsets.UTF_8))) { desc.writeString(pw, false); //System.out.println("Legacy resource definition dmr written to: " + dmrFile.getAbsolutePath()); } }