4 Introduction to Java Platform-independent programming language Used to createrobust and secure applications, which can run onsingle computer or can be distributed among servers and clients4 aspects of JavaJava Programming Language (JDK)Java Runtime Environment (JRE)Java Virtual Machine (JVM)Java Platform
5 Java Programming Language An object oriented languageSyntax is similar to C, C++Fulfills following primary goals of object oriented language:Uses the object-oriented methodologyAllows the same program to be executed on multiple operating systemsContains built in support for using computer networksExecutes code securely from remote sourcesIt is widely used standard in enterprise programming
6 Java Runtime Environment (JRE) Also known as Java RuntimePart of Java Development Kit (JDK)JDK is a set of programming tools required for developing Java appsJRE consists of-Java librariesJava Virtual MachineOther components essential for running java applications
7 JVM It is an application that actually executes the java program When JVM is installed on a computer,It can run Java programs.Java programs therefore needn’t be self-sufficient, andthey don’t have to include all the machine-level code that actually runs on the computer.Instead, Java programs are compiled into compact bytecodes, andthe JVM reads and interprets these bytecodes to run your program.E.g. when you are downloading and applet from internet, you are actually downloading a bytecodeJVM ensures that Java programs include less code, becauseall the machine-level code to run your program is already on the target computer and doesn’t need to be downloaded.
8 JVMJIT CompilerInitially java programs were interpreted- i.e. executed bytecode by bytecodeInterpretation can be a slow processTo solve this, Java2 comes with JIT compiler-It actually reads your bytecodes in sections and compiles them interactively into machine language, so that the program can run faster(the whole program is not compiled at once because java performs runtime checks on various sections of the code)
9 The Java PlatformOver the years, the Java platform evolved into three major editions, each addressing a distinct set of programming needs:The Java Platform, Standard Edition (Java SE)Most commonly used among the three editionsUsed for developing desktop and console-based applicationsIt consists of:A runtime environmentSet of APIs, to build a wide variety of applications comprising standalone applications that can run on various platforms- Windows, Linux, SolarisThe Java Platform, Enterprise Edition (Java EE)Used for building server-side applications, by using its component-based approachThe Java Platform, Micro Edition (Java ME)Used for computing micro devices- handheld devices- PDAs, mobile phones – with limited display and memory support
11 Enterprise Architecture Helps in understanding the structure of an enterprise applicationIt can be broken down into three fundamental logical layers:User interface layerDisplays data elements to the users and collecting data from the usersOften called the ‘presentation’ layer- it includes the part of the software that creates and controls the user interface and validates the user’s actionsProcessing layerHelps an application to work and handle processing of business logicAlso called the ‘business layer’Data storage & accessHelps the processing layer to read and store data
12 Enterprise Architecture Types An enterprise application can be designed in many ways,but, here we discuss the following types of enterprise architectures:Single-tier architecture2-tier architecture3-tier architecturen-tier architecture
13 Single-tier Architecture It consists ofthe presentation, the business rules, and the data access layersin a single computing layer.Such applications arerelatively easy to manage,and implement data consistency, since data is stored in a single locationProblem-Such applications can’t be scaled up to handlemultiple users, andthey do not provide an easy means of sharing data across enterprise
14 2-tier Architecture It separates the data and business logic. the application resides entirely on the local machine, andthe database is deployed at a specific and secured location.In 2-tier application (a. k. a. client-server application),the processing load is entrusted with the client,while the server simply controls the traffic between the application and dataData LayerData Access Layer1st LayerPresentation LogicBusiness LogicDatabase
16 3-tier ArchitectureIn 3-tier architecture, an application is virtually split into three separate logical layers
17 3-tier Architecture Layers: First tier: ‘presentation layer’- consists of a GUI to interact with the userMiddle tier: ‘business layer’- consists of the application (or business) logic;Third tier: ‘data layer’ – contains data access logic needed for the application.This separation of application logic from the user interface adds enormous flexibility, as compared to the 2-tier system, to the design of an application.By using this architecture, multiple user interfaces can be built and deployed without changing the application logic; provided it defines a clear interface to the presentation layer.
20 n-tier ArchitectureThere can be numerous layers in this kind of architectures.In this model,The user interface logic is retrieved from the application running on the desktop.The application on the desktop is responsible for presenting the user interface to the end user and for communicating to the business logic tier.It is no longer responsible for enforcing business rules or accessing databases.There is no hard & fast way to define an application in this architecture.In fact, n-tier architecture can support a number of different configurations.
21 n-tier ArchitectureIt can be virtually distributed in to the following segments:
22 n-tier Architecture Advantages Improved maintainability Consistency Such applications are easier to maintainConsistencyBy means of component designing and their association with the layer in the architecture where they are providing functionalityInteroperabilitySuch applications are highly interoperable, as we can implement components in different layers to support different technologies and platformsFlexibilityDeveloper is free to design and develop various types of components for different layers with all flexibilityScalabilityWe can add new components without affecting the performance of the existing application
23 Goals of enterprise applications Ensure robustnessEnsure scalability and performanceImplement OO design principlesAvoid complexityEnsure maintainability and extensibilityEnsure ease of testingPromote reuse of applicationsSupport for multiple client typesportability
25 Applications Development Requirement Platform independence - Do not get caught in complexity of operating systemsDevelop Once, run everyStrong framework, ensure repeatability – Ensure building blocksFlexibility in individual implementation over common rulesInternationalization requirementsAccess of business rules including data and methodsReduced dependency on databaseOrganization component modellingStandardization with Business entitiesTechnology PortabilityAbility to change business rules easilyJ2SE (Java 2 Standard Edition) : JVM, tools, Libraries and DocJ2EE Java 2 Enterprise EditionJ2EE adds additional specifications, libraries, documentation and toolsStandard based: The J2EE Connector Architecture defines a standard, transactionally capable, scalable, and secure architecture for leveraging EIS investment -- thereby simplifying integration with such mainframe applications as Enterprise Resource Planning (ERP) and Customer Relationship Management (CRM) systems.Some of the J2EE Application Servers available areApache (Servelet/ JSP container Only)IBM WebSphereJRunJBossBEA WebLogicTCS Internal
26 What is J2EE? J2EE is a standard based platform for developing, deploying and managing multitier, web-enabled, server centric and component based enterprise applicationsJ2EE enhances J2SE with:Enterprise JavaBeans componentsJava Servlets APIJava Server PagesXMLThis suite is the Java 2 Enterprise Edition, commonly known as J2EE.J2EE (Java2 Enterprise Edition) offers a suite of software specification to design, develop, assemble and deploy enterprise applications.It provides a distributed, component-based, loosely coupled, reliable and secure, platform independent and responsive application environment.J2EE environment provides a framework for bundling together the components into an application and provide the applications necessary common services such as persistence, security, mail, naming and directory service etc.Java 2 Platform, Enterprise Edition (J2EE) defines the standard for developing component-based multi-tier distributed enterprise applications.A J2EE component is a self-contained functional software unit that is assembled into a J2EE application along with related components.Application logic is divided into components according to functionJ2SE (Java 2 Standard Edition) : JVM, tools, Libraries and DocJ2EE Java 2 Enterprise EditionJ2EE adds additional specifications, libraries, documentation and toolsStandard based: The J2EE Connector Architecture defines a standard, transactionally capable, scalable, and secure architecture for leveraging EIS investment -- thereby simplifying integration with such mainframe applications as Enterprise Resource Planning (ERP) and Customer Relationship Management (CRM) systems.Some of the J2EE Application Servers available areApache (Servelet/ JSP container Only)IBM WebSphereJRunJBossBEA WebLogicTCS Internal
27 Exploring the Java EE5 platfom It comprises of the following:A runtime infrastructure for managing and hosting applications. All runtime applications are hosted in this server.A set of Java APIs to build applications. These Java APIs describe the programming model for Java EE appliations.
28 The Runtime Infrastructure It includes numerous services to manage enterprise applications.The Java EE architecture provides the uniform means of accessing platform-level services via its runtime environment.These services include:messaging, security and distributed transactions
29 The Java EE APIsIn the enterprise services, the distributed applications require server access for running.These enterprise services include transaction processing, managing, multithreading, and database access.J2EE5 unifies access to such services in its enterprise service APIs.The j2ee5 application program can access these APIs through the containers such as Web and EJB,
31 EJB 3.0An enterprise bean is a server-side piece of code with fields and methods to implement the modules of the business logic.It is a building block that can be used alone or with other enterprise beans to execute the business logic on the Java EE serverIt is a component based architecture for developing, deploying, and managing reliable enterprise applications
32 Java Servlet Technology It allows you to define HTTP-specific servlet-classes.A servlet class extends the capabilities of servers that host the applications accessed by the way of request-response programming model.
33 Java Server Pages & JSP Tag Library(JSTL) It allows you to integrate the combined snippets of Java code with static markup in a text-based document.It is a text-based document that contains two types of text:Static template data, which can be expressed in any text-based format such as HTML or XMLJSP elements, which determine how the page constructs the dynamic contentJSTL provides a set of standard tags that can be used in a JSP pageIt provides tags to use java code embedded in a JSP pageIt includes various tags to control the flow of execution, to support internationalization and to access database using SQL
34 Java Server FacesProvides component based API for building rich user interfaces for web applications.Used in conjunction with JSP and servletsThey handle all the complexities of managing the UI, enabling the developer to concentrate on the business logic.
35 Java Message Service (JMS) The JMS API is a messaging standard that allows Java EE application components to create, send, receive, and read messages.It enables distributed communication that is loosely coupled, reliable, and asynchronous.
36 Java Transaction API(JTA) JTA is used to manage distributed transactions.This API specifies a standard java interface for a transaction manager to interact with the resource manager, application server, and transactional appliacations.
37 JavaMail APIMany enterprise applications need to send notifications.Java EE platform includes the JavaMail API with a JavaMail Service provider that application components can use to send s.It has two parts:An application-level interface used by the application components to send sA service provider interface
38 JavaBeans Activation Framework (JAF) it provides the standard services –to determine the type of an arbitraryto encapsulate access to itto identify the operations available on it, andto instantiate appropriate JavaBean components to perform these operations
39 Java API for XML Processing (JAXP) it enables applications to parse, transform, validate, and query XML documentsThis API is independent of XML processor implementation
40 Java API for XML Web Services(JAX-WS) The JAX-WS specification helpscreate web service endpoints and client components to access the web services.It also describes the deployment information of web services and clients.It also supports JAXBJAXB API is used to bind XML data to java objects.
41 Java Architecture for XML Binding(JAXB) It helps on binding an XML schema with a java object in a simple and easy way.It helps in marshalling java content tree into XML instance documents, and vice versa.
42 JDBC APIThe Java DataBase Connectivity API helps execute SQL commands from Java programs.JDBC API can be used withEnterprise java beans,JSP,Servlets, andJava classes
43 Java Persistence API (JPA) In Java EE, a solution for persistence has been provided in the form of JPA.An object relational mapping, which is used by persistence, is used for bringing an OO model and relational database model together.JPA consist ofthe Persistence API,query language, andobject/relational mapping metadata.
44 Java Naming and Directory Interface (JNDI) It provides the naming and directory functionality.It provides Java EE applications with the methods to perform standard directory operations, such asassociating attributes with the objects and searching for the objects by using their attributes.Using JNDI, a Java EE application can store and retrieve any type of named Java objects.
45 Java Authentication and Authorization Service (JAAS) JAAS provides a way for a Java EE application to authenticate and authorize a specific user or group of users.JAAS is a Java based standard Pluggable Authentication Module (PAM) framework,which extends the Java platform security architecture to support user-based authorization.
46 J2EE Suite (summary)Core technology: Container infrastructure, language and environment supportXML technologyThe Java API for XML Processing (JAXP)The Java API for XML-based RPC (JAX-RPC)SOAP with Attachments API for Java (SAAJ)The Java API for XML Registries (JAXR)Web TechnologyJava ServletsJavaServer PagesJavaServer Pages Standard Tag LibraryEnterprise Java Bean (EJB) technologySession beansEntity beansEnterprise JavaBeans Query LanguageMessage-driven beansPlatform servicesSecurityTransactionsResourcesConnectorsJava Message Service
48 Distributed Multi-tiered Applications Services, clients (people and application) and data are distributed geographically across many platforms and many machines.Multiple tiers:Client-tier (browser or client-application)Web-tier (web-server: Java Server Pages)Business-tier (logic; Examples: Enterprise Java Beans)Enterprise-Information-System (EIS) tier (database)
50 J2EE Multi-tier Framework EJB ContainerJSP/ServletContainerWEB CLIENTDatabase/Legacy SystemsANY CLIENTClientTierEIS TierWebBusinessMachineJ2EEServerDatabaseServer /LegacyBusiness logic is in EJB (Enterprise Java Bean) container and can be accessed either by a web client (browser) or any other client. These clients include swing based GUI applications, other applications developed in other platform and programming languages, applications running on PDAs (Personal Digital Assistant) and mobile phones etc.EIS – Enterprise Information Systems (legacy systems).Container is a logical concept which holds components.Client is a software sitting on the desktop interacting with server through network using some protocol.
51 J2EE Architecture CLIENTS TIER BACK END External Clients from INTERNET(Browsers , WAP etc.) AppletsInternal Clients from INTRANET(Browsers , Desk topApplications etc.)Applets, JavabeansBACK ENDJ2EE WEB APPLICATION SERVER TIERPRESENTATION LOGIC(Web Components)BUSINESS LOGIC(EJB Container )ENTERPRISE SERVICESHTMLJDBCXMLSERVLETSJSPWMLEJBJNDIJMSJTSRMI - IIOPEnterpriseInformationSystems(Databases,ERP,Legacy Systems)Applets : An applet is a small client application written in the Java programming language that executes in the Java virtual machine installed in the Web browser. client systems will likely need the Java Plug-in and possibly a security policy file in order for the applet to successfully execute in the Web browser.Application clients: Swing bases rich GUI. Either can access data tier directly or through HTTP socket connection.Web clients:A web client consists of two parts:Dynamic Web pages containing various types of markup language (HTML, XML, and so on), which are generated by Web components running in the Web tier, andA Web browser, which renders the pages received from the server.A Web client is sometimes called a thin client. Thin clients usually do not query databases, execute complex business rules, or connect to legacy applications. When you use a thin client, such heavyweight operations are off-loaded to enterprise beans executing on the J2EE server, where they can leverage the security, speed, services, and reliability of J2EE server-side technologies.Web tier consists of servlets and JSP pages. It is also called presentation layer/logic/tier.Enterprise Java Beans capture the business logic. They are kept in EJB containers.Apart from these, J2EE provides some common services like, messaging, mail, lookup etc.Various devices can interact with application in XML (Extensible Markup Language), HTML and WML (Wireless Markup Language) format
52 J2EE-based Application The J2EE APIs enable distributed systems and applications through the following:Unified application model across tiers with enterprise beansSimplified response and request mechanism with JSP pages and servletsReliable security model with JAASXML-based data interchange integration with JAXPSimplified interoperability with the J2EE Connector ArchitectureEasy database connectivity with the JDBC APIEnterprise application integration with message-driven beans and JMS, JTA, and JNDI
54 J2EE offerings for Developer Java Server PagesJavaMail APIEnterprise JavaBeansJava Authentication &Authorization ServiceJava Naming &Directory InterfaceJAXP – JAXB –JAXR – JAXRPCJava ServletTechnologyJDBCJava Message ServiceJ2EEJava Transaction API& ServiceJTA + JTSSAAJ (Web Services)Enterprise Java Beans is used to capture business logic.Servlets and JSP provides a mechanism to communicate between clients (browsers) and servers.JDBC is the middle tier used to talk to underlying database.Naming service is used to lookup various components dynamically during runtime.Authentication and authorization service is used to provide role based access to various users.Messaging service is used form inter-component communication.Transaction is used to ensure that atomicity is maintained for each transaction.
55 J2EE Application Components J2EE applications comprises various components.Client ComponentsBuilt using applets which runs on client machineWeb CompoentsBuilt using Java Servlet technology and JSP technology which runs on server.Business CompnentsBuilt using EJB technolgy which runs on server.Web clientsDynamic web pages with HTML, rendered by web browsers.Can include applets.Communicates with server typically using HTTP.Application clientsUser interface using GUI components such as Swing and AWT.Directly accesses the business logic tier.Components are self contained software modules which can be used for plug-and-play kind of software development. If want to change one functionality, the current component can be replaced by another component without affecting the whole application.
56 Web Components J2EE Web components can be either servlets or JSP pages Servlets are Java programming language classes that dynamically process requests and construct responses.JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static contentStatic HTML pages and applets are bundled with Web components during application assembly, but are not considered Web components by the J2EE specification.Server-side utility classes can also be bundled with Web components and, like HTML pages, are not considered Web components.
57 Web TierAs shown in the next slide Figure the Web tier, like the client tier, might include a JavaBeans component to manage the user input and send that input to enterprise beans running in the business tier for processing
58 Business TierBusiness code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier.
59 Java 2 Enterprise Edition (J2EE) Example Java 2 Enterprise Edition (J2EE) (continued)An EJB Container is a run-time environment that controls the enterprise beans and provide system-level services such as:Transaction management, security (through deployment descriptors)Remote client connectivity (through Java RMI over IIOP protocol)Life cycle management such as creating and removing the beans, and maintaining the beans in their active and passive statesDatabase connection pooling to maintain a pool of database connections, thus reducing the cost and time involved in obtaining database connections.A database is a persistent storage for the data.Instructor NoteThe details of servlets and JSPs are covered in other courses. Do not discuss them here in detail. Various terms introduced here such as deployment descriptors and life cycle management are discussed in detail in the following lessons.J2EE serverWeb ContainerHTTP RequestServletHTTP ResponseClient(Browser)Bean1Bean2EJB ContainerDatabase
60 Containers Containers are a central theme in J2EE architecture. Containers are like the rooms in the house-People and things exist in the rooms, and interface with the infrastructure through well-defined interfaces.In an application server,Web and business components exist inside the containers and interface with the Java EE infrastructure through well-defined interfaces.
61 J2EE Containers What is a Container Containers are the interface between a component and the low-level platform specific functionality that supports the component.How does it workContainer settings are specified for each component during assembly process before deployment.What do I getSupport for security, transaction management, JNDI lookup, Remote connectivity.Here are some of the highlights:The J2EE security model lets you configure a Web component or enterprise bean so that system resources are accessed only by authorized users.The J2EE transaction model lets you specify relationships among methods that make up a single transaction so that all methods in one transaction are treated as a single unit.JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access naming and directory services.The J2EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine.
62 J2EE Containers (cont..) Manage life cycle of objects Manage transactionsProvide securityResource optimizationDB poolingCompiled JSP CachingPersistence supportCMP (EJB-QL)Here are some of the highlights:The J2EE security model lets you configure a Web component or enterprise bean so that system resources are accessed only by authorized users.The J2EE transaction model lets you specify relationships among methods that make up a single transaction so that all methods in one transaction are treated as a single unit.JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access naming and directory services.The J2EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine.CMP – Container Managed PersistenceEJB–QL – Enterprise Java Bean Query Language (similar to SQL).
63 Types of Containers EJB Container Web Container Application Client ContainerApplet Container
65 Compilation and Deployment Compilation (building the executables) uses build tool such as Apache Ant.The components of the various tiers are packaged: .jar, .war, .earDeclarative resources are added.A deploy tool or management tool is used to deploy the packaged units into a J2EE server (container).