667514 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

J2EE patterns J2EE patterns J2EE patterns Messages: 1 Messages: 1 Messages: 1 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Configuration Inheritance(CI) Pattern

Posted by: mikab Peng on September 16, 2008 DIGG
The Configuration Inheritance Pattern,Its exact name is configuration information inheritance with the template technology. Like class inheritance, the application get function’s configuration information from the parent node first, then extend and override the configuration information. The emphasis of this pattern is that function takes the full control of configuration, but functions can share their configurations through inheritance. In addition, we can use regular expression and script in the configuration file, function determines the match result of the regular expression and value of script expression. This is like the usage of wildcards in configuration file of STRUCTS 1.2.
Normally, one system can divide into several modules, and each module has several modules or functions. The relationship between the system, modules and functions determine the way of the inheritance. Like URL in web, we can give each function or module a symbol which is called the function-path. Basically, the system’s function-path is ‘/’, and the module’s function-path ends with character ‘/’. Usually, the System has many types of configuration information. So we define that the configuration of a function with a special type is a domain. Now, the Configuration Inheritance could treat as this: If we want to get information of a domain, firstly we get the function’s domain with the same type from parent according the function-path, then extend and override the item of the domain; at last we should use the function-path to get the value of regular expressions and scripts.
Comparing with the old method of configuration, we do less work but it is more powerful and convenient.
Let’s think about a sample case: the system has two modules and each module has two functions; at the development stage and early stage of running, all of the functions use the same data source; at later stage, the system may use two or more data sources because of growth of user and data. How can we fulfill the requirement without any modifying the code?
If we use the Configuration Inheritance Pattern, at the development stage and early stage of running, we could define the name of data source in the system’s domain, so every function could use the same name; if the first module use another data source lately, we could define the new data source name in the module’s domain to override the name which inherited from the system’s domain; even every function use a different data source, we just define a special name for each function. If configuration can solve the problem, just solve it using configuration.
If we use the Configuration Inheritance Pattern, there are some differences for coding: you must get the information with implicit function-path, not get the information from a global variable. The new code just like this:
ConfigDomain config = ConfigurationManager.getInformation(functionPath,configType);
Like the Spring framework is the implementation of the DI pattern, I just have finished a simple implement, I call it pyramid. You can get the code from http://code.google.com/p/pyramid/. But I apologizes the comments are written in Chinese; I may translate them into English later. Fortunately we must write java code in English. If you have any question or advice, you can send emails to mikab@sohu.com.
  Message #322624 Post reply Post reply Post reply Go to top Go to top Go to top

Thanks

Posted by: Ashique Raheem on September 29, 2009 in response to Message #268666
Thanks mikab, i really needed this piece of information

regards
SEO Services UK

J2EE PatternsJ2EE PatternsJ2EE Patterns
Patterns

We are proud to provide this patterns/strategies repository to the community. Feel free to post any useful design tips you know!

EJB Design Patterns PDFEJB Design Patterns PDFEJB Design Patterns PDF

EJB Design Patterns is now available for free download in PDF format. The book contains a catalog of twenty advanced EJB patterns and provides strategies for mapping application requirements to patterns-driven design, J2EE development best practices, and more. EJB Design Patterns was the #2 book at Java One 2002, and held the #1 Java book position on Amazon.com for weeks since the book was released in March. Download your PDF here.
Useful patterns around the webUseful patterns around the webUseful patterns around the web
Patterns

EntityBeansAsDomainObjects

This essential pattern describes how to model your entity beans.

The Aggregate Entity pattern

How to make an entity bean a facade to a set of dependent objects.

EJB Unit Testing Strategies

Every guru should use unit testing.

Other Patterns sitesOther Patterns sitesOther Patterns sites

Portland Patterns Repository

The original reference site for patterns. Frequented by the gang of 4 and their mentors (Kent Beck, Ward Cunningham).

Sun Java Center Patterns

A catalogue of J2EE design patterns from Suns Consulting Division.

IBM Patterns for e-Business

A catalogue of high level business, architectural and topological patterns for large scale systems.

J2EE Blueprints Patterns

Design Patterns from the J2EE Blueprints, Suns authoritative guide to J2EE development.


News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map