SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Collaborate


Knowledge Byte
    In this section, you will learn about:


         •   EJB in J2EE Architecture
         •   EJB Design Patterns




 ©NIIT                          Collaborate   Lesson 3C / Slide 1 of 36
Collaborate


EJB in J2EE Architecture
    •    Enterprise JavaBeans are the server side components that are based on Java
         technology.
    •    EJB enables you to inherit all the features that an enterprise component
         requires.
    •    For example, you do not need to write a code to establish a database
         connection.
    •    You can concentrate on writing business logic of an enterprise bean
         development and leaving all the middleware service requirements for
         application server to handle.
    •    You can concentrate on the programming logic of an application using EJB.
    •    Moreover, you can buy EJB components instead of building own components.




 ©NIIT                         Collaborate                  Lesson 3C / Slide 2 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    The various characteristics of using EJB in J2EE architecture are:
           • Supporting multiple clients
           • Improving the reliability and productivity of an application
           • Supporting large scale deployment of applications
           • Developing transactional applications
           • Supporting reusability
           • Implementing security




 ©NIIT                           Collaborate                   Lesson 3C / Slide 3 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Supporting Multiple Clients
          • An enterprise bean can service only one client request at an instance of
            time, as enterprise beans are single threaded.
          • The container creates a pool of bean instances, and selects a bean
            instance from the pool to service the request whenever a client sends the
            request.
          • After servicing a client request, the bean instance is returned to the pool
            and container can assign this instance to another client request.
          • In this manner, the container uses a small number of bean instances to
            service a large number of client requests.
          • The container increases the pool size when the load on the server
            increases, and reduces the pool size when the load on the server is
            reduces.




 ©NIIT                          Collaborate                   Lesson 3C / Slide 4 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Supporting Multiple Clients (Contd.)
          • The following figure shows how a container uses pool of beans to service
            client requests:




 ©NIIT                          Collaborate                  Lesson 3C / Slide 5 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Improving the Reliability and Productivity of an Application
         • EJB improves the productivity and reliability of an enterprise application
             by distributing the whole tasks into various subtasks.
         • Creating an enterprise bean component, assembling the components in
             an application, and deploying the application in an application server
             into different parties are the examples of subtasks.
         • EJB considers that each party is an expert in its task. Some of the
             parties involved are:
             • Bean Developer: Is required to concentrate on the business logic
                  of the bean.
             • Application Assembler: Is responsible for assembling the enterprise
                  beans into an application.
             • Bean Deployer: Is an expert of an application server environment.


 ©NIIT                        Collaborate                  Lesson 3C / Slide 6 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Supporting Large Scale Deployment of Applications
          • You can use the functionality of an existing system using the legacy
              integration.
          • For example, a client on a Web server invokes a session bean on an
              application server.
          • The session bean further invokes an entity bean that uses a database
              server for storing data.
          • This type of application requires a highly secure fault-tolerant
              environment.
          • It also has to maintain a very high level of performance and
              availability.




 ©NIIT                      Collaborate                 Lesson 3C / Slide 7 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Supporting Large Scale Deployment of Applications (Contd.):
          • To meet all the requirements of enterprise applications EJB provides
              support for:
                • Instance Pooling: Uses a pool of bean instances to service client
                     requests.
                • Connection Pooling: Uses a pool of connections that are
                     required by components.
                • Transactions: Contains a sequence of operations executed
                     under a single process.
                • Location Transparency: Does not require a client to be aware of
                     the actual location of the object.




 ©NIIT                       Collaborate                  Lesson 3C / Slide 8 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Developing Transactional Applications
          • A transaction is defined as a sequence of operations.
          • The transaction succeeds if all the operations in the transaction
               succeed and it fails if any of the operation in a transaction fails.
          • In EJB, a transactional application can be developed by two
               approaches:
                • Declarative: Enables you to declare the required transactional
                     attributes, such as Required, Supports, Mandatory, and Never
                     in the deployment descriptor file.
                • Programmatic: Enables you to explicitly code the transactional
                     behavior of the bean in the bean class.




 ©NIIT                       Collaborate                   Lesson 3C / Slide 9 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Supporting Reusability
          • EJB components are not reusable by default.
          • However, you can make a bean reusable using following approaches:
                • Customization: Enables you to modify the properties of a bean
                     according to application requirements.
                • Extension: Enables you to write an application specific code by
                     extending the bean class.




 ©NIIT                       Collaborate                Lesson 3C / Slide 10 of 36
Collaborate


EJB in J2EE Architecture (Contd.)
    •    Implementing Security
          • An enterprise application is susceptible to unauthorized access and
              attacks.
          • Therefore, you need to protect an enterprise application from these
              threats.
          • The EJB container provides a secure environment for enterprise
              beans.
          • Securing an application involves two steps:
               • Authentication: Verifies the identity of a user.
               • Authorization: Provides restricted access to authenticated
                    users.




 ©NIIT                       Collaborate                Lesson 3C / Slide 11 of 36
Collaborate


