Bryan,
You're using "get-name" and "set-name" methods, those need to be "get-method" and "set-method" respectively.
--Keith
Bryan LaPlante wrote:
Ok what am I doing wrong. ServerEvent is a field value for one or more fields that the control developer wishes to expose an event on. That event will call the class referenced in the new ServerEvent(Object source,"methodToCall") constructor. Below is the mapping entry I am using and after that the error given by the Marshaller.
ContextListener extends EventListener and has a uniqueID that must be implemented, the above source object becomes that listener.
<class name="org.xoscript.server.event.ContextListener" identity="uniqueID" auto-complete="true" verify-constructable="false">
<field name="uniqueID" type="java.lang.String"/>
</class>
<class name="org.xoscript.server.event.ServerEvent">
<field name="target" type="java.lang.String" direct="false">
<bind-xml name="target" node="attribute" />
</field>
<field name="name" type="java.lang.String" direct="false">
<bind-xml name="name" node="attribute" />
</field>
<field name="uniqueID" type="java.util.EventListener" collection="set" direct="false" get-name="getListeners" set-name="setListeners" >
<bind-xml name="listener" reference="true" node="element" />
</field>
</class>
Here is the error:
org.exolab.castor.mapping.MappingException: The method getUniqueID in class org.xoscript.server.event.ServerEvent accepting/returning object of type interface java.util.Set was not found
at org.exolab.castor.mapping.loader.MappingLoader.createFieldHandler(MappingLoa der.java:923)
at org.exolab.castor.mapping.loader.MappingLoader.createFieldDesc(MappingLoader .java:752)
at org.exolab.castor.xml.XMLMappingLoader.createFieldDesc(XMLMappingLoader.java :338)
at org.exolab.castor.mapping.loader.MappingLoader.createFieldDescs(MappingLoade r.java:615)
at org.exolab.castor.mapping.loader.MappingLoader.createDescriptor(MappingLoade r.java:438)
at org.exolab.castor.xml.XMLMappingLoader.createDescriptor(XMLMappingLoader.jav a:202)
at org.exolab.castor.mapping.loader.MappingLoader.loadMapping(MappingLoader.jav a: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 org.xoscript.server.Application.writeXML(Application.java:145)
at org.xoscript.test.CreateXML.main(CreateXML.java:48)
----- Original Message -----
From: "Keith Visco" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, February 14, 2005 4:55 AM Subject: Re: [castor-user] Changed my mind was (Mental block)
Bryan,
Have you thought about using an ID/IDREF approach?
In the mapping file you can specify an identity field for a class:
<class name="MyClass" identity="id"> <field name="id" ...> ... </class>
Then whatever fields use the MyClass you can mark them as references:
<class name="SomeOtherClass"> <field name="myClass" type="MyClass"> <bind-xml reference="true" node="attribute"/> </field> ... </class>
--Keith
Bryan LaPlante wrote:
I hate the idea that I came up with and I have a better one, but I will
need
some help to point me in the right direction or come up with a better
way.
Let me know if I need to move this to the developer list.
Concern
ing object references. To instances that have already been created
but are referred to in many places in the output xml, I need a way to
reuse
the instances already created. Upon unmarshalling I need only one
instance
of an object created for ever setter and adder method that expects it.
Create an interface that tells the Marshaller that I want to temporarily store a reference to all created objects.
public interface ReferenceObject{ public Hashtable references = new HashTable(); public Object getReference(int hashCode); public void addReference(int hash, Object ref); public boolean hasReference(int hash); }
Now my root object implements this interface so that Marshaller knows it
has
a place to store references. As the xml is being created you store each instance received from the getValue or convertUponGet method if used in
the
Hashtable.
In addition to the normal xml output expected will be the tags
representing
the Hashtable with the hasCode as the key and the xsi:type or classPath
or
even null indicating to the unmarshaller that the instance has not yet
been
created.
When the Unmarshaller is given the xml it will populate the hastable
first
and then before every tag is converted into an object, check to see if
the
hascode in the tag refers to an instance in the hastable that already
exists
and use that instance to populate the setValue or convertUponGet if used instead of creating yet another instance of the object.
I can come close to doing this by using the GeneralizedFieldHandler
except
that I am creating an API and the (user) developer will have to carry
the
baton and continue this for his or her own classes, I would like to make this functionality available while expecting a minimum of effort from
the
developer.
What do you think.
Bryan LaPlante
----------------------------------------------------------- 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
----------------------------------------------------------- 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
