CREATE DEPLOY AND USAGE OF STATELESS SESSION BEANS




AIM:
Write a program to create deploy and usage of stateless session beans

PROCEDURE:
Coding  window:
Step1: Open Application Developer  5.0.
Step2: Create a new folder and click ok.
Step3: File->New->Enterprise Application project->create J2EE 1.3 Enterpries Application-
           next.
Step 4: Give a project name->finish
Step5: Select the EJB module which was created->Right click->Enterprise Bean  creation.
Step6: Form the package selects the bean class and adds our own method
Step7: Create the method public and write relevant code.
Bean.java
Step1: Create a method inside the bean class.
Step2: Select the new method right click on it  select Enterprise Bean ->promote to remote   
          interface.
Step3: Select the EJB module ->Right click and select generate deploy and rmi code.
Executing Window.
Step1: EJB module ->right click->run on server.
Step2: select JNDI explorer ->EJB->project->name->EJB home.


Step3: select EJB reference ->select bean class ->select bean create() method
Step4: click the invoke button->work with object button->click it
Step5: select the name from the left pane click it ->select the name created.
Step6: Give the input then click invoke  button.
Step7: stop the program.
package xyz;
/**
 * Bean implementation class for Enterprise Bean: mcaaa
 */
public class mcaaaBean implements javax.ejb.SessionBean {
            private javax.ejb.SessionContext mySessionCtx;
            /**
             * getSessionContext
             */
            public javax.ejb.SessionContext getSessionContext() {
                        return mySessionCtx;
            }
            /**
             * setSessionContext
             */
            public void setSessionContext(javax.ejb.SessionContext ctx) {
                        mySessionCtx = ctx;
            }
            /**
             * ejbCreate
             */
            public void ejbCreate() throws javax.ejb.CreateException {
            }
            /**
             * ejbActivate
             */
            public void ejbActivate() {
            }
            /**
             * ejbPassivate
             */
            public void ejbPassivate() {
            }
            /**
             * ejbRemove
             */
            public void ejbRemove() {
            }
            public int add(int a,int b)
            {
            return(a+b);
}
}

0 comments: