Presentation is loading. Please wait.

Presentation is loading. Please wait.

Self-executing Java, J2EE James Atlas July 29, 2008.

Similar presentations


Presentation on theme: "Self-executing Java, J2EE James Atlas July 29, 2008."— Presentation transcript:

1 Self-executing Java, J2EE James Atlas July 29, 2008

2 James Atlas - CISC3702 Review Software Testing Software Testing  Design process

3 July 29, 2008James Atlas - CISC3703 Announcements Final Exam Final Exam  08/15 at 3:30PM to 5:30PM in 107 Sharp Lab (SHL107)  We will have a review on 08/12, no class on 08/14 Remaining topics Remaining topics  Java Security  3D graphics API + Sound

4 July 29, 2008James Atlas - CISC3704 Today Self-executing Java Self-executing Java J2EE Intro J2EE Intro

5 July 29, 2008James Atlas - CISC3705 Self-executing Java "How do I make an.EXE file from my Java application?“ "How do I make an.EXE file from my Java application?“ Many different approaches: Many different approaches:  Executable Jars  Java Web Start  Custom launcher/wrapper  Ahead-Of-Time Compilers

6 July 29, 2008James Atlas - CISC3706 Executable Jars “zip” archive containing application code and resources “zip” archive containing application code and resources contains a META-INF/MANIFEST.MF file contains a META-INF/MANIFEST.MF file  Main-Class: MyAppMain  Class-Path: mylib.jar automatically associated in Windows with your installed JRE (javaw.exe) automatically associated in Windows with your installed JRE (javaw.exe) requires a working, installed JRE requires a working, installed JRE

7 July 29, 2008James Atlas - CISC3707 Java Web Start From a web-link it automatically downloads application to a local cache and launches it From a web-link it automatically downloads application to a local cache and launches it Less secure than Applets (with user confirmation) Less secure than Applets (with user confirmation) Internet connectivity required Internet connectivity required Similar to: java -classpath http://www.mysite.com/app/MyApp.jar com.mysite.app.Main Similar to: java -classpath http://www.mysite.com/app/MyApp.jar com.mysite.app.Main Example: http://www.calcexp.com/weblaunch.htm Example: http://www.calcexp.com/weblaunch.htm

8 July 29, 2008James Atlas - CISC3708 Custom launcher/wrapper Creates a small native program that calls the appropriate java commands Creates a small native program that calls the appropriate java commands  Allows custom taskbar icons and splashscreens  Can be configured to use a bundled JRE Launch4J - http://launch4j.sourceforge.net/ Launch4J - http://launch4j.sourceforge.net/

9 July 29, 2008James Atlas - CISC3709 Ahead-Of-Time Compilers Produces a conventional native executable for the target platform Produces a conventional native executable for the target platform Pros: Pros:  performance  Intellectual Property  No “warm-up” time Cons: Cons:  limited tools depending on what version of Java  very hard to do dynamic applications (custom classloaders like web servers with JSP content)  produces executable that is platform specific but somewhat hardware agnostic

10 July 29, 2008James Atlas - CISC37010 Programming Assignment 5

11 July 29, 2008James Atlas - CISC37011 J2EE

12 July 29, 2008James Atlas - CISC37012 History Initially two tier architecture (client server applications) Initially two tier architecture (client server applications) Client is responsible for data access applying business logic and presentation of data Client is responsible for data access applying business logic and presentation of data Only service provided by Server was that of database server. Only service provided by Server was that of database server.

13 July 29, 2008James Atlas - CISC37013 Two Tier Application Architecture Client Server Client Server

14 July 29, 2008James Atlas - CISC37014 Two Tier Application Architecture Drawbacks Drawbacks - Easy to deploy but difficult to enchance or upgrade. - It makes reuse of business and presentation logic difficult - Not scalable and not suited for internet

15 July 29, 2008James Atlas - CISC37015 J2EE To develop N tier application To develop N tier application It supports the development of a variety of application types It supports the development of a variety of application types  small client server systems  Systems running on Intranets  Systems on large scale internet e- commerce site

16 July 29, 2008James Atlas - CISC37016 J2EE Features Component based model Component based model Container provided services Container provided services Highly Scaleable Highly Scaleable Simplified Architecture Simplified Architecture Flexible security model Flexible security model

17 July 29, 2008James Atlas - CISC37017 Key J2EE APIs Component Technologies Component Technologies  Servlets  Java Server Pages (JSP)  Enterprise Java Beans (EJB) Standard Services Standard Services  Java Database Connectivity (JDBC API)  Java Naming and Directory Interface (JNDI)  Java Transaction API (JTA) Other Services Other Services  HTTP, HTTPS, RMI-IIOP, JMS, JavaMail

18 July 29, 2008James Atlas - CISC37018 Containers in the N-Tier J2EE Architecture

