29
Building Web Building Web Applications With Applications With J2EE J2EE Ohioedge Enterprise Java Solutions Prov Since 1996 By Sandeep Dixit, Partner

Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Embed Size (px)

Citation preview

Page 1: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Building Web Building Web Applications With J2EEApplications With J2EE

Ohioedge Enterprise Java Solutions Provider

Since 1996

By Sandeep Dixit, Partner

Page 2: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

AssumptionsAssumptionsAudience BackgroundAudience Background

Elementary knowledge of J2EE

Currently planning or in the process of building Web applications with J2EE

Page 3: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

AssumptionsAssumptionsAudience ExpectationsAudience Expectations

Want to learn or verify essential concepts of Web application development with J2EE

Want to see live demonstrations of – sample applications– deploying sample applications in J2EE-compliant

application server– how a proper implementation of these concepts results

in robustness, quality, and improved productivity

Page 4: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Today’s AgendaToday’s Agenda

– Origin of J2EE– Mindset for building Web applications– Generalization: J2EE Patterns– Three-tier component: EJB-JavaBean-JSP– XML schema-driven applications– Directory structure: Effective organization of java,

jsp, xml, sql and bat script files– Package structure: Effective grouping of Java and

JSP source code– Live Demonstration of J2eeBuilder Framework &

component plug-in

Page 5: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

J2EE FactsJ2EE Facts

J2EE is not a programming language.

J2EE is a specification for writing enterprise applications (distributed computing)

J2EE specification compliant code is portable between J2EE-compliant application servers.

Page 6: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

1985-19921985-1992

• One programming language for One programming language for building distributed (client-server) building distributed (client-server) applicationsapplications

• IDE for compilation, debugging, IDE for compilation, debugging, execution and file managementexecution and file management

• Procedural programmingProcedural programming

Page 7: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

1990+1990+

• VB brings client-server (distributed) VB brings client-server (distributed) application development application development environment to desktopsenvironment to desktops

• Procedural programmingProcedural programming

• GUI development is more user-GUI development is more user-friendlyfriendly

Page 8: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

1995+1995+

• Java, an OS independent, pure Object-Java, an OS independent, pure Object-oriented, programming language starts oriented, programming language starts gaining groundgaining ground

• Object-oriented programming is more Object-oriented programming is more user friendlyuser friendly

• Java Remote Method Invocation (RMI) is Java Remote Method Invocation (RMI) is made available for distributed computingmade available for distributed computing

Page 9: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

1997+1997+

• Apache Web Server becomes de-Apache Web Server becomes de-facto web serverfacto web server

• Java RMI is further strengthened by a Java RMI is further strengthened by a specification - J2EE specification - on specification - J2EE specification - on how to write an RMI server. how to write an RMI server.

• Developing distributed applications is Developing distributed applications is made more user friendly.made more user friendly.

Page 10: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

1999+1999+

• Servlet/JSP makes HTML-based Web GUI Servlet/JSP makes HTML-based Web GUI a real thing for enterprise applicationsa real thing for enterprise applications

• Object-oriented programming is further Object-oriented programming is further extended into XML definition driven extended into XML definition driven object-oriented programmingobject-oriented programming

• J2EE incorporates XML as the way to J2EE incorporates XML as the way to specify dataspecify data

Page 11: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

2000+2000+

• Enthusiastic software developers Enthusiastic software developers start using J2EE. start using J2EE.

• Container Managed Persistence Container Managed Persistence becomes a realitybecomes a reality

• Methodologies for writing J2EE Methodologies for writing J2EE applications are discovered.applications are discovered.

Page 12: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

2001+2001+

• Various articles, papers, and books on J2EE Various articles, papers, and books on J2EE Patterns, Practices, and Strategies are Patterns, Practices, and Strategies are published and presentedpublished and presented

• Jboss an open-source J2EE 1.3-compliant Jboss an open-source J2EE 1.3-compliant application server is used by more than 1 application server is used by more than 1 Million developers world-wideMillion developers world-wide

• J2EE is free. J2EE is open. J2EE is here to J2EE is free. J2EE is open. J2EE is here to stay.stay.

Page 13: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Mindset for building Web Mindset for building Web applicationsapplications

• Think in terms of “Servicing a request”Think in terms of “Servicing a request”

• For example, a click on a “create” button For example, a click on a “create” button on a “customer” page in a browser is a on a “customer” page in a browser is a request.request.