EJB Design Patterns
    •    The EJB design patterns can de defined as best practices for designing an
         EJB application.
    •    It provides a reusable approach for you to design and develop an
         application.
    •    The EJB design patterns enable you to design secure, reliable, and scalable
         applications.
    •    The various EJB design patterns are:
           • Client-Side EJB Interaction Design Patterns
           • EJB Layer Architectural Design Patterns
           • Inter-Tier Data Transfer Design Patterns
           • Transaction and Persistence Design Patterns




 ©NIIT                        Collaborate                  Lesson 3C / Slide 12 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Client-Side EJB Interaction Design Patterns
          • The Client-Side EJB Interaction design patterns are used to improve
                the performance and maintainability of client-side applications.
          • The various client-side EJB interaction design patterns are:
                 • EJB Home Factory
                 • Business Delegate
          • EJB Home Factory Pattern
                 • The EJB Home Factory design pattern is used to locate the
                      EJBHome object in order to access the remote interface of EJB.
                 • Locating the EJBHome object for each Web request reduces the
                      application performance.
                 • The better approach is to abstract the EJBHome lookup code
                      into a reusable EJBHomeFactory that can cache EJBHome
                      objects for the lifetime of a client application.


 ©NIIT                       Collaborate                  Lesson 3C / Slide 13 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Client-Side EJB Interaction Design Patterns (Contd.)
          • EJB Home Factory Pattern (Contd.)
                 • You can implement the EJB home factory pattern in any
                      environment, such as applets, servlets, and EJBs.
                 • The advantages of using the EJB Home Factory design pattern
                      are:
                       • Providing an efficient technique for abstracting the EJB
                            home complexity from the client in a reusable format.
                       • Improving the performance by reducing the cost involved
                            in locating the redundant home lookups.




 ©NIIT                      Collaborate                 Lesson 3C / Slide 14 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Client-Side EJB Interaction Design Patterns (Contd.)
          • Business Delegate Pattern
                 • The Business Delegate design pattern is used to map session
                      beans present in the session facade pattern and wrap it with
                      multiple message-driven beans.
                 • Business Delegate is a Java class that acts as an intermediary
                      between client and server.
                 • The advantages of using the Business Delegate design pattern
                      are:
                       • Maintaining integration between non-Java applications
                            and EJB by wrapping the business delegate Java objects
                            with non-Java code using Java Naming Interface (JNI).
                       • Hiding the complexity of EJB API by encapsulating the
                            code required to invocate the session and message
                            facade EJB layers.


 ©NIIT                       Collaborate                 Lesson 3C / Slide 15 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    EJB Layer Architectural Design Patterns
          • The EJB Layer Architectural design patterns are used to select a
               correct EJB architecture in order to improve the performance,
               portability, and maintainability of applications.
          • The EJB Layer Architectural design patterns include various
               architectural design patterns:
                • Message Facade
                • EJB Command
                • Data Transfer Object Factory
          • Message Facade Pattern
                • The Message Facade design pattern is used when an enterprise
                      Java bean client needs to call different methods available in
                      multiple EJBs within the context of a single use case.




 ©NIIT                       Collaborate                 Lesson 3C / Slide 16 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    EJB Layer Architectural Design Patterns (Contd.)
          • Message Facade Pattern (Contd.)
                • The advantages of using the Message Facade design pattern
                     are:
                       • Enabling a client to continue performing other tasks
                            without waiting for the server’s response after sending a
                            JMS message.
                       • Enabling a pending transaction to retrieve later from the
                            queue, this is rolled back due to non-functioning of the
                            EJB server.
                • You can use the message facade design pattern when a client
                     wants to update the data available on the server but has no
                     time constraints for checking the updated results.




 ©NIIT                        Collaborate                  Lesson 3C / Slide 17 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    EJB Layer Architectural Design Patterns (Contd.)
          • EJB Command Pattern
                • The EJB Command design pattern is used when a client needs
                     to execute business logic to complete a use case.
                • The business logic of a use case determines the logic that needs
                     to be operated across multiple session beans and entity beans.
                • The advantages of using the EJB Command design pattern are:
                      • Writing a use case as a command bean enables you to
                            easily deploy and test the application.
                      • Executing the command beans in an EJB server requires
                            only a single network call to complete even a complex
                            use case.
                • You can use the EJB Command design pattern to decouple the
                     client from EJB in lightweight command beans that act as a
                     facade for the EJB layer.


 ©NIIT                       Collaborate                 Lesson 3C / Slide 18 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    EJB Layer Architectural Design Patterns (Contd.)
          • Data Transfer Object Factory Pattern
                • The Data Transfer Object (DTO) Factory design pattern is used
                     to separate the logic associated with the DTO from other
                     components, such as entity beans.
                • The DTOs have a tendency to change frequently in an
                     application.
                • The DTOs are of two types, domain DTO and custom DTO.
                • Domain DTO changes when a domain attribute is modified, such
                     as adding a new attribute to an entity bean.
                • Custom DTO transports data across a network.




 ©NIIT                      Collaborate               Lesson 3C / Slide 19 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    EJB Layer Architectural Design Patterns (Contd.)
          • Data Transfer Object Factory Pattern (Contd.)
                • The advantages of using the data transfer object factory design
                     pattern are:
                      • Improving the maintainability of system by separating
                            the use case from the entity beans.
                      • Enabling different projects to reuse the entity beans
                            because different DTO factories can suit the requirements
                            of different applications.
                • You can use the Data Transfer Object Factory design pattern to
                     read and update the data present on the server.
                • You can implement Data Transfer Object Factory design pattern
                     as a stateless session bean in a servlet or as a Java class in a
                     session bean.



 ©NIIT                        Collaborate                 Lesson 3C / Slide 20 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Inter-Tier Data Transfer Design Patterns
          • The Inter-Tier Data Transfer design pattern is used to transfer data
               from the server to the client and vice-versa.
          • The Inter-Tier Data Transfer design pattern includes various design
               patterns:
                 • Data Transfer Object
                 • Domain Data Transfer Object
                 • Custom Data Transfer Object
          • Data Transfer Object Pattern
                 • A data transfer object represents a serializable Java class,
                      which contains data contained in a bundle placed on the server.
                 • You can use the Data Transfer Object design pattern for
                      performing read and update operations in distributed enterprise
                      applications.


 ©NIIT                        Collaborate                 Lesson 3C / Slide 21 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Inter-Tier Data Transfer Design Patterns (Contd.)
          • Data Transfer Object Pattern (Contd.)
                 • The advantages of using the Data Transfer Object design
                      pattern are:
                        • Transporting data between different tiers in a J2EE
                            system.
                        • Performing read operations from server to client in a
                            single network call.
          • Domain Data Transfer Object Pattern
                 • The Domain Data Transfer Object design pattern provides data
                      transfer objects to clients.
                 • This pattern provides local access to duplicate copies of server-
                      side domain objects.




 ©NIIT                       Collaborate                  Lesson 3C / Slide 22 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Inter-Tier Data Transfer Design Patterns (Contd.)
          • Domain Data Transfer Object Pattern (Contd.)
                 • The advantages of using the Domain Data Transfer Object
                      design pattern are:
                        • Duplicating and sending copies of entity beans from
                            server to a client using a single network call.
                        • Performing syntactic validation of entity bean attributes
                            at client-side by incorporating a valid logic in domain DTO
                            set methods.
                 • You can use the Domain Data Transfer Object design pattern
                      when you want to retrieve and manipulate data from the
                      server-side domain object model, such as an entity bean.
                 • This pattern is also used to marshal the copies of domain model
                      instead of domain objects.



 ©NIIT                        Collaborate                  Lesson 3C / Slide 23 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Inter-Tier Data Transfer Design Patterns (Contd.)
          • Custom Data Transfer Objects Pattern
                 • The Custom Data Transfer Objects design pattern implements a
                      use-case-driven approach, in which the DTOs are designed
                      according to the client requirements.
                 • The custom DTOs are immutable in contrast to domain DTOs.
                 • The custom DTOs are used to perform read-only operations.




 ©NIIT                      Collaborate               Lesson 3C / Slide 24 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Transaction and Persistence Design Patterns (Contd.)
          • The Transaction and Persistence design pattern is associated with
               transaction control, persistence, and performance of a system.
          • The Transaction and Persistence design pattern includes various
               design patterns:
                 • JDBC for Reading
                 • Data Access Command Beans
                 • Dual Persistent Entity Bean
          • JDBC for Reading Pattern
                 • The JDBC for Reading design pattern represents a static server-
                     side data to a client in a tabular user interface.
                 • You can use the JDBC for Reading design pattern to represent a
                     relational database for an EJB application.




 ©NIIT                       Collaborate                Lesson 3C / Slide 25 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Transaction and Persistence Design Patterns (Contd.)
          • JDBC for Reading Pattern (Contd.)
                • The advantages of using the JDBC for Reading design pattern
                     are:
                      • Retrieving the data from any number of tables required
                           by use-case queries.
                      • Extracting the data required by the client in a single bulk
                           database call.
                • Data Access Command Beans Pattern
                      • The Data Access Command Beans design pattern creates
                           a data access command bean for an enterprise
                           application.
                      • A data access command bean is used to apply the
                           required information and invoke the required methods for
                           executing the bean.


 ©NIIT                       Collaborate                 Lesson 3C / Slide 26 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Transaction and Persistence Design Patterns (Contd.)
          • Data Access Command Beans Pattern (Contd.)
                • It also enables you to call the corresponding getter methods to
                     retrieve the data from the bean.
                • The advantages of using the Data Access Command Beans
                     design pattern are:
                      • Extracting the content of persistence logic layer to data
                            access command beans layer to reduce the efforts
                            required in making modifications.
                      • Providing a clean and robust persistence mechanism for
                            EJB, servlets, and JSP.
                • You can use the Data Access Command Beans design pattern to
                     retrieve a persistent data store, such as RDBMS for an
                     enterprise bean application.



 ©NIIT                      Collaborate                 Lesson 3C / Slide 27 of 36
