Java Doc for MetadataManager.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » metadata » 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 » db ojb » org.apache.ojb.broker.metadata 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.ojb.broker.metadata.MetadataManager

MetadataManager
public class MetadataManager (Code)
Central class for metadata operations/manipulations - manages OJB's metadata objects, in particular: This class allows transparent flexible metadata loading/manipulation at runtime.

How to read/merge metadata
Per default OJB loads default org.apache.ojb.broker.metadata.DescriptorRepository and org.apache.ojb.broker.metadata.ConnectionRepository instances, by reading the specified repository file. This is done first time the MetadataManager instance was used.
To read metadata information at runtime use MetadataManager.readDescriptorRepository readDescriptorRepository and MetadataManager.readConnectionRepository readConnectionRepository methods.
It is also possible to merge different repositories using MetadataManager.mergeDescriptorRepository mergeDescriptorRepository and MetadataManager.mergeConnectionRepository mergeConnectionRepository

Per thread handling of metadata

Per default the manager handle one global org.apache.ojb.broker.metadata.DescriptorRepository for all calling threads, but it is ditto possible to use different metadata profiles in a per thread manner - profiles means different copies of org.apache.ojb.broker.metadata.DescriptorRepository objects.

Enable the per thread mode
To enable the 'per thread' mode for
org.apache.ojb.broker.metadata.DescriptorRepository instances:

 MetadataManager mm = MetadataManager.getInstance();
 // tell the manager to use per thread mode
 mm.setEnablePerThreadChanges(true);
 ...
 
This could be done e.g. at start up.
Now it's possible to use dedicated DescriptorRepository instances per thread:
 // e.g we get a coppy of the global repository
 DescriptorRepository dr = mm.copyOfGlobalRepository();
 // now we can manipulate the persistent object metadata of the copy
 ......
 // set the changed repository for this thread
 mm.setDescriptor(dr);
 // now let this thread lookup a PersistenceBroker instance
 // with the modified metadata
 // all other threads use the global metadata
 PersistenceBroker broker = Persis......
 
Note: Change metadata before lookup the org.apache.ojb.broker.PersistenceBroker instance for current thread, because the metadata was bound to the PB at lookup.

How to use different metadata profiles
MetadataManager was shipped with a simple mechanism to add, remove and load different persistent objects metadata profiles (different org.apache.ojb.broker.metadata.DescriptorRepository instances) in a per thread manner. Use

Note: method MetadataManager.loadProfile loadProfile only works if the per thread mode is enabled.


author:
   Armin Waibel
version:
   $Id: MetadataManager.java,v 1.19.2.7 2005/12/21 22:26:10 tomdz Exp $




Method Summary
public  voidaddProfile(Object key, DescriptorRepository repository)
     Add a metadata profile.
public  voidclearProfiles()
     Remove all metadata profiles.
public  ConnectionRepositoryconnectionRepository()
     Returns the ConnectionRepository .
public  DescriptorRepositorycopyOfGlobalRepository()
     Returns a copy of the current global org.apache.ojb.broker.metadata.DescriptorRepository

Note: All classes within the repository structure have to implement java.io.Serializable to be able to create a cloned copy.

public  ObjectgetCurrentProfileKey()
     Returns the last activated profile key.
public  PBKeygetDefaultPBKey()
     Return the default PBKey used in convinience method org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker .
public  DescriptorRepositorygetGlobalRepository()
     Returns explicit the global org.apache.ojb.broker.metadata.DescriptorRepository - use with care, because it ignores the MetadataManager.isEnablePerThreadChanges per thread mode .
public static synchronized  MetadataManagergetInstance()
     Returns an instance of this class.
public  DescriptorRepositorygetRepository()
     Returns the current valid org.apache.ojb.broker.metadata.DescriptorRepository for the caller.
public  booleanisEnablePerThreadChanges()
     If returns true if per thread runtime changes of the org.apache.ojb.broker.metadata.DescriptorRepository is enabled and the MetadataManager.getRepository method returns a threaded repository file if set, or the global if no threaded was found.
public  voidloadProfile(Object key)
     Load the given metadata profile for the current thread.
public  voidmergeConnectionRepository(ConnectionRepository repository)
     Merge the given ConnectionRepository with the existing one (without making a deep copy of the containing connection descriptors).
public  voidmergeConnectionRepository(ConnectionRepository targetRepository, ConnectionRepository sourceRepository, boolean deep)
     Merge the given source ConnectionRepository with the existing target.
public  voidmergeDescriptorRepository(DescriptorRepository repository)
     Merge the given org.apache.ojb.broker.metadata.DescriptorRepository (without making a deep copy of containing class-descriptor objects) with the global one, returned by method MetadataManager.getRepository() - keep in mind if running in per thread mode merge maybe only takes effect on current thread.
