日期:2014-05-20  浏览次数:20545 次

EJB 3.0 怎么返回 StringBuffer?StringBuffer为什么为空啊?
class   Test
{
        void   change(StringBuffer   a)
        {
                  a.append( "hehe ");
        }
        public   static   void   main(String[]   args)
        {
                StringBuffer   b=new   StringBuffer( "haha ");
                Test   t=   new   Test();
                t.change(b);
                System.out.println(b);
        }
}
运行后,打印   hahahehe
但是在EJB   3.0   中


//RoleControl.java
-----------------------
package   com.shitong.authority;

public   interface   RoleControl  
{
boolean   QueryDefaultRole(StringBuffer   xmlstring);
}
------------------------

//RoleControlBean.java
-----------------------
package   com.shitong.authority.imp;

import   javax.ejb.EJB;
import   javax.ejb.Local;
import   javax.ejb.Remote;
import   javax.ejb.Stateless;
import   java.util.*;
import   com.shitong.authority.*;
import   java.io.*;

@Stateless
@Remote   ({RoleControl.class})
@Local   ({RoleControl.class})
public   class   RoleControlBean   implements   RoleControl
{
                  public   boolean   QueryDefaultRole(StringBuffer   xmlstring)
{
                              xmlstring.append( "hehe ");
                              return   true;
                  }
}
-----------------------

//RoleControlBeanClient
-----------------------
package   com.shitong.authority.imp;
import   com.shitong.authority.*;
import   java.util.Properties;
import   javax.naming.InitialContext;


public   class   RoleControlBeanClient  
{

public   static   void   main(String[]   args)
{
Properties   props   =   new   Properties();
props.setProperty( "java.naming.factory.initial ", "org.jnp.interfaces.NamingContextFactory ");
props.setProperty( "java.naming.provider.url ",   "localhost:1099 ");
props.setProperty( "java.naming.factory.url.pkgs ",   "org.jboss.naming ");
try  
{
InitialContext   ctx   =   new   InitialContext(props);
RoleControl   role   =   (RoleControl)   ctx.lookup( "RoleControlBean/remote ");
                                                      StringBuffer   sXmlString=new   StringBuffer( "haha ");