Can't a ArrayList be passed as a parameter?

If I pass a ArrayList as a parameter, the changes made to that ArrayList inside 
the container don't return to the client!

Consider this simple interface:

import java.util.ArrayList;
import javax.ejb.Remote;

@Remote
public interface Echo {

        public ArrayList doEcho(ArrayList myList);
        
}

And the corresponding Session bean:

import java.io.Serializable;
import java.util.ArrayList;

import javax.ejb.Stateful;

@Stateful
public class EchoBean 
        implements Echo, Serializable
{
        public ArrayList doEcho(ArrayList myList)
        {
                myList.add("ECHO");
                return myList;
        }
}


And the folowing test:

        ArrayList myList = new ArrayList();
        InitialContext ctx = new InitialContext();
        Echo myEcho = (Echo) ctx.lookup(Echo.class.getName());
        Echo myLocalEcho = new EchoBean();
        
        myLocalEcho.doEcho(myList); // After this point we have one item on 
myList
        myEcho.doEcho(myList); // After this point myList should have two 
items, but still only has one!
       
        myList = myEcho.doEcho(myList); // Ok, now we have two items on the 
List!
       
Does this mean that we have a behavior for remote calls diferent from the local 
call, and we need to return the ArrayList like a function? Am I wrong or is 
this a bug?

I'm using JBoss 4.0.3SP1 on Windows XP.

Thanks,
Jose

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

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


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to