R4R
Right Place For Right Person TM
 
R4R Java EJB

R4R
provide basic EJB Tutorials concept with EJB Examples . Through R4R you can develop EJB programming concept. R4R provide EJB Interview Questions with answers.R4R provide EJB Languages study materials in easy way.

EJB Tutorials

1.1    EJB Basic Tutorials

EJB Interview Questions with Answers

3.1    EJB Interview Questions And Answers
3.2    EJB Objective Questions and Answers
3.3    EJB Subjective Questions And Answers
3.3    EJB FAQS

ENTERPRISE JAVA BEANS

An enterprise bean is a server-side component that encapsulates the business logic of an application. It written in java so, it is called enterprise java beans. EJB is a managed, server-side component architecture for modular construction of enterprise applications.
The EJB technology provides a distributed component architecture which integrates many enterprise-level requirements like distribution, persistence, transactions, messaging, security, and connectivity to mainframes . EJB technology provides us with different types of components for business logic, persistence, and enterprise messages. They are not only platform independent but also implementation independent. That is, EJBs can run in any application server that implements the EJB specifications.

EJB COMPONENT ARCHITECTURE

An enterprise java bean is a non-visual component of a distributed, transaction -oriented application. enterprise beans are deployed in EJB containers and run on EJB servers. there are mainly three types of EJB session beans,entity beans ,message driven beans.

EJB SERVER

An EJB server provide environment for the support and execution of application developed using EJB components. An EJB server is a high-level process or application server that gives a run-time environment to support the execution of server applications which are  used enterprise beans. An EJB server provide one or more containers.

EJB CONTAINER

An EJB container manages the EJB contain inside it. For each enterprise bean, the container is responsible for registering the object, providing a remote interface for the object, creating and destroying object instances, checking security for the object, managing the active state for the object, and coordinating distributed transactions. Optionally, the container can also manage all persistent data within the object.

ENTERPRISE BEANS

An enterprise bean is a server-side component that encapsulates the business logic of an application. written in the Java programming language.The business logic is the code that fulfill the purpose of application. In an application enterprise beans add the business logic.

BENEFITS OF ENTERPRISE BEANS

Enterprise beans simplify the development of large, distributed applications. because the EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems. EJB container is responsible for system-level services such as transaction management and security authorization. The EJB architecture provides a simple, elegant component container model. Java server components can be developed once and deployed in any EJB-compliant server.
The EJB architecture can be used for small-scale or large-scale business transactions. As processing requirements grow,
the enterprise beans can be migrated to more powerful operating environments.

TYPES OF ENTERPRISE BEANS

There are tree types of enterprise beans:
1.Session beans:
-Session bean perform task for a client  A session bean represents a single client and is not shared across clients.There are two types of session beans: statefull and stateless.
Statefull  session bean :-
A stateful session bean maintains a conversational state with one client for the duration of a single session.
Stateless session bean :-
A stateless session bean does not maintain a conversational state for each individual client
Stateless session beans are not persisted to secondary storage by the EJB container; therefore a programmer must recognize that all data is transient between invocations for each client
.2.Entity bean:-Represent a business entity object that persistent in the storage. entity bean can be restored to its original state by the EJB container. Entity beans allow shared access – they may be shared by multiple clients ,Entity beans have primary keys – primary-key classes exist to identify an instance of an entity bean. and Entity beans can participate in transactions
3.Message -driven bean:-
Acts as a listener for the Java Message Service API, processing messages asynchronouslyAn instance of an MDB is instantiated by an EJB container to act as a message listener. Messages received by an MDB may be sent by any JMS-compatible message transmitter, such as a JMS-enabled publish/subscribe topic.

CREATING AN ENTERPRISE JAVA BEAN

The creation of enterprise java bean requires to code remote interface, home interface, and EJB class
To understand EJB here we take the example of stateless session bean.
Coding the remote interface
A remote interface defines the business methods that a client may call. The business methods are implemented in the enterprise bean code.
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import java.math.*;

public interface Converter extends EJBObject
{
   public BigDecimal dollarToRupee(BigDecimal dollars)
      throws RemoteException;
   public BigDecimal RupeeToEuro(BigDecimal Rupee)
      throws RemoteException;
}

Coding home interface
A home interface defines the methods that allow a client to create, find, or remove an enterprise bean. The Home interface contains a single create method, which returns an object of the remote interface type .


import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;

public interface ConverterHome extends EJBHome
	{
   Converter create() throws RemoteException, CreateException;
}

