Java Doc for AppConfigFactory.java in  » Database-ORM » XORM » org » xorm » util » 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 » Database ORM » XORM » org.xorm.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.xorm.util.AppConfigFactory

AppConfigFactory
public class AppConfigFactory (Code)
Base class for deriving custom AppConfig factories. This object provides the core support for loading AppConfig objects from well-known set places. All you have to do when subclassing this object is to pass in the appropriate settings in the constructor. The rest is handled by this object.

For example, here is the code for a singleton implementation:

package com.myapp;
 import org.xorm.util.AppConfigFactory;
 public final class MyConfigFactory extends AppConfigFactory {
 private static MyConfigFactory singleton;
 static {
 singleton = new MyConfigFactory();
 }
 public static MyConfigFactory getInstance() {
 return singleton;
 }
 private MyConfigFactory() {
 super("myapp/config",
 "com.myapp.configFile",
 "/myapp.properties");
 }
 }

The example above would look for application configuration in the following places:

  1. It looks for a "myapp/config" JNDI resource, which you could set up under your servlet engine (i.e. Tomcat) or webapp configuration. If you choose to configure your application via JNDI, you should make sure the resource points to an AppConfig object.
  2. It looks at the "com.myapp.configFile" system property, which would specify the resource or file where the application properties live.
  3. It falls back on a default resource or file "/myapp.properties" which can live either on the classpath or on the file system. Generally you are encouraged to build a default property file into your application's JAR or class files...in the case above named myapp.properties.

Then, in your application code, whenever you need to access properties or get a PersistenceManager instance, simply do this:

package com.myapp;
 import javax.jdo.PersistenceManager;
 import org.xorm.util.AppConfig;
 public class Example {
 public void main(String[] args) {
 AppConfig appConfig = MyAppConfigFactory.getInstance().getAppConfig();
 PersistenceManager mgr = appConfig.getPersistenceManager();
 String prop = appConfig.getProperty("someProperty");
 }
 }

author:
   Dan Checkoway
See Also:   AppConfig


Field Summary
protected  ClassappConfigClass
    
protected  AppConfigconfig
    
protected  StringconfigFileSystemProperty
    
protected  StringdefaultConfigFile
    
protected  StringjndiConfigResource
    
protected  Loggerlogger
    

Constructor Summary
protected  AppConfigFactory(String jndiConfigResource, String configFileSystemProperty, String defaultConfigFile)
    
protected  AppConfigFactory(String jndiConfigResource, String configFileSystemProperty, String defaultConfigFile, Class appConfigClass)
    

Method Summary
public  AppConfiggetAppConfig()
     Get the AppConfig associated with this factory.
protected  AppConfigloadAppConfig()
     Load the AppConfig from the specified locations.
protected  AppConfigloadAppConfigFromJNDI()
    

Field Detail
appConfigClass
protected Class appConfigClass(Code)



config
protected AppConfig config(Code)



configFileSystemProperty
protected String configFileSystemProperty(Code)



defaultConfigFile
protected String defaultConfigFile(Code)



jndiConfigResource
protected String jndiConfigResource(Code)



logger
protected Logger logger(Code)




Constructor Detail
AppConfigFactory
protected AppConfigFactory(String jndiConfigResource, String configFileSystemProperty, String defaultConfigFile)(Code)
Constructor
Parameters:
  jndiConfigResource - the resource path (under "jndi:comp/env")where the first attempt to load the configuration should look
Parameters:
  configFileSystemProperty - the name of a system property thatmay have been defined as a second-level fallback, pointing to a fileor resource where the configuration should be loaded
Parameters:
  defaultConfigFile - the path of a file or resource where thelast ditch attempt to find the configuration will look



AppConfigFactory
protected AppConfigFactory(String jndiConfigResource, String configFileSystemProperty, String defaultConfigFile, Class appConfigClass)(Code)




Method Detail
getAppConfig
public AppConfig getAppConfig()(Code)
Get the AppConfig associated with this factory. This factory loads a single instance of AppConfig and keeps it around for subsequent calls. Only that one instance is ever created. the respective AppConfig object
See Also:   AppConfig



loadAppConfig
protected AppConfig loadAppConfig()(Code)
Load the AppConfig from the specified locations. This method will first try to load the config from the specified JNDI resource. Then it will look at the specified system property value, falling back on the default path. a new instance of a freshly loaded AppConfig



loadAppConfigFromJNDI
protected AppConfig loadAppConfigFromJNDI()(Code)
Load the AppConfig as a JNDI resource any AppConfig instance configured under the specified resourcepath, if found; otherwise null



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.