Java Doc for DomConfigFactory.java in  » J2EE » hgcommons » biz » hammurapi » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » hgcommons » biz.hammurapi.config 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   biz.hammurapi.config.DomConfigFactory

DomConfigFactory
public class DomConfigFactory (Code)
Creates and configures objects from DOM org.w3c.dom.Element (XML file). DOM Element can be read from InputStream, File or URL. Instantiation and configuration happens as follows:

Instantiation

  • If there is no 'type' attribute then type defaults to java.lang.String and text of the element will be returned. E.g. <name>Pavel</name> will yield string 'Pavel'. 'type' attribute name can be changed through biz.hammurapi.config.DomConfigInfo.setCodeExpression(String) method. Create biz.hammurapi.config.DomConfigInfo , change code expression and then use DomConfigFactory.DomConfigFactory(DomConfigInfo) to instantiate DomConfigFactory.
  • Otherwise class specified in 'type' attribute will be loaded and verified by classAcceptor (if any)
  • If there is no nested 'constructor'' element and element text is blank then default constructor will be used
  • If there is no nested 'constructor'' element and element text is not blank then constructor which takes a single argument of type java.lang.String will be used
  • If there is nested 'constructor' element then 'arg' elements of 'constructor' element are iterated to create a list of arguments. Arguments are constructed in the same way as described here. 'arg' element also supports 'context-ref' attribute. If this attribute is set argument value will be taken from context entry set by DomConfigFactory.setContextEntry(StringObject) method

Configuration

Examples
  1. <name>Pavel</name> will yield java.lang.String with value 'Pavel'
  2. <age type="java.lang.Integer">33</age> will yield java.lang.Integer with value '33'
  3. <config type="org.myself.myproject.MyConfig" url="http://myproject.myself.org/MyConfig.xml"/> will load configuration from URL and configure MyConfig object
  4. <config type="org.myself.myproject.MyParameterizableConfig">
     <parameter name="pi" type="java.lang.Double">3.14159</parameter>
     </config>
    will create MyParameterizableConfig object and then invoke its setParameter() method if MyParameterizableConfig implements biz.hammurapi.config.Parameterizable or invoke setPi() method if there is such method. In lenient mode nothing will happen if there is no setPi() method. Otherwise exception will be thrown.
  5. <config type="org.myself.myproject.MyParameterizableConfig">
     <pi type="java.lang.Double">3.14159</pi>
     </config>
    same as above.

author:
   Pavel Vlasov
version:
   $Revision: 1.12 $


Field Summary
final public static  StringCODE_EXPRESSION
    
final public static  StringMAP_KEY_EXPRESSION
    
final public static  StringMAP_VALUE_EXPRESSION
    
final public static  MapPRIMITIVES
    

Constructor Summary
public  DomConfigFactory()
    
public  DomConfigFactory(Context context)
    
public  DomConfigFactory(ClassLoader classLoader)
    
public  DomConfigFactory(ClassLoader classLoader, Context context)
    

Method Summary
public  Objectcreate(Node node)
     Creates object.
public  Objectcreate(File file, String xPath)
     Parses file and returns object.
public  Objectcreate(File file, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor)
     Parses file and returns object
Parameters:
  file - XML configuration file
Parameters:
  xPath - XPath expression, can be null
Parameters:
  classAcceptor - Class acceptor, validates that class about to be instantiated is 'the right one'
Parameters:
  objectAcceptor - Object acceptor, validates instantiated object.
public  Objectcreate(InputStream in, String xPath)
    
public  Objectcreate(InputStream in, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor)
    
public  Objectcreate(Reader in, String xPath)
    
public  Objectcreate(Reader in, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor)
    
public  Objectcreate(URL url, String xPath)
    
public  Objectcreate(URL url, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor)
    
public  Objectcreate(Node node, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor)
    
protected  Objectcreate(Node node, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor, CachedXPathAPI cxpa)
     Creates and configures object
Parameters:
  node -
Parameters:
  classAcceptor -
Parameters:
  objectAcceptor -
Parameters:
  cxpa - Cached XPath API to accelerate XPath expressions evaluation.
public static  voidinject(Object instance, Context context)
    
public static  voidmain(String[] args)
    

Field Detail
CODE_EXPRESSION
final public static String CODE_EXPRESSION(Code)



MAP_KEY_EXPRESSION
final public static String MAP_KEY_EXPRESSION(Code)



