Hi,

I have an intriguing quetsion for every one. 
I have got a stateful bean which has one attribute and two interfaces method
along with neccessary callback methods as shown below.

/**
 * @ejb.bean name="XXX"
 *  jndi-name="XXXBean"
 *  type="Stateful" 
 *    
 *  @ejb.transaction type="Required"
 * 
 *   @ejb.dao class="XXXDAO"
 *   impl-class="XXXDAOImpl" 
 */

public abstract class XXXBean implements SessionBean {

        private String id;   
        public SessionContext ctx;
        
        /**
         *   Sets the session context 
         *  @param javax.ejb.SessionContext the new ctx value
         * 
         **/   
         public void setSessionContext(javax.ejb.SessionContext ctx)  {
                          this.ctx = ctx;       
         }
    
        /**
         * Unsets the session context 
         *  @param javax.ejb.SessionContext ctx value
         *  
         **/
         public void unsetSessionContext()  {
                  this.ctx = null;      
         }    

        /**
         * @ejb.interface-method
         * view-type="remote" 
         **/       
        public String getId ( ) {
               return id;
        }

         /**
          * The  ejbCreate method.
          * @ejb.create-method 
          * 
          **/
        public void ejbCreate (String id ) throws  javax.ejb.CreateException {
                this.id = id;
        }     
             
        /**
         * @ejb.interface-method
         * view-type="remote" 
         * @dao.call name="loginUser"
         **/   
        public String login(String username, String password ) {
                          
            return id;
        }
                   
        public void ejbActivate() {
        }

        public void ejbPassivate() {

        }
}

Now when i use xdoclet to generate the classes using necassary tags as shown below all 
the methods in various the calsses are generated. Now coming to point in generated 
class which XXXSession class.

public class XXXSession extends XXXBean implements javax.ejb.SessionBean
{
   public void ejbActivate()    {
      super.ejbActivate();
   }

   public void ejbPassivate()    {
      super.ejbPassivate();
   }

   public void setSessionContext(javax.ejb.SessionContext ctx)    {
      super.setSessionContext(ctx);
   }

   public void unsetSessionContext()    {
      super.unsetSessionContext();
   }

   public void ejbRemove()  {
   }

   private XXXDAO dao = null;

   protected XXXDAO getDao()
   {
      if (dao != null) {
         return dao;
      } else {
         dao = (XXXDAO) new XXXDAOImpl();
         dao.init();
         return dao;
      }
   }

  public java.lang.String loginUser(java.lang.String username,java.lang.String 
password)
    {
        super.loginUser(username,password);
        return getDao().loginUser(username,password);
    }
}
 
Now loginUser returns id when invoked from client, but since i'm passing attribute 
'id' in ejbCreate method I want the value assigned to that attribute, but the way the 
this class is generated , if i invoke the method getId after call to loginUser it 
returns null. which is the right behavior because in genrated class that attributr 
doesn't exist.

My question is how do i get this 'id' value from Databse in this stateful bean 
attribute using this DAO class and loginUser method.

I have looked at various examples but haven't come cross like this yet, so can anyone 
suggest me whats wrong here or is it possible to use DAO pattern with stateful bean in 
XDoclet,or the way i have desigend this is wrong.

Any help will highly appreciated.
 










-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to