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 <[EMAIL PROTECTED]>
09/16/2004 04:41 AM
|
|
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
DISCLAIMER: The information contained in this message is intended only and solely for the addressed individual or entity indicated in this message and for the exclusive use of the said addressed individual or entity indicated in this message (or responsible for delivery of the message to such person) and may contain legally privileged and confidential information belonging to Tata Consultancy Services Limited. It must not be printed, read, copied, disclosed, forwarded, distributed or used (in whatsoever manner) by any person other than the addressee. Unauthorized use, disclosure or copying is strictly prohibited and may constitute unlawful act and can possibly attract legal action, civil and/or criminal. The contents of this message need not necessarily reflect or endorse the views of Tata Consultancy Services limited on any subject matter. Any action taken or omitted to be taken based on this message is entirely at your risk and neither the originator of this message nor Tata Consultancy Services Limited takes any responsibility or liability towards the same. Opinions, conclusions and any other information contained in this message that do not relate to the official business of Tata Consultancy Services limited shall be understood as neither given nor endorsed by Tata Consultancy Services Limited or any affiliate of Tata Consultancy Services Limited. If you have received this message in error, you should destroy this message and may please notify the sender by e-mail. Thank you.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
