Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/Dynamic/def1"

(Mechanism in Java5/Java6)
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
<css>.source-xml {padding:4px;border:1px solid black;}</css><css>.source-java5 {padding:4px;border:1px solid black;}</css>
 
 
===== Dynamic Persistence =====
 
===== Dynamic Persistence =====
Dynamic Persistence is defined as the ability to create a persistent entity class and use it within an application without <i>a-priori</i> the Java class existing (no <tt>.class</tt> file on the classpath or in the relevant <tt>.jar/.war</tt> archive).
+
<onlyinclude>
 +
Dynamic Persistence is defined as the ability to create a dynamic persistent entity and use it within an application without <i>a-priori</i> the entity's Java <tt>.class</tt> being present on the classpath (or in some <tt>.jar/.war</tt> archive).
  
===== Mechanism in Java5/Java6 =====
+
The purpose of Dynamic Persistence is to enable simplified data access where only mapping information is required and no concrete Java model is required. This allows applications with dynamic storage requirements to avoid coupling to static classes or require specialized handling of new types. The application uses standard EclipseLink APIs to read, create, modify, and remove dynamic persistent entities from their data stores based on types that are either defined in XML mapping files or are constructed within the running application.
In order to create a Java class at runtime without the use of the <tt>javac</tt> compiler, the use of a custom ClassLoaderer is required,
+
</onlyinclude>
along with a bytecode manipulation library (such as [http://asm.objectweb.org ASM] or some other [http://www.java-source.net/open-source/bytecode-libraries framework]).<br />
+
[[Image:custom_classloader.gif]]
+
 
+
===== Mechanism in Java7 =====
+
<i>Future</i><br />JSR-292 (Supporting Dynamically Typed Languages on the Java &trade; Platform) introduces a new type of classloader,
+
<code>java.dyn.AnonymousClassLoader</code>. <code>AnonymousClassLoader</code> is designed to solve two problems:
+
# Generating many classes with similar bytecode and only minor changes is very inefficient, wasting a lot of precious memory.
+
# Generated bytecode must be contained in a class, which must be contained in a ClassLoader, which keeps a hard reference to the class; as a result, to make even one byte of bytecode garbage-collectable, it must be wrapped in its own class and its own classloader.
+
 
+
First, classes loaded by <code>AnonymousClassLoader</code> are not given full-fledged symbolic names in the global symbol tables; they're given rough numeric identifiers. They are effectively anonymized, allowing much more freedom to generate them at will, since naming conflicts essentially do not happen.
+
 
+
Second, the classes are loaded without a parent ClassLoader, so there's no overprotective mother keeping them on a short leash. When the last normal references to the class disappear, it's eligible for garbage collection like any other object.
+
 
+
Third, it provides a mechanism whereby an existing class can be loaded and slightly modified, producing a new class with those modifications but sharing the rest of its structure and data.
+

Latest revision as of 10:50, 17 September 2009

Dynamic Persistence

Dynamic Persistence is defined as the ability to create a dynamic persistent entity and use it within an application without a-priori the entity's Java .class being present on the classpath (or in some .jar/.war archive).

The purpose of Dynamic Persistence is to enable simplified data access where only mapping information is required and no concrete Java model is required. This allows applications with dynamic storage requirements to avoid coupling to static classes or require specialized handling of new types. The application uses standard EclipseLink APIs to read, create, modify, and remove dynamic persistent entities from their data stores based on types that are either defined in XML mapping files or are constructed within the running application.

Back to the top