Presentation is loading. Please wait.

Presentation is loading. Please wait.

An architecture for webb applications, J2EE

Similar presentations


Presentation on theme: "An architecture for webb applications, J2EE"— Presentation transcript:

1 An architecture for webb applications, J2EE
A quick look at Java 2 Enterprise Edition

2 J2EE Overview A framework for Enterprise Applications Scalable
Distributed Transactional Losely coupled Multi-tired Portable Secure Access to different systems

3 J2EE Overview Built on top of Java 2 Standard Edition, J2SE
Access to all of J2SE-APIs 100% Java All Java, nothing but Java, allmost (IIOP) J2SE is part of the puzzle

4 J2EE Overview J2EE is a specifaction, not a produkt
No vendor lock in Several implementations BEA (Weblogic) IBM (Websphere) Oracle (Oracle9iAS and OC4J) JBoss Ironflare (Orion) Jakarta Tomcat Sun provide a reference implementation, but it’s not allowed to use it for production JBoss and Jakarata-Tomcat is Open Source Tomcat is the reference implementation of JSP and Servlets, and the container we will use Oracle9iAS contains a J2EE Container called OC4J (Oracle Container for Java) that is based on Orion

5 J2EE Overview – Content of J2EE
Enterprise Java Beans, EJB Java Servlets Java Server Pages, JSP Java Messaging Service, JMS Java Database Connectivity, JDBC JavaMail Java Transaction API, JTA Connector Architecture

6 J2EE Overview – Content of J2EE
RMI/IIOP Java Naming and Directory Interface, JNDI Webservices, in version 1.4

7 J2EE Overview – Benefits of J2EE
Separates business logic from system code Separates busines logic from presentation Deploy-time configuration Scalable from start Distributed from start Component model on the server = easier team work Declarative security and transactions Basically, leave everything but the business logic to the container. Business logic is all the functions you write that makes your application behave as it does Since the security framework, the threading and all the other parts are well tested you can focus on your problems and trust the functionality of the conatiner

8 Containers and Components
A J2EE Server (except the database)

9 Containers and Components
A J2EE Application server provides containers for all components of J2EE There is one container per J2EE component The Application server runs the entire J2EE solution

10 Containers and Components
The Application server handles all system level programming Security Authorization – Is the user allowed to do this operation? Authentication – Is the user who he says? Validate credentials Transactions Threading Object life time management Caching Object persistence Database Connection pooling Robust and scalable system programming is a very complex task, and quite different from writing good business logic Most system level programming is the same in most situations. Why re-write it all the time, it error-prone and expensive

11 Containers and Components
Several clients – one system A complex (thick) client can call the EJB layer at once A thin client (web browser, cell-phone, PDA) call the web layer. Different layouts are generated for different clients XML is heavily used to generate a general layout that’s transformed with XSLT to the specific layout, for example HTML

12 Enterprise Java Beans The core of J2EE Server side components
Three base types of EJB Session Beans Entity Beans Message Driven Beans Transactional components Bean managed or Container managed Deploy time configuration of security and transactions

13 Enterprise Java Beans - Architecture
Since version 1.3 of J2EE there is also a Local Home interface and Local “Remote” interface for inter-container-calls, that is, calls between components within the same JVM. This is mainly for performance since calls on the Remote interface are expensive network calls The implementation bean (the Enterprise Java Bean Component) is the same for Local and Remote. In other ways, there are two different ways to call the same EJB

14 Enterprise Java Beans – Session Beans
Stateless and statefull beans Handles busines logic Acts as frontend for Entity beans A Stateless Session bean doesn’t maintain a state between invocations. Two different calls are not guarantied to end up in the same instance. Session beans are typically used to handle all of the business logic in the system. When it comes to data access the mostly rely on Entity beans A typical solution is to have a Session bean as front end to the EJB layer. The Session bean performs controll logic in the EJB layer and calls other Session beans and Entity beans as needed

