Advanced article master: Jive in the use of analytical Jdom
Well-known Open Source Forum Jive has a lot of things worthy of our analysis and study, by analyzing the use of its Jdom mechanism, we can easily facilitate the reading and writing xml configuration files in order to achieve the following functions:
Settings in the configuration file system attributes languages, different language versions, the system not the same as the text interface, you can define your own country's language, such as the English version of Simplified Chinese version. In this way, the will can be easily extended to a system in various languages, do not directly modify the program, as long as the modified xml configuration file can be.
Settings in the configuration file e-mail the contents of a system usually have a variety of automatic e-mail distribution, such as user registration is successful, there will be an Email sent to his mailbox, the system is installed in different occasions, customers, Email the content of course not the same as , such as A customer using the system, of course, wish to Email in the Name of A customers, which do not have to modify the program to be completed.
The system of optional attributes, a system installed in different occasions, customers, customers have some different requirements, some features are optional, then of course these must be set in the xml configuration file.
XML tree structure used record store is most convenient, especially for those classification system directory, such as Yahoo, in a small classification category, or directly from relational database elements we know are not good at tree data stored in relational databases typical approach is to take two tables: one table for each recorded cell; a table indicating the relationship between before and after; but once we start from the two tree structure table to be in space and time repeatedly balance.
If you are using XML as a data source, it is convenient to solve this problem, if the line with the XML data source by a very convenient, maintenance, and other functions, then we will of course choose to XML, in fact, Jdom readily available on the tool. Jdom DOM SAX is similar to XML, such as analytical methods are only suitable for java language, Jdom is characterized by easy and convenient.
So let us take a look at how Jive is it to achieve the above functions, it is to write all these attributes in a document called jive_config.xml. The XML documents and use of the arrangement is like this:
XML content of the document format:
<! - Root element, all properties must be under this element ->
<fromName> Jive_Administrator </ fromName>
<fromEmail> firstname.lastname@example.org </ fromEmail>
<subject> Your thread was updated! </ subject>
<body> Hello (name)! The thread (threadName) was updated! </ body>
<jive> </ jive>
Is the root element, all attributes must be in one. Also relatively simple to use, the use of punctuation "." To intervals. For example, we want email@example.com the value of the above, then you can use email.fromEmail. In Jive, the specific statement is JiveGlobals.getJiveProperty ( "email.fromEmail"); this value is very simple to obtain and understand, no matter how deep the XML tree structure, we can easily access.
The key here is a Jdom to resolve the use of XML document type: XMLProperties, which has several major methods of operation:
access (query): getProperty (name);
Add to amend: properties.setProperty (name, value);
Delete: properties.deleteProperty (name);
Several ways this is very similar to the method Hasntable? Hashtable data is stored in memory, and the XML is stored in the file system, no doubt we can use hashtable as easy as the use of XML.
We can XMLProperties intact copy of our system. The only preparation to do is similar to Jive's JiveGlobals, In fact, this is also very simple, in two steps: first remove the XML file load; then provide getProperty (name) and so on. Such as the public class JiveGlobals (
private static final String JIVE_CONFIG_FILENAME = "jive_config.xml";
public static String getJiveProperty (String name) (
return properties.getProperty (name);
private synchronized static void loadProperties () (
if (properties == null) (
/ / Create a manager with the full path to the xml config file.
properties = new XMLProperties (jiveHome + File.separator +
Of course, the premise of all these is to http://www.jdom.org Download Jdom package, and added to the Tomcat's common / lib, or in the Add Classpath.
Other supporting documents: DataFormatFilter.java DataUnformatFilter.java XMLFilterBase.java. If you are a Jdom specifically how to use each and can be carefully studied XMLProperties, easy to understand.
Java and XML Articles
- Dynamic WEB application in the creation of PDF documents
- Environment variable with the deployment of custom applications on the Web to discuss the scope of layer properties
- Web Application Framework for JDBC-ODBC configuration
- Learn to how to use Java Web Start application deployment
- Web applications, how to start the background task
- Manually created namespace SOAP message processing
- Web Service Appender management log record
- Spring WebFlow: 2 (WebFlow of key components)
- Spring WebFlow: 3 (WebFlow achieve reuse)
- Axis 1.1 for Java for Web Services Development
- Technical Analysis: Based on the Custom Axis Object Serialization
- To adapt to multi-database environment ConnectionManager
- Eclipse plug-ins to achieve Axis WebService client
- JWSDP completed using the Web Service entry in java (a)
- JWSDP completed using the Web Service entry in the java (b)
- Learn to teach you the basis of XML Web Service
- Apache Img Tag used to generate images immediately verify
- Advanced article master: Jive in the use of analytical Jdom
- Analysis of Web Service development of different levels
- WSDL in the Web Service in the meaning and role of
Can't Find What You're Looking For?
Rating: Not yet rated