380 likes | 894 Views
EJB (Enterprise Java Beans). Agenda. What is an EJB ? EJB Component. EJB Benefit EJB Security Java Beans v/s EJB Some EJB Server References. What is an EJB ?. Development and deployment of Java applications that are: Portable, Multi-tier, Scaleable, Secure, Distributed, Transactional
E N D
Agenda • What is an EJB ? • EJB Component. • EJB Benefit • EJB Security • Java Beans v/s EJB • Some EJB Server • References
What is an EJB ? • Development and deployment of Java applications that are: • Portable, Multi-tier, Scaleable, Secure, Distributed, Transactional • Server-side component encapsulating application functionality • Business logic • DB access • Integrate with other legacy systems • Serve multiple clients • Browser • Desktop apps • Other EJBs • Web app components (e.g., Servlets) • Web Service clients
What is an EJB ? • EJB container provides services to bean and manages its life cycle. • A component architecture • A component model • For developing object-oriented • distributed enterprise-level applications
EJB Session Beans • Session beans perform work for a client application • For example, a session bean could charge a credit card for a specific transaction • Two types of session beans • Stateful • Stateless
Session Beans - Stateful • Stateful – A stateful bean maintains a conversational state with a client. The client perceives that it is only talking to one bean, and that bean maintains information between calls
Session Beans - Stateless • Stateless – A stateless bean maintains no client information between method calls – the container can substitute beans as necessary between method calls
Stateless vs. Stateful • Stateful • Possess internal state • Needs to handle passivation and activation • One per client • Stateless • No internal state, nothing maintained across client calls • Does not need to be passivated • Can be pooled to service multiple
EJB - Entity Beans • Entity beans are classes that map to individual entities – typically, an Entity bean references a row in a database table, providing an object representation of that database object. • For example, an entity bean could represent a customer, and changing the values in that entity bean would cause updates to that database row • Entity beans provide an abstraction layer so that working with the entity is not specific to the storage mechanism for that entity.
Entity Beans - Persistence • Container Managed Persistence (CMP) • The EJB container automatically persists the EJB objects, usually to a relational database where each type of object is represented as a table, and each instance of the object is a row in that table • Bean Managed Persistence (BMP) • The EJB container calls bean methods when it is appropriate for the bean to load, save or update data, enforcing transactions without transaction code written by the bean developer
EJB – Message Beans • Message beans are classes that receive asynchronous notification from a Java Message Service server • For example, a message bean could be activated when vendor sends a purchase order to a JMS queue.
EJB - Benefits • Provides a high-level language to discuss design issues. • Provides much of the design. • Combinations of patterns form reusable architectures. • Simplifies the development of middleware components that are secure, transactional, scalable & portable. • Simplifies the process to focus mainly on business logic rather than application development. • Overall increase in developer productivity • Reduces the time to market for mission critical applications
EJB - Sequrity • Two security measures that client must pass when you add security to EJB system – Authentication and Authorization. • Authentication must be performed before any EJB method is called. • Authorization occurs at the beginning of each EJB method call.
Authentication in EJB • Two ways to perform authentication in EJB: • We can call authentication logic through Java Authentication and Authorization Service (JAAS), a separate J2EE API. • JAAS is a portable interface that enables you to authenticate and authorize users in Java. It allows to login to the system without knowing about the underlying security system being used.
Authorization in EJB • Two ways to perform authorization in EJB: • With programmatic authorization, we can hard code security checks into our bean code. • With declarative authorization, the container performs all authorization checks for us.
Java Beans vs. EJB • Can be either visible non-visible. • Local Invocation • Synchronous Invocation • Decidedly non-visible remote objects • Remote and Local Invocation • Synchronous and Asynchronous Invocation • Object Pooling • Transparent Persistence • Supports Transactions • Support Relationships between entity EJBs • J2EE Security Features
Some EJB Server CompanyProduct • IBM WebSphere • BEA Systems BEA WebLogic • Sun Microsystems Sun Application Server • Oracle Oracle Application Server • JBoss JBoss
References • J2EE Tutorial - http://java.sun.com/j2ee/tutorial/1_3-fcs • J2EE Developers Guide - http://java.sun.com/j2ee/sdk_1.2.1/techdocs/guides/ejb/html/DevGuideTOC.html • JNDI - http://java.sun.com/products/jndi/tutorial/ • JMS - http://java.sun.com/products/jms/tutorial/ • JDBC - http://java.sun.com/docs/books/tutorial/jdbc • Servlets - http://java.sun.com/docs/books/tutorial/servlets • JSP - http://java.sun.com/products/jsp/docs.html • JAXP - http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial • http://www.oracle.com/technology/tech/java/index.html