public  voidmergeDescriptorRepository(DescriptorRepository targetRepository, DescriptorRepository sourceRepository, boolean deep)
     Merge the given org.apache.ojb.broker.metadata.DescriptorRepository files, the source objects will be pushed to the target repository.
public  ConnectionRepositoryreadConnectionRepository(String fileName)
     Read JdbcConnectionDescriptors from the given repository file.
public  ConnectionRepositoryreadConnectionRepository(InputStream inst)
     Read JdbcConnectionDescriptors from this InputStream.
public  DescriptorRepositoryreadDescriptorRepository(String fileName)
     Read ClassDescriptors from the given repository file.
public  DescriptorRepositoryreadDescriptorRepository(InputStream inst)
     Read ClassDescriptors from the given InputStream.
public  voidremoveAllProfiles()
    
public  DescriptorRepositoryremoveProfile(Object key)
     Remove the given metadata profile.
public  voidsetDefaultPBKey(PBKey defaultPBKey)
     Set the PBKey used in convinience method org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker .
It's only allowed to use one JdbcConnectionDescriptor with enabled JdbcConnectionDescriptor.isDefaultConnection default connection .
public  voidsetDescriptor(DescriptorRepository repository, boolean global)
     Set the org.apache.ojb.broker.metadata.DescriptorRepository - if global was true, the given descriptor aquire global availability (use with care!), else the given descriptor was associated with the calling thread.
public  voidsetDescriptor(DescriptorRepository repository)
     Set DescriptorRepository for the current thread.
public  voidsetEnablePerThreadChanges(boolean enablePerThreadChanges)
     Enable the possibility of making per thread runtime changes of the org.apache.ojb.broker.metadata.DescriptorRepository .
public  voidsetPerThreadDescriptor(DescriptorRepository repository)
     Convenience method for MetadataManager.setDescriptor setDescriptor(repository, false) .
public  voidshutdown()
    



Method Detail
addProfile
public void addProfile(Object key, DescriptorRepository repository)(Code)
Add a metadata profile.
See Also:   MetadataManager.loadProfile



clearProfiles
public void clearProfiles()(Code)
Remove all metadata profiles.



connectionRepository
public ConnectionRepository connectionRepository()(Code)
Returns the ConnectionRepository .



copyOfGlobalRepository
public DescriptorRepository copyOfGlobalRepository()(Code)
Returns a copy of the current global org.apache.ojb.broker.metadata.DescriptorRepository

Note: All classes within the repository structure have to implement java.io.Serializable to be able to create a cloned copy.
See Also:   MetadataManager.getGlobalRepository
See Also:   MetadataManager.getRepository




getCurrentProfileKey
public Object getCurrentProfileKey() throws MetadataException(Code)
Returns the last activated profile key. the last activated profile key or null if no profile has been loaded
throws:
  MetadataException - if per-thread changes has not been activated
See Also:   MetadataManager.loadProfile(Object)



getDefaultPBKey
public PBKey getDefaultPBKey()(Code)
Return the default PBKey used in convinience method org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker .
If in JdbcConnectionDescriptor the JdbcConnectionDescriptor.isDefaultConnection default connection is enabled, OJB will detect the default org.apache.ojb.broker.PBKey by itself.
See Also:   MetadataManager.setDefaultPBKey



getGlobalRepository
public DescriptorRepository getGlobalRepository()(Code)
Returns explicit the global org.apache.ojb.broker.metadata.DescriptorRepository - use with care, because it ignores the MetadataManager.isEnablePerThreadChanges per thread mode .
See Also:   MetadataManager.getRepository
See Also:   MetadataManager.copyOfGlobalRepository



getInstance
public static synchronized MetadataManager getInstance()(Code)
Returns an instance of this class.



getRepository
public DescriptorRepository getRepository()(Code)
Returns the current valid org.apache.ojb.broker.metadata.DescriptorRepository for the caller. This is the provided way to obtain the org.apache.ojb.broker.metadata.DescriptorRepository .
When MetadataManager.isEnablePerThreadChanges per thread descriptor handling is enabled it search for a specific org.apache.ojb.broker.metadata.DescriptorRepository for the calling thread, if none can be found the global descriptor was returned.
See Also:   MetadataManager.getGlobalRepository
See Also:   MetadataManager.copyOfGlobalRepository



isEnablePerThreadChanges
public boolean isEnablePerThreadChanges()(Code)
If returns true if per thread runtime changes of the org.apache.ojb.broker.metadata.DescriptorRepository is enabled and the MetadataManager.getRepository method returns a threaded repository file if set, or the global if no threaded was found.
If returns false the MetadataManager.getRepository method return always the MetadataManager.getGlobalRepository() global repository.
See Also:   MetadataManager.setEnablePerThreadChanges



loadProfile
public void loadProfile(Object key)(Code)
Load the given metadata profile for the current thread.



