Hi Arunj,

There's currently no way to directly pass parameters that come from the unmarshalling to a constructor. This is something that would be interesting to add, but gets very messy - we'd need some way of indicating which items represent constructor parameters, their order, etc. There are also issues of ordering - you're probably going to want to be able to have some non-constructor items come before some of the constructor items, in general, and that means the generated code would need to unmarshall these items and save them somewhere before the constructor is called, then store them into the object after it's been constructed.

I'm leading toward implementing a kind of adapter approach to handle this type of situation. For this you'd need to define a bean-type class that holds the necessary constructor parameter values (and anything else that needs to be unmarshalled in the course of getting to these values). JiBX would work with the bean-type class, with the adapter you specify used to convert to and from the "real" object. Kind of like a serializer/deserializer, but for objects rather than simple values.

- Dennis

arun jamwal wrote:

Hi,
I was wondering if it's possible to create an object which has constructor with 
parameters? For example:

package example1;

public class Person {
public int customerNumber;
public String firstName;
public String lastName;
public Person(int customerNumber) {
this.customerNumber = customerNumber;
}
}


If it's possible (using Factory?) then what will the binding (.xml) look like?

All the examples create bean-type classes - which have only the default no-argument constructors.

Seems like Castor and JAXB also require a no-argument default constructor for unmarshalling the xml to Java objects...

Thanks in advance!

Arunj






------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to