I think this is a users_at_jaxb.dev.java.net discussion.
Chisarick, Dan wrote:
> Kohsuke,
>
> Thanks for the reply. I tried that and it still didn't quite do what I
> need (although it does simplify my plug-in if that is my only recourse).
> At the bottom of this message is a sample XSD. I generated it 3x:
>
> 1) Using JAXB 1.0.5
> 2) Using JAXB 2.0.3
> 3) Using JAXB 2.0.3 w/the globalBinding switch you mentioned
I should have mentioned that the generated interfaces are not
necessarily compatible with the JAXB 1.0.x.
And there's really no way to make it compatible, either. Sorry.
>
> For completeness, I also specified the global binding
> underscoreBinding="asCharInWord" for all three. Anyway, here are the
> files that were generated for all three cases (I've omitted the
> ObjectFactory classes and such for brevity):
>
> 1)
> - Employee.java
> - EmployeeInfo.java
> - EmployeeInfo_Type.java
>
> 2)
> - Employee.java
> - EmployeeInfo_Type.java
>
> 3)
> - Employee.java
> - EmployeeInfo_Type.java
>
> It's that "EmployeeInfo.java" interface that's generated by JAXB 1.x
> that I'm trying to generate w/my plug-in (looks like it might come from
> my "ref" element in the "Employee" type). Is there a switch or setting
> that will give me that interface for all the generated classes? Thanks.
>
> Contrived sample schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:complexType name="Employee">
> <xs:sequence>
> <xs:element ref="EmployeeInfo"/>
> </xs:sequence>
> </xs:complexType>
>
> <!-- These would probably be in an external schema, perhaps as part
> of a shared library -->
> <xs:element name="EmployeeInfo" type="EmployeeInfo_Type"/>
>
> <xs:complexType name="EmployeeInfo_Type">
> <xs:sequence>
> <xs:element name="first-name" type="xs:string"/>
> <xs:element name="last-name" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
>
> Dan
>
>
> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
> Sent: Thursday, November 16, 2006 1:26 PM
> To: dev_at_jaxb.dev.java.net
> Subject: Re: Migrating a large JAXB v1.x project to JAXB v2.x &
> interfaces
>
> Chisarick, Dan wrote:
>> Hi. I've read through the FAQ, the specification, and a bunch of the
>> mailing list archives. I realize that the JAXB v1.x generated
>> interfaces were done away with, and I understand the motivation.
>> Still, there's this small matter of a few thousand references to those
>
>> interfaces in our existing code base. It's just not practical to
>> migrate them all right now.
>
> Right.
>
>> At least as a transitional step, I'd like to generate those interfaces
>
>> just so the code compiles and work can continue identifying the
>> feasibility of moving to JAXB2. A plug-in seems to be the approach to
>
>> take.
>
> Actually, if you just need to do the old interface/impl style split, you
> could just use the stock customization. <jaxb:globalBindings
> generateValueClass="false"/>
>
>
> I think Lexi addressed the rest of the questions.
>
> > Currently I have a development project open where I have a
>> skeletal plugin that just prints out stuff like the target directory
>> for class generation, the class type name and it's package name. Ok,
>> good so far. Here's what I (think I) still need to do:
>>
>> 1) Set an additional interface for each generated class. Assuming
> "co"
>> is a ClassOutline instance, this seems to work:
>>
>> co.implClass._implements(MyNewInterface.class);
>>
>> Unfortunately that only works for interface classes that already
> exist.
>> Since I'm generating them dynamically, that doesn't work too well. I
>> see there's an overloaded method that takes a JClass, but the means
>> for creating one is sending me in circles.
>>
>> Question 1: How can I specify the name of an interface for a JAXB
>> generated class when that interface does not exist? I'd like to be
>> able to specify the interface simply as a String if possible.
>>
>> 2) In order to generate the interface, I need to know the public
>> methods of each generated class. Any pointers on how I can retrieve
>> that information starting w/a ClassOutline instance?
>>
>> I am a little new to the internals of JAXB2 so if what I'm trying to
>> do (discouraged though it may be) has already been addressed
>> somewhere, I missed it. Thanks.
>>
>> Dan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jaxb.dev.java.net For
>> additional commands, e-mail: dev-help_at_jaxb.dev.java.net
>>
>>
>
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: dev-help_at_jaxb.dev.java.net
>
>
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com