Application Servers

Session 4 – Main Theme JEE and .Net OMA Implementations (Part 1)

Dr. Jean-Claude Franchitti

1

Icons / Metaphors

Information

Common Realization

Knowledge/Competency Pattern

Governance

Alignment

Solution Approach

22 Servers Architectures (Evolution)

ƒ Traditional client-server technology ƒ CGI frameworks ƒ Page-based extended HTML environments ƒ Distributed object computing platforms ƒ Java-Based ƒ Object Management Architectures (OMAs) ƒ Component-based computing environments ƒ Web Services platforms ƒ Next generation application servers (reflective, multimedia- and agent enabled, MDA-compliant, etc.)

3

Web Application Servers Architectures (Page-Based Extended HTML Environments Details) ƒ Application Servers for Enhanced HTML (traditional) ƒ a.k.a., Page-Based Application Servers ƒ Tag-Oriented (e.g., ColdFusion 5.0 Server) ƒ Script Oriented (e.g., Microsoft IIS with ASP, PHP) ƒ Mostly Used to Support Standalone Web Applications ƒ Typically less expensive than standalone and IDE-based servers ƒ HTML-based development ƒ New Generation Page-Based Script-Oriented App. Servers ƒ First Generation Extensions (e.g., Microsoft IIS with COM+/ASP) ƒ Servlet/JSP Environments ƒ XSP Environment ƒ Can now be used as front-end to enterprise applications ƒ Hybrid development environments 4 Web Application Servers Architectures (Beyond Page-Based Extended HTML Environments Details) ƒ Distributed Object Computing Platforms ƒ Provide an infrastructure for distributed communications enabling ƒ Still need to merge traditional web-oriented computing with object computing ƒ Object Management Architectures ƒ DOC Platform + to reusable services and facilities ƒ OMAs + Component Models -> JEE, CCM, DNA, ASP/.Net

5

CORBA OMA Services

ƒ Activation Services ƒ CORBA POA ƒ CORBA Lifecycle ƒ Naming Service ƒ CosNaming ƒ Directory and Trading Services ƒ CosTrading ƒ Object Transaction Service (OTS) ƒ Messaging Services ƒ CORBA Event Service ƒ CORBA Notification Service

6 Traditional Web and Client Application Services

ƒ Activation Services ƒ Client: MIME Handler, and Applet Activation ƒ : File-Stream, Process, Script Engine, Servlet, JSP, and EJB Activation ƒ Naming and Directory Service ƒ DNS and Java-Based DNS Interfacing ƒ NIS, NDS, LDAP ƒ Custom Transaction Services ƒ Based on Encina, Tuxedo, etc. ƒ Custom Messaging Services ƒ TIBCO ƒ MQSeries

7

Agenda

11 TowardsTowards Microsoft’sMicrosoft’s .Net.Net ComponentComponent ModelModel

22 TowardsTowards Sun’sSun’s JEEJEE ComponentComponent ModelModel

33 eXtensibleeXtensible ServerServer PagesPages (XSP)(XSP) EnvironmentEnvironment

44 ConclusionConclusion

8 Microsoft (Logical Architecture)

9

Microsoft Active Platform (Features) ƒ Logically centralized architecture ƒ Physically de-centralized architecture ƒ Scripting ƒ Client-Side: Improved and data validation ƒ Server-Side: Business rules and data access ƒ VBScript and JavaScript built-in support ƒ PerlScript support via ActiveX scripting engine (e.g., ActiveState’s) ƒ Ability to mix scripting languages ƒ Active Server Components ƒ Provide OS services to ASPs ƒ Encapsulate business rules to ease programming ƒ e.g., TextStream Component (FileSystem object)

10 Microsoft Active Platform (Physical Architecture)

11