Collaborate


EJB Design Patterns (Contd.)
    •    Transaction and Persistence Design Patterns (Contd.)
          • Dual Persistent Entity Bean Pattern
                • The Dual Persistent Entity Bean design pattern is made to
                     support both Container Managed Persistent (CMP) entity bean
                     and Bean Managed Persistent (BMP) entity bean.
                • A dual persistent entity bean divides the entity bean logic into
                     classes, CMP-compliant superclass and a subclass that extends
                     ejbLoad() and ejbStore() methods.
                • The advantages of using the Dual Persistent Entity Bean design
                     pattern are:
                       • Creating portable enterprise bean applications.
                       • Migrating BMP entity beans to CMP entity beans.
                • You can use the Dual Persistent Entity Bean design pattern to
                     include entity bean components that support both Container
                     Managed Persistent (CMP) entity bean and Bean Managed
                     Persistent (BMP) entity bean.
 ©NIIT                       Collaborate                 Lesson 3C / Slide 28 of 36
Collaborate


From the Expert’s Desk

    In this section, you will learn:


         •    Best Practice on:
              • Using Design Patterns to Improve Performance
         •    Tips and Tricks on:
              • Setting the Optimum Age for Stateful Session Bean
              • Using BMP and DAO
         •    FAQs on Design Patterns




 ©NIIT                           Collaborate           Lesson 3C / Slide 29 of 36
Collaborate


Best Practices
Using Design Patterns to Improve Performance
    •    The functions of different design patterns in improving the performance of a
         system are:
         • Value list handler: Improves the performance by providing the search
              facility, caching the results, and providing a filterable result set.
         • Session facade: Improves the performance by reducing the network
              overhead and grouping the related updates into transactions.
         • Service locator: Caches the references, such as EJB references, data
              sources, and Java Message Service (JMS) to hold the results obtained
              by Java Naming and Directory Interface (JNDI) lookups.
         • Data transfer objects: Improves the performance by reducing the
              network traffic that creates a network boundary between two entity
              beans.



 ©NIIT                        Collaborate                  Lesson 3C / Slide 30 of 36
Collaborate


Tips and Tricks
Setting the Optimum Age for Stateful Session Bean
    •    You can set the optimum age for a stateful session bean by using the
         remove() method in a bean client class.
    •    The remove() method is used to explicitly remove the bean instance from
         the container when the class does not require the use of bean.
    •    A container either passivates the bean or stores the bean in the instance
         cache, when a client cannot use the remove() method.
    •    This bean instance binds up the resources with server and consumes
         significant amount of memory.
    •    You need to set the bean age explicitly, as a turnaround.
    •    Setting the bean age explicitly enables a container to remove the bean, when
         age of a bean expires even if the client does not call the remove() method.
    •    You can configure the required bean timeouts by specifying the server-
         specific timeout properties using application servers.


 ©NIIT                        Collaborate                 Lesson 3C / Slide 31 of 36
Collaborate


