Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/DesignDocs/384399"
m (→Package Splitting) |
(→Package Splitting) |
||
Line 79: | Line 79: | ||
This 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. | This 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 === | ||
+ | |||
+ | This design makes use of generics, below is an example if you are not familiar with the mechanism in Javaq. | ||
+ | |||
+ | <source lang="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); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
== Requirements == | == Requirements == |
Revision as of 11:01, 6 July 2012
Contents
Design Specification: MOXy Footprint Reduction
Document History
Date | Author | Version Description & Notes |
---|---|---|
2012/07/05 | Blaise Doughan | Work In Progress |
Project overview
Problem
The install footprint is currently preventing MOXy from being bundled with other software and used on mobile platforms.
XML Binding Install Footprint (EclipseLink 2.4)
Bundle | Size |
---|---|
org.eclipse.persistence.moxy_2.4.0.v20120608-r11652.jar | 455 KB |
org.eclipse.persistence.asm_3.3.1.v201206041142.jar | 271 KB |
org.eclipse.persistence.core_2.4.0.v20120608-r11652.jar | 4711 KB |
5437 KB |
JSON Binding Install Footprint (EclipseLink 2.4)
Bundle | Size |
---|---|
org.eclipse.persistence.moxy_2.4.0.v20120608-r11652.jar | 455 KB |
org.eclipse.persistence.asm_3.3.1.v201206041142.jar | 271 KB |
org.eclipse.persistence.core_2.4.0.v20120608-r11652.jar | 4711 KB |
org.eclipse.persistence.antlr_3.2.0.v201206041011.jar | 190 KB |
5627 KB |
Goals
- Reduce the install footprint to 1 MB (from 5.4 MB)
- Be compatible with Project Jigsaw
Concepts
Present any concepts relevant to the feature.
Package Splitting
This 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
This design makes use of generics, below is an example if you are not familiar with the mechanism in Javaq.
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
The following sections will expand the goals of this project into more concrete requirements.
Design Constraints
All bundles must remain binary compatible except the OXM aspects of org.eclipse.persistence.core.
Design / Functionality
Bundle Changes
New Bundle - org.eclipse.persistence.micro
This bundle will include the all the common classes to both MOXy and JPA.
Modify Bundles - org.eclipse.persistence.moxy & org.eclipse.persistence.core
The OXM classes from core will be moved to MOXy.
Testing
API
GUI
N/A
Config files
N/A
Documentation
The following items will need to be documented:
- What the binary incompatibilities are (if any).
- How to migrate to the new release.
Open Issues
This section lists the open issues that are still pending that must be decided prior to fully implementing this project's requirements.
Issue # | Owner | Description / Notes |
---|---|---|
1 | Peter/Doug | Does the implementation of this feature require us to bump the version number to 3.0? |
Decisions
This section lists decisions made. These are intended to document the resolution of open issues or constraints added to the project that are important.
Issue # | Description / Notes | Decision |
---|---|---|
Future Considerations
During 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.