Presentation is loading. Please wait.

Presentation is loading. Please wait.

J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.

Similar presentations


Presentation on theme: "J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise."— Presentation transcript:

1 J2EE Chris Hundersmarck Maria Baron Jeff Webb

2  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise Edition (J2EE)  (J2ME) ‘is a subset of’ (J2SE) and (J2EE) ‘is a superset of’ (J2SE).

3 J2EE is…  A distributed multi-tiered application model for enterprise applications.  Divided into components according to function.  Components installed on different machines Client, Server, Database Server Machines

4

5 Containers  Provide access to the underlying services of the J2EE Server environment.  Different types of containers for different types of components  The interface between a component and the low-level functionality that supports a component.

6 Containers  For example EJB container:  manages the execution of enterprise beans. Web container  manages the execution of JSP pages and servlet components.

7 Containers

8 Client Tier 1. Web clients 1. HTML, XML, etc.. 2. Applets 2. Application clients 1. GUI 2. Command line

9

10 Web Tier 1. Servlets 2. JSP Pages

11 Web Components

12 JavaServer Faces  Lets you create user interfaces from a set of standard, reusable server- side components  Provides a set of JSP tags to access those components  Transparently saves state information and repopulates forms when they redisplay

13 JavaServer Faces  Provides a framework for implementing custom components  Encapsulates event handling and component rendering so you can use standard JSF components or custom components to support markup languages other than HTML  Lets tool vendors develop IDEs for a standard Web application framework

14 JSF Components  Each component represents one or more Web page elements  Simple components – individual components such as a text box  Compound components – comprised of multiple elements such as a table

15 Each JSF component has:  A list of child components  A hashmap of attributes  One or more validators  One or more event handlers  An identifier for an optional renderer

16 Components  All JSF components perform three fundamental tasks Render the component, typically by generating markup Handle the component's events Validate the component's values

17 Benefits  Foster the creation of development tools that allow user interface designers to drag and drop components into a layout.  Developer(s) can write event-handling code that will allow the view components to interact with the application model.  Faster GUI creation for prototyping and rapid application development (RAD).

18 JSP And Java

19 JSF AND JSP  JSF is not bound to JSP - strict decoupling of components from their view rendering  Rendering is done by using a rendering kit  JSP is a required rendering kit but developers can also use custom rendering kits to render views

20 Business Tier 1. Enterprise Java Beans 1. Session Beans 2. Entity Beans 3. Message-Driven Bean

21 Java Beans vs. Enterprise Beans 1. Java Beans are not considered J2EE components by the J2EE specification 2. Java Beans: 1. Can exist on Server tier or Client tier. 2. Manage communication between all three tiers. 3. Enterprise Beans: 1. Only exist on Business Tier as part of the Server Tier

22 Business Components

23 Enterprise Java Beans  Server-side component  Encapsulates business logic  Simplifies development EJB container provides system-level services Separates business logic from client. EJB are portable components.

24 Session Beans 1. Represents a single client. 2. Client invokes the session bean's methods. 3. Performs work for the client. 4. when the client finishes executing, the session bean and its data are gone.

25 Session Beans  Two types of Session beans: Stateless Stateful

26 Entity Beans 1. Represents persistent data stored in one row of a database table. 2. If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved.

27 Entity Beans  What makes Entity Beans different from Session Beans? Persistence Shared Access Primary Key Relationships

28 Message-Driven Bean 1. Combines features of a session bean and a Java Message Service (JMS) message listener 2. Allows a business component to receive JMS messages asynchronously.

29 Message-Driven Bean  Message-driven beans have the following characteristics: They execute upon receipt of a single client message. They are invoked asynchronously. They are relatively short-lived. They do not represent directly shared data in the database, but they can access and update this data. They can be transaction-aware. They are stateless.

30 Component Packaging .jar - Java archive : classes and web content for a J2EE application .war - web application archive .ear – enterprise archive contains the whole application along with deployment descriptor that provides information about the application and its assembled components

31

32 Deployment  Deployment tool provides ability to configure and deploy a complex enterprise application onto the : Sun Java System Application Server or onto other application servers