Tips and Tricks
Using BMP and DAO
    •    The various uses of Bean Managed Persistence (BMP) entity beans or Data
         Access Objects (DAO) are:
         • Working with legacy databases or persistence storage, such as
              Relational Database Management System (RDBMS).
         • Executing complicated queries, such as bulk updates, and complex
              joins.
         • Executing the already existing complex applications.
    •    The various situations, in which you cannot use BMP and DAO, are:
         • Implementing batch loading or servicing queries that return large result
              sets. However, you can use DAO by encapsulating JDBC.
         • Invoking the get and set methods of entity beans from clients.


 ©NIIT                        Collaborate                Lesson 3C / Slide 32 of 36
Collaborate


FAQs
    •    Which patterns are used by SUN in designing the Enterprise JavaBeans
         model?
         The various design patterns used by SUN in designing the Enterprise
         JavaBeans model are:
         • Factory method: Defines an interface for creating classes in the EJB
              creation model.
         • Singleton: Provides a global access to a class by creating a single
              instance of the class.
         • Abstract factory: Creates objects using interfaces without specifying the
              classes.
         • Builder: Creates different representations by separating the composition
              of a complex factory from its representation.
         • Adapter: Converts an interface of a class into another interface.
         • Proxy: Provides replacement of other objects to control their access in
              an application.
         • Memento: Acquires an internal state of an object.
 ©NIIT                        Collaborate                 Lesson 3C / Slide 33 of 36
Collaborate


FAQs (Contd.)
    •    What is session facade?
         Session facade is a J2EE design pattern used in developing session enterprise
         bean applications. The session facade design pattern provides a remote
         reference layer, which exposes the required interfaces to be used by clients.


    •    What are collaboration patterns?
         Collaboration patterns are the techniques used to collaborate teamwork
         among users. These patterns can be used to gather requirement inputs for a
         team.




 ©NIIT                        Collaborate                  Lesson 3C / Slide 34 of 36
Collaborate


Challenge
    1.   _____is responsible for assembling the enterprise bean components into a
         J2EE application.
    2.   A _______ is a single unit of work that consists of a sequence of operations.
    3.   A stateless session bean exist in two states exists state and ready state.
         (True/False)
    4.   The ______ exception is thrown, when a client is not associated with a
         transaction, which is associated with the mandatory transaction attribute.
    5.   The Never transaction attribute specifies that it is not mandatory for a bean
         method to be part of a transaction. (True/False)




 ©NIIT                         Collaborate                  Lesson 3C / Slide 35 of 36
Collaborate


Solutions to Challenge

    •    Application Assembler
    •    Transaction
    •    False
    •    TransactionRequiredException
    •    False




 ©NIIT                     Collaborate   Lesson 3C / Slide 36 of 36

Weitere ähnliche Inhalte

Was ist angesagt?

Vb net xp_10
Vb net xp_10Vb net xp_10
Vb net xp_10Niit Care
 
4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture PortfolioMajong DevJfu
 
2 - Architetture Software - Software architecture
2 - Architetture Software - Software architecture2 - Architetture Software - Software architecture
2 - Architetture Software - Software architectureMajong DevJfu
 
8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processes8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processesMajong DevJfu
 
Eight deadly defects in systems engineering and how to fix them
Eight deadly defects in systems engineering and how to fix themEight deadly defects in systems engineering and how to fix them
Eight deadly defects in systems engineering and how to fix themJoseph KAsser
 
Context-Oriented Programming
Context-Oriented ProgrammingContext-Oriented Programming
Context-Oriented Programmingkim.mens
 
Software Architecture: Design Decisions
Software Architecture: Design DecisionsSoftware Architecture: Design Decisions
Software Architecture: Design DecisionsHenry Muccini
 
3 f6 9_distributed_systems
3 f6 9_distributed_systems3 f6 9_distributed_systems
3 f6 9_distributed_systemsop205
 
3 f6 8_databases
3 f6 8_databases3 f6 8_databases
3 f6 8_databasesop205
 
3 f6 11_softdevmethodologies
3 f6 11_softdevmethodologies3 f6 11_softdevmethodologies
3 f6 11_softdevmethodologiesop205
 
Object and method exploration for embedded systems
Object and method exploration for embedded systemsObject and method exploration for embedded systems
Object and method exploration for embedded systemsMr. Chanuwan
 
Software Patterns
Software PatternsSoftware Patterns
Software Patternskim.mens
 
Sa 004 quality_attributes
Sa 004 quality_attributesSa 004 quality_attributes
Sa 004 quality_attributesFrank Gielen
 
