INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent...
Transcript of INF5040 (Open Distributed Systems) · Remote Method Invocation Java RMI Load Balancing Transparent...
INF5040 (Open Distributed Systems)
Lucas Provensi ([email protected])
Department of InformaticsUniversity of Oslo
September 13, 2010
Features of Distributed Systems Java EE Architecture Enterprise Java Beans (EJB) J2EE Application Servers◦ Jboss
Example
2INF5040 - Group Meetings
Remote Method Invocation◦ Java RMI
Load Balancing Transparent failover Integration to legacy systems Transactions Clustering◦ State replication across servers
Resource pooling◦ Grouping together resources
Security …..
3INF5040 - Group Meetings
Middleware services provides those features Goal: To separate these concerns from the
application logic.◦ Business logic is more important for developers
Too costly to build from scratch Distributed apps should be portable across
middleware service providers
4INF5040 - Group Meetings
"The Java Platform Enterprise Edition reduces the cost and complexity of developing ... multi‐tier services, resulting in services that can be rapidly deployed and easily enhanced“
Introduced in June, 1999
5INF5040 - Group Meetings
Distributed multitiered application model for enterprise applications.
6INF5040 - Group Meetings
A web client consists of two parts: ◦ Dynamic web pages containing various types of
markup language (HTML, XML, and so on), which are generated by web components running in the web tier, and ◦ A web browser, which renders the pages received
from the server. Sometimes called a thin client◦ Usually do not query databases, execute complex
business rules, or connect to legacy applications
7INF5040 - Group Meetings
The client communicates with the business tier running on the server either directly or by going through JSP pages or servlets running in the web tier.
8INF5040 - Group Meetings
Business code is logic that solves the needs of a particular business domain◦ Receives data from clients, processes it (if necessary),
and sends it to the enterprise information system tier for storage
9INF5040 - Group Meetings
A server‐side software component model for distributed enterprise applications
Core of the Java EE technology Goal: To provide a standard way to manage
distribution issues in enterprise applications through reusable code◦ By implementing the back‐end 'business' code
typically to enterprise applications◦ Addressing the same types of problems through the
same code
10INF5040 - Group Meetings
11INF5040 - Group Meetings
EJB
Entity Bean(persistent)
Session Bean(non-persistent)
Stateful StatelessContainer Managed
Persistence
Bean Managed
Persistence
12INF5040 - Group Meetings
EJB
Message Driven Bean
(non-persistent)Session Bean
(non-persistent)
Stateful Stateless
JPA
Persistent Entities
Entity Beans (deprecated)◦ Now JPA Entity◦ Represent persistent business Entity◦ Persist in storage system ( usually Database)
JPA Entity represents a table in a relational database, and each entity instance corresponds to a row in that table ◦ The class must be annotated with the
javax.persistence.Entity annotation;◦ Entities are managed by one entity manager.
13INF5040 - Group Meetings
Session Beans◦ Perform work for individual clients on the server◦ Encapsulate complex business logic◦ Can coordinate transactional work on multiple
entity beans Session beans can be◦ Stateless‐The SBs belong to the client for duration
of the method call only◦ Stateful‐The SBs belong to the client for duration of
client lifetime
14INF5040 - Group Meetings
Message driven beans◦ Business objects whose execution is triggered by
messages instead of by method calls;◦ Receive messages asynchronously.
The Message Driven Bean is used among others to provide a high level ease-of-use abstraction for the lower level JMS (Java Message Service) specification.
It may subscribe to JMS message queues or message topics, which are typically injected into the bean.
15INF5040 - Group Meetings
Industry standard◦ Vendors design containers to EJB specs
Portability possible across containers◦ The application assembler can build new
applications from existing beans. RAD ability because of the services provided
by container◦ The EJB container, rather than the bean developer,
is responsible for system-level services such as transaction management and security authorization.
16INF5040 - Group Meetings
Rarely necessary for web‐based applications Spring, a lightweight container, can achieve most
of the EJB services◦ makes it easy to use many different services and
frameworks◦ accepts any Java bean instead of specific components
Complexity◦ Specifications were getting more complex◦ EJB 3.0 tries to address this issue
Difficulty in Unit testing◦ If anything goes wrong, is it container related or app
related?
17INF5040 - Group Meetings
Definition◦ Is a software framework dedicated to the efficient
execution of n‐tiered web applications.
Java EE Application Server. ◦ A software package that implements all of the Java
EE APIs and frameworks that allow you to deliver Java EE applications.
18INF5040 - Group Meetings
Connectivity to various applications and DBs on various operating environments and hardware
Provides an integrated IDE for all aspects Support for reusable distributed components
(CORBA, COM, EJB) Performance management (load balancing,
caching, monitoring) Robust and reliable software –redundancy,
backup/recovery User‐friendly administrative, diagnostic tools Strong security framework
19INF5040 - Group Meetings
A Java EE Application Server provides (at a minimum):◦ Servlet engine/container◦ EJB engine/container◦ Web Server (or ability to integrate with a web server)◦ Concrete implementations of all the J2EE APIs Java Mail Messaging RMI etc.
A vendor‐bought App Server will have additional functionalities
20INF5040 - Group Meetings
Full Java EE App Servers:◦ Apache Geronimo (Apache Software Foundation) ◦ Glassfish Application Server (Oracle Corporation)◦ Caucho Resin Application Server ◦ WebSphere Application Server ◦ JBoss (Red Hat) ◦ Jetty (Eclipse Foundation) ◦ JRun (Adobe Systems)◦ WebLogic Server (Oracle)
Others◦ Tomcat (servlet only)
21INF5040 - Group Meetings
Introduced in 1999 The product of an Open Source developer
community dedicated to developing the best J2EE‐compliant application server in the market
With 1000 developers worldwide and a steadily growing number of downloads per month, reaching 72,000 for October ’01 (per independent www.sourceforge.net), Jboss is arguably the most downloaded application server in the world today
Distributed under an LGPL license, Jboss is absolutely FREE for use.
22INF5040 - Group Meetings
JBoss 4.0 is compliant to the Java EE specification. So Java EE components such as EJBs can be reused even if they were developed for other application servers
It also supports Java EE Web Services and Service Oriented Architecture
Since JBoss is java based, it can be used on any operating system that supports java
JBoss requires smaller memory than some other application servers and is considerablly faster
It has a very powerful documentation on its web page
23INF5040 - Group Meetings
Some Features◦ Clustering◦ Failover (including sessions)◦ Load balancing◦ Distributed caching (using JBoss Cache, a standalone product)◦ Distributed deployment (farming)◦ Aspect-Oriented Programming (AOP) support◦ JSP/Servlet 2.1/2.5 (Tomcat)◦ JavaServer Faces 1.2 (Mojarra)◦ Enterprise Java Beans versions 3 and 2.1◦ JNDI (Java Naming and Directory Interface)◦ Hibernate-integration (for persistence programming: JPA)◦ JDBC◦ JTA (Java Transaction API)◦ Etc.
24INF5040 - Group Meetings
Using Eclipse IDE for Java EE Downloading JBoss and integrating with
eclipse Sample EJB Application◦ Creating a Session Bean◦ Execution using JBoss
25INF5040 - Group Meetings
1. Create a EJB project1. Create a Session Bean and define its business
methods2. Create a Servlet that uses the Session Bean
1. Use the @EJB annotation to create a container managed bean
2. Use the doGet() method to interact with the bean3. Package the application in a EAR(Enterprise
Archive) file4. Deploy the application in the JBoss server
26INF5040 - Group Meetings