users@jaxb.java.net

Re: XJC Plugin development question

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 15 Mar 2006 16:46:16 -0800

Sounds like it's fairly general purpose and useful to me. If you don't
mind, I'd really encourage you to post it in jaxb2-commons.

If you are interested, let me know your java.net user id and plugin
name. Maybe "jmx"?

Gertelman, Michael, VF-JP wrote:
> However, this plugin is very simple and I took your own CodeInjector as a template, so it wouldn't be interesting enough to host it separately.
> The reason why I need this ObjectFactory change is that my plugin helps to generate Managed Java Beans (JMX) from XML Schema.
> I want all of them to extend StandardMBean, so I use this global binding:
>
> <xjc:superClass name="javax.management.StandardMBean"/>
>
> And here comes the trick: to do this I need to create a constructor for every Bean that looks like this:
>
> public ExampleImpl() throws NotCompliantMBeanException
> {
> super(ExampleIntf.class);
> }
>
> The NotCompliantMBeanException is thrown from the StandardMBean constructor, so I have to throw it here too. (I cannot surround it with try/catch for the obvious reason that "super" must be the first word in the constructor).
> And this is the reason why both(!) of my ObjectFactories have to throw the same exception:
>
> public Example createExample() throws NotCompliantMBeanException
> {
> return new ExampleImpl();
> }
>
> Otherwise, of course, I cannot compile the code.
> So I have to inject this code into both of the ObjectFactories.
>
> Now, I guess, this would be an example why sometimes this access is really needed.
>
> Michael
>
> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
> Sent: Thursday, March 16, 2006 9:21 AM
> To: users_at_jaxb.dev.java.net
> Subject: Re: XJC Plugin development question
>
>
>
> I'm curious what plugin you are developing. Would you be interested in
> hosting that at http://jaxb2-commons.dev.java.net/, so that other people
> can use yours?
>
> Gertelman, Michael, VF-JP wrote:
>> Thanks a lot,
>> Michael
>>
>> -----Original Message-----
>> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
>> Sent: Thursday, March 16, 2006 5:59 AM
>> To: users_at_jaxb.dev.java.net
>> Subject: Re: XJC Plugin development question
>>
>>
>> Gertelman, Michael, VF-JP wrote:
>>> Hi Kohsuke,
>>> yes, I need to access both ObjectFactories, in intf and in impl
>>> packages. If it's too tricky it's ok, I found a way to work around it
>>> (ugly but at least it does not keep me from going on). Of course, if
>>> you have a real solution it would be great.
>>
>> Glad to hear that you found a workaround.
>>
>> I changed DualObjectFactoryGenerator and made publicOFG/privateOFG
>> available as public final fields.
>>
>> You can get individual ObjectFactoryGenerator (and hence
>> JDefinedClass)
>> through these properties.
>>
>>
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com