Software Development using MacroMedia s JRun



Similar documents
Objectives. Software Development using MacroMedia s JRun. Enterprise Application Model. Topics for Discussion

Java E-Commerce Martin Cooke,

EJB & J2EE. Component Technology with thanks to Jim Dowling. Components. Problems with Previous Paradigms. What EJB Accomplishes

How To Protect Your Computer From Being Hacked On A J2Ee Application (J2Ee) On A Pc Or Macbook Or Macintosh (Jvee) On An Ipo (J 2Ee) (Jpe) On Pc Or

Lösungsvorschläge zum Übungsblatt 13: Fortgeschrittene Aspekte objektorientierter Programmierung (WS 2005/06)

Component Middleware. Sophie Chabridon. INT - INF Department - Distributed Systems team 2006

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch

Getting Started with Web Applications

Java 2 Platform, Enterprise Edition (J2EE): Enabling Technologies for EAI

Enterprise Applications

PowerTier Web Development Tools 4

Java 2 Platform, Enterprise Edition (J2EE) Bruno Souza Java Technologist, Sun Microsystems, Inc.

Chapter 4. Architecture. Table of Contents. J2EE Technology Application Servers. Application Models

NetBeans IDE Field Guide

Web Application Architecture (based J2EE 1.4 Tutorial)

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Oracle WebLogic Server 11g Administration

Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat

Glassfish, JAVA EE, Servlets, JSP, EJB

Listeners. Formats. Free Form. Formatted

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

Java EE 7: Back-End Server Application Development

How To Write A Bean In Java (Java) (Java 2.4.2) (Java.Net) (Javax) 2 (Java Bean) ( Java Bean) 2-4.5

SAP Web Application Server 6.30: Learning Map for Development Consultants

JAVA ENTERPRISE IN A NUTSHELL. Jim Farley and William Crawford. O'REILLY 4 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo.

WebOTX Application Server

What Is the Java TM 2 Platform, Enterprise Edition?

CONFIGURATION AND APPLICATIONS DEPLOYMENT IN WEBSPHERE 6.1

Enterprise JavaBeans Fundamentals

Introduction to Entity Beans

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

Introduction to Sun ONE Application Server 7

JBS-102: Jboss Application Server Administration. Course Length: 4 days

Java Application Server Guide. For Version 10.3 or Later

Work with XI 3.0 Java Proxies

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

J2EE Web Development. Agenda. Application servers. What is J2EE? Main component types Application Scenarios J2EE APIs and Services.

Advantage Joe. Deployment Guide for WebLogic v8.1 Application Server

As you learned about in Chapter 1, WebSphere Application Server V6 supports the

CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012

Enterprise Application Integration

Implementing the Shop with EJB

New Methods for Performance Monitoring of J2EE Application Servers

Working with WebSphere 4.0

Building Web Applications, Servlets, JSP and JDBC

