Sun River
Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ...
posts - 78,comments - 0,trackbacks - 0

Step1: Definition of Remote Interface
              public interface Count extends EJBObject{
                        public int count() throws RomoteException;
                      }
Step2: Definition of Home Interface
               public interface CountHome extends EJBHome {
                        Count create(int val) throws RemoteException, CreateException;
                      }
Step3: Definition of Bean Class
               Public class CountBean implements SessionBeam {
                          public int val;
                           public int count() {
                              System.out.println("count()");
                              return ++val;
                              }
               public void ejbCreate(int val) throws CreateException {
                            this.val=val;
                            System.out.println("ejbCreate()");
                         }
                 public void ejbRemove(){};
                 public void ejbActivate(){};
                 public void ejbPassivate(){};
                 public void setSessionContext(SessionContext ctx){};
          }

Step4: Definition of ejb-jar.xml

                   <ejb-jar>
                      <enterprise-beans>
                        <session>
                           <ejb-name>Count</ejb-name>
                            <home>CountHome</home>
                            <remote>Count</remote>
                            <ejb-class>CountBean</ejb-class>
                            <session-type>Stateful</session-type>
                            <transaction-type>Container</transaction-type>
                        </session>
                      </enterprise-beans>
                    </ejb-jar>                    

        

posted on 2006-09-24 06:45 Sun River 阅读(259) 评论(0)  编辑  收藏 所属分类: SBS Series