• Building a Web application requires an Building a Web application requires an approach of handling and processing http approach of handling and processing http requests and sending appropriate requests and sending appropriate responses back to the requestersresponses back to the requesters

ApplicationServer

CRM

Page 14: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Generalization of ServicesGeneralization of Services

• Generalization of how http requests Generalization of how http requests are serviced by presentation-tier, are serviced by presentation-tier, middle-tier, and data-tier results in middle-tier, and data-tier results in a generic, inter-tier dependent, a generic, inter-tier dependent, reusable library of source code - reusable library of source code - J2EE patternsJ2EE patterns

Page 15: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Generalization of ServicesGeneralization of Services

• For an example, the application processing “customer-create” For an example, the application processing “customer-create” request needs to verify if the requester is valid, requester’s request needs to verify if the requester is valid, requester’s session is valid, and license to use application itself is valid. session is valid, and license to use application itself is valid. These validation steps are independent of “customer-create” These validation steps are independent of “customer-create” request and are applicable to any requests such as, “customer-request and are applicable to any requests such as, “customer-delete”, “contact-find”, etc.delete”, “contact-find”, etc.

• This requires that every time a request is received it should be This requires that every time a request is received it should be first passed-on to a “generic validation service” that would either first passed-on to a “generic validation service” that would either permit or deny further servicing of the request. permit or deny further servicing of the request.

• Typically, validation service would get categorized under Typically, validation service would get categorized under “presentation services”. Depending upon the layer where the “presentation services”. Depending upon the layer where the services are called, they would be categorized under either - services are called, they would be categorized under either - presentation, business, or data services.presentation, business, or data services.

Page 16: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Servicing a requestServicing a requestHttp request originates in a browser

Http response ends in the browser

URL

Presentation-tier

Business-tier

Page 17: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

J2EE Patterns: J2EE Patterns: Presentation-tierPresentation-tier

• Front Controller Front Controller

• View HelperView Helper

• Composite ViewComposite View

• Service To Service To WorkerWorker

• Dispatcher Dispatcher ViewView

Page 18: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Brief overview of Brief overview of Presentation-tier patternsPresentation-tier patterns

• Front Controller: Provides a centralized controller for Front Controller: Provides a centralized controller for managing the handling of a requestmanaging the handling of a request

• View Helper: Encapsulates logic that is not related to View Helper: Encapsulates logic that is not related to presentation formatting into Helper componentspresentation formatting into Helper components

<servlet-mapping> <servlet-name>TheViewController</servlet-name> <url-pattern>*.ctrl</url-pattern> </servlet-mapping>

Page 19: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Brief overview of Brief overview of Presentation-tier patternsPresentation-tier patterns

• Dispatcher View: Similar to Service To Worker; Dispatcher plays a limited Dispatcher View: Similar to Service To Worker; Dispatcher plays a limited role in the processing of requests - Dispatcher plays limited to moderate role in the processing of requests - Dispatcher plays limited to moderate role in view management. role in view management. – Limited roleLimited role: No outside resources are utilized in order to choose the view. The information : No outside resources are utilized in order to choose the view. The information

encapsulated in the request is sufficient to determine the view to dispatch the request. For encapsulated in the request is sufficient to determine the view to dispatch the request. For example: http://my.server.com/myContextRoot/Controller?next=example: http://my.server.com/myContextRoot/Controller?next=login.jsplogin.jsp

– Moderate roleModerate role: The information contains an action to be completed: : The information contains an action to be completed: http://my.server.com/myContextRoot/Controller?action=http://my.server.com/myContextRoot/Controller?action=login login The responsibility of the The responsibility of the dispatcher component here is to translate the logical name ‘login’ into the resource name of an dispatcher component here is to translate the logical name ‘login’ into the resource name of an appropriate view, such as ‘login.jsp’, and dispatch to that view. To accomplish this translation, appropriate view, such as ‘login.jsp’, and dispatch to that view. To accomplish this translation, the dispatcher may access resources such as an XML configuration file that specifies the the dispatcher may access resources such as an XML configuration file that specifies the appropriate view to display.appropriate view to display.

• Service To Worker: Combines a Dispatcher component with the Front Service To Worker: Combines a Dispatcher component with the Front Controller and View Helper patterns - Dispatcher plays Controller and View Helper patterns - Dispatcher plays moderate to large moderate to large role role in view management. Dispatcher is more sophisticated. The dispatcher in view management. Dispatcher is more sophisticated. The dispatcher may invoke a business service to determine the appropriate view to display. may invoke a business service to determine the appropriate view to display.