Basic TCP/IP networking knowledge of client/server concepts Basic Linux commands and desktop navigation (if don't know we will cover it )

A Flexible Security Architecture for the EJB Framework

Announcements. Comments on project proposals will go out by in next couple of days...

Oracle WebLogic Server 11g: Administration Essentials

Geronimo Quartz Plugins

Contents. Client-server and multi-tier architectures. The Java 2 Enterprise Edition (J2EE) platform

WebSphere Training Outline

Oracle WebLogic Server

MagDiSoft Web Solutions Office No. 102, Bramha Majestic, NIBM Road Kondhwa, Pune Tel: /

Sample copy. Introduction To WebLogic Server Property of Web 10.3 Age Solutions Inc.

IBM Rational Rapid Developer Components & Web Services

In this chapter, we lay the foundation for all our further discussions. We start

ucosminexus Application Server and BPM/ESB Platform Terminology Guide Y99(E)

Automatic generation of distributed dynamic applications in a thin client environment

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

WebSphere Application Server V7: Deploying Applications

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

enterprise^ IBM WebSphere Application Server v7.0 Security "publishing Secure your WebSphere applications with Java EE and JAAS security standards

WebSphere Server Administration Course

IBM WebSphere Server Administration

Enterprise JavaBeans 3.1

CACHÉ: FLEXIBLE, HIGH-PERFORMANCE PERSISTENCE FOR JAVA APPLICATIONS

Install guide for Websphere 7.0

This training is targeted at System Administrators and developers wanting to understand more about administering a WebLogic instance.

The Duke s Bank Application

rpaf KTl enterprise EJB 3.1 Cookbook I I flv* IV I I professional expertise distilled

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

MDA Overview OMG. Enterprise Architect UML 2 Case Tool by Sparx Systems by Sparx Systems

No.1 IT Online training institute from Hyderabad URL: sriramtechnologies.com

Chapter 5 Application Server Middleware

HOW TO DEPLOY AN EJB APLICATION IN WEBLOGIC SERVER 11GR1

An introduction to creating JSF applications in Rational Application Developer Version 8.0

25 May Code 3C3 Peeling the Layers of the 'Performance Onion John Murphy, Andrew Lee and Liam Murphy

Services. Custom Tag Libraries. Today. Web Development. Role-Based. Development. Code Reuse. Tag Libraries Custom Tags. Tag Lifecycle.

Controlling Web Application Behavior

Expert One-on-One J2EE Design and Development

Oracle WebLogic Server

Course Name: Course in JSP Course Code: P5

Complete Java Web Development

zen Platform technical white paper

3-Tier Architecture. 3-Tier Architecture. Prepared By. Channu Kambalyal. Page 1 of 19

Migrating Applications From IBM WebSphere to Apache Tomcat

Internet Engineering: Web Application Architecture. Ali Kamandi Sharif University of Technology Fall 2007

Load Balancing in Cluster

Exam : Oracle 1Z : Oracle WebLogic Server 10gSystem Administration. Version : DEMO

Distributed Objects and Components

WEBLOGIC ADMINISTRATION

Web Application Programmer's Guide

Choosing a J2EE application server for your commercial software application

The Evolution to Components. Components and the J2EE Platform. What is a Component? Properties of a Server-side Component

Aufgabenstellung. Aufgabenstellung

Using the DataDirect Connect for JDBC Drivers with the Sun Java System Application Server

SW5706 Application deployment problems

WebLogic 8.1 Student Guide V1.1

WebLogic Server Admin

Transcription:

Software Development using MacroMedia s JRun B.Ramamurthy 6/10/2005 BR 1

Objectives To study the components and working of an enterprise java bean (EJB). Understand the features offered by Jrun4 environment. To be able to deploy and execute application using JMC of Jrun4. Analyzing a problem and arriving at a component-based solution. 6/10/2005 BR 2

Topics for Discussion General introduction to Enterprise EJB JRUN 4 application server from Macromedia Demos on JRUN 4 From problem statement to J2EE components via use case analysis 6/10/2005 BR 3

What are EJBs? Enterprise JavaBeans TM is the serverside component architecture for the J2EE TM platform. EJB TM enables rapid and simplified development of distributed, transactional, secure and portable Java applications. An EJB is a collection of Java classes, and a XML file (deployment descriptor) bundled into a single unit. Java classes in this bundle follow certain rules and provide specific callbacks for the containers. 6/10/2005 BR 4

EJB Types There are three major types of EJBs: Session: Represents conversational/transient state; stateless and stateful Entity bean: Represents a persistent relation in the relational DB. Bean-managed persistence (BMP), container-managed persistence (CMP) Message-driven: Alternative to remote method call: asynchronous and used for realizing loose coupling among systems. Uses messaging middleware. Lets look at Ed Roman s view of the EJB technology. 6/10/2005 BR 5

Examples of Session beans calling entity beans Session bean Bank teller Credit card authorizer Order entry form Catalog engine Auction broker Purchase order router Entity bean Bank account Credit card Order, line item Product Bid, item Purchase order 6/10/2005 BR 6

Explicit Middleware (CORBAlike) API Transaction Service Client Stub Remote interface Distributed object Skeleton API Security Service Database Driver network 6/10/2005 BR 7

Implicit Middleware (Through declarations as in J2EE) Client Stub Remote interface Distributed object Request Interceptor Skeleton API API Transaction Service Security Service Database Driver network 6/10/2005 BR 8

Implicit VS Explicit services We used to include the services such as transaction, security, data base drivers, etc. programmatically making every programmer learn the inner details all the possible services needed in an application. Now we can declare what we want and let the container take care of carrying it out. Container is the silent partner: container s glue code tools are responsible for transforming an enterprise into a fully managed, distributed server-side component. Declaration is done through a XML deployment descriptor. 6/10/2005 BR 9

Parts of EJB EJB class that implements the business methods and life cycle methods; uses other helper classes and libraries to implement. Client-view API: consists of EJB home interface and remote interface. Home interface: controls life cycle : invokes Home Object methods: create, remove, find methods Remote interface: to invoke the EJB object methods 6/10/2005 BR 10

Parts of EJB (contd.) Deployment Descriptor: XML document for bean assembler and deploy tool; A declaration about EJB environment needed for customizing the bean to the operating environment. Container Runtime services that can be declared include: transactions, security,distribution,load balancing, multithreading, persistence, failure recovery, resource pooling, state management, clustering.. 6/10/2005 BR 11

Creating a EJB-jar file Home interfaces Local Interfaces Enterprise Bean Classes Remote Interfaces Jar file creator Ejb Jar file Deployment Descriptor Vendor Specific Files 6/10/2005 BR 12

Step 1: Retrieve Home Object reference using JNDI Client code As servlets, applets 1: Retrieve HomeObject Reference 2: Return Home Object Ref. Home Object EJB Container/Server Enterprise Beans JNDI Remote interface EJB Object 6/10/2005 BR 13

Step 2: Retrieve EJBObject using Home Interface and Objects Client code As servlets, applets 1:create 3: Return EJBObject Reference Remote interface Home Object 2:Create EJBObject EJB Object EJB Container/Server Enterprise Beans 6/10/2005 BR 14

Step 3: Invoke Business Methods Using Remote Interface and EJB Objects Client code As servlets, applets 1: call a method 5: return result 2: call middleware API EJB Container/Server Transaction, Security, Persistence services Remote interface EJB Object 4: method returns Enterprise Bean 3: call a bean 6/10/2005 BR 15

JRUN4 JRun (J2EE) Server can be started, stopped, refreshed, and status checked three different ways, From command line Using a JLauncher Using a web-based JRun Management Console (JMC) Demo1: Jrun4 Environment 6/10/2005 BR 16

JRun4 Development Version Comes with three servers: admin, default and sample Admin: is reserved for running administrative tools such as JMC. So you are advised not to do any application development on this. At port 8000. Samples: has many applications already deployed for you to study the working code for various J2EE technologies. At port 8200. Default: is where we will do most of our development and deployment. At port 8100. Demo2: Lets study the application compass served by the samples server. 6/10/2005 BR 17

Demo 3: Add a server tutorial at port 8101 Add a server tutorial. We can do hot deployment by copying over the compass application. Also see how the data access to the pointbase data base is declaratively added to the server using the JMC. Look around the other features offered by JMC. Observe how easy it is to delete, refresh, and stop a server using the various iconized buttons. Study the explorer window on the left pane of JMC to see the various declarative customization possible for your applications. 6/10/2005 BR 18

Compass Online Vacation Reservation System 1. User logon for authentication using a registered user id and password. 2. Application home provides a list of trips you can choose from. Click the name of a trip to get details about that trip 3. Trip details provides details about the selected trip. Click the book button to book the trip. 4. Reservation allows you to enter payment information. Select a credit card type, specify a credit card number and the expiration date. 5. Confirmation displays your confirmation number if the reservation was successful, and an error message if a problem occurred. 6/10/2005 BR 19

Compass Application: Use Case Diagram Logon Display List of Trips Traveler Display Details of chosen trip Make Reservation record information Place Order Credit Card Info Validate Credit card 6/10/2005 Display Conformation/Denial BR 20

Compass Application: From Use Cases to Component List Use JSP for all web user interface: Logon.jsp, home.jsp, Triplist.jsp, Atrip.jsp, Reservation.jsp (includes confirmation/denial use case), creditcard.jsp Data access for non-conversational JSP can be direct. For reservation and credit card we have a conversation with the user, so will have a stateless session bean ReservationBean and CreditCardBean. These two are remotely accessible beans. Finally all the information gets conveyed to a entity bean OrderBean for storing the order information. This could be a local bean not (remotely) accessible to the client. 6/10/2005 BR 21

Business Entities, Processes and Rules EJB Applications organize business entities, processes and rules into components. Entity: is an object representing some information maintained in the enterprise. Has a state which may be persistent. Example: Customer, Order, Employee Process: Is an object that typically encapsulates an interaction of a user with business entities. A process typically updated and changes the state of the entities. Example: Sales, pricing, place order, reservation Rules: constraints on the state of the entities. Example: overdraft, creditlow, validity 6/10/2005 BR 22

Choosing the type of Bean Entity (business entity) is typically implemented as entity bean or a dependent object of an entity bean. Conversational (business) process as a session bean. Collaborative bean as an entity bean. Any process that requires persistence is implemented as an entity bean. When exposure to other applications are not needed for an entity or process (local/private process) then they are implemented as bean dependent objects. You may use local EJBs for this purpose if container services are needed. 6/10/2005 BR 23

Review We studied the basics of Enterprise Java Beans. We will develop on these concepts further in the next lectures. We also looked JRUn4 environment: its JLauncher, JRun Management Console (JMC), and servers and deployment of applications. We looked at how to analyze a problem to arrive at a set of components (web components and different types of ejb components). 6/10/2005 BR 24

On To EJBs Understand the parts of the EJBs Package the EJBs and deploy them Design web application to access the EJBs Understand the various descriptors and directory structure Understand local naming conventions and JNDI naming conventions 6/10/2005 BR 25

Designing Components Designing components: esp. enterprise java beans: session beans: stateless and stateful. Connecting web component to an EJB. Enterprise application (ear) directory structure and naming conventions; hot deploy. XYZ-INF : META-INF, WEB-INF, SERVER-INF, web.xml, ejb-jar.xml, jrun.xml. Analyzing compass application of the samples server; JNDI and java naming. 6/10/2005 BR 26

Contents of an Enterprise Bean Interfaces: The remote and home interface for remote access. Local and local home accesses for local access. Enterprise bean class: Implements the methods defined in the above interfaces. Deployment descriptor: An XML file that specifies information about the bean such as its type, transaction attributes, etc. Helper classes: non-bean classes needed by the enterprise bean class such as utility and exception classes. 6/10/2005 BR 27

Naming Conventions Item Directory Name EJB JAR display name (DD) Enterprise bean class Home interface Remote interface Local home interface Local interface Syntax <name>-ear <name> <name>bean <name>home <name> Local<name>Home Local<name> Example Account-ear Account AccountBean AccountHome Account LocalAccountHome LocalAccount 6/10/2005 BR 28

Session Beans Tuition Need Calculator application. It takes in many numbers and uses handful of formulae to come up a dollar amount for financial need for attending a given college. We will implement this using a session bean. 6/10/2005 BR 29

Directory Structure for Need Calculator examples Jrun4 servers admin default samples tutorial SERVER-INF NeedCalculator-ear META-INF META-INF Calculator NeedCalculator WEB-INF NeedCalculator-war index.jsp CalculatorHome Calculator CalculatorBean 6/10/2005 BR 30

INF Directories Contain the descriptor files Descriptor files are in XML Can be auto-generated by tools. SERVER-INF has configuration of the server such as users, security. META-INF directory for ejb has ejb-jar.xml (ejb specific details) and jrun-ejb-jar.xml (ejb services specific details) WEB-INF directory for web applications has web.xml and jrun-web.xml. In general, xyz.xml and jrun-xyz.xml separate the application-server dependent and independent descriptors respectively. 6/10/2005 BR 31

Session Beans Session beans implement the façade design pattern, typically facilitating the data transfer between the user interface and the business logic beans (possible entity beans). These are conversational as opposed to entity beans being transactional. Stateless session beans don t remember anything about the user data so can be freely shared. Lets say we have 5000 users accessing your system, instead of 5000 sessions running, 50 stateless sessions can be shared among the users. 6/10/2005 BR 32

Home Interface: CalculatorHome.java package NeedCalculator; import javax.ejb.ejbhome; import java.rmi.remoteexception; import javax.ejb.createexception; import java.util.collection; public interface CalculatorHome extends EJBHome { public Calculator create() throws RemoteException, CreateException; } 6/10/2005 BR 33

Remote Interface: Calculator.java package NeedCalculator; import javax.ejb.ejbobject; import java.rmi.remoteexception; public interface Calculator extends EJBObject { public double calc (double cost, double avail) throws java.rmi.remoteexception; } 6/10/2005 BR 34

Session Bean: CalculatorBean.java package NeedCalculator; import javax.ejb.sessionbean; import javax.ejb.sessioncontext; import javax.ejb.createexception; public class CalculatorBean implements SessionBean { private SessionContext context; public double calc (double cost, double avail) { return (cost avail); } public CalculatorBean() {} 6/10/2005 BR 35

CalculatorBean (contd.) public void ejbcreate() throws CreateException { } public void setsessioncontext(sessioncontext context) { this.context = context; } public void ejbremove() { } public void ejbactivate() {} public void ejbpassivate() {} public void ejbpostcreate() {} } 6/10/2005 BR 36

Descriptor (ejb-jar.xml) <ejb-jar> <enterprise-beans> <session> <display-name>calculator</display-name> <ejb-name>calculator</ejb-name> <home>needcalculator.calculatorhome</home> <remote>needcalculator.calculator</remote> <ejb-class>needcalculator.calculatorbean</ejb-class> <session-type>stateless</session-type> <transaction-type>container</transaction-type> <security-identity> <use-caller-identity /> </security-identity> </session> </enterprise-beans> </ejb-jar> 6/10/2005 BR 37

Creating the files Can do it manually using templates of previous applications. Can use JWizard that will automatically generate the XML descriptors. Can use XDocLet which will automatically generate files and regenerate to reflect any changes. Other methods from a integrated development environment such as Sun Studio, and IntelliJ. 6/10/2005 BR 38

Deployment Hot deploy: This is most convenient way to deploy the components. Lets try this with compass example. Create the standard directory structure either manually or using tools. Place the files in the appropriate directories. Start the server or restart the server. If there are errors, correct them, recompile and restart/redeploy. 6/10/2005 BR 39

Web Application to test the NeedCalculator We will write a very simple JSP file called index.jsp that: 1. Resolves the JNDI name from the initial context to create the home directory. 2. Narrows and casts the object reference obtained in the above steps to the home object of the NeedCalculator. 3. Creates the EJbObject representing the remote interface of the Calculator. 4. Invokes the calc method on the reference obtained in step3. 6/10/2005 BR 40

NeedCalculator-war/index.jsp <%@ page import="needcalculator.*" %> <html> <head> <title>need Calculator</title> </head> <body> <% try { javax.naming.initialcontext ctx = new javax.naming.initialcontext(); Object obj = ctx.lookup("java:comp/env/ejb/calculator"); 6/10/2005 BR 41

Web Application (contd.) CalculatorHome home = (CalculatorHome)javax.rmi.PortableRemoteObject.narrow(ob j, CalculatorHome.class); %> Calculator needcal = home.create(); double d= needcal.calc(10000, 5000); out.println("your Need is = $" + d); <br>thank you.your need has been calculated.<br><br> <% %> } catch (Exception e) { <br>sorry, unable to calculate need. 6/10/2005 BR 42

WEB-INF/web.xml <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <ejb-ref> <description>calculator session bean</description> <ejb-ref-name>ejb/calculator</ejb-ref-name> <ejb-ref-type>session</ejb-ref-type> <home>needcalculator.calculatorhome</home> <remote>needcalculator.calculator</remote> </ejb-ref> 6/10/2005 BR 43

JNDI Names This application uses ejb-refs so that clients can always locat the ejb under the java:comp/env environment naming context (ENC). The jrun-web.xml file maps the ejb-ref-name to the actual JNDI location. Clients can then lookup the EJB using either the actual JNDI location or java:comp/env/*ejb-ref-name* If there is no tags corresponding to ejb-ref then lookup will be to the actual name Calculator of the java naming service. 6/10/2005 BR 44

JNDI Names (contd.) Java:jndiname java comp env ejb jdbc jms Ejbs Data sources java:comp/env/ejb/calculator java:comp/env/jdbc/compass java:comp/env/jms/newsqueue Message queues + topics 6/10/2005 BR 45