I would do it like this:

Have a class something like:

public class Message {

        private MyEvent myEvent;

        //getters and seters for myEvent
}


Then, define a jibx binding like:

<mapping
                class="xxx.MyEvent"
                abstract="true" />



<mapping name="message">
        <structure field="myEvent" type="xxx.MyEvent" />
</mapping>



<mapping name="createMyEvent"
                class="xxx.CreateMyEvent"
                extends="xxx.MyEvent">
                <structure map-as="xxx.MyEvent" />
<!-- other fields -->
        </mapping>




<mapping name="deleteMyEvent"
                class="xxx.DeleteMyEvent"
                extends="xxx.MyEvent">
                <structure map-as="xxx.MyEvent" />
<!-- other fields -->
        </mapping>


By having the above, depending on whether the message contains create or
delete event elements, the correct object will be populated in to the
field 'myEvent' in the Message object.

HTH

-----Original Message-----
From: David Newcomb [mailto:[EMAIL PROTECTED] 
Sent: 04 November 2008 11:53
To: jibx-users@lists.sourceforge.net
Subject: [jibx-users] Java Interfacing


Hi All,

I am sure this problem has come up before, but I
can't find any examples or any help.

I have an interface:

public interface MyEvent
{
   public void process () throws Exception ;
}

with several implementations in the form of:

public class CreateMyEvent implements MyEvent
{
   public void process () throws Exception
     {
     // do something
     }
}
public class DeleteMyEvent implements MyEvent
{
   public void process () throws Exception
     {
     // do something
     }
}

I am placing them in a JMS queue and would like them to be
remapped back to objects when they come out, so that I can
do something like:

   while  (mess = read from queue)
   {
     mess.process();
   }

I have created a mapping binding for each MyEvent implementation
but have found that I can only use one de-serialiser at the
other end.

Please can someone help me with what the "right" way of achieving this
is.


Regards,
David


------------------------------------------------------------------------
-
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
The information contained in this email is strictly confidential and for the 
use of 

the addressee only, unless otherwise indicated. If you are not the intended 
recipient, please do not read, copy, use or 

disclose to others this message or any attachment. Please also notify the 
sender by replying to this email or by 

telephone (+44 (0)20 7896 0011) and then delete the email and any copies of it. 
Opinions, conclusions (etc.) that do 

not relate to the official business of this company shall be understood as 
neither given nor endorsed by it. IG Index 

plc is a company registered in England and Wales under number 01190902. VAT 
registration number 761 2978 07. Registered 

Office: Friars House, 157-168 Blackfriars Road, London SE1 8EZ. Authorised and 
regulated by the Financial Services 

Authority. FSA Register number 114059.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to