mergeConnectionRepository
public void mergeConnectionRepository(ConnectionRepository repository)(Code)
Merge the given ConnectionRepository with the existing one (without making a deep copy of the containing connection descriptors).
See Also:   MetadataManager.mergeConnectionRepository(ConnectionRepository targetRepository,ConnectionRepository sourceRepository,boolean deep)



mergeConnectionRepository
public void mergeConnectionRepository(ConnectionRepository targetRepository, ConnectionRepository sourceRepository, boolean deep)(Code)
Merge the given source ConnectionRepository with the existing target. If parameter deep is set true deep copies of source objects were made.
Note: Using deep copy mode all descriptors will be serialized by using the default class loader to resolve classes. This can be problematic when classes are loaded by a context class loader.

Note: All classes within the repository structure have to implement java.io.Serializable to be able to create a cloned copy.




mergeDescriptorRepository
public void mergeDescriptorRepository(DescriptorRepository repository)(Code)
Merge the given org.apache.ojb.broker.metadata.DescriptorRepository (without making a deep copy of containing class-descriptor objects) with the global one, returned by method MetadataManager.getRepository() - keep in mind if running in per thread mode merge maybe only takes effect on current thread.
See Also:   MetadataManager.mergeDescriptorRepository(DescriptorRepository targetRepository,DescriptorRepository sourceRepository,boolean deep)



mergeDescriptorRepository
public void mergeDescriptorRepository(DescriptorRepository targetRepository, DescriptorRepository sourceRepository, boolean deep)(Code)
Merge the given org.apache.ojb.broker.metadata.DescriptorRepository files, the source objects will be pushed to the target repository. If parameter deep is set true deep copies of source objects were made.
Note: Using deep copy mode all descriptors will be serialized by using the default class loader to resolve classes. This can be problematic when classes are loaded by a context class loader.

Note: All classes within the repository structure have to implement java.io.Serializable to be able to create a cloned copy.
See Also:   MetadataManager.isEnablePerThreadChanges
See Also:   MetadataManager.setEnablePerThreadChanges




readConnectionRepository
public ConnectionRepository readConnectionRepository(String fileName)(Code)
Read JdbcConnectionDescriptors from the given repository file.
See Also:   MetadataManager.mergeConnectionRepository



readConnectionRepository
public ConnectionRepository readConnectionRepository(InputStream inst)(Code)
Read JdbcConnectionDescriptors from this InputStream.
See Also:   MetadataManager.mergeConnectionRepository



readDescriptorRepository
public DescriptorRepository readDescriptorRepository(String fileName)(Code)
Read ClassDescriptors from the given repository file.
See Also:   MetadataManager.mergeDescriptorRepository



readDescriptorRepository
public DescriptorRepository readDescriptorRepository(InputStream inst)(Code)
Read ClassDescriptors from the given InputStream.
See Also:   MetadataManager.mergeDescriptorRepository



removeAllProfiles
public void removeAllProfiles()(Code)
Remove all profiles
See Also:   MetadataManager.removeProfile
See Also:   MetadataManager.addProfile



removeProfile
public DescriptorRepository removeProfile(Object key)(Code)
Remove the given metadata profile.



setDefaultPBKey
public void setDefaultPBKey(PBKey defaultPBKey)(Code)
Set the PBKey used in convinience method org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker .
It's only allowed to use one JdbcConnectionDescriptor with enabled JdbcConnectionDescriptor.isDefaultConnection default connection . In this case OJB will automatically set the default key.
Note: It's recommended to set this key only once and not to change at runtime of OJB to avoid side-effects. If set more then one time a warning will be logged.
throws:
  MetadataException - if key was set more than one time



setDescriptor
public void setDescriptor(DescriptorRepository repository, boolean global)(Code)
Set the org.apache.ojb.broker.metadata.DescriptorRepository - if global was true, the given descriptor aquire global availability (use with care!), else the given descriptor was associated with the calling thread.
See Also:   MetadataManager.isEnablePerThreadChanges
See Also:   MetadataManager.setEnablePerThreadChanges



setDescriptor
public void setDescriptor(DescriptorRepository repository)(Code)
Set DescriptorRepository for the current thread. Convenience method for MetadataManager.setDescriptor(DescriptorRepository repository,boolean global) setDescriptor(repository, false) .



setEnablePerThreadChanges
public void setEnablePerThreadChanges(boolean enablePerThreadChanges)(Code)
Enable the possibility of making per thread runtime changes of the org.apache.ojb.broker.metadata.DescriptorRepository .
See Also:   MetadataManager.isEnablePerThreadChanges



setPerThreadDescriptor
public void setPerThreadDescriptor(DescriptorRepository repository)(Code)
Convenience method for MetadataManager.setDescriptor setDescriptor(repository, false) . MetadataManager.setDescriptor



shutdown
public void shutdown()(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.