Microsoft IIS - COM+/.Net - ASP ƒ IDE: ƒ Visual InterDev (ASP) ƒ Management of site development process / Scripting ƒ Alternative IDEs ƒ Macromedia Drumbeat, Ultradev, Dreamweaver ƒ NetObjects Fusion ƒ Microsoft FrontPage 2000 ƒ Adobe GoLive ƒ Visual Studio .Net ƒ Server Platforms ƒ /NT ƒ Use ChiliSoft (now Sun’s/Oracle’s) for other platforms ƒ Platforms: Solaris, Linux, AIX, HP-UX, Windows ƒ Immunity from current IIS attacks ƒ e.g., Code red worms on Win 2000 ƒ Web Server: Apache, iPlanet ƒ Chili!Beans support for Java ƒ Similar to Microsoft with COM+ & ASP for ++ 12 Microsoft IIS - COM+/.Net - ASP

ƒ COM+ / ASP ƒ Equivalent to JEE EJB / JSP ƒ Included in 2000 Advanced Server ƒ COM+ ƒ Attributes (declare what runtime services are needed by the component) ƒ Threads and connection pools (access via Active Data Object API) ƒ ASP Object Model sub-systems ƒ HTTP request ƒ COM+ transaction ƒ External COM+ components ƒ Other solution components: ƒ Visual Studio 6.0-8.0 / .Net ƒ Internet Security and Acceleration Server (ISA) ƒ static content caching, fault tolerance, load balancing, request handling

13

Win32 Services

ƒ Win32 executable that satisfy several properties ƒ Lifetime is controlled by the Service Control Mgr (SCM) ƒ Service is registered with SCM, and understands and obeys SCM commands ƒ Service has its own login session or shares one with another service ƒ Service runs as a user or local system and abides to applicable security ƒ Service implements a set of service-specific functions ƒ Starting up, message handler, communication back to SCM

14 Microsoft (Logical Architecture)

15

Distributed InterNet Applications Architecture (DNA)

16 DNA OMA Services

ƒ Activation Services ƒ DCOM Activation Framework ƒ Naming and Directory Service ƒ DCOM Class and Object Naming (i.e., CLSIDs, ProgIDs, and Monikers) ƒ Trading Service ƒ Microsoft Active Directory ƒ Transaction Service ƒ COM+ MTS ƒ Messaging Service ƒ COM+ MSMQ

17

COM+ = DCOM/COM + MTS http://members.tripod.com/gsraj/misc/ejbmts/ejbmtscomp.html

18 COM+ Services

ƒ COM+ Catalog (v.s. Windows Registry) ƒ COM+ Load Balancing ƒ COM+ In-Memory Database (IMDB) ƒ COM+ Object Pooling ƒ COM+ Queued Components ƒ COM+ Events ƒ C++ Compiler Changes

19

DCOM Class and Object Naming (file moniker file: bind)

20 DCOM Class and Object Naming (url moniker http:, ftp:, gopher: bind)

21

DCOM Class and Object Naming (class moniker clsid: bind)

ƒ Display name for class monikers: display-name = "CLSID:" string-clsid-no-curly-braces *[";" clsid-options] ":" clsid-options = clsid-param "=" value clsid-param = none currently defined

ƒ C++ example (tell moniker to use an object that can read a document instead of the document itself): ProgIDFromCLSID( &clsid, "xyz.activator.1") CreateClassMoniker( clsid, &pmkClass ) MkParseDisplayName( pcb, "\\northamerica\central\employee.doc", &dwEaten, pmkFile ) pmkFile->BindToObject( pcb, pmkClass, IID_IDispatch, &pDisp )

22 Trading Service - Active Directory http://www.microsoft.com/windows2000/server/evaluation/features/dirlist.asp

23

COM+ Catalog vs. Windows Registry

ƒ Stores COM+ application attributes, class attributes, and computer-level attributes ƒ Guarantees consistency among attributes ƒ Provide common operations on top of attributes ƒ Two different stores ƒ COM+ registration database ƒ Microsoft Windows Registry (HKEY_CLASSES_ROOT) ƒ COM components that do not require new COM+ services ƒ Type library ƒ Interface proxy/stub registration ƒ Unified logical view via COM+ Admin Library

