I have a situation that works but I have no idea why. I am hoping for an explanation.

Our system has a session bean that manages an entity bean. All external calls pass 
through the session bean. There is an Info value object which is used to pass 
information into and out of the entity bean. The remote interface for the entity bean 
simply consists of a get and set method using this value object. 


  | public class ProductEligibilityInfo implements Serializable {
  | 
  | 
  |   private String                  stock_code;
  |   private String                  special_print_code;
  |   private Long                  item_process_id;
  | ...
  | }
  | 
  | public interface ProductEligibility extends EJBObject {
  | 
  |   public ProductEligibilityInfo getInfo() throws RemoteException;
  | 
  |   public void setInfo(ProductEligibilityInfo rebate_info) throws RemoteException;
  | 
  | }
  | 
  | public class ProductEligibilityPK implements Externalizable, Serializable {
  |   private String stock_code;
  |   private String special_print_code;
  |   private long item_process_id;
  | ...
  | }
  | 
  | 



In one call the session bean calls a finder function on the entity bean and the entity 
bean returns an enumeration of PK objects. The session bean iterates through the 
enumeration and assigns the element (PK object) to a remote interface object (rif).  
rif.getInfo() is called and the returned object is assigned to a new vector. 


  | while (enumOfPK.hasMoreElements() )
  | {
  |   RemoteIF rif = (RemoteIF)enumOfPK.nextElement();
  |   vector.add(rif.getInfo());
  | }
  | 

This somehow works! How can I cast the PK object to a RemoteIF and not get a class 
cast exception.

When I step through the bean code , the eclipse debugger can identify each of the 
objects types correctly. This is what the debugger displays when I highlight the 
$Proxy object in the returned enumeration.

ProductEligibility:[ProductEligibilityPK: stock_code '   58T'
special_print_code '0005'
item_process_id '9']

When I highlight the vector that is being built with the rif.getInfo() call after the 
add the debugger displays.

[[ProductEligibilityInfo: stock_code '   58T'
special_print_code '0005'
item_process_id '4']]


The Info object and the PK object have identical data layouts which I guess is how we 
have lucked out for the last 3 years.





View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3853772#3853772

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3853772


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to