Hi Govind,
Ah ok, I see the problem now...
If you're just trying to marshal, and not unmarshal, you can disable the
constructor check as such:
<class name="MasterData" verify-constructable="false">
I need to update the code to handle classes with factory methods.
Currently the only factory method supported is a String based factory
method for Type-safe enums such as:
public static Object getValue(String);
In any case, the above should work for you.
--Keith
[EMAIL PROTECTED] wrote:
>
> Hi,
>
> Here is how my singleton class Master Data looks like
>
> public class MasterData extends RFDTValueObject implements
> Serializable
> {
> private List terminalList;
>
> private static MasterData masterData = null;
>
> private MasterData()
> {
>
> }
> public static MasterData getInstance()
> {
> if ( null != masterData)
> {
> return masterData;
> }
> else
> {
> masterData = new MasterData ();
> return masterData;
> }
> }
>
> public List getTerminalList()
> {
> return terminalList;
> }
> public void setTerminalList(List list)
> {
> terminalList = list;
> }
>
> }
>
> And to marshal this as pet the castor documentation we have develped
> one more class RFDTMasterData as follows with the method
> getSingletonMasterData()
>
> public class RFDTMasterData extends RFDTValueObject
> {
> MasterData masterData;
>
> public RFDTMasterData()
> {
>
> }
>
> public MasterData getMasterData()
> {
> masterData = getSingletonMasterData();
> return masterData;
> }
> public void setMasterData(MasterData data)
> {
> masterData = data;
> }
> public MasterData getSingletonMasterData()
> {
> return MasterData.getInstance() ;
> }
> }
>
> and the Mapping XML looks like
>
> <!DOCTYPE databases PUBLIC
> "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> "http://castor.exolab.org/mapping.dtd">
> <mapping>
> <class name="RFDTMasterData">
> <map-to xml="RFDTMasterData"/>
> <field name="masterData" type="MasterData"
> create-method="getSingletonMasterData">
> <bind-xml name="MasterData" node="element"/>
> </field>
> </class>
> <class name="MasterData">
> <map-to xml="MasterData"/>
> <field name="terminalList" type="MasterTerminal"
> collection="arraylist">
> <bind-xml name="TerminalList" node="element"/>
>
> </field>
> </class>
> <class name="MasterTerminal">
> <map-to xml="TerminalList"/>
> <field name="code" type="java.lang.String">
> <bind-xml name="Terminal" node="element"/>
> </field>
> </class>
> </mapping>
>
> As per the documentation we have develped the mapping file but still
> it throws the exception.Can you please guide how this can be achieved.
>
> Regards,
> Govind
>
> Below is the Terminal class which is refrred in singleton class and
> mapping xml
>
> public class MasterTerminal extends RFDTValueObject
> {
> private String code;
>
> public MasterTerminal()
> {
>
> }
>
> public String getCode()
> {
> return code;
> }
>
> public void setCode(String string)
> {
> code = string;
> }
>
> }
>
> Keith Visco To
> <[EMAIL PROTECTED]> [EMAIL PROTECTED]
>
> 09/16/2004 04:41 AM cc
> Please respond to Subject
> <[EMAIL PROTECTED]> Re: [castor-user] Marshalling Singleton
> Class
>
> What does your class look like?
>
> --Keith
>
> [EMAIL PROTECTED] wrote:
> >
> > Hi,
> >
> > How can we marshal a singleton class through castor.Currently when
> we
> > try to marshal it,we are getting following exception
> >
> > org.exolab.castor.mapping.MappingException: The Java class
> MasterData
> > is not constructable -- it does not contain a default public
> > constructor
> > at
> >
> org.exolab.castor.mapping.loader.ClassDescriptorImpl.<init>(ClassDescriptorImpl.java:152)
> >
> > at
> >
> org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(MappingLoader.java:557)
> >
> > at
> >
> org.exolab.castor.xml.XMLMappingLoader.createDescriptor(XMLMappingLoader.java:202)
> >
> > at
> >
> org.exolab.castor.mapping.loader.MappingLoader.loadMapping(MappingLoader.java:289)
> >
> > at
> > org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:291)
> > at
> > org.exolab.castor.mapping.Mapping.getResolver(Mapping.java:246)
> > at
> > org.exolab.castor.xml.Marshaller.setMapping(Marshaller.java:523)
> > at marshalMasterData(DefaultTransformer.java:129)
> >
> > Regards,
> > Govind
> >
> > Name: InterScan_Disclaimer.txt
> > InterScan_Disclaimer.txt Type: Plain Text (text/plain)
> > Encoding: 7bit
> >
> > ---------------------------------------------------------------
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-user
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
>
> ForwardSourceID:NT00008F12
>
> Name: InterScan_Disclaimer.txt
> InterScan_Disclaimer.txt Type: Plain Text (text/plain)
> Encoding: 7bit
>
> ---------------------------------------------------------------
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user