33 What Is XML ?  Text-based markup language  As with HTML, you identify data using tags. Collectively, the tags are known as markup.  Unlike HTML, XML tags identify the data rather than specify how to display it.

34 What Is XML ? you@yourAddress.com me@myAddress.com XML Is Really Cool How many ways is XML cool? Let me count the ways...

35 Java API for XML Processing  (JAXP) is for processing XML data using applications written in the Java programming language.  Leverages the parser standards: Simple API for XML Parsing (SAX)  parse your data as a stream of events OR Document Object Model (DOM)  build an object representation of it.

36 Java API for XML Processing  Simple API for XML Parsing (SAX) It is read forward only SAX simply sends data to the application as it is read Requires much less memory than DOM, because SAX does not construct an internal representation (tree structure) of the XML data Fast and efficient

37 Java API for XML Processing  Document Object Model (DOM) When you need to modify an XML structure interactively in-memory structure (Object model) provides many powerful capabilities for large-scale documents requires more complex coding

38 JAX-RPC  Java API for XML-based RPC  Technology for building web services and clients that use remote procedure calls (RPC) and XML  Remote procedure call is represented by an XML-based protocol such as SOAP

39

40 SOAP  SOAP specification defines the envelope structure encoding rules Conventions for representing remote procedure calls and responses in XML.  These calls and responses are transmitted as SOAP messages (XML files) over HTTP.

41 SOAP  SOAP messages are complex  The JAX-RPC API hides this complexity from the application developer.

42 Web Service using JAX-RPC  On the server side, the developer specifies the remote procedures by defining methods in an interface (written in the Java programming language)  The developer also codes one or more classes that implement those methods

43 Web Service using JAX-RPC  A client creates a proxy (a local object representing the service) and then simply invokes methods on the proxy.  The developer does not generate or parse SOAP messages  The JAX-RPC runtime system converts the API calls and responses to and from SOAP messages.

44 Web Service using JAX-RPC  JAX-RPC client can access a web service that is not running on the Java platform, and vice versa.  Flexibility is possible because JAX- RPC uses World Wide Web Consortium (W3C) technologies:  HTTP, SOAP, WSDL  WSDL: Web Service Description Language. WSDL specifies an XML format for describing a service.

45 Web Service using JAX-RPC Web ClientWeb Service

46 Web Service using JAX-RPC  Service Code Extends the java.rmi.Remote interface Methods must throw the java.rmi.RemoteException or one of its subclasses Method parameters and return types must be supported JAX-RPC types

47 Hello Web Service package helloservice; import java.rmi.Remote; import java.rmi.RemoteException; public interface HelloIF extends Remote { public String sayHello(String s) throws RemoteException; }

48 Hello Web Service package helloservice; import java.io.*; public class HelloImpl implements HelloIF { public String message = "Hello "; public String sayHello(String s) { return message + s; }

49 package staticstub; import javax.xml.rpc.Stub; public class HelloClient { private String endpointAddress; public static void main(String[] args) { System.out.println("Endpoint address = " + args[0]); Stub stub = createProxy(); stub._setProperty(javax.xml.rpc.Stub._ ENDPOINT_ADDRESS_PROPERTY, args[0]); HelloIF hello = (HelloIF) stub; System.out.println(hello.sayHello("Duke!")); } private static Stub createProxy() { return (Stub) (new MyHelloService_Impl().getHelloIFPort()); }

50 package staticstub; import javax.xml.rpc.Stub; public class HelloClient { private String endpointAddress; public static void main(String[] args) { System.out.println("Endpoint address = " + args[0]); Stub stub = createProxy(); stub._setProperty(javax.xml.rpc.Stub._ ENDPOINT_ADDRESS_PROPERTY, args[0]); HelloIF hello = (HelloIF) stub; System.out.println(hello.sayHello("Duke!")); } private static Stub createProxy() { return (Stub) (new MyHelloService_Impl().getHelloIFPort()); }


Download ppt "J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise."

Similar presentations


Ads by Google