24 COM+ Load Balancing

25

COM+ IMDB

26 COM+ Queued Components

27

COM+ Events

28 C++ Compiler Changes

ƒ Sample Attributes: ƒ in/out direction of parameter in a method ƒ threading model ƒ component housing (i.e., DLL or EXE)

29

Creating an MTS Component

ƒ Example:

try {

// create the MTS component bank.IChecking server= (bank.IChecking) new bank.Checking ();

// invoke business methods on the component server.createAccount (1234, "Athul", 1000671.54d); } catch (Exception ex) { ex.printStackTrace (); }

30 .NET Framework

ƒ Common Language Runtime (CLR) ƒ Accessible to any compiler that produced Microsoft Intermediate Language (IL) code ƒ Runtime Classes ƒ Visual Studio.Net (VS.Net) ƒ Includes VB.Net, VC.Net (C#), and Visual C++.Net

31

.Net Remoting (http://www.dotnetremoting.cc/)

ƒ Native .Net Remote Object Invocation ƒ Allows Object Invocation and Communications Across Processes and Machines ƒ Wire Protocol and Format Independent ƒ Extensible via Custom Formatters (SOAP, Binary, etc.), Channels (HTTP, TCP, etc.), and Sink Chain (i.e., Channels + Formatters) Steps ƒ Flexible as Configuration can be Changed after Deployment with Little or no Code Changes ƒ Flexible (IIS not required on server) but more Complex than Web Services

32 .Net Remoting Vs. DCOM

ƒ Not as Transparent as DCOM ƒ Has no COM Interop Involved ƒ Offers More Deployment Options ƒ Not Tied to a Specific Wire Protocol or Format ƒ Firewall Friendly ƒ Allows you to Specify which Objects are Remoted

33

.Net CLR and COM+

ƒ CLR Introduces a Newer and Easier Programming Model for COM+ ƒ The COM+ Services are still Available only at the OS/Unmanaged World ƒ Transitions Between Managed/Unmanaged Layers are Taken Care of by “System.EnterpriseServices” Namespace ƒ System.EnterpriseServices.ContextUtil class provides access to contexts (as did CoGetObjectContext) ƒ Services are Made Available to Components Using Attributes 34 .NET, Win32, COM, and COM+

ƒ .Net applications can call functions that reside in Win32 DLLs via the DllImport attribute of System.Runtime.InteropServices’ platform invocation (PInvoke) services ƒ .Net applications can call traditional COM components using Runtime Callable Wrappers (RCWs) which uses interop assemblies (i.e., .Net components) created via COM Interop using the TLBIMP utility ƒ COM+ services (transactions, object pooling, JIT activation) can be used from .Net (via System.EnterpriseServices namespace) ƒ .Net runtime uses COM+ to support some of its services (e.g., transactions for managed classes)

35

ContextUtil Class

ƒ Useful Static Members ƒ ActivityId ƒ IsSecurityEnabled ƒ TransactionId ƒ DesactivateOnReturn ƒ MyTransactionVote ƒ Rich Set of Member Functions ƒ SetComplete ƒ SetAbort ƒ EnableCommit ƒ DisableCommit ƒ IsCallerInRole ƒ GetNamedProperty

36 .Net and ServicedComponent

ƒ COM+ Class Derives from “ServicedComponent” [ComVisible(true)] [ObjectPooling(MinPoolSize=2, MaxPoolSize=5)] [Guid(“57F01F20-9C0C-4e63-9588-720D5D537E66)] [Transaction(TransactionOption.Required)] public class SVCCompClass : ServicedComponent ƒ In COM+ 1.0, the List of Services Are not Changed ƒ In COM+ 1.5 (Microsoft Windows XP Professional and .Net server), Newer Services are Available to Leverage CLR Features

37

Agenda

11 Microsoft’sMicrosoft’s PrePre .Net.Net ComponentComponent ModelModel

22 TowardsTowards Sun’sSun’s JEEJEE ComponentComponent ModelModel

33 eXtensibleeXtensible ServerServer PagesPages (XSP)(XSP) EnvironmentEnvironment

44 ConclusionConclusion

38 JEE Platform: The Whole is Greater than the Sum of its Parts

39

JEE: A Complete Computing Environment

ƒ Platform Specification ƒ Lists required elements of the platform ƒ Lists policies to follow for a valid implementation ƒ Reference Implementation ƒ Semantically correct prototype to test against ƒ Compatibility Test Suite ƒ API-level compatibility, component-level tests, end-to-end compatibility ƒ Application Programming Model: ƒ http://java.sun.com/javaee/index.jsp

40 JEE Features

ƒ Standard Documents and Software Libraries ƒ Specification ƒ Programming Model ƒ Platform ƒ Reference Implementation ƒ Compatibility Test Suite ƒ http://java.sun.com/javaee/

41

The Three Cs: Components, Containers, Connectors

42 JEE: Components

ƒ Enterprise JavaBeans ƒ Server-side solutions can be built without regards for the database, transaction server, or application they run on ƒ Servlets ƒ Run on vast majority of web servers ƒ JavaServer Pages ƒ Dynamic content leverages off the full power of Java

43

JEE: Containers

ƒ Containers provide high-performance, scalable environments for JEE-enabled servers ƒ JEE-enabled servers support EJB-based components, servlets, and JSP-based pages

44 JEE: Connectors

ƒ Connectors allow JEE-based solution to preserve, protect, and leverage off of existing enterprise investments

45

JEE: Unifying the Three Cs

ƒ Single platform ƒ Standard platform-independent technology ƒ Applications built with components can be run on any JEE server, and are able to talk to enterprise- class systems that exist today

46 JEE Server and Containers

47

Distributed Multi-tiered Applications

48 Server Communications

49

Web Tier and JEE Application

50 Web Tier and JEE Application

51

Business and EIS Tiers

52 Servlets Technology (http://java.sun.com/products/servlet/index.jsp, http://java.sun.com/products/jsp/)

ƒ Java’s standard mechanism for writing code that runs and extends the functionality of a servlet engine ƒ A servlet is to a server what an applet is to a browser ƒ HTTP servlets ƒ Replacement for CGI ƒ Standard mechanisms for handling cookies, sessions, session/application contexts ƒ Advantages over CGI: performance, platform and web-server independance ƒ Servlet filters are new in the Java Servlet Specification 2.3 (2.5 is latest spec)

53

JSP Technology (http://java.sun.com/products/jsp/)

ƒ Answer to Microsoft’s ƒ Provide mechanism for including tags/scriptlets into an HTML or XML page ƒ JSPs have .jsp extension and are processed using a special servlet ƒ JSP page is compiled into a servlet upon first access or after each modification ƒ Ability to instantiate and access JavaBeans within JSP pages

54 Introduction to Servlets and JSPs

ƒ See http://www.java-shop.com/jsp.htm ƒ Servlets (http://java.sun.com/products/servlet/index.jsp) ƒ Java’s standard mechanism for writing code that runs and extends the functionality of a servlet engine ƒ A servlet is to a server what an applet is to a browser ƒ HTTP servlets ƒ Replacement for CGI ƒ Standard mechanisms for handling cookies, sessions, session/application contexts ƒ Advantages over CGI: performance, platform and web-server independance ƒ Servlet filters are new in the Java Servlet Specifiation 2.3 ƒ Java Server Pages (http://java.sun.com/products/jsp/) ƒ Answer to Microsoft’s Active Server Pages ƒ Provide mechanism for including tags/scriptlets into an HTML or XML page ƒ JSPs have .jsp extension and are processed using a special servlet ƒ JSP page is compiled into a servlet upon first access or after each modification ƒ Ability to instantiate and access JavaBeans within JSP pages

55

Servlets and JSPs Examples

ƒ JSP displaying a banner image based on who is referring the user to the site: <%@ page import="com.ibm.jspredbook.*;” errorPage="error.jsp" %> ">

56 Servlets and JSPs Examples (continued)

ƒ Servlet referenced in the IMG tag of the previous slide (partial): package com.ibm.projsp; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import java.io.*; public class ImageServlet extends HttpServlet { private String docHome = "."; public void service( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); ServletConfig config = getServletConfig(); ServletContext application = config.getServletContext(); File file = findFile(request, response); if (file == null) { return; } else { response.setContentType(application.getMimeType(file.getName())); response.setContentLength((int) file.length()); sendFile(file, response); } } 57

Catalog of Patterns (www.martinfowler.com/eaaCatalog) ƒ Domain Logic Patterns (e.g., Service Layer) ƒ Data Source Architectural Patterns ƒ e.g., Data Mapper ƒ Object-Relational Behavioral Patterns ƒ e.g., Unit of Work ƒ Object-Relational Structural Patterns ƒ e.g., Inheritance Mappers ƒ Object-Relational Metadata Mapping Patterns ƒ e.g., Repository ƒ Web Presentation Patterns ƒ e.g., MVC, Application Controller ƒ Distribution Patterns (e.g., Remote Façade, DTO) ƒ Offline Concurrency Patterns (e.g., Implicit lock) ƒ Session State Patterns (e.g., Server Session State) ƒ Base Patterns (e.g., record set, value object) 58 MVC Pattern Splits user interface interaction into three different roles

59

MVC Review http://java.sun.com/blueprints/patterns/index.html

ƒ MVC architecture decouples the code to handle user actions (controller), the data and business logic (Model), and the presentation (View)

60 MVC or Model 2 Design Pattern

ƒ Used to implement Modern Web Applications as a combination of ƒ Servlets/Servlet filters ƒ Controller receiving/filtering requests from the user ƒ Updates the application’s model composed of JavaBeans ƒ Passes the page request to a view JSP ƒ Java Server Pages ƒ Display information based on the current state of the application’s model ƒ JavaBeans ƒ Enable component reuse ƒ Custom Tag Libraries ƒ Make it possible to move out of the JSP where it is difficult to maintain and into reusable JavaBeans ƒ Rich array of Java APIs ƒ See http://www.mhsoftware.com/resources/iisjserv.html for a comparison of IIS/ASP and Servlet/JSP technology

61

Implementing the “V” of “MVC” Using JSPs

ƒ When the view is implemented as a JSP, the controller object (e.g., servlet) forwards processing of the request and the response to a JSP view ƒ Controller adds a reference to the model object to the user’s session or request object ƒ JSP gets a handle on the model object and constructs the HTML or other markup to be returned to the client

62 Implementing the “V”of “MVC”Using JSPs (continued)

63

Architectural Considerations

ƒ Page-Centric v.s. Dispatcher Type ƒ Page-Centric architectures have a JSP handling the request directly ƒ Dispatcher architectures include a Servlet that handles the request and delegates to a JSP ƒ Sample architectural patterns: ƒ Page-View (Page-Centric) ƒ Page-View with Bean (Page-Centric) ƒ Mediator-View (Dispatcher) ƒ Mediator-Composite View (Dispatcher) ƒ Service-to-Workers (Dispatcher)

64 Servlet / JSP Engines

ƒ Apache + TomCat ƒ http://www.apache.org ƒ Apache + Jrun ƒ http://www.adobe.com/ ƒ Apache + Jetty ƒ http://jetty.mortbay.org/jetty/index.html ƒ Mainstream JEE Applications Servers Come Bundled with an HTTPD service and Servlet/JSP engines

65

Application Controller Pattern

66 Data Transfer Object Pattern object that carries data between processes to reduce the number of calls

67

Remote Facade Pattern provide coarse-grained object façade to optimize network usage

68 Enterprise JavaBeans (EJBs)

ƒ Enterprise Application Platforms: ƒ Provide model for the development and deployment of reusable Java server components ƒ Support component modeling ƒ Handle the serving of EJBs ƒ Next Steps: ƒ “Model-Centric” Application Development

69

Enterprise JavaBeans Container

70 Enterprise JavaBeans and Services

Application Server Container Services Lifecycle Transaction Security Load Balancing Error Handling Threading Enterprise Java Persistence* Bean

* In the EJB 1.0 specification support for persistence services is optional. In the EJB 1.1 specification it is mandatory.

71

Sample DemoBean Application Architecture

72 Entity Beans in EJB Application Servers

ƒ Represent sets of data (all or part of a database table or a view) ƒ Functionality limited to creation, update, and deletion of data ƒ Manage persistence of data ƒ Maintained in a cache ƒ Can be container or bean managed ƒ Container-managed beans are under the control of an for persistence and transaction management ƒ Container-managed beans are restricted in the type and complexity of data they can manage ƒ Bean-managed beans rely on user provided code for persistence and transaction management

73

Session Beans in EJB Application Servers

ƒ Handle the business logic of EJB applications ƒ May use multiple entity beans to gather application data

74 Session and Entity Beans

Application Server

ct ra Account bt Up Su 00 Entity Bean dat Transfer $100 from $1 e A cco Account A to Account B ATM A unt

Session A t d un d co Database Bean $ Ac 1 e 0 at 0 pd Account U Entity Bean B

75

EJB Physical Partitioning

Web Web Web A Domain Name System (DNS) Browser Browser Browser server routes incoming browser requests evenly across a pool of web servers. This technique is referred to as DNS round-robining. The application server provides fail-over if one of the web servers goes down. Web Web Web Server Server Server The application server distributes load across all available EJB servers and provides fail-over if one of the EJB servers goes down. EJB EJB EJB Server Server Server

EJBs communicate to the database through Java Database Connectivity (JDBC). The application server pools and Database manages database connections for maximum efficiency.

76 EJB Component/Programming Model

77

Creating an EJB Component

ƒ Example: try {

// get the JNDI naming Context initialCtx = new InitialContext ();

// use the context to lookup the home interface CheckingHome home = (CheckingHome) initialCtx.lookup ("checking");

// use the home interface to create the enterprise Bean Checking server = home.create ();

// invoke business methods on the bean server.createAccount (1234, "Athul", 1000671.54d); } catch (Exception ex) { ex.printStackTrace (); }

78 JEE Integration Services

79

Oracle’s BEA WebLogic Application Server

80 JEE OMA Services

ƒ Activation Services ƒ RMI Activation Framework ƒ http://docstore.mik.ua/orelly/java-ent/jenut/ch14_01.htm ƒ JavaBeans Activation Framework ƒ Naming and Directory Service ƒ JNDI and JNDI SPIs for CosNaming, RMI, NIS, NDS, LDAP ƒ Trading Service ƒ Jini ƒ JTA and JTS* ƒ Messaging Services* ƒ JMS ƒ JavaMail

81

Agenda

11 Microsoft’sMicrosoft’s PrePre .Net.Net ComponentComponent ModelModel

22 TowardsTowards Sun’sSun’s JEEJEE ComponentComponent ModelModel

33 eXtensibleeXtensible ServerServer PagesPages (XSP)(XSP) EnvironmentEnvironment

44 ConclusionConclusion

82 Apache Cocoon http://xml.apache.org/cocoon

ƒ XML based publishing Framework ƒ An Apache Software Foundation open source project ƒ Written in Java, runs mostly as a servlet ƒ Started as a simple servlet based XSL styling engine for http://www.apache.org site ƒ Current version is in the second generation of evolution ƒ Designed for scalability ( uses SAX processing ) -- can process huge documents using small amount of memory

83

Apache Cocoon (continued)

ƒ Cocoon promotes the separation of Content, Logic, Presentation and Management in web-site design.

84 Cocoon 2

ƒ Web Publishing framework implemented as a servlet ƒ Requires a servlet engine to operate ƒ Cocoon 2 has been re-architected to truly support the MVC pattern ƒ Cocoon processor: ƒ Cocoon Java type that takes a DOM tree as an input and produces another ƒ Cocoon producer: ƒ Cocoon Java type used to feed the initial XML content to the Cocoon processing pipeline ƒ e.g., Cocoon serves static XML documents using its built-in FileProducer ƒ Cocoon processing instructions act upon a whole document, which generates a result document ƒ ƒ Result document is passed to the next Cocoon processor ƒ Similar to servlet chaining ƒ Alternatives: Rocket, and CPan’s

85

Cocoon Servlet Directories & Files

Directory for auto mounting sub-sitemaps

Cocoon Configuration file

A sub-sitemap directory

Main sitemap file

Directory for log files

86 Cocoon Sitemap

ƒ Sitemap Goal » Used to de-couple the exposed URI space from the actual location of resources » Allows easily changeable specification of processing steps ƒ Sitemap Contents » Component declarations • generators, transformers, serializers, ... » Resource declarations • named collection of pipeline components » Pipeline declarations • sequential arrangement of components for processing

87

Cocoon Sitemap (continued)

ƒ A sitemap is an XML file ƒ Sitemaps are hierarchical -- A sitemap can point, explicitly or implicitly, to sub-sitemaps ƒ A sitemap is translated into a java program and is compiled into bytecode ƒ Changes to sitemaps can be loaded dynamically and asynchronously

88 Cocoon Request Processing

ƒ Request is dispatched to matching pipeline ƒ Basic pipeline operation ƒ The generator generates XML content ƒ Zero or more transformers transform the content ƒ The serializer writes it to the output stream ƒ Different Kinds of generators ƒ File, Directory, XSP, JSP, Stream, … ƒ Different Kinds of transformers ƒ XSLT, I18N, Log, … ƒ Different Kind of Serializers ƒ HTML, XML, Text, PDF, SVG, ...

89

Cocoon Processing Mechanisms http://cocoon.apache.org/2.1/userdocs/concepts/index.html

ƒ Dispatching based on Matchers.

ƒ Generation of XML documents (from content, logic, relational DBMS, objects or any combination) through Generators

ƒ Transformation (to another XML, objects or any combination) of XML documents through Transformers

ƒ Aggregation of XML documents through Aggregators

ƒ Rendering XML through Serializers

90 Sample Cocoon Pipeline

91

Dynamic Content Generation from XSP

ƒ Document root element must be: ƒ ƒ All language and Taglib declarations must appear as attributes in the root element tag: ƒ e.g., ƒ Note: Minimal JSP page is an HTML document 94 XSP Example

ƒ XSP logic tag: . . .

Good String timeOfDay = ( new SimpleDateFormat("aa") ).format(new Date());

if (timeOfDay.equals("AM")) { Morning } else { Afternoon } !

. . . ƒ May be rephrased using a library tag as: ...

Good !

... 95

XSP v.s. JSP

ƒ XSP ƒ Tailored to maximize code reuse ƒ Allows separation of content from presentation ƒ Developers handle content generation (content can static or generated via servlets or Java code) ƒ XML/XSL authors handle style/presentation via style sheet modifications ƒ As XSP processing occurs prior to styling, the content can be presented in various ways ƒ Keep development teams well isolated ƒ Can use IBM's Bean Scripting Framework (BSF) to support other scripting languages in addition to Java ƒ JSP ƒ Popular and widely understood ƒ Requires tight collaboration between application developers and presentation designers ƒ At best presentation designers must understand how to use tag libraries

96 Using Cocoon as a Presentation Framework for Web-Services www.pankaj-k.net/sdwest2002/Cocoon-FWS.ppt

WS Registry

Cocoon

Web Services Servlet Container

Client Tier Web Tier Enterprise Apps

97

Cocoon as a Processing Framework for Web Services (continued)

WS Registry

Cocoon Servlet Container

Web Services

P

P

2 1 Client Tier Web Tier Enterprise Apps

98 Sample Implementation

ƒ Use Google Web Services API from http://www.google.com/apis to create a simple web application that accepts a search string from user and displays the list of result entries. ƒ Sample is based on the XSP contributed by Ugo Cei in Cocoon-dev mailing list ƒ Application components: ƒ sitemap.xmap -- Sitemap for this application ƒ index.html -- HTML file to accept search string ƒ google.xsp -- XSP file that makes the SOAP call to Google using SOAP logicsheet. ƒ search-results.xsl -- XSL stylesheet to transform SOAP response from Google Web Service to HTML page ƒ Downloadable from: ƒ http://www.pankaj-k.net/sdwest2002/google.zip

99

Application Architecture

Browser Cocoon Servlet Google WS

http:///cocoon/mount/google/ Maps request to index.html index.html

…/search?q=... SOAP request

SOAP response executes google.xsp Search results in HTML Applies search-results.xsl

100 Agenda

11 LegacyLegacy Page-BasedPage-Based ApplicApplicationation ServerServer TechnologyTechnology

22 DistributedDistributed ObjectObject ComputingComputing ConceptsConcepts

33 ObjectObject ManagementManagement ArchitectureArchitecture

44 ConclusionConclusion

101

Summary – Key Application Server Objectives ƒ Microsoft IIS - COM+/.Net - ASP is a Page-Based Script- oriented application server ƒ COM+/.Net and ASP are “equivalent” to JEE EJB and JSP ƒ Servlets are more efficient than traditional CGI approaches, and are not subject to the issues that arise from in-process approaches (ISAPI, NSAPI, fast-CGI, etc.) ƒ JSPs allow custom tags and Java scriptlets within HTML pages ƒ JSPs are a first step towards separation of content/presentation. True separation using that component model requires discipline ƒ Cocoon2 is a web publishing framework implemented as a servlet ƒ XSP is a core technology available in Cocoon 2 that allows true separation of content/style/logic 102 Class Project

ƒ Project Description ƒ The project focus is two-fold: ƒ Based on a framework-based enterprise application of your choice, you will implement common facilities and application-level services on top of various types of application server technologies to support the various aspects of your chosen application ƒ As you transition from one platform to another you will study and develop model-based migration and interoperability tools that leverage off of the cutting- edge concepts subsumed by modern Model Driven Architectures (MDAs)

103

Assignments & Readings

ƒ Readings ƒ Handouts posted on the course Web site ƒ Explore the Microsoft IIS - COM+/.Net - ASP, TomCat, JRun, and Cocoon 2/XSP Environments ƒ Read white papers/documentation at: ƒ http://www.javaworld.com/javaworld/jw-02-2001/jw-0209- xmlj2ee.html ƒ http://xml.apache.org/cocoon/ ƒ http://www.alphaworks.ibm.com/tech/bsf ƒ Also read Microsoft IIS, TomCat, JRun, and Cocoon 2 related whitepapers on the vendor sites ƒ Modeling and Analysis of Software Architectures ƒ XADL 2.0: http://www.isr.uci.edu/projects/xarchuci/ ƒ http://www- 2.cs.cmu.edu/~able/talks_online/icse99_tutorial/ppframe.htm 104 Assignment

ƒ Assignment #2 (Ongoing): ƒ #2a: Investigate distributed object computing platforms’ development environments for the technologies covered in this session. Write a short report that documents your findings and recommendations with respect to selection criteria in support of development environments for application server technologies covered in this session ƒ #2b: See homework #2 specification

105

Project Related Frameworks

ƒ Project Frameworks Setup (ongoing) ƒ Apache Web Server (www.apache.org) ƒ Perl (www.perl.com) ƒ Microsoft IIS with COM+/.Net and ASP ƒ Apache Tomcat ƒ Adobe JRun4 ƒ Apache Cocoon 2/XSP

106 Next Session: JEE and .Net OMA Implementations (Part 2)

107