270 likes | 415 Views
Distributed Application Services and E-business Part II. So far …. E-business Definitions, E-business Models E-business Patterns Systems requirements E-business drivers for Multi-tier Applications Architecture Emerging web development technologies
E N D
So far … • E-business • Definitions, E-business Models • E-business Patterns • Systems requirements • E-business drivers for Multi-tier Applications Architecture • Emerging web development technologies • Thin versus Thick Clients, and Thin server vs Thick server • In this session …. • A brief introduction to Java • Brief introduction to Java • Overview of XML • Web applications using Java and XML • An example web application services • Tutorial session
What is Java? Enterprise edition 1.0 1.1 Java 2 Platform Standard edition Micro edition • Java language and environment • Born on May 23rd 1995. • Grew out of a product called Oak • Oak was designed for embedded software and consumer devices. • See http://www.javasoft.com • Java is an environment is • Ideal environment for writing object-oriented, distributed and platform independent applications, real-time, etc. • Java has a lot in common with C and C++ • Versions and editions
The Java timeline May - Sun launches Java (alpha version) on the Internet Sun announces Jini technology JDK 1.1 ships 1995 2000 2001 ++ 1996 1997 1998 1999 Sun announces Java 2 Platform (JDK 1.2) January - Java Development Kit (JDK) 1.0 ships Many more Sun announces Java 2 Platform (JDK 1.3) Sun announces Java 2 Platform (JDK 1.4)
How does it work? • A Java program is compiled into bytecodes • These bytecodes are interpreted by a JVM • The JVM converts these instructions into appropriate machine code • The program executes on the machine • Each platform therefore needs its own JVM • Enabling WORA -- “Write Once, Run Anywhere” • Java Virtual Machine • “An imaginary machine that is implemented by emulating it in software on a real machine.” • It specifies: Instruction set, register set, class file format, stack, garbage collection, memory area • A JVM exists for various operating systems including; • Windows 95/98/NT/2000, Solaris, Macintosh, OS/2, Linux, OS/400, OS/390, HPUX, AIX, IRIX, EPOC, Windows CE, PlamOS, etc.
Java Runtime Environment Java source (java) Class loader Byte code verifier Java class libraries Java interpreter Just-in-time compiler Java compiler Java byte codes move locally or through network Runtime system Java byte code (class) Operating system Hardware
Running Java Programs • A Java application is a stand-alone program that can use all of the features of the Java language environment • A Java applet is a restricted Java application that is designed to be run inside a Java-enabled web browser • Security restrictions • Applets have a different lifecycle to applications • A Java servlet is the equivalent of an applet, which is executed at server-side • It is a Java application that is designed to be run inside a Http servers
Examples: Java Programme /** Comments here – Example of authenticator class */ package test; import java.util.*; import java.security.*; import com.server.http.*; public class TestAuthenticator extends AbstractAuthenticator { public void init(CauchoApplication app, RegistryNode params) { } public Principal authenticateCookie(String cookieValue) { return null; } public Principal authenticate(String user, String password) { if (password != null && password.equals("quidditch")) return new BasicPrincipal(user); else return null; } public boolean updateCookie(Principal user, String cookieValue) {return true; } public boolean isUserInRole(Principal user, String role) {return user != null && "user".equals(role); }}
Java 2 Enterprise Edition • Enterprise JavaBeansTMArchitecture • Defines an API to enable developers to create, deploy and manage cross-platform, component-based enterprise applications. • JavaServer PagesTM • Enables rapid development of server-side web-based applications, such as; dynamic web content management. • JavaTM Servlet • Java Naming and Directory InterfaceTM (JNDI) • JavaTM Message Service (JMS) • Provides a standard Java API for enterprise messaging services such as reliable queuing, publish and subscribe communication and various aspects of push/pull technologies. • JavaTM Transaction API (JTA) • JavaMail
Example Application #1 • Location & Advertisement Services
… But … Web Layer Request Data source Response
HTML Code <html > <head> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="Microsoft Theme" content="global 101, default"> <meta name="Microsoft Border" content="tlrb, default"> <title>Home Page</title> </head> <body background="../../_themes/global/glotextb.gif" bgcolor="#FFFFCC" text="#510000" link="#999900" vlink="#CC9966" alink="#990066"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td><font face="Arial, Helvetica"> <p align="center"><br> <font size="4" face="Arial">Student Learning Space</font></p> <p align="center"><a href="../Default.htm">Home</a> <a href="../cmssem011/Module%20specification.doc">Module <a href="http://www.cms.livjm.ac.uk/markallen/multi-media.htm">Tutorials</a> <a href="../cmssem011/indicative_references.htm"> Reading List</a></p> <p align="left"><font size="4">Contemporary issues in IT: Distributed Applications and E-Commerce <em>CMSCB3005</em><font size="4" face="Arial"> </font></font></p> </html>
Associated XML Code <?xml version="1.0"?>> <?xml-stylesheet type="text/xsl" href="..\xsl\ENR-change-table.xsl"?> <!DOCTYPE Components SYSTEM "Project6.dtd"> <head> <meta name="Microsoft Theme" content="global 101, default"> <title> Student Learning Space </title> </head> <body> <main> <page type=“html” href="../Default.htm"> <headings> <heading 1 href="../cmssem011/Module%20specification.doc"> <heading 2 href="http://www.cms.livjm.ac.uk/markallen/multi-media.htm"> <heading 3 href="../cmssem011/indicative_references.htm"> </headings> </main> </body> </xml>
What is XML? • XML is • an eXtensible Markup Language for describing both structured and unstructured information, which could be usedon the web. • XML documents containing structured information including; • Content: words, pictures (vector graphics), e-commerce transactions, mathematical equations, object meta-data, server APIs, and other XML documents. • XML is a meta-language for defining other markup languages not like HTML or SGML • Unlike Html or SGML it provides; • extensible tag semantics • a facility to define tags and the structural relationships between them. • All of the semantics of an XML document will either be defined by the applications that process them or by stylesheets.
How Is XML Defined? • XML is defined by a number of related specifications: • Extensible Markup Language (XML) 1.0 • Defining the syntax of XML. • XML Pointer Language (XPointer) and XML Linking Language (XLink) • Defining a standard way to represent links between resources. In addition to simple links, like HTML's <A> tag, XML has mechanisms for links between multiple resources and links between read-only resources. • XPointer describes how to address a resource, • XLink describes how to associate two or more resources. • Extensible Style Language (XSL) • Defines the standard stylesheet language for XML. • XQL -- Defines a standard query language for XML. • XUL -- Defines a standard user-interface language for XML.
XML Markup #1 • Six kinds of markup used in XML documents: • 1. Elements -- Delimited by angle brackets, most elements identify the nature of the content they surround. • It begins with a start-tag, <element>, and ends with an end-tag, </element>. • Attributes -- Attributes are name-value pairs that occur inside start-tags after the element name. • <div class="preface">is a div element with the attribute class having the value preface. • 2. entity references -- introduce markup into a document, some characters have been reserved to identify the start of markup. • entities are used to represent these special characters. Entities are also used to refer to often repeated or varying text and to include the content of external files. • Entity references begin with the ampersand and end with a semicolon.
XML Markup #2 • For example, the lt entity inserts a literal < into a document. So the string <element> can be represented in an XML document as <element>. • A special form of entity reference, called a character reference, can be used to insert arbitrary Unicode characters into your document. This is a mechanism for inserting characters that cannot be typed directly on your keyboard. • 3. Comments -- begin with <!-- and end with -->. • Comments can contain any data except the literal string. • 4. processing instructions(PIs) -- are an escape hatch to provide information to an application. • Processing instructions have the form: <?name pidata?>. The name, called the PI target, identifies the PI to the application. • 5. CDATA Sections – to instruct the parser to ignore most markup characters. • to prevent xml parser from evaluating a CDATA. • <![CDATA[ *p = &q; b = (i <= 3); ]]>
XML Markup #3 • Between the start of the section, <![CDATA[ and the end of the section, ]]>, all character data is passed directly to the application, without interpretation. • The only string that cannot occur in a CDATA section is ]]>. • 6. Document Type Declarations • XML allows you to create your own tag names. • DTD enables document to communicate their meta-information to the parser including; • allowed sequence and nesting of tags, • attribute values and their types • defaults, the names of external files that may be referenced • formats of some external (non-XML) data that may be referenced, • the entities that may be encountered.
Validation • Two categories of XML documents: • Well-formed Documents • it obeys the syntax and the grammar of XML documents. • A document that includes sequences of markup characters that cannot be parsed or are invalid cannot be well-formed. • not well-formed document -- is not XML document. • well-formed and valid: • well-formed document is valid only if it contains a proper document type declaration and if the document obeys the constraints of that declaration.
XML Document Parsing DTD No Yes Yes XML Well- DTD Valid? Document formed? Required? No No Structural XML Non-conformance Syntax Error Message Error Message Stop Processing / Edit XML and/or DTD / Re-initiate Parsing Well-formed XML XML Document Further processing of Well-formed & Valid XML PARSER
XML Processing and Rendering DTD SAX Application Script/Program PARSER DOM XML API XML Document XSL XSL-based Processing layer Other Markup Languages WML Scalable Vector Graphics (SVG) RDF, XMI Etc. RTF (MS Word) PDF HTML Output Output • XML Document/DTD/Parser • Document Object Model (DOM) • Script/Programming (manipulation of objects) • XSL (render ready transformation) • Browser/Display Application • (rendering)
Combining Java and XML Communication Fire Fighter RDBMS Login System Mobilisation tool C&C Operator Search Engine Admin tools System Admin. Reporting tools