19 July 29, 2008James Atlas - CISC37019 J2EE Tiers Client Presentation Client Presentation  HTML or Java applets deployed in Browser  XML documentations transmitted through HTTP  Java clients running in Client Java Virtual Machine (JVM) Presentation Logic Presentation Logic  Servlets or JavaServer Pages running in web server Application Logic Application Logic  Enterprise JavaBeans running in Server

20 July 29, 2008James Atlas - CISC37020 J2EE Application Model Browser is able to process HTML and applets pages. Browser is able to process HTML and applets pages. It forwards requests to the web server, which has JSPs and Servlets It forwards requests to the web server, which has JSPs and Servlets Servlets and JSPs may access EJB server. Servlets and JSPs may access EJB server. Java Standalone runs on java client, which access EJB server using RMI. Java Standalone runs on java client, which access EJB server using RMI.

21 July 29, 2008James Atlas - CISC37021 J2EE Application Model

22 July 29, 2008James Atlas - CISC37022 EJB – Enterprise Java Beans Enterprise Java Beans are components that are deployed into containers Enterprise Java Beans are components that are deployed into containers The container provides services The container provides services  Loading / Initialization  Transactions  Persistence  Communication with EJB clients  Enterprise Naming Context (JNDI name space)

23 July 29, 2008James Atlas - CISC37023 Anatomy of an EJB Remote Interface Remote Interface  Methods that can be accessed by the outside world.  Extends javax.ejb.EJBObject Remote Home Interface Remote Home Interface  Life-cycle methods (create, findByPrimaryKey)  Extends javax.ejb.EJBHome which extends java.rmi.Remote Bean class Bean class  The class performing the actual business process  Implements an interface based on type of bean

24 July 29, 2008James Atlas - CISC37024 EJB – Enterprise Java Beans Entity Beans Entity Beans Session Beans Session Beans Message Beans Message Beans  New in EJB 2.0

25 July 29, 2008James Atlas - CISC37025 Client / EJB Relationship How does a client application (Java class) utilize EJBs? How does a client application (Java class) utilize EJBs?  Lookup - JNDI ENC  Network protocol - RMI  EJB container creates object with RemoteHome and Home interfaces – this object passes calls to the bean class

26 July 29, 2008James Atlas - CISC37026 EJB – Enterprise Java Beans Entity Beans Entity Beans Session Beans Session Beans Message Beans Message Beans  New in EJB 2.0

27 July 29, 2008James Atlas - CISC37027 EJB – Entity Beans Entity beans are classes that map to individual entities – typically, an Entity bean references a row in a database table, providing an object representation of that database object. Entity beans are classes that map to individual entities – typically, an Entity bean references a row in a database table, providing an object representation of that database object.  For example, an entity bean could represent a customer, and changing the values in that entity bean would cause updates to that database row Entity beans provide an abstraction layer so that working with the entity is not specific to the storage mechanism for that entity. Entity beans provide an abstraction layer so that working with the entity is not specific to the storage mechanism for that entity.

28 July 29, 2008James Atlas - CISC37028 Entity Beans - Persistence Container Managed Persistence (CMP) Container Managed Persistence (CMP)  The EJB container automatically persists the EJB objects, usually to a relational database where each type of object is represented as a table, and each instance of the object is a row in that table Bean Managed Persistence (BMP) Bean Managed Persistence (BMP)  The EJB container calls bean methods when it is appropriate for the bean to load, save or update data, enforcing transactions without transaction code written by the bean developer

29 July 29, 2008James Atlas - CISC37029 EJB – Session Beans Session beans perform work for a client application Session beans perform work for a client application  For example, a session bean could charge a credit card for a specific transaction.

30 July 29, 2008James Atlas - CISC37030 Session Beans – State Stateful – A stateful bean maintains a conversational state with a client. The client perceives that it is only talking to one bean, and that bean maintains information between calls Stateful – A stateful bean maintains a conversational state with a client. The client perceives that it is only talking to one bean, and that bean maintains information between calls Stateless – A stateless bean maintains no client information between method calls – the container can substitute beans as necessary between method calls Stateless – A stateless bean maintains no client information between method calls – the container can substitute beans as necessary between method calls

31 July 29, 2008James Atlas - CISC37031 EJB – Session Bean Example package org.jboss.docs.interest; import javax.ejb.EJBObject; import java.rmi.RemoteException; /** This interface defines the `Remote' interface for the `Interest' EJB. Its single method is the only method exposed to the outside world. The class InterestBean implements the method. */ public interface Interest extends EJBObject { /** Calculates the compound interest on the sum `principle', with interest rate per period `rate' over `periods' time periods. This method also prints a message to standard output; this is picked up by the EJB server and logged. In this way we can demonstrate that the method is actually being executed on the server, rather than the client. */ public double calculateCompoundInterest(double principle, double rate, double periods) throws RemoteException; }