MAP_VALUE_EXPRESSION
final public static String MAP_VALUE_EXPRESSION(Code)



PRIMITIVES
final public static Map PRIMITIVES(Code)




Constructor Detail
DomConfigFactory
public DomConfigFactory()(Code)
Default constructor



DomConfigFactory
public DomConfigFactory(Context context)(Code)
Default constructor



DomConfigFactory
public DomConfigFactory(ClassLoader classLoader)(Code)



DomConfigFactory
public DomConfigFactory(ClassLoader classLoader, Context context)(Code)




Method Detail
create
public Object create(Node node) throws ConfigurationException(Code)
Creates object. Same as create(node, null, null)
Parameters:
  node -
throws:
  ConfigurationException -



create
public Object create(File file, String xPath) throws ConfigurationException, IOException(Code)
Parses file and returns object. Same as create(file, xPath, null, null)
Parameters:
  file - XML configuration file
Parameters:
  xPath - XPath expression, can be null configured object



create
public Object create(File file, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor) throws ConfigurationException, IOException(Code)
Parses file and returns object
Parameters:
  file - XML configuration file
Parameters:
  xPath - XPath expression, can be null
Parameters:
  classAcceptor - Class acceptor, validates that class about to be instantiated is 'the right one'
Parameters:
  objectAcceptor - Object acceptor, validates instantiated object. Configured object



create
public Object create(InputStream in, String xPath) throws ConfigurationException, IOException(Code)
Same as create(in, xPath, null, null)
Parameters:
  in - Input stream
Parameters:
  xPath - XPath expression, can be null Configured object
throws:
  ConfigurationException -
throws:
  IOException -



create
public Object create(InputStream in, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor) throws ConfigurationException, IOException(Code)
Creates and configures object from InputStream
Parameters:
  in - Input stream
Parameters:
  xPath - XPath expression, can be null
Parameters:
  classAcceptor -
Parameters:
  objectAcceptor - Configured object
throws:
  ConfigurationException -
throws:
  IOException -



create
public Object create(Reader in, String xPath) throws ConfigurationException, IOException(Code)
Same as create(in, xPath, null, null)
Parameters:
  in - Reader
Parameters:
  xPath - XPath expression, can be null Configured object
throws:
  ConfigurationException -
throws:
  IOException -



create
public Object create(Reader in, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor) throws ConfigurationException, IOException(Code)
Creates and configures object from InputStream
Parameters:
  in - Reader
Parameters:
  xPath - XPath expression, can be null
Parameters:
  classAcceptor -
Parameters:
  objectAcceptor - Configured object
throws:
  ConfigurationException -
throws:
  IOException -



create
public Object create(URL url, String xPath) throws ConfigurationException, IOException(Code)
Same as create(url, xPath, null, null)
Parameters:
  url - URL to read configuration from
Parameters:
  xPath - XPath expression, can be null Configured object
throws:
  ConfigurationException -
throws:
  IOException -



create
public Object create(URL url, String xPath, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor) throws ConfigurationException, IOException(Code)
Creates and configures object from URL
Parameters:
  url - Url
Parameters:
  xPath - XPath expression, can be null
Parameters:
  classAcceptor -
Parameters:
  objectAcceptor - Configured object
throws:
  ConfigurationException -
throws:
  IOException -



create
public Object create(Node node, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor) throws ConfigurationException(Code)
Creates object from org.w3c.dom.Node
Parameters:
  node - Node
Parameters:
  classAcceptor -
Parameters:
  objectAcceptor - Configured object
throws:
  ConfigurationException -



create
protected Object create(Node node, ClassAcceptor classAcceptor, ObjectAcceptor objectAcceptor, CachedXPathAPI cxpa) throws ConfigurationException(Code)
Creates and configures object
Parameters:
  node -
Parameters:
  classAcceptor -
Parameters:
  objectAcceptor -
Parameters:
  cxpa - Cached XPath API to accelerate XPath expressions evaluation. Configured object
throws:
  ConfigurationException -



inject
public static void inject(Object instance, Context context) throws ConfigurationException(Code)
Sets property (field or through setter) using reflection
Parameters:
  instance -
Parameters:
  lenient - If false then inject throws ConfigurationException if property does not exists
Parameters:
  string -
Parameters:
  object -



main
public static void main(String[] args)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.