enterprise java overview panos konstantinidis java developer jug leader & java champion

45
Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion http://thejavablog.wordpress.com

Upload: martha-parker

Post on 20-Jan-2016

238 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Enterprise Java Overview

Panos KonstantinidisJava Developer

JUG Leader & Java Championhttp://thejavablog.wordpress.com

Page 2: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Java Enterprise Edition

Introduction to JEE JEE architecture/technologies JEE Application Servers SOA – The next step Spring Framework.

Page 3: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Enterprise Systems

Enterprise Systems Large scale and complex systems n number or tiers Distributed Thousands of users Multithreading Thousands or millions of requests per hour Support for fail-over Support for transactions Support for security

Page 4: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Before JEE

Developer had to do everything Care about multithreading Care about transactions Care about fail-over Care about security ... on top of that care about the business logic

Page 5: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

After JEE

Application Server/Container takes care of application details

Multithreading Security Fail-over etc.

Developer takes care of business logic

Page 6: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

JEE Architecture

JEE architecture layers (image taken from http://www.itindepth.com/)

Page 7: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Servlets

Servlets Java objects that extend the functionality of a

web server Run on the server Require a servlet container to run in Platform and server independent They access all the Java APIs Having HTML/XML/WML code within a Java

class is ugly, error-prone and hard to maintain

Page 8: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

JSP

JSP A simple and easy way to create dynamic web

content HTML/XML/WML/etc with Java code (scriplets)

embedded into it Runs on the server Platform and server independent Needs to be pre-compiled into a servlet

Page 9: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Servlets & JSP

They work together JSP used for presentation Servlets are used as controllers/implement

logic By separating logic from presentation

(design) it is easier to maintain, scale and build web applications

Page 10: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

EJB

The cornerstone of a JEE application Server side components They enable fast and simplified

development of distributed, transactional, secure and portable enterprise applications

They are deployed into a container

Page 11: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

EJB (continued)

Three types of EJB (Session, Entity, Message driven)

The container is responsible for Loading and initialising Transactions Persistence (activation/passivation and db

persistence) communication with clients via remote

interfaces JNDI for finding EJB instances

Page 12: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Session Beans

Perform actions on behalf of a particular client

Stateful Maintains conversational state with the client

Stateless Does not maintain state between client calls.

The container can substitute beans as necessary between method calls.

Page 13: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Entity Beans

Map data to a database row Provide abstraction layer so when working

with an entity the storage mechanism is not specific.

Container Managed The container persists the data to the db

automatically. Beans Managed

Developer writes code that persists data to the db and container calls these methods

Page 14: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Message Driven Beans

Receive asynchronous notifications from a JMS server

for example send a purchase order to a JMS queue

Client does not interact with them directly but only through message queues

Page 15: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Java Messaging Service

Software that provides service for messaging

Can be stand-alone or consolidated within an application server

JMS Queue Messages are sent into a queue and read from

the queue. One consumer only JMS Topic

Publish/subscribe mode. Messages are broadcast to all the consumers

Page 16: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

JNDI

Java Naming and Directory Interface It is used to store and retrieve objects by

name Object have to register with a naming service

first Can interact with existing naming services

like LDAP

Page 17: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

JTA

The Java Transaction API allows application servers to handle transactions

Developer declares the transaction properties

The application server takes care of the rest

Page 18: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Java Mail

The Java Mail API provides classes that model a mail system

Supports many common protocols IMAP POP SMTP MIME

Page 19: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

JAAS

Java Authentication and Autorisation Service Authenticates users, makes sure users can log

into the system and execute Java code Authorises users, makes sure users have the

right permissions to perform the actions required Authentication modules include

Kerberos Keystore Windows NT

Page 20: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

JDBC

Java Database Connectivity Lets developers access database from

Java Also provides access to other form of data

such as excel files There are drivers for all the known

databases

Page 21: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

J2EE Connectors

Connectors provide a way to connect J2EE applications to heterogenous systems not written in Java (Siebel, SAP, etc)

System vendor provides the right connector

Page 22: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Application Servers

Take care of application-related functionality

Provide sophisticated means to handle multithreading/transactions/security/etc

Handle the life-cycle of the installed components

Usually cost thousands of pounds per CPU

Page 23: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Application Servers (continued)

All of application servers provide their own services (JMS, JNDI, servlet containers, etc)

Some application servers WebLogic WebSphere Oracle JBoss (free and open source, but you pay for

support) Glassfish (same)

Page 24: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Deployment

You deploy the application onto the application server in a form of EAR (Enterprise ARchive) file

EAR is nothing more than a zipped file that contains all relevant files needed.

It is expanded on deployment

Page 25: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Console

Application servers usually provide a console where the administrator or developer can manage the application

Deploy/undeploy applications Define JDBC resource Define users and roles etc

Page 26: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Web Services

Services residing somewhere on the web Web services enable application to

application interaction via the web Built on existing standards (SOAP over

HTTP) Web services are focused on messages

not APIs (we don't care what created the message)

Page 27: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Web Services (continued)

Interoperability between disparate systems You can access a .NET web service from a

Java client (the opposite is also true), etc Enable Service Oriented Architecture

(SOA) Traditional approach is based on objects, we

discover and use objects With SOA we discover and use services

Page 28: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Web Services protocol

Simple Object Access Protocol (SOAP) Transmission over existing HTTP protocol

In essence we send HTTP requests with the whole SOAP message in the body of the POST

XML based

Page 29: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

WSDL

Web Services Description Language Describes a web service Describes methods and parameter types Describes return types How to access it (what port it's running on,

where it's running on) XML based

Complicated, use tools to generate the WSDL

Page 30: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

UDDI

Universal Description, Discovery and Integration

It's a registry of services Publishes information about a web service

(similar to yellow pages) Publishes the access point of a web service

Page 31: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring

Aims behind Spring Enterprise Java should be easier. Interfaces are better than classes. JavaBeans better than EJBs. Testability is important and should be easier.

Page 32: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring (continued)

Small size (around 6MB). One core jar file (and a few more

dependencies). Spring manages life-cycle and

configuration of application objects. Dependency Injection

Objects are given their dependencies instead of creating/looking for them.

Spring gives dependencies upon instatiation.

Page 33: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring (continued)

Application data are configured through an XML configuration file.

Can be complicated and hard to maintain if there are too many beans configured.

Like JEE, developer is only concerned about business logic, Spring takes care of application related functionality.

Page 34: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring Modules

Spring contains several modules, each one can be used on its own.

Core and Context modules, the heart of the Spring framework. Provide fundamental functionality.

AOP module. JDBC module. ORM Module (hooks for other ORM

implementations). Web Module.

Page 35: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring Core Modules

Initialise all the application objects (JavaBeans) by reading the XML configuration file.

Supply enterprise services such as JNDI, multithreading, remote calls etc.

Provide support with integration with other frameworks (FreeMarker, iBatis etc).

Page 36: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & AOP

Aspect – a general feature we want to apply globally to our application (e.g. logging or exception handling).

Aspects are declared through the XML configuration file.

Container executes the aspect after, before or around a method call.

Around can change the method behaviour.

Page 37: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & JDBC

Provides functionality for JDBC. Database information (url, port etc) is

configured via the XML configuration file. Handles the creation of connections, result

sets, statements, pools etc. Closes the connection and returns it to the

pool of available connections.

Page 38: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & Transactions

Declare transactions in the configuration file/class meta data by using annotations.

Can declare roll back behaviour per method or exception type.

You can't do that with EJBs, only programmatically.

No native support for distributed transactions. Only through JTA.

EJBs support distributed transactions by default.

Page 39: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & Persistence

Doesn't support out of the box ORM solutions.

We need to integrate with existing technologies (Hibernate, TopLink etc). Spring provides the right plumbing to do so.

Alternatively use plain JDBC.

Page 40: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & Web applications

Provides its own web framework (Spring MVC).

Typical MVC pattern with a central servlet acting as controller.

Spring supports several web-oriented tasks (multipart file uploading, session handling etc).

Can be integrated with other web frameworks like Struts, Tapestry, JSF.

Page 41: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & Distributed computing

Remote calls to Spring ca be done via RMI (same as EJBs) JAX/RPC (for Web Services)

Page 42: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & Security

Spring Security (formerly Acegi security) Supports declarative security via XML

configuration or class meta data annotations for security (EJBs also support declarative security via roles and users).

Page 43: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Spring & Deployment

Platform independent. A Spring application should run the same

on any other machine that supports Spring. Migration should be easy (just copy & paste

the application data & the XML configuration file).

Same with EJBs, although a bit tricky.

Page 44: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Learning more Enterprise Java - http://java.sun.com/javaee/ JEE compatible servers -

http://java.sun.com/products/servlet/industry.html JEE tutorial - http://java.sun.com/javaee/5/docs/tutorial/doc/ JDBC tutorial - http://java.sun.com/docs/books/tutorial/jdbc/basics/ JNDI - http://java.sun.com/products/jndi/tutorial/ Servlets tutorial -

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html JMS - http://java.sun.com/products/jms/ Spring Framework - http://www.springframework.org/ Spring projects - http://www.springsource.org/projects WebLogic Server - http://www.bea.com WebSphere server - http://www.ibm.com/software/info/websphere/r JBoss Server - http://www.jboss.org/ Glassfish Server - https://glassfish.dev.java.net/

Page 45: Enterprise Java Overview Panos Konstantinidis Java Developer JUG Leader & Java Champion

Questions?