32 July 29, 2008James Atlas - CISC37032 EJB – Session Bean Example package org.jboss.docs.interest; import java.io.Serializable; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; /** This interface defines the 'home' interface for the 'Interest' EJB. */ public interface InterestHome extends EJBHome { /** Creates an instance of the `InterestBean' class on the server, and returns a remote reference to an Interest interface on the client. */ Interest create() throws RemoteException, CreateException; }

33 July 29, 2008James Atlas - CISC37033 EJB – Session Bean Example package org.jboss.docs.interest; import java.rmi.RemoteException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; /** This class contains the implementation for the 'calculateCompoundInterest' method exposed by this Bean. It includes empty method bodies for the methods prescribe by the SessionBean interface; these don't need to do anything in this simple example. */ public class InterestBean implements SessionBean { public double calculateCompoundInterest(double principle, double rate, double periods) { System.out.println("Someone called `calculateCompoundInterest!'"); return principle * Math.pow(1+rate, periods) - principle; } public void ejbCreate() {} public void ejbPostCreate() {} public void ejbRemove() {} public void ejbActivate() {} public void ejbPassivate() {} public void setSessionContext(SessionContext sc) {} }

34 July 29, 2008James Atlas - CISC37034 EJB – Session Bean Example JBoss Interest Sample Application Interest EJB Interest org.jboss.docs.interest.InterestHome org.jboss.docs.interest.Interest org.jboss.docs.interest.InterestBean Stateless Bean

35 July 29, 2008James Atlas - CISC37035 EJB – Session Bean Example package org.jboss.docs.interest; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; class InterestClient { /** This method does all the work. It creates an instance of the Interest EJB on the EJB server, and calls its `calculateCompoundInterest()' method, then prints the result of the calculation. */ public static void main(String[] args) { try { InitialContext jndiContext = new InitialContext(); ref = jndiContext.lookup("interest/Interest"); InterestHome home = (InterestHome) PortableRemoteObject.narrow(ref, InterestHome.class); Interest interest = home.create(); //Create an Interest object from the Home interface System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2)); } catch(Exception e) { System.out.println(e.toString()); }

36 July 29, 2008James Atlas - CISC37036 EJB – Message Beans Message beans are classes that receive asynchronous notification from a Java Message Service server Message beans are classes that receive asynchronous notification from a Java Message Service server  For example, a message bean could be activated when vendor sends a purchase order to a JMS queue.

37 July 29, 2008James Atlas - CISC37037 JMS – Java Message Service JMS Queue

38 July 29, 2008James Atlas - CISC37038 JMS – Java Message Service JMS Topic

39 July 29, 2008James Atlas - CISC37039 JMS – Java Message Service Why should I use JMS? Why should I use JMS?  Loosely-coupled systems Connectionless Connectionless Removes dependence on client and server platform / programming language / version Removes dependence on client and server platform / programming language / version  Publish / Subscribe metaphor Send / receive information with many, unknown clients Send / receive information with many, unknown clients  Integration with other messaging systems IBM MQ-Series IBM MQ-Series Microsoft Message Queue Microsoft Message Queue

40 July 29, 2008James Atlas - CISC37040 Example EJB Application

41 July 29, 2008James Atlas - CISC37041 Servlets Are container managed web components Are container managed web components Replace Common Gateway Interface(CGI) or Active Server Pages (ASP) Replace Common Gateway Interface(CGI) or Active Server Pages (ASP) Generate dynamic response to requests from web based clients Generate dynamic response to requests from web based clients Synchronize multiple concurrent client request Synchronize multiple concurrent client request Serve as client proxies Serve as client proxies

42 July 29, 2008James Atlas - CISC37042 JavaServer Pages (JSP) Text based documents describe how to process a request and create a response Text based documents describe how to process a request and create a response Contains HTML or XML and other JSP elements defined by JSP specification. Contains HTML or XML and other JSP elements defined by JSP specification. Installed on web server Installed on web server Web components that sit on top of java servlets Web components that sit on top of java servlets

43 July 29, 2008James Atlas - CISC37043 J2EE Application Packaging

44 July 29, 2008James Atlas - CISC37044 JBoss

45 July 29, 2008James Atlas - CISC37045 What is JBoss Created in 1999, JBoss is the product of an OpenSource developer community dedicated to developing the best J2EE-compliant application server in the market Created in 1999, JBoss is the product of an OpenSource 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 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. No cost. Period. Distributed under an LGPL license, JBoss is absolutely FREE for use. No cost. Period.

46 July 29, 2008James Atlas - CISC37046 What is Application Server  Application servers enable the development of multi-tiered distributed applications. They are also called “middleware”  An application server acts as the interface between the database(s), the web servers and the client browsers

47 July 29, 2008James Atlas - CISC37047 JBoss- Application Server

48 July 29, 2008James Atlas - CISC37048 JBoss - example

49 July 29, 2008James Atlas - CISC37049 Project 2 Need to setup group meeting time Need to setup group meeting time


Download ppt "Self-executing Java, J2EE James Atlas July 29, 2008."

Similar presentations


Ads by Google