15 Enterprise Java Beans – Entity Beans
Handels data Mapped on Database tables Container managed (CMP) and Bean Managed Persistence (BMP) CMP releaves the developer from writing SQL code Minimizes the risk for database lock-in. EJB-QL – a query language for EJBs In general, there is a one to one mapping between Entity beans and database tables, but it doesn’t have to be like that When an instance of the bean is created, the correspondig row in the database is created. When an instance is deleted, the corresponding row i deleted and when a bean is updated, the update propagate to the database Since the Container generates all SQL code in the CMP case we don’t risk to use vendor specific SQL Since Entity beans are used to handle the data, a way of searching amongst them is needed == EJB-QL EJB-QL is very similar to SQL but work on objects and properties instead of tables and columns

16 Enterprise Java Beans – Message Driven Beans
Activated by a JMS queue Asynchronous execution No need for the client to wait for an answer The MDB is in fact a Message listener in a JMS system, more about that in the next page Scalable solution that is good if the client doesn’t need a response right away

17 Java Messaging Service, JMS
A messaging API for Java A Sender sends a message to a JMS Queue A Listener listens for messages on a Queue Guarantied delivery Asynchronous processing After the Sender has sent its message there is no need to wait for the Listener to get it Great for scalability Good for operations that doesn’t have to occur at once, for example logging

18 JavaMail A high level API for sending and receiving mail
No need to know everything about the underlying protocolls Support for IMAP, POP and SMTP

19 Java Transaction API, JTA
The easy way to handle complex transactions You can have transactions between different components A mailserver, a database and a JMS system can participate in the same transaction, given that they support it Based on XA The mechanism behind the transactions of EJBs

20 Java Connector Architecture, JCA
Hook into existing legacy systems You can write a connector for basically anything Anything with a Connector can be plugged into the J2EE Server Simplifies system integration JDBC Drivers will be Connectors in upcoming releases. JBoss, for example, already treats a JDBC Driver as a Connector

21 RMI/IIOP Integration with other systems through Corba
Call your J2EE Components from Visual Basic, Delphi, C++ and C Java might not be the best or only choice for your clients Corba is a system for distributed objects that has been around a while. Mostly used with C++ Great for interoperability between different types of systems

22 Java Naming and Directory Interface, JNDI
Very fundamental functionality in J2EE The way that distributed objects are located Any kind of objects can be stored in JNDI All objects are stored in a hierarchical way The way the Home interface for EJBs are located JNDI is very fundamental and used all the time. It’s a very simple to use interface JNDI can interact with LDAP

23 Java Naming and Directory Interface, JNDI
Used to store connection pools for JDBC Context.lookup(“java:comp/env/jdbc/Pool1”) Private context from within components Defined with a <resource-ref> in deployment descriptors Context.lookup(“Pool1”) Global context from the outside

24 Web Development The web is static by nature Based on HTTP
A stateless network environment The stateless nature is what have made the Internet into what it is today

25 HTTP A very simple and readable protocol Several methods Text based
GET The basic request to get a page POST Used from forms in the web pages DELETE HEAD

26 HTTP A typical browser request for www.dn.se/index.html
Connect to GET /index.html HTTP/1.0 Disconnect

27 CGI Common Gateway Interface
An early interface for making the web more dynamic Executes programs on the server Cumbersome programming and bad resource management Basically each request starts a new process on the server

28 Java Servlets Extensions of the web server
One of the front ends to the J2EE system Generates HTML with print statements Good for implementing control logic Support for sessions Multithreaded by nature Not so good for generation nice layout

29 Java Server Pages (JSP)
HTML with embedded Java code Good for presentation Compiled to a Servlet at runtime Easy for web designers to use Support for Java Beans and Custom tags

30 Servlets and JSP Servlets and JSPs are often used together
The Servlet handles the request The Servlets calls Java Beans or EJBs to handle the business logic The Servlest forwards to a JSP The JSP handles the Presentation Model View Controller, MVS

31 Other technologies for the web
Microsoft Active Server Pages Embed VB code in your HTML Similar to JSPs PHP Quite like ASP, but open source and available on all platform. Used at many sites today Coldfusion Webobjects (Mac) Zope

32 Next time The next session will be all about Servlet programming


Download ppt "An architecture for webb applications, J2EE"

Similar presentations


Ads by Google