Open Tomas-Kraus opened 11 years ago
@glassfishrobot Commented Reported by pbielicki
@glassfishrobot Commented pbielicki said: how can I upload a patch file? I fixed this problem and I would like to submit my proposal
@glassfishrobot Commented pbielicki said: I sent my patch to dev@jaxb.java.net
Cheers, Przemek
@glassfishrobot Commented pbielicki said: Patch available on GitHub: https://github.com/pbielicki/jaxb/commit/c70183967936ed3e3b0be46eb65694e95c4d583c
@glassfishrobot Commented Was assigned to yaroska
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-980
JAXB implementation does not allow a generic factory method. Let's take a look at this simple example:
Example provided above is impossible to implement in current JAXB. The problem here is that you either let JAXB invoke no-arg constructor of CalculatorInput class or explicit static factory method inside this class or in specific factory class. Note that you must have one factory method per class which is extremely bulky, not object-oriented, boilerplate, blah blah blah. Basically it's a mistake. I know better than JXAB how to create my objects - I need JAXB only to fill these beans with parsed XML content.
Another argument is that JAXB in the current state completely ignores existence of Dependency Injection (which is a part of Java EE specification). In case JAXB creates my CalculatorInput, someContext attribute will be ignored (thus null) by DI container as it has absolutely no knowledge on this instance. The only correct way to make the injection work is to obtain the new instance from the DI bean / object factory - see IocContainerObjectFactory. OK, it is possible but only in such form (again, bulky, boilerplate, ugly):
Imagine what happens if you have more than couple of beans...
Note on JSR-222 specification
JavaDoc of javax.xml.bind.annotation.XmlType says:
But, the JSR-222 specification does not explicitly say that it must be a no-arg factory method.
Please correct me if I'm wrong.
Affected Versions
[2.2.7]