[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with GitIvano Malavolta
 
Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuseMarco Brambilla
 

Was ist angesagt? (20)

Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Vb net xp_10
Vb net xp_10Vb net xp_10
Vb net xp_10
 
4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio4 - Architetture Software - Architecture Portfolio
4 - Architetture Software - Architecture Portfolio
 
2 - Architetture Software - Software architecture
2 - Architetture Software - Software architecture2 - Architetture Software - Software architecture
2 - Architetture Software - Software architecture
 
05 architectural design
05 architectural design05 architectural design
05 architectural design
 
8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processes8 - Architetture Software - Architecture centric processes
8 - Architetture Software - Architecture centric processes
 
08 component level_design
08 component level_design08 component level_design
08 component level_design
 
Eight deadly defects in systems engineering and how to fix them
Eight deadly defects in systems engineering and how to fix themEight deadly defects in systems engineering and how to fix them
Eight deadly defects in systems engineering and how to fix them
 
Mcq m4
Mcq m4Mcq m4
Mcq m4
 
Context-Oriented Programming
Context-Oriented ProgrammingContext-Oriented Programming
Context-Oriented Programming
 
Software Architecture: Design Decisions
Software Architecture: Design DecisionsSoftware Architecture: Design Decisions
Software Architecture: Design Decisions
 
3 f6 9_distributed_systems
3 f6 9_distributed_systems3 f6 9_distributed_systems
3 f6 9_distributed_systems
 
3 f6 8_databases
3 f6 8_databases3 f6 8_databases
3 f6 8_databases
 
3 f6 11_softdevmethodologies
3 f6 11_softdevmethodologies3 f6 11_softdevmethodologies
3 f6 11_softdevmethodologies
 
Object and method exploration for embedded systems
Object and method exploration for embedded systemsObject and method exploration for embedded systems
Object and method exploration for embedded systems
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Sa 004 quality_attributes
Sa 004 quality_attributesSa 004 quality_attributes
Sa 004 quality_attributes
 
[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git
 
Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuse
 

Ähnlich wie EJB Architecture and Design Patterns Explained

Ejb training institute in navi-mumbai
Ejb training institute in navi-mumbaiEjb training institute in navi-mumbai
Ejb training institute in navi-mumbaivibrantuser
 
Vb.net session 03
Vb.net session 03Vb.net session 03
Vb.net session 03Niit Care
 
Transforming to Microservices
Transforming to MicroservicesTransforming to Microservices
Transforming to MicroservicesKyle Brown
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionKelum Senanayake
 
J2 ee container & components
J2 ee container & componentsJ2 ee container & components
J2 ee container & componentsKeshab Nath
 
Mcv design patterns
Mcv design patternsMcv design patterns
Mcv design patternsRob Paok
 
Mulesoft torronto meetup_16
Mulesoft torronto meetup_16Mulesoft torronto meetup_16
Mulesoft torronto meetup_16Anurag Dwivedi
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Phil Leggetter
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01Niit Care
 
Building Enterprise Application with J2EE
Building Enterprise Application with J2EEBuilding Enterprise Application with J2EE
Building Enterprise Application with J2EECalance
 
Ejb course in-mumbai
Ejb course in-mumbaiEjb course in-mumbai
Ejb course in-mumbaivibrantuser
 

Ähnlich wie EJB Architecture and Design Patterns Explained (20)

Unite5-EJB-2019.ppt
Unite5-EJB-2019.pptUnite5-EJB-2019.ppt
Unite5-EJB-2019.ppt
 
UNIT 4.pptx
UNIT 4.pptxUNIT 4.pptx
UNIT 4.pptx
 
Ejb training institute in navi-mumbai
Ejb training institute in navi-mumbaiEjb training institute in navi-mumbai
Ejb training institute in navi-mumbai
 
Vb.net session 03
Vb.net session 03Vb.net session 03
Vb.net session 03
 
Transforming to Microservices
Transforming to MicroservicesTransforming to Microservices
Transforming to Microservices
 
EJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another IntroductionEJB 3.0 - Yet Another Introduction
EJB 3.0 - Yet Another Introduction
 
Ejb
EjbEjb
Ejb
 
Java Spring
Java SpringJava Spring
Java Spring
 
J2 ee container & components
J2 ee container & componentsJ2 ee container & components
J2 ee container & components
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Mcv design patterns
Mcv design patternsMcv design patterns
Mcv design patterns
 
0764543857.excerpt.pdf
0764543857.excerpt.pdf0764543857.excerpt.pdf
0764543857.excerpt.pdf
 
Mulesoft torronto meetup_16
Mulesoft torronto meetup_16Mulesoft torronto meetup_16
Mulesoft torronto meetup_16
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
 
Ch4 ejb
Ch4 ejbCh4 ejb
Ch4 ejb
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01
 
Building Enterprise Application with J2EE
Building Enterprise Application with J2EEBuilding Enterprise Application with J2EE
Building Enterprise Application with J2EE
 
Ejb course in-mumbai
Ejb course in-mumbaiEjb course in-mumbai
Ejb course in-mumbai
 
Component based software engineering
Component based software engineeringComponent based software engineering
Component based software engineering
 

Mehr von Niit Care

Mehr von Niit Care (19)

Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 
Dacj 1-3 b
Dacj 1-3 bDacj 1-3 b
Dacj 1-3 b
 
Dacj 1-3 a
Dacj 1-3 aDacj 1-3 a
Dacj 1-3 a
 
Dacj 1-2 c
Dacj 1-2 cDacj 1-2 c
Dacj 1-2 c
 
Dacj 1-2 a
Dacj 1-2 aDacj 1-2 a
Dacj 1-2 a
 
Dacj 1-1 c
Dacj 1-1 cDacj 1-1 c
Dacj 1-1 c
 
Dacj 1-1 b
Dacj 1-1 bDacj 1-1 b
Dacj 1-1 b
 
Dacj 1-1 a
Dacj 1-1 aDacj 1-1 a
Dacj 1-1 a
 
Dacj 2-2 b
Dacj 2-2 bDacj 2-2 b
Dacj 2-2 b
 
Dacj 2-2 a
Dacj 2-2 aDacj 2-2 a
Dacj 2-2 a
 
Dacj 2-1 c
Dacj 2-1 cDacj 2-1 c
Dacj 2-1 c
 
Dacj 2-1 b
Dacj 2-1 bDacj 2-1 b
Dacj 2-1 b
 

Kürzlich hochgeladen

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

EJB Architecture and Design Patterns Explained

  • 1. Collaborate Knowledge Byte In this section, you will learn about: • EJB in J2EE Architecture • EJB Design Patterns ©NIIT Collaborate Lesson 3C / Slide 1 of 36
  • 2. Collaborate EJB in J2EE Architecture • Enterprise JavaBeans are the server side components that are based on Java technology. • EJB enables you to inherit all the features that an enterprise component requires. • For example, you do not need to write a code to establish a database connection. • You can concentrate on writing business logic of an enterprise bean development and leaving all the middleware service requirements for application server to handle. • You can concentrate on the programming logic of an application using EJB. • Moreover, you can buy EJB components instead of building own components. ©NIIT Collaborate Lesson 3C / Slide 2 of 36
  • 3. Collaborate EJB in J2EE Architecture (Contd.) • The various characteristics of using EJB in J2EE architecture are: • Supporting multiple clients • Improving the reliability and productivity of an application • Supporting large scale deployment of applications • Developing transactional applications • Supporting reusability • Implementing security ©NIIT Collaborate Lesson 3C / Slide 3 of 36
  • 4. Collaborate EJB in J2EE Architecture (Contd.) • Supporting Multiple Clients • An enterprise bean can service only one client request at an instance of time, as enterprise beans are single threaded. • The container creates a pool of bean instances, and selects a bean instance from the pool to service the request whenever a client sends the request. • After servicing a client request, the bean instance is returned to the pool and container can assign this instance to another client request. • In this manner, the container uses a small number of bean instances to service a large number of client requests. • The container increases the pool size when the load on the server increases, and reduces the pool size when the load on the server is reduces. ©NIIT Collaborate Lesson 3C / Slide 4 of 36
  • 5. Collaborate EJB in J2EE Architecture (Contd.) • Supporting Multiple Clients (Contd.) • The following figure shows how a container uses pool of beans to service client requests: ©NIIT Collaborate Lesson 3C / Slide 5 of 36
  • 6. Collaborate EJB in J2EE Architecture (Contd.) • Improving the Reliability and Productivity of an Application • EJB improves the productivity and reliability of an enterprise application by distributing the whole tasks into various subtasks. • Creating an enterprise bean component, assembling the components in an application, and deploying the application in an application server into different parties are the examples of subtasks. • EJB considers that each party is an expert in its task. Some of the parties involved are: • Bean Developer: Is required to concentrate on the business logic of the bean. • Application Assembler: Is responsible for assembling the enterprise beans into an application. • Bean Deployer: Is an expert of an application server environment. ©NIIT Collaborate Lesson 3C / Slide 6 of 36
  • 7. Collaborate EJB in J2EE Architecture (Contd.) • Supporting Large Scale Deployment of Applications • You can use the functionality of an existing system using the legacy integration. • For example, a client on a Web server invokes a session bean on an application server. • The session bean further invokes an entity bean that uses a database server for storing data. • This type of application requires a highly secure fault-tolerant environment. • It also has to maintain a very high level of performance and availability. ©NIIT Collaborate Lesson 3C / Slide 7 of 36
  • 8. Collaborate EJB in J2EE Architecture (Contd.) • Supporting Large Scale Deployment of Applications (Contd.): • To meet all the requirements of enterprise applications EJB provides support for: • Instance Pooling: Uses a pool of bean instances to service client requests. • Connection Pooling: Uses a pool of connections that are required by components. • Transactions: Contains a sequence of operations executed under a single process. • Location Transparency: Does not require a client to be aware of the actual location of the object. ©NIIT Collaborate Lesson 3C / Slide 8 of 36
  • 9. Collaborate EJB in J2EE Architecture (Contd.) • Developing Transactional Applications • A transaction is defined as a sequence of operations. • The transaction succeeds if all the operations in the transaction succeed and it fails if any of the operation in a transaction fails. • In EJB, a transactional application can be developed by two approaches: • Declarative: Enables you to declare the required transactional attributes, such as Required, Supports, Mandatory, and Never in the deployment descriptor file. • Programmatic: Enables you to explicitly code the transactional behavior of the bean in the bean class. ©NIIT Collaborate Lesson 3C / Slide 9 of 36
  • 10. Collaborate EJB in J2EE Architecture (Contd.) • Supporting Reusability • EJB components are not reusable by default. • However, you can make a bean reusable using following approaches: • Customization: Enables you to modify the properties of a bean according to application requirements. • Extension: Enables you to write an application specific code by extending the bean class. ©NIIT Collaborate Lesson 3C / Slide 10 of 36
  • 11. Collaborate EJB in J2EE Architecture (Contd.) • Implementing Security • An enterprise application is susceptible to unauthorized access and attacks. • Therefore, you need to protect an enterprise application from these threats. • The EJB container provides a secure environment for enterprise beans. • Securing an application involves two steps: • Authentication: Verifies the identity of a user. • Authorization: Provides restricted access to authenticated users. ©NIIT Collaborate Lesson 3C / Slide 11 of 36
  • 12. Collaborate EJB Design Patterns • The EJB design patterns can de defined as best practices for designing an EJB application. • It provides a reusable approach for you to design and develop an application. • The EJB design patterns enable you to design secure, reliable, and scalable applications. • The various EJB design patterns are: • Client-Side EJB Interaction Design Patterns • EJB Layer Architectural Design Patterns • Inter-Tier Data Transfer Design Patterns • Transaction and Persistence Design Patterns ©NIIT Collaborate Lesson 3C / Slide 12 of 36
  • 13. Collaborate EJB Design Patterns (Contd.) • Client-Side EJB Interaction Design Patterns • The Client-Side EJB Interaction design patterns are used to improve the performance and maintainability of client-side applications. • The various client-side EJB interaction design patterns are: • EJB Home Factory • Business Delegate • EJB Home Factory Pattern • The EJB Home Factory design pattern is used to locate the EJBHome object in order to access the remote interface of EJB. • Locating the EJBHome object for each Web request reduces the application performance. • The better approach is to abstract the EJBHome lookup code into a reusable EJBHomeFactory that can cache EJBHome objects for the lifetime of a client application. ©NIIT Collaborate Lesson 3C / Slide 13 of 36
  • 14. Collaborate EJB Design Patterns (Contd.) • Client-Side EJB Interaction Design Patterns (Contd.) • EJB Home Factory Pattern (Contd.) • You can implement the EJB home factory pattern in any environment, such as applets, servlets, and EJBs. • The advantages of using the EJB Home Factory design pattern are: • Providing an efficient technique for abstracting the EJB home complexity from the client in a reusable format. • Improving the performance by reducing the cost involved in locating the redundant home lookups. ©NIIT Collaborate Lesson 3C / Slide 14 of 36
  • 15. Collaborate EJB Design Patterns (Contd.) • Client-Side EJB Interaction Design Patterns (Contd.) • Business Delegate Pattern • The Business Delegate design pattern is used to map session beans present in the session facade pattern and wrap it with multiple message-driven beans. • Business Delegate is a Java class that acts as an intermediary between client and server. • The advantages of using the Business Delegate design pattern are: • Maintaining integration between non-Java applications and EJB by wrapping the business delegate Java objects with non-Java code using Java Naming Interface (JNI). • Hiding the complexity of EJB API by encapsulating the code required to invocate the session and message facade EJB layers. ©NIIT Collaborate Lesson 3C / Slide 15 of 36
  • 16. Collaborate EJB Design Patterns (Contd.) • EJB Layer Architectural Design Patterns • The EJB Layer Architectural design patterns are used to select a correct EJB architecture in order to improve the performance, portability, and maintainability of applications. • The EJB Layer Architectural design patterns include various architectural design patterns: • Message Facade • EJB Command • Data Transfer Object Factory • Message Facade Pattern • The Message Facade design pattern is used when an enterprise Java bean client needs to call different methods available in multiple EJBs within the context of a single use case. ©NIIT Collaborate Lesson 3C / Slide 16 of 36
  • 17. Collaborate EJB Design Patterns (Contd.) • EJB Layer Architectural Design Patterns (Contd.) • Message Facade Pattern (Contd.) • The advantages of using the Message Facade design pattern are: • Enabling a client to continue performing other tasks without waiting for the server’s response after sending a JMS message. • Enabling a pending transaction to retrieve later from the queue, this is rolled back due to non-functioning of the EJB server. • You can use the message facade design pattern when a client wants to update the data available on the server but has no time constraints for checking the updated results. ©NIIT Collaborate Lesson 3C / Slide 17 of 36
  • 18. Collaborate EJB Design Patterns (Contd.) • EJB Layer Architectural Design Patterns (Contd.) • EJB Command Pattern • The EJB Command design pattern is used when a client needs to execute business logic to complete a use case. • The business logic of a use case determines the logic that needs to be operated across multiple session beans and entity beans. • The advantages of using the EJB Command design pattern are: • Writing a use case as a command bean enables you to easily deploy and test the application. • Executing the command beans in an EJB server requires only a single network call to complete even a complex use case. • You can use the EJB Command design pattern to decouple the client from EJB in lightweight command beans that act as a facade for the EJB layer. ©NIIT Collaborate Lesson 3C / Slide 18 of 36
  • 19. Collaborate EJB Design Patterns (Contd.) • EJB Layer Architectural Design Patterns (Contd.) • Data Transfer Object Factory Pattern • The Data Transfer Object (DTO) Factory design pattern is used to separate the logic associated with the DTO from other components, such as entity beans. • The DTOs have a tendency to change frequently in an application. • The DTOs are of two types, domain DTO and custom DTO. • Domain DTO changes when a domain attribute is modified, such as adding a new attribute to an entity bean. • Custom DTO transports data across a network. ©NIIT Collaborate Lesson 3C / Slide 19 of 36
  • 20. Collaborate EJB Design Patterns (Contd.) • EJB Layer Architectural Design Patterns (Contd.) • Data Transfer Object Factory Pattern (Contd.) • The advantages of using the data transfer object factory design pattern are: • Improving the maintainability of system by separating the use case from the entity beans. • Enabling different projects to reuse the entity beans because different DTO factories can suit the requirements of different applications. • You can use the Data Transfer Object Factory design pattern to read and update the data present on the server. • You can implement Data Transfer Object Factory design pattern as a stateless session bean in a servlet or as a Java class in a session bean. ©NIIT Collaborate Lesson 3C / Slide 20 of 36
  • 21. Collaborate EJB Design Patterns (Contd.) • Inter-Tier Data Transfer Design Patterns • The Inter-Tier Data Transfer design pattern is used to transfer data from the server to the client and vice-versa. • The Inter-Tier Data Transfer design pattern includes various design patterns: • Data Transfer Object • Domain Data Transfer Object • Custom Data Transfer Object • Data Transfer Object Pattern • A data transfer object represents a serializable Java class, which contains data contained in a bundle placed on the server. • You can use the Data Transfer Object design pattern for performing read and update operations in distributed enterprise applications. ©NIIT Collaborate Lesson 3C / Slide 21 of 36
  • 22. Collaborate EJB Design Patterns (Contd.) • Inter-Tier Data Transfer Design Patterns (Contd.) • Data Transfer Object Pattern (Contd.) • The advantages of using the Data Transfer Object design pattern are: • Transporting data between different tiers in a J2EE system. • Performing read operations from server to client in a single network call. • Domain Data Transfer Object Pattern • The Domain Data Transfer Object design pattern provides data transfer objects to clients. • This pattern provides local access to duplicate copies of server- side domain objects. ©NIIT Collaborate Lesson 3C / Slide 22 of 36
  • 23. Collaborate EJB Design Patterns (Contd.) • Inter-Tier Data Transfer Design Patterns (Contd.) • Domain Data Transfer Object Pattern (Contd.) • The advantages of using the Domain Data Transfer Object design pattern are: • Duplicating and sending copies of entity beans from server to a client using a single network call. • Performing syntactic validation of entity bean attributes at client-side by incorporating a valid logic in domain DTO set methods. • You can use the Domain Data Transfer Object design pattern when you want to retrieve and manipulate data from the server-side domain object model, such as an entity bean. • This pattern is also used to marshal the copies of domain model instead of domain objects. ©NIIT Collaborate Lesson 3C / Slide 23 of 36
  • 24. Collaborate EJB Design Patterns (Contd.) • Inter-Tier Data Transfer Design Patterns (Contd.) • Custom Data Transfer Objects Pattern • The Custom Data Transfer Objects design pattern implements a use-case-driven approach, in which the DTOs are designed according to the client requirements. • The custom DTOs are immutable in contrast to domain DTOs. • The custom DTOs are used to perform read-only operations. ©NIIT Collaborate Lesson 3C / Slide 24 of 36
  • 25. Collaborate EJB Design Patterns (Contd.) • Transaction and Persistence Design Patterns (Contd.) • The Transaction and Persistence design pattern is associated with transaction control, persistence, and performance of a system. • The Transaction and Persistence design pattern includes various design patterns: • JDBC for Reading • Data Access Command Beans • Dual Persistent Entity Bean • JDBC for Reading Pattern • The JDBC for Reading design pattern represents a static server- side data to a client in a tabular user interface. • You can use the JDBC for Reading design pattern to represent a relational database for an EJB application. ©NIIT Collaborate Lesson 3C / Slide 25 of 36
  • 26. Collaborate EJB Design Patterns (Contd.) • Transaction and Persistence Design Patterns (Contd.) • JDBC for Reading Pattern (Contd.) • The advantages of using the JDBC for Reading design pattern are: • Retrieving the data from any number of tables required by use-case queries. • Extracting the data required by the client in a single bulk database call. • Data Access Command Beans Pattern • The Data Access Command Beans design pattern creates a data access command bean for an enterprise application. • A data access command bean is used to apply the required information and invoke the required methods for executing the bean. ©NIIT Collaborate Lesson 3C / Slide 26 of 36
  • 27. Collaborate EJB Design Patterns (Contd.) • Transaction and Persistence Design Patterns (Contd.) • Data Access Command Beans Pattern (Contd.) • It also enables you to call the corresponding getter methods to retrieve the data from the bean. • The advantages of using the Data Access Command Beans design pattern are: • Extracting the content of persistence logic layer to data access command beans layer to reduce the efforts required in making modifications. • Providing a clean and robust persistence mechanism for EJB, servlets, and JSP. • You can use the Data Access Command Beans design pattern to retrieve a persistent data store, such as RDBMS for an enterprise bean application. ©NIIT Collaborate Lesson 3C / Slide 27 of 36
  • 28. Collaborate EJB Design Patterns (Contd.) • Transaction and Persistence Design Patterns (Contd.) • Dual Persistent Entity Bean Pattern • The Dual Persistent Entity Bean design pattern is made to support both Container Managed Persistent (CMP) entity bean and Bean Managed Persistent (BMP) entity bean. • A dual persistent entity bean divides the entity bean logic into classes, CMP-compliant superclass and a subclass that extends ejbLoad() and ejbStore() methods. • The advantages of using the Dual Persistent Entity Bean design pattern are: • Creating portable enterprise bean applications. • Migrating BMP entity beans to CMP entity beans. • You can use the Dual Persistent Entity Bean design pattern to include entity bean components that support both Container Managed Persistent (CMP) entity bean and Bean Managed Persistent (BMP) entity bean. ©NIIT Collaborate Lesson 3C / Slide 28 of 36
  • 29. Collaborate From the Expert’s Desk In this section, you will learn: • Best Practice on: • Using Design Patterns to Improve Performance • Tips and Tricks on: • Setting the Optimum Age for Stateful Session Bean • Using BMP and DAO • FAQs on Design Patterns ©NIIT Collaborate Lesson 3C / Slide 29 of 36
  • 30. Collaborate Best Practices Using Design Patterns to Improve Performance • The functions of different design patterns in improving the performance of a system are: • Value list handler: Improves the performance by providing the search facility, caching the results, and providing a filterable result set. • Session facade: Improves the performance by reducing the network overhead and grouping the related updates into transactions. • Service locator: Caches the references, such as EJB references, data sources, and Java Message Service (JMS) to hold the results obtained by Java Naming and Directory Interface (JNDI) lookups. • Data transfer objects: Improves the performance by reducing the network traffic that creates a network boundary between two entity beans. ©NIIT Collaborate Lesson 3C / Slide 30 of 36
  • 31. Collaborate Tips and Tricks Setting the Optimum Age for Stateful Session Bean • You can set the optimum age for a stateful session bean by using the remove() method in a bean client class. • The remove() method is used to explicitly remove the bean instance from the container when the class does not require the use of bean. • A container either passivates the bean or stores the bean in the instance cache, when a client cannot use the remove() method. • This bean instance binds up the resources with server and consumes significant amount of memory. • You need to set the bean age explicitly, as a turnaround. • Setting the bean age explicitly enables a container to remove the bean, when age of a bean expires even if the client does not call the remove() method. • You can configure the required bean timeouts by specifying the server- specific timeout properties using application servers. ©NIIT Collaborate Lesson 3C / Slide 31 of 36
  • 32. Collaborate Tips and Tricks Using BMP and DAO • The various uses of Bean Managed Persistence (BMP) entity beans or Data Access Objects (DAO) are: • Working with legacy databases or persistence storage, such as Relational Database Management System (RDBMS). • Executing complicated queries, such as bulk updates, and complex joins. • Executing the already existing complex applications. • The various situations, in which you cannot use BMP and DAO, are: • Implementing batch loading or servicing queries that return large result sets. However, you can use DAO by encapsulating JDBC. • Invoking the get and set methods of entity beans from clients. ©NIIT Collaborate Lesson 3C / Slide 32 of 36
  • 33. Collaborate FAQs • Which patterns are used by SUN in designing the Enterprise JavaBeans model? The various design patterns used by SUN in designing the Enterprise JavaBeans model are: • Factory method: Defines an interface for creating classes in the EJB creation model. • Singleton: Provides a global access to a class by creating a single instance of the class. • Abstract factory: Creates objects using interfaces without specifying the classes. • Builder: Creates different representations by separating the composition of a complex factory from its representation. • Adapter: Converts an interface of a class into another interface. • Proxy: Provides replacement of other objects to control their access in an application. • Memento: Acquires an internal state of an object. ©NIIT Collaborate Lesson 3C / Slide 33 of 36
  • 34. Collaborate FAQs (Contd.) • What is session facade? Session facade is a J2EE design pattern used in developing session enterprise bean applications. The session facade design pattern provides a remote reference layer, which exposes the required interfaces to be used by clients. • What are collaboration patterns? Collaboration patterns are the techniques used to collaborate teamwork among users. These patterns can be used to gather requirement inputs for a team. ©NIIT Collaborate Lesson 3C / Slide 34 of 36
  • 35. Collaborate Challenge 1. _____is responsible for assembling the enterprise bean components into a J2EE application. 2. A _______ is a single unit of work that consists of a sequence of operations. 3. A stateless session bean exist in two states exists state and ready state. (True/False) 4. The ______ exception is thrown, when a client is not associated with a transaction, which is associated with the mandatory transaction attribute. 5. The Never transaction attribute specifies that it is not mandatory for a bean method to be part of a transaction. (True/False) ©NIIT Collaborate Lesson 3C / Slide 35 of 36
  • 36. Collaborate Solutions to Challenge • Application Assembler • Transaction • False • TransactionRequiredException • False ©NIIT Collaborate Lesson 3C / Slide 36 of 36