Adobe 38000382 JRun Guide - Page 111
Using XML metadata, Nested elements have their own metadata classes.
UPC - 718659575946
View all Adobe 38000382 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 111 highlights
Using XML metadata Follow these steps to edit the XML files. To edit XML files: 1 Find the appropriate class name. For web.xml, the JRunWebAppMetaData class instantiates this file. 2 Create a new class. If the file exists, you must execute the importXML(URL url) method on it. The URL is the file. If the file does not exist, you do not have to take any additional steps. You will set the location when you save the changes. 3 Issue getter and setter methods, as needed. The XML metadata classes include getters and setters for all elements found in the DTD. For example, if you want to set the value of the context-root in the web.xml file, you use the following method: fmd.setContextRoot("/root"); If there are multiple subelements, use the addXXX method, where XXX is the name of the element. For example, the following method adds several mappings for a filter in the web.xml file: fmmd.addURLPattern("/*"); You can also delete elements or set them to null. If an element does not extend XMLMetaData, use setFoo(null). Otherwise, call the XMLMetaData.remove method. When you import the XML file with the importXML method, JRun sets all the values using the following naming conventions: • First character is lowercase. • Hyphens are replaced with uppercase characters. • Nested elements have their own metadata classes. For example, the element context-root becomes contextRoot in your class. 4 Save the elements out to the file. 5 Call xmlclass.setMetaDataSource(file). 6 Call xmlclass.exportDocument. 7 Compile the class. Add jrun.jar to your classpath when compiling classes that use XML metadata methods. The following example compiles the MyMetaDataClass.java file: %> javac -classpath "c:/jrun4/lib/jrun.jar" MyMetaDataClass.java 8 Run the class. Add jrun.jar to your classpath when running classes that use XML metadata methods. If you created the class as a stand-alone Java application, you can execute the following: %> java -classpath "c:/jrun4/lib/jrun.jar" MyMetaDataClass Using XML metadata 97