tags:

views:

74

answers:

1

From the JMX MXBean specification, a java class type J must satisfy

Either if J has at least one public constructor with a ConstructorProperties annotation, Or if J has a public no-arg constructor, and for every getter in J with type T and name N there is a corresponding setter with the same name and type

So how can I use JAXB to generate JAVA class model which satisfy the MXBean constrain?

Thanks YU

A: 

JAXB satisfies the getter/setter constraint, doesn't it? Or, rather xjc satisfies it. JAXB itself is just the framework. xjc is used to generate Java code from an XML schema definition file.

As for the annotation: This doesn't seem to be necessary. JAXB always needs a no-arg constructor for unmarshalling.

If this doesn't sound right to you, maybe you could clarify your question (with a small example if appropriate).

musiKk
I use eclipse xjc plugin for JAXB unmarshalling. Sometimes, xjc doesn't always generate paired getter and setter if one generated class contains container data member like java.util.List. And It also doesn't generate no-arg constructor in my side. Does it need extra JAXB configuration?
yucubby
Yes, you're right. It seems to me that providing a setter for a `List` violates the JAXB spec (see 'Design Note' in 5.5.2.2 of the JAXB 2.0 spec). If you're willing to accept that, it is indeed possible to create plugins for JAXB that alter the generated source code. Look for JAXB2 Basics Plugins for some examples. This also seems to be implementation specific.
musiKk