– For example: http://my.server.com/myContextRoot/For example: http://my.server.com/myContextRoot/Customer.ctrlCustomer.ctrl?submit=?submit=SetSet

Page 20: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Service To WorkerService To Worker

URL

Business-tier

Page 21: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Processing the requestProcessing the request

URL

ServiceLocator

ValueObject

Requests EJB/Business Service Locates

Business Service

EJB BusinessDelegate

Page 22: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

J2EE Patterns: J2EE Patterns: Business-tierBusiness-tier

• Business DelegateBusiness Delegate

• Value ObjectValue Object

• Session FaçadeSession Façade

• Composite EntityComposite Entity

• Value Object AssemblerValue Object Assembler

• Value List HandlerValue List Handler

• Service LocatorService Locator

Page 23: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Brief overview of Brief overview of Business-tier patternsBusiness-tier patterns

• Business Delegate: De-couples presentation and Business Delegate: De-couples presentation and service tiers, and provides a façade and proxy service tiers, and provides a façade and proxy interface to the services. interface to the services.

• Value Object: Facilitates data exchange between EJB Value Object: Facilitates data exchange between EJB and BusinessDelegateand BusinessDelegate

• Value List Handler: Manages query execution, results Value List Handler: Manages query execution, results caching, and results processing.caching, and results processing.

• Service Locator: Encapsulates complexity of business Service Locator: Encapsulates complexity of business service lookup and creation; locates business service service lookup and creation; locates business service factories.factories.

Page 24: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

J2EE Patterns for Servicing J2EE Patterns for Servicing RequestsRequests

• Front Controller Front Controller

• View HelperView Helper

• Composite ViewComposite View

• Service To Service To WorkerWorker

• Dispatcher Dispatcher ViewView

• Business DelegateBusiness Delegate

• Value ObjectValue Object

• Session FaçadeSession Façade

• Composite EntityComposite Entity

• Value Object Value Object AssemblerAssembler

• Value List HandlerValue List Handler

• Service LocatorService Locator

• Service ActivatorService Activator

• Data Access ObjectData Access Object

Business-tierPresentation-tier Data-tier

Page 25: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Directory StructureDirectory Structure

• Source CodeSource Code• ScriptsScripts• J2EE Specification CodeJ2EE Specification Code

– ejb.xmlejb.xml– web.xmlweb.xml– application.xmlapplication.xml

• J2EE Application Specific CodeJ2EE Application Specific Code– jboss.xmljboss.xml– jboss-web.xmljboss-web.xml

• Java/Jar Specific CodeJava/Jar Specific Code– manifest.mfmanifest.mf

Page 26: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Package StructurePackage Structure

• Business Functionality codeBusiness Functionality code

– extends framework codeextends framework code

• Framework codeFramework code

– implementation of patternsimplementation of patterns

Page 27: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

J2eeBuilder FrameworkJ2eeBuilder Framework

• Demonstration of a frameworkDemonstration of a framework

– Implementation of patternsImplementation of patterns

– Session ManagementSession Management

– User ManagementUser Management

– License ManagementLicense Management

– j2eebuilder-config.xmlj2eebuilder-config.xml

• Demonstration of plugging-in a “product” Demonstration of plugging-in a “product” component into the frameworkcomponent into the framework

Page 28: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

SummarySummary

• J2EE is Java, EJB specification, Servlet, JSP, Html, and XMLJ2EE is Java, EJB specification, Servlet, JSP, Html, and XML

• Use open-source software such JDOM, LOG4J, Apache Web Server, Use open-source software such JDOM, LOG4J, Apache Web Server, Tomcat Servlet Container, and JBoss Application ServerTomcat Servlet Container, and JBoss Application Server

• Document your architecture, data-structure, functional scope, Document your architecture, data-structure, functional scope, directory structure, and package structure, before launching a full-directory structure, and package structure, before launching a full-scale developmentscale development

• Understand key concepts. Learn to Understand key concepts. Learn to do-it by hand do-it by hand using simple using simple TextPad before using IDEs.TextPad before using IDEs.

• Keep it J2EE compliant. Avoid getting locked into any vendor specific Keep it J2EE compliant. Avoid getting locked into any vendor specific technology.technology.

• You build a generic framework and robustness, quality and You build a generic framework and robustness, quality and productivity will come.productivity will come.

Page 29: Building Web Applications With J2EE Ohioedge Enterprise Java Solutions Provider Since 1996 By Sandeep Dixit, Partner

Q & AQ & A