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/2.1/DynamicMOXy/296967/BootstrapFromOXM/ObjectFactory"

(Background)
(Background)
Line 12: Line 12:
 
A public class <tt>ObjectFactory</tt> contains:
 
A public class <tt>ObjectFactory</tt> contains:
 
• An instance factory method signature for each Java content within the
 
• An instance factory method signature for each Java content within the
package.<br>
+
package.<br><br>
Given Java value class named Foo, here is the derived factory method:
+
 
public Foo createFoo();
+
Given Java value class named Foo, here is the derived factory method:<br><br>
 +
 
 +
<tt>public Foo createFoo();</tt>
 +
 
 
• An element instance factory method signature for each bound element
 
• An element instance factory method signature for each bound element
declaration.
+
declaration.<br><br>
public JAXBElement<T> createFoo(T elementValue);
+
 
• Dynamic instance factory allocator method signature:
+
<tt>public JAXBElement<T> createFoo(T elementValue);</tt>
public Object newInstance(Class javaContentInterface);
+
 
• Property setter/getter
+
• Dynamic instance factory allocator method signature:<br><br>
Provide the ability to associate implementation specific property/value
+
 
pairs with the instance creation process.
+
<tt>public Object newInstance(Class javaContentInterface);</tt>
Enum Type
+
 
1/8/09 JAXB 2.2 – Final Release 51
+
• Property setter/getter - Provide the ability to associate implementation specific property/value
java.lang.Object getProperty(String name);
+
pairs with the instance creation process.<br><br>
void setProperty(String name, Object value);
+
 
 +
<tt>java.lang.Object getProperty(String name);
 +
void setProperty(String name, Object value);</tt>
 +
 
 
}}
 
}}
  
 
</div>
 
</div>

Revision as of 14:27, 2 September 2010

Supporting ObjectFactory in Dynamic JAXB

Background

In standard JAXB, when classes are generated from a schema, an ObjectFactory class is also created, with methods to create new instances of all types in the schema, etc. From the JAXB 2.2 spec:


Idea.png
A public class ObjectFactory contains:

• An instance factory method signature for each Java content within the package.

Given Java value class named Foo, here is the derived factory method:

public Foo createFoo();

• An element instance factory method signature for each bound element declaration.

public JAXBElement<T> createFoo(T elementValue);

• Dynamic instance factory allocator method signature:

public Object newInstance(Class javaContentInterface);

• Property setter/getter - Provide the ability to associate implementation specific property/value pairs with the instance creation process.

java.lang.Object getProperty(String name);

void setProperty(String name, Object value);


Back to the top