Coding Enterprise bean class
The enterprise bean class for this example is called ConverterEJBBean. This class implements the two business methods, dollarToRupee and RupeeToEuro, that the Converter remote interface defines.


import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.math.*;

public class ConverterEJBBean implements SessionBean {

   BigDecimal RupeeRate = new BigDecimal("45.4104");
   BigDecimal euroRate = new BigDecimal("0.016523");

   public BigDecimal dollarToRupee(BigDecimal dollars) 
	   {
      BigDecimal result = dollars.multiply(RupeeRate);
      return result.setScale(2,BigDecimal.ROUND_UP);
   }

   public BigDecimal RupeeToEuro(BigDecimal yen) 
	   {
      BigDecimal result = Rupee.multiply(euroRate);
      return result.setScale(2,BigDecimal.ROUND_UP);
   }

   public ConverterEJBBean() {}
   public void ejbCreate() {}
   public void ejbRemove() {}
   public void ejbActivate() {}
   public void ejbPassivate() {}
   public void setSessionContext(SessionContext sc) {}
}

Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

10:New Updates
Tutorials,examples and Interview Questions with answers
Posted By: Shashi     Posted Date:02.10.14

9:C# Tutorials,C# examples and C# Interview Questions with answers
R4R provide C# Tutorials,C# examples and C# Interview Questions with answers. Through R4R you can develop a small application and small programs.We cover C# Tutorials,C# examples and C# Interview Questions and answers for freshers as well experienced programmer.
Posted By: Shashi     Posted Date:11.17.13

8:Java/J2EE(Servlet,JSP,JNDI,Struts,Spring,Hibernate,EJB,JSF,JMS,Web-Services)
In this section R4R covers Java/J2EE(Servlet,JSP, JNDI, Struts, Spring, Hibernate, EJB,JSF,JMS,Web-Services) Tutorials with Examples.R4R provide Java/J2EE (Servlet,JSP, JNDI,Struts, Spring, Hibernate, EJB, JSF, JMS, Web-Services) Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.13.13

7:CoreJava Tutorials , CoreJava Examples and CoreJava Interview Questions with answers
In this section R4R covers CoreJava Tutorials with CoreJava Examples. R4R covers CoreJava programming concept in easy way. R4R provide CoreJava Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.04.13

6:Microsoft.net Technology ASP.NET,c# ,ADO.NET,WCF,WPF,Silverlight ,VB.net
R4R provides Microsoft Technologies(like ASP.NET,c# ,ADO.NET,WCF,WPF, Silverlight and VB.ne)Tutorials with Examples,programming concept and Interview Questions with answers study materials for freshers and experienced.
Posted By: Shashi     Posted Date:11.04.13

5:J2me Tutorials concept with Examples with Netbean IDE and J2ME Application Examples.
R4R cover basic J2me Tutorials concept with Examples and provide a way to develop J2me programming concept in easy way. R4R provide J2me Interview Questions with answers.R4R provide J2me Languages study materials with examples uing Netbean IDE and J2ME Application Examples.
Posted By: Shashi     Posted Date:10.30.13

4:J2me Tutorials concept with Examples ith netbean IDE and J2ME Application Examples.
R4R cover basic J2me Tutorials concept with Examples and provide a way to develop J2me programming concept in easy way. R4R provide J2me Interview Questions with answers.R4R provide J2me Languages study materials with examples uing Netbean IDE and J2ME Application Examples.
Posted By: Shashi     Posted Date:10.30.13

3:Java ebooks , Java tutorials , Java examples , Java interview questions and answers
R4R provides study materials for Java/j2EE technologies. R4R covers core java, advanced java, servlet, JSP, Struts, Spring, Hibernate, EJB, JSF, J2ME, ANT, JUnit and Some APIS .R4R also provides ebooks,tutorials,examples, interview questions and answers.
Posted By: Shashi     Posted Date:10.30.13

2:Learn basic C++ Tutorials with Examples , C++ Interview Questions with answers
R4R is a free E-learning website.You can learn basic C++ Tutorials with Examples , C++ Interview Questions with answers and also some hot topics.
Posted By: Shashi     Posted Date:10.30.13

1:C Tutorials with Example C subjective and objective interview questions and answers
R4R provide C Tutorials with Example and also provides C subjective and objective interview questions and answers.You can learn C in easy way.We cover basics of C here and give some examples.
Posted By: Shashi     Posted Date:10.30.13

[an error occurred while processing this directive]