An architecture for webb applications J 2 EE
An architecture for webb applications, J 2 EE A quick look at Java 2 Enterprise Edition
J 2 EE Overview n A framework for Enterprise Applications q q q q Scalable Distributed Transactional Losely coupled Multi-tired Portable Secure Access to different systems
J 2 EE Overview n Built on top of Java 2 Standard Edition, J 2 SE q q Access to all of J 2 SE-APIs 100% Java
J 2 EE Overview n J 2 EE is a specifaction, not a produkt q n No vendor lock in Several implementations q q q BEA (Weblogic) IBM (Websphere) Oracle (Oracle 9 i. AS and OC 4 J) JBoss Ironflare (Orion) Jakarta Tomcat
J 2 EE Overview – Content of J 2 EE n n n n Enterprise Java Beans, EJB Java Servlets Java Server Pages, JSP Java Messaging Service, JMS Java Database Connectivity, JDBC Java. Mail Java Transaction API, JTA Connector Architecture
J 2 EE Overview – Content of J 2 EE n n n RMI/IIOP Java Naming and Directory Interface, JNDI Webservices, in version 1. 4
J 2 EE Overview – Benefits of J 2 EE n n n n 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
Containers and Components
Containers and Components n n n A J 2 EE Application server provides containers for all components of J 2 EE There is one container per J 2 EE component The Application server runs the entire J 2 EE solution
Containers and Components n The Application server handles all system level programming q Security n n q q q 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
Containers and Components n Several clients – one system
Enterprise Java Beans n n n The core of J 2 EE Server side components Three base types of EJB q q q n Transactional components q n Session Beans Entity Beans Message Driven Beans Bean managed or Container managed Deploy time configuration of security and transactions
Enterprise Java Beans - Architecture
Enterprise Java Beans – Session Beans n n n Stateless and statefull beans Handles busines logic Acts as frontend for Entity beans
Enterprise Java Beans – Entity Beans n n n Handels data Mapped on Database tables Container managed (CMP) and Bean Managed Persistence (BMP) q q n CMP releaves the developer from writing SQL code Minimizes the risk for database lock-in. EJB-QL – a query language for EJBs
Enterprise Java Beans – Message Driven Beans n n n Activated by a JMS queue Asynchronous execution No need for the client to wait for an answer
Java Messaging Service, JMS n n n 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 q q q 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
Java. Mail n A high level API for sending and receiving mail q n No need to know everything about the underlying protocolls Support for IMAP, POP and SMTP
Java Transaction API, JTA n n The easy way to handle complex transactions You can have transactions between different components q n n 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
Java Connector Architecture, JCA n n Hook into existing legacy systems You can write a connector for basically anything Anything with a Connector can be plugged into the J 2 EE Server Simplifies system integration
RMI/IIOP n n Integration with other systems through Corba Call your J 2 EE Components from Visual Basic, Delphi, C++ and C q Java might not be the best or only choice for your clients
Java Naming and Directory Interface, JNDI n n n Very fundamental functionality in J 2 EE 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
Java Naming and Directory Interface, JNDI n n Used to store connection pools for JDBC Context. lookup(“java: comp/env/jdbc/Pool 1”) q q n Private context from within components Defined with a <resource-ref> in deployment descriptors Context. lookup(“Pool 1”) q Global context from the outside
Web Development n The web is static by nature q q q Based on HTTP A stateless network environment The stateless nature is what have made the Internet into what it is today
HTTP n A very simple and readable protocol q n Text based Several methods q GET n q POST n q q The basic request to get a page Used from forms in the web pages DELETE HEAD
HTTP n A typical browser request for www. dn. se/index. html q q q Connect to www. dn. se GET /index. html HTTP/1. 0 Disconnect
CGI n Common Gateway Interface q q q An early interface for making the web more dynamic Executes programs on the server Cumbersome programming and bad resource management n Basically each request starts a new process on the server
Java Servlets n n n n Extensions of the web server One of the front ends to the J 2 EE system Generates HTML with print statements Good for implementing control logic Support for sessions Multithreaded by nature Not so good for generation nice layout
Java Server Pages (JSP) n n n 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
Servlets and JSP n n n 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
Other technologies for the web n Microsoft Active Server Pages q q n PHP q n n n Embed VB code in your HTML Similar to JSPs Quite like ASP, but open source and available on all platform. Used at many sites today Coldfusion Webobjects (Mac) Zope
Next time n The next session will be all about Servlet programming
- Slides: 32