-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java to EMF EPackage converters #61
base: snapshot
Are you sure you want to change the base?
Conversation
- Fix for issue with custom `java.util.Map$Entry`, used when creating `EMap` - Fix for issue with `org.gecko.emf.converter` used as package name in integration tests Signed-off-by: Michael H. Siemaszko <[email protected]>
- Refactor related to "EMF model driven development of Jakarta RESTful OSGi applications" - Minor fixes and improvements Signed-off-by: Michael H. Siemaszko <[email protected]>
- Refactor required to avoid code duplication and facilitate further development as part of "EMF model driven development of Jakarta RESTful OSGi applications" - Extracted interface, moved logic shared between existing `DTOToEPackageConverter` and new `JavaReferenceTypeToEPackageConverter` to abstract class, and changed both `DTOToEPackageConverter` and `JavaReferenceTypeToEPackageConverter` from static utility class to OSGi singleton component - Added new converter method which allows to pass path to JAR whose classes should be converted to `EPackage`, in addition to existing method which accepts array of such classes - Added new integration test suite for `JavaReferenceTypeToEPackageConverter` - Minor fixes and improvements Signed-off-by: Michael H. Siemaszko <[email protected]>
- Refactor required to avoid code duplication and facilitate further development as part of "EMF model driven development of Jakarta RESTful OSGi applications" - Extracted interface, moved logic shared between existing `DTOToEPackageConverter` and new `JavaReferenceTypeToEPackageConverter` to abstract class, and changed both `DTOToEPackageConverter` and `JavaReferenceTypeToEPackageConverter` from static utility class to OSGi singleton component - Added new converter method which allows to pass path to JAR whose classes should be converted to `EPackage`, in addition to existing method which accepts array of such classes - Added new integration test suite for `JavaReferenceTypeToEPackageConverter` - Minor fixes and improvements Signed-off-by: Michael H. Siemaszko <[email protected]>
- Fixes for issues in bundles' metadata Signed-off-by: Michael H. Siemaszko <[email protected]>
This is totally okay. |
I suggest managed this via the upper Bound of the EAttribute. We can change this later, if we think this is necessay. |
I suggest the following: |
Makes sense. |
I pointed to the jar in the initial task as an example, and to provide a set of packages and classes to limit the scope. I thought more along the line of giving a package name or a list of classes to convert. You can find the classes in a Package e.g. with this method: https://www.baeldung.com/java-find-all-classes-in-package |
I looked at the ecore you provided and it looks largely as if we are on the right track. 2 Things jumped at me right away though:
jakarta.ws.rs 3.1.0 - If you add the GenModel -> basePackage - jakarta.ws as Annotation, we also don't loose the full name |
Just for the record, those are mostly To summarize my understanding of what you suggest:
So, for example:
Would become:
|
This is a misunderstanding, perhaps because you did not take a look at the code I shared via this PR, or at least relevant parts. Class has to be loaded first before it can be passed for conversion, and there are interdependencies between classes, in addition to transitive dependencies, which prevent class to be loaded unless those conditions are met. My question was whether there is a better way that you know of, by accessing parent classloader, etc. ( see original question for details ) - what you mentioned does not address that question. All this is already taken care of - as mentioned in PR details I shared ( #61 (comment) ): (...)
(...) Please see new integration test suite for (...) Specifically, see:
|
Some follow-up questions on this topic: a) Do you mean b) What about naming clashes ? I.e. |
ad. "Annotations should be marked as Interfaces."In addition to classes and annotations, there are also interfaces in "Jakarta RESTful WS API" - should those interfaces be also marked as interfaces ? ad. "The Converter should always produce a List of EPackages to represent the original Java Packages""Jakarta RESTful WS API" defines the following packages:
As per your new requirement, the generated dynamic EMF of entire “Jakarta RESTful WS API”, when serialized, would contain the following enhancements:
(...)
It is not clear to me: a) what should be defined as b) should |
+1 |
yes.
EClassifiers are unique inside their EPackage, similar to Java. If you find two EClassifiers, that would claim the same InstanceClass, I would simply use the first one found. If you need a unique Identifier for an EClassifier you can use |
Yes, we need one, as it is mandatory for an EPackage. I suggest |
Regarding your question with the dependent jar files. I understood what you asked of me. I simply stated, that I never intended to get a converter, we can hand a complete jar to convert. Now that we have it though, we can later use it in the tooling. In the end, the tooling will need to provide all the dependent jars, as no one else will be able to guarantee that all dependent classes will be around. You can create the |
- Mark annotations as interfaces - Group EClassifiers in ESubpackages, to represent the original Java Packages - Refactoring related to above mentioned, as well as minor fixes and improvements Signed-off-by: Michael H. Siemaszko <[email protected]>
Latest commits ( https://github.com/geckoprojects-org/org.gecko.emf.utils/pull/61/commits ) include all that you requested for this phase, including:
.. in addition to refactoring related to above mentioned, as well as minor fixes and improvements. Some additional clarifying questions, pertaining to implementation shared via recent commit ( 1117885 ) - see (a) and (b) below. ad. "The Converter should always produce a List of EPackages to represent the original Java Packages" (c.d.)(a)In this requirement, as originally stated ( #61 (comment) ), you provided example of how names of Since I could only choose one or the other, I based this implementation provided via recent commit ( 1117885 ) on original package names, only sanitized to make them compatible with I.e., if original package names of "Jakarta RESTful WS API" are the following:
.. then, Please see attached
(b)Continuing from (a), this one pertains to how Please see attached |
- Construct and add 'nsURI' to each sub-package - Construct and add 'nsPrefix' to each sub-package - Instead of creating custom EDataTypes for array types, re-use "single instance" equivalents as type in such cases and set upperBound to 'ETypedElement.UNBOUNDED_MULTIPLICITY' - Reuse EDataTypes from EPackagesRegistry attached to ResourceSet - Use current Classloader when constructing URLClassLoader - When looking up EClassifier, check package name as well - Refactoring related to above mentioned, as well as minor fixes and improvements Signed-off-by: Michael H. Siemaszko <[email protected]>
- Fix 'basePackage' inconsistency Signed-off-by: Michael H. Siemaszko <[email protected]>
In EMF packages can't have a dot in their name, as the dot is the delimiter between subpackages. I would do it as follows for e.g. the jakarta rs jar: jakarta.ws.rs would result in the following EPackages (the |- marks a subpackage) So For your felix servlet api, there would be no common denominator. Thus the result would be two root packages. one starts with |
for the last case: if you need a common root EPackage, simply call it root and give it some fixed URI. in such a case somebody needs to take the result and restructure it anyway. |
Regarding dots - this was already fixed in commits ( https://github.com/geckoprojects-org/org.gecko.emf.utils/pull/61/commits ) several days ago. Please see updated comment #61 (comment) with examples and refer to that. |
Okay. but is your question answered by this comment? |
No, it is not answered - you did not understand my question it seems. Please see screenshots and Best would be familiarize yourself with examples share, and perhaps re-read those questions in that context ( partially re-phrased now in previous paragraph ) and provide answers this way. Also, I need itemized list of what other changes are required to close this PR. |
I modified the ecore for the felix servlet api jar, to represent what I think the result should be. org.apache.felix.http.servlet-api-2.1.0.zip The same should work for the jakarta rs model as well. |
- Support for tree of EPackages, instead of flat list - Drop 'basePackage' eAnnotations, as per example provided - Refactoring related to above mentioned, as well as minor fixes and improvements Signed-off-by: Michael H. Siemaszko <[email protected]>
Quality Gate passedIssues Measures |
PR was marked as ready for review, as what you requested via #61 (comment) is now part of this PR ( 11c478e ). Attached please see examples of Regarding jakarta.ws.rs-api-3.1.0.ecore.zip |
@juergen-albert
This PR is a continuation of refactor of
DTOToEPackageConverter
code, related to "EMF model driven development of Jakarta RESTful OSGi applications" project you assigned to me.That initial phase of refactor was shared via PR #60, which uses a separate branch (
JakartaRS-OSGi-Apps-EMF-MDE
) - please refer to that PR for more details regarding this inintial phase of refactor.Since
DTOToEPackageConverter
started off as a static utility class, adding another converter,JavaReferenceTypeToEPackageConverter
, which shares and builds upon most of that logic, necessitated extracting common parts as to avoid code duplication. That is one the points I mentioned during requirements elicitation phase for "EMF model driven development of Jakarta RESTful OSGi applications" project.Unfortunately, since static methods cannot be overriden, I was unable to continue using this approach - i.e. having both converters be static utility classes and avoid duplicating most of the code.
Therefore, I created this PR ( #61 ) on a separate branch (
Converter-as-Singleton-Component
), which continues with that initial refactor ( #60 ) using a different approach, which allows to easily share common logic, i.e.: extracted interface, moved logic shared between existingDTOToEPackageConverter
and newJavaReferenceTypeToEPackageConverter
to abstract classAbstractJavaToEPackageConverter
, and changed bothDTOToEPackageConverter
andJavaReferenceTypeToEPackageConverter
from static utility classes to OSGi singleton components.In addition:
jakarta.ws.rs.core.Response.Status
;EOperation
s;EPackage
, in addition to existing method which accepts array of such classes;JavaReferenceTypeToEPackageConverter
;EPackage
;Please see new integration test suite for
JavaReferenceTypeToEPackageConverter
, where you will find two new test cases, through which you can test functionality of this new converter (JavaReferenceTypeToEPackageConverter
). Attached is also output of one of those test cases, with generated dynamic EMF of entire "Jakarta RESTful WS API" serialized asjakarta.ws.rs-api-3.1.0.ecore
.Questions
Built-in Java classes (
java.*
), which are referred to from "Jakarta RESTful WS API" classes ( fields as well as methods' return types and input params, etc. ) are currently added to generated EMF model asEDataType
s, as I wanted to avoid having to built entireEClass
es for such - please confirm / clarify whether this approach is acceptable to you or suggest different approach;All exception-related classes are currently added to generated EMF model as
EDataType
s, for the same exact reason as mentioned in item no. 1 above - please confirm / clarify whether this approach is acceptable to you or suggest different approach;Should dedicated
EDataType
s be created for array-types likeObject[]
,Class[]
,Locale[]
,Variant[]
,Link[]
,NewCookie[]
- similar to how such custom array-types those were defined inorg.gecko.emf.converter.model
?How should rationale behind extracting such common custom
EDataType
s toorg.gecko.emf.converter.model
be applied to these cases mentioned in items no. 1-3 above ? I.e. during the course of generating such dynamic EMF different customEDataType
s are created and added to generated EMFEPackage
and such is serialized with no problems - please confirm / clarify whether this approach is acceptable to you or suggest different approach;Naming of inner classes is constructed via camel-casing coalesced ( dot removed ) full name of such class, less package name - please confirm / clarify whether this approach is acceptable to you or suggest different approach;
Regarding this new converter method, which allows to pass path to JAR ( and its dependencies ), i.e.
org.gecko.emf.converter.JavaToEPackageConverter.convert(String, String, String, Path, Path...)
, implemented inorg.gecko.emf.converter.AbstractJavaToEPackageConverter.convert(String, String, String, Path, Path...)
- perhaps there is a way to obtain such via classloader for a given bundle, after having added those to its bundle descriptor (.bnd
) file, instead of passing absolute paths to JARs ? Seeorg.gecko.emf.converter.tests.JavaReferenceTypeToEPackageConverterTest.testConvertJakartaRESTfulWSAPI(ServiceAware<JavaToEPackageConverter>)
for example of how this is used currently;jakarta.ws.rs-api-3.1.0.ecore.zip