PASX simplifies Java development

Source: Internet
Author: User
Have you ever compiled a program but found that its configuration process is unreasonable during review? Have you ever used configuration files but found that they cannot meet the needs of describing applications? Have you created temporary configuration patches to solve a few special problems, but have you pinned your hopes for spending more time and developing universal solutions in the future?
If your answer is yes, you are as lucky as most other Java programmers and have some tools to help you solve these problems. If your answer is no, the discussion about the limitation of the attribute file may convince you-there are better ways to use it.
Attribute files are an important part of Java programming and runtime environments. However, when a programmer needs more functions than the simple name-value pair provided by the Properties class, he needs more abundant representations. Generally, a Java programmer extends an attribute file by adding additional semantic information to the name or value (or both) of the attribute. In many cases, such an effective method will make the problem more and more complex.
To illustrate the problem, use the attribute to assign a series of values to a single name. Let's assume that you want to manage a group of name servers. The attribute file content may be as follows:
Hosts_1 = ns.foo.com
Hosts_2 = ns.bar.com
Hosts_3 = ns.acme.com
The code is simple. After changing the meaning of the name-value pair, you can easily compile a program that treats the name starting with "hosts _" as an element in the "hosts" list.
Next, let's look at a more complex example. Suppose you have two different instances of the same Bean class InternetHost: instance A is associated with the list of A Web server, and instance B is associated with the list of A name server. To configure the two instances from the same file, one possible solution is as follows:
Name_hosts_1 = ns.foo.com
Name_hosts_2 = ns.bar.com
Name_hosts_3 = ns.acme.com
Web_hosts_1 = www.foo.com
Web_hosts_2 = www.bar.com
Web_hosts_3 = www.acme.com
This method works, but it always gives people the feeling of spelling together. If you do not believe it, you can add a little more complexity: Make an element in the list itself a list; or, make the underline character ("_") valid in name-value pairs. In these cases, simple attribute files become very complex.
As a careful reader, you may have discovered that the naming methods of InternetHost instances are gradually blurred. In order to assign the first three attributes to instance A and the last three attributes to instance B, you must use A method unrelated to the specific instance to tell the instance which group of attribute values should be used. If instance A is directly encoded to search for attributes starting with "name _" and instance B to search for attributes starting with "Web, the two instances no longer belong to the same object class.
The last example shows another problem. This is how to call instance? Simply call it ""? Where can I find it? Is it a local instance or a remote interface? Is there a global static reference pointing to it? If so, how to access instance B (or, is it "B ")?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.