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.
EclipseLink/DesignDocs/384399
Contents
- 1 Design Specification: MOXy Footprint Reduction
- 1.1 Document History
- 1.2 Project overview
- 1.3 Concepts
- 1.4 Requirements
- 1.5 Design Constraints
- 1.6 Design / Functionality
- 1.7 Development Plan
- 1.7.1 Phase #1 - Introduce XMLSession and Supporting Classes
- 1.7.2 Phase #2 - Move MOXy Specific Classes Out of Core Bundle
- 1.7.3 Phase #3 - Create the Common Bundle
- 1.7.4 Phase #4 - Have Core Classes Extend Corresponding Common Classes
- 1.7.5 Phase #5 - Introduce XMLProject Class
- 1.7.6 Phase #6 - Change OXM Classes to Extend Common Classes
- 1.7.7 Phase #7 - Move ORM Specific Classes Out of Core Bundle
- 1.7.8 Phase #8 - Move Common Classes to Core Bundle
- 1.8 Testing
- 1.9 API
- 1.10 Config files
- 1.11 Documentation
- 1.12 Open Issues
- 1.13 Decisions
- 1.14 Future Considerations
Design Specification: MOXy Footprint Reduction
Document History
Date | Author | Version Description & Notes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2012/07/05 | Blaise Doughan | Initial draft | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2012/08/20 | Blaise Doughan | Pre-review Draft | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}
Project overviewProblemThe install footprint is currently preventing MOXy from being bundled with other software and used on mobile platforms. XML Binding Install Footprint (EclipseLink 2.4)
JSON Binding Install Footprint (EclipseLink 2.4)
Primary Goals
Secondary GoalsMemory ImprovementMany of the current "core" classes contains information that is only required for object-relational mapping. This type of metadata needlessly increases the amount of memory MOXy requires to run. This refactor will reduce the amount of memory MOXy requires to run. Ability to Release/Upgrade SeparatelyThe new core bundle should not need to change frequently. Breaking the dependency between ORM and OXM should give us some flexibility if we ever wanted to release MOXy independent of JPA. More importantly it would allows users to upgrade to a newer version of MOXy without having to upgrade JPA. ConceptsPackage SplittingThis is when classes from the same package are distributed among different bundles. This is not compatible with OSGi, and therefore is something that we can not do. Generics & Parameterized TypesThis design makes use of generics, below is an example if you are not familiar with the mechanism in Java. package demo; import java.lang.reflect.Method; public class Demo { private static String METHOD_NAME = "sample"; private static Class<?>[] PARAMETER_TYPES = new Class[] {String.class}; public static void main(String[] args) throws Exception { // Use Method - Test Method Can Be Called Integer a = new Foo().sample("A"); // YES Integer b = new Bar().sample("B"); // YES Integer c = new Baz().sample("C"); // YES // Reflection - Test Method Accessed Via Reflection hasMethod(Foo.class, METHOD_NAME, PARAMETER_TYPES); // YES hasMethod(Bar.class, METHOD_NAME, PARAMETER_TYPES); // NO hasMethod(Baz.class, METHOD_NAME, PARAMETER_TYPES); // YES } private static void hasMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) { try { Method method = clazz.getMethod(methodName, parameterTypes); System.out.println(method); } catch(NoSuchMethodException e) { e.printStackTrace(); } } // Regular Java Class static class Foo { public Integer sample(String string) { return null; } } // Parameterized Type static abstract class AbstractBar<RETURN, PARAMETER> { private RETURN value; public RETURN sample(PARAMETER parameter) { return value; } } // Subclass of Parameterized type static class Bar extends AbstractBar<Integer, String>{ } // Subclass of Parameterized type that overrides method from super class static class Baz extends AbstractBar<Integer, String> { @Override public Integer sample(String parameter) { return super.sample(parameter); } } }
Requirements
Design Constraints
Design / FunctionalityHigh LevelBundle Changes
Common AbstractionsThe common bundle will include abstractions that are common to both MOXy and ORM. Below is an example of the current and proposed architectures.
Medium LevelRequired AbstractionsInitial prototyping indicates that abstractions would be required for the following classes:
Low LevelInheritance HierarchiesDevelopment PlanPhase #1 - Introduce XMLSession and Supporting ClassesThe following items will be done during this phase:
Phase #2 - Move MOXy Specific Classes Out of Core BundleThe following items will be done during this phase:
Phase #3 - Create the Common BundleThe following items will be done during this phase:
Phase #4 - Have Core Classes Extend Corresponding Common Classes
Phase #5 - Introduce XMLProject ClassThe following items will be done during this phase:
Phase #6 - Change OXM Classes to Extend Common Classes
Phase #7 - Move ORM Specific Classes Out of Core BundleThe following items will be done during this phase:
Phase #8 - Move Common Classes to Core BundleThe following items will be done during this phase:
TestingAPICore PackagesThe following would be the proposed package structure for the core bundle.
Core Class StructureThe core classes will contain type variables. The corresponding OXM and ORM classes will be specify the appropriate types in their concrete subclasses. package org.eclipse.persistence.core; ... public abstract class CoreProject< LOGIN extends CoreLogin, DESCRIPTOR extends CoreDescriptor> implements Serializable { protected Map<String, DESCRIPTOR> aliasDescriptors; protected LOGIN datasourceLogin; protected Map<Class, DESCRIPTOR> descriptors; protected String name; protected List<DESCRIPTOR> orderedDescriptors; /** * PUBLIC: * Add an alias for the descriptor. */ public void addAlias(String alias, DESCRIPTOR descriptor) { if (aliasDescriptors == null) { aliasDescriptors = new HashMap(10); } aliasDescriptors.put(alias, descriptor); } ... } OXM Project A new OXM XMLProject class will be introduced that extends the CoreProject class. public class XMLProject extends CoreProject<XMLLogin, XMLDescriptor> { ... } ORM Project The existing ORM Project class will be modified to extend the new CoreProject class. public class Project extends CoreProject<DatasourceLogin, ClassDescriptor> { ... } Config filesDeployment XML - OXMIf we continue to support the deployment XML file for OXM projects, we will need to map the old format to the new objects. See Open Issue #4. DocumentationThe following items will need to be documented:
Open IssuesThis section lists the open issues that are still pending that must be decided prior to fully implementing this project's requirements.
DecisionsThis section lists decisions made. These are intended to document the resolution of open issues or constraints added to the project that are important.
Future ConsiderationsDuring the research for this project the following items were identified as out of scope but are captured here as potential future enhancements. If agreed upon during the review process these should be logged in the bug system. Project JigsawIs a standard module system being designed for the Java SE platform. It is being applied to the JDK itself. While this feature is not dependent on Jigsaw, care will be taken as to what modules we will need to depend on. |