I neglected to append the BindingImpl class - included at the end for completeness.

Thanks..

-----Original Message-----
From: Brent Picasso [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 22, 2004 9:22 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] problems with polymorphic mapping-


Hello,

I am trying to unmarshal the following structure, involving mapping a concrete class 
to a field that defined with an interface.

It's failing with an error:  

testBindingMapping(com.schemalogic.integrator.BindingMappingTest)java.lang.NoClassDefFoundError:
 com/schemalogic/integrator/Bindingconfig (wrong name: 
com/schemalogic/integrator/BindingConfig)

I've looked at the castor mapping documents and implemented the polymorphic behavior 
for auto-naming="deriveByClass". it seems to be ignoring this..

Thanks for any help.
Brent Picasso

My mapping file is:

<mapping>
    <class name="com.schemalogic.integrator.BindingImpl">
        <map-to xml="binding"/>
        <field name="id" type="java.lang.String">
            <bind-xml name="objectid" node="attribute"/>
        </field>
        <field name="name" type="java.lang.String">
            <bind-xml name="name" node="attribute"/>
        </field>
        <field name="description" type="java.lang.String">
            <bind-xml name="description" node="element"/>
        </field>
        <field name="bindingConfig" type="com.schemalogic.integrator.BindingConfig" 
required="true">
            <bind-xml auto-naming="deriveByClass" node="element" 
location="bindingconfig"/>
        </field>
    </class>

    <class name="com.schemalogic.integrator.CustomBindingConfig">
        <map-to xml="custombindingconfig"/>
        <field name="loginId" type="java.lang.String">
            <bind-xml name="loginid" node="attribute"/>
        </field>
        <field name="password" type="java.lang.String">
            <bind-xml name="password" node="attribute"/>
        </field>
        <field name="port" type="java.lang.String">
            <bind-xml name="port" node="attribute"/>
        </field>
        <field name="server" type="java.lang.String">
            <bind-xml name="server" node="attribute"/>
        </field>
    </class>
    
</mapping>

My sample XML to be unmarshalled is:

<binding objectid="1234" name="binding_sample">
    <description>binding sample description</description>
    <bindingconfig>
        <custombindingconfig loginid="uid" password="pwd" port="1234" 
server="custom.kom"/>
    </bindingconfig>
</binding>


Here is the BindingConfig interface:


package com.schemalogic.integrator;

import com.schemalogic.SchemalogicObject;

public interface BindingConfig extends SchemalogicObject{
    
    /** Indicate whether this Binding Configuration is in a valid data state
     * @true if it is in a valid state
     */
    public boolean isValid();
    
}

package com.schemalogic.integrator;

public class CustomBindingConfig extends BaseIntegratorObject implements BindingConfig 
{
    
    private String loginId;
    private String password;
    private String port;
    private String server;
    
    public boolean isValid() {
        return (null!=getLoginId() && null !=getPassword() && null !=getPort() && null 
!=getServer());
    }
    
    public void setLoginId(String newLoginId){
        this.loginId=newLoginId;
    }
    
    public String getLoginId(){
        return this.loginId;
    }
    
    public void setPassword(String newPassword){
        this.password=newPassword;
    }
    
    public String getPassword(){
        return this.password;
    }
    
    public void setPort(String newPort){
        this.port=newPort;
    }
    
    public String getPort(){
        return this.port;
    }
    
    public void setServer(String newServer){
        this.server=newServer;
    }
    
    public String getServer(){
        return this.server;
    }
}


And the parent class:

package com.schemalogic.integrator;

import java.util.List;

public class BindingImpl extends BindingShortImpl implements Binding{
    
    private BindingConfig bindingConfig;
    private List permissions;
    private List subscriptions;
    
    public BindingConfig getBindingConfig() {
        return this.bindingConfig;
    }
    
    /** Sets the Binding Configuration for this Binding
     * @param the new Binding Config
     */
    public void setBindingConfig(BindingConfig newBindingConfig){
        this.bindingConfig=newBindingConfig;
    }
    
    public java.util.List getPermissions() {
        return this.permissions;
    }
    
    /** sets the Permissions for this Binding
     * @param the new Permissions
     */
    public void setPermissions(List newPermissions){
        this.permissions=newPermissions;
    }
    
    public java.util.List getSubscriptions() {
        return this.subscriptions;
    }
    
    /** sets the subscriptions for this Binding
     * @param the new Subscriptions
     */
    public void setSubscriptions(List newSubscriptions){
        this.subscriptions=newSubscriptions;
    }
    
}

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to