Slide 1 EE557: Server-Side Development eXtensible Stylesheet Language (XSL) XSL is the language that describes how XML documents are displayed XSL developed

  • Published on

  • View

  • Download

Embed Size (px)


<ul><li><p>EE557: Server-Side DevelopmenteXtensible Stylesheet Language (XSL) XSL is the language that describes how XML documents are displayed</p><p> XSL developed by the W3C Working Group</p><p> Consists of three parts - XSLT (XSL Transformations)- XSL Formatting Objects (XSL-FO)- XPath</p><p> XSLT is the language that specifies the conversion of a document from one format to another, where the XSL stylesheet defines the means -&gt; typically used for for textual transformations, such as HTML or WML from XML</p><p> XSL-FO formatting objects used when converting XML into binary formats such as PDF files, or Word Documents. This part is not covered by JAXP or here</p><p> XPath allows you to specify the part of the structure you are talking about It allows you to distinguish between and -&gt; We can describe different transformations for different elements </p></li><li><p>EE557: Server-Side Development </p><p>DavidMolloy John Peter Smith Jane Grogan </p><p>xslexample1.xml</p></li><li><p>EE557: Server-Side Developmentxslexample1.xsl </p><p> stylesheet is the top level element -&gt; root of the XSL stylesheet tree associates the template with the root of the doc works like a for loop selects the value of the tag within the root elementEmployee Firstname: Lastname: </p></li><li><p>EE557: Server-Side DevelopmentClient-Side/Server-Side Transformations</p></li><li><p>EE557: Server-Side DevelopmentClient-Side/Server-Side Internet Explorer 5.0+ goes a long way towards implementing client side transformations of XML</p><p> Non standards compliant in many ways with some omissions/changes</p><p> Perform a client transformation example</p><p> Many advantages in performing a manual transformation on the server - works across multiple browsers (HTML) - lightweight clients - transformations are performed in advance quicker</p><p> java classpath .;xalan.jar org.apache.xalan.xslt.Process IN xslexample1.xml XSL xslexample1.xsl -OUT xslexample1.html</p><p> Work through second example in the notes xslcustomers.xml/.xsl</p></li><li><p>EE557: Server-Side DevelopmentXSLT and JAXP Often need to perform transformation real-time with dynamic data Eg. XML to browser-specific HTML XML to Wireless Markup Language (WML) for mobile phones Personalized webpages/documentation</p><p> JAXP contains four packages responsible for handling XSLT - javax.xml.transform- javax.xml.transform.dom- javax.xml.transform.sax-</p></li><li><p>EE557: Server-Side DevelopmentXSLT and JAXP Steps:</p><p> 1) Import javax.xml.transform package classes and other classes such as DOM packages if you use DOM</p><p> 2) Instantiate a TransformerFactory objectTransformerFactory tFactory = TransformerFactory.newInstance()</p><p> 3) Create a Transformer, in which we can define a set of transformation instructions. In our example, we supply an XSL StreamSource</p><p> 4) Perform the transformation on the input (which can be created from a SAX reader, a DOM or an input stream) in our example, we provide a DOMSource. The transform method takes a second argument, which in our example is a File (via a FileWriter)</p><p> 5) Handle the possible exceptions</p><p> Work through the example in the notes</p></li><li><p>Messaging with Java Most common form of message is eMail</p><p> This is person-to-person or server-to-person messaging, not application to application messaging</p><p> Email is made up of a Header and Content</p><p> Each header attribute has its own line, with attributes split by a :</p><p> Eg.Precedence: bulkFrom: David Molloy</p><p> Show full email message from the notesEE557: Server-Side Development</p></li><li><p>Messaging with Java Email messages are stored or sent using one of a number of different protocols</p><p>- Simple Mail Transfer Protocol (SMTP)- Post Office Protocol (POP3)- Internet Message Access Protocol (IMAP4)</p><p> IMAP4 typically considered more advanced than POP3, since it supports folders and status flags (among other features)</p><p>EE557: Server-Side Development</p></li><li><p>JavaMail API J2EE developer does not need to understand underlying protocols</p><p> JavaMail API includes providers for the most commonly used protocols</p><p> JavaMail sits on top of the electronic mail vendors systems</p><p> Provides a standard, independent framework for Java client applications to use electronic mail</p><p> Can use JavaMail to: - Compose messages (including multi-part messages with attachments) - Send messages to particular servers - Retrieve and store messages in folders </p><p> When using JavaMail, the application needs network access to a mail service that can send messages to the destination (dialup or network service)EE557: Server-Side Development</p></li><li><p>JavaMail API JavaMail is contructed with an Open Architecture, so can support future protocols and standards</p><p> Two different types of protocols providers can implement:</p><p> - Transport: is the service which sends messages to the destination Most commonly used transport is SMTP</p><p> - Store: the service that provides access to messages that have been delivered to a mailboc. Most commonly used is POP3 but IMAP4 is considered better and becoming more common</p><p> JavaMail relies heavily on the Java Activation Framework (JAF). JAF designed to work in a standard way with different types of data</p><p> When an application needs to work with a particular data type, these JAF objects can be activated and used to process data (mail.jar, activation.jar, J2EE standard inclusion)</p><p>EE557: Server-Side Development</p></li><li><p>JavaMail API javax.mail.Session class is starting point for JavaMail. Allows the specification of properties, such as the transport mechanism and the mail server</p><p> Using the Session we can create a new MimeMessageObject</p><p> We then set the properties for the email message, such as the sender, recipient, subject and contents of the message</p><p> Finally, we use Transport.send(message) to open up a new connection to the mail service and send the message</p><p> Show the example code -&gt; issues with running application (local access only etc.) - demoMail.javaEE557: Server-Side Development</p></li><li><p>Java Message Service (JMS) JavaMail is an API for Messaging using email</p><p> Java Message Service (JMS) is an API for Messaging between applications</p><p> Developed by Sun Microsystems as part of the Java 2 Enterprise Ed.</p><p> Provides a common way for Java programmers to create, send, receive and read an enterprise messaging systems messages</p><p> A message is a unit of data that is sent from a process running on one computer to other processes running on the same computer or a different computer</p><p> Messages can be simple text, or more complicated structures such as Java Hashtables or other serializable Java objects</p><p> Object is serializable if it can be transmitted across a network as a series of bytes and re-created into a copy of the original objectEE557: Server-Side Development</p></li><li><p> MOM is a specialized type of middleware that coordinates the sending and receiving of messages</p><p> Provides dependable mechanisms that enable applications to create, send, and receive messages asynchronously in an enterprise environ.</p><p> Numerous examples of MOM:</p><p>- IBM MQ Series- Fiorano Message Server- Progress SonicMQ- SilverStream JbrokerMQ</p><p>-&gt; JMS provides a standard interface to these MOM products Frees developers from having to write low level infrastructure code, also known as plumbing, allowing them to build solutions quicker</p><p> JMS is used and integrates with other components of J2EE (eg. JDBC used for persisting messages, JMS used in MDBs)EE557: Server-Side DevelopmentJava Message Service (JMS)</p></li><li><p> Two primary communication modes:EE557: Server-Side DevelopmentJava Message Service (JMS)Synchronous Communication: conducted between two parties, both parties must be active and must acknowledge receipt of a message (known as a blocking call) before proceeding- easily affected by hardware, software and network failures, resulting in delayed messages and traffic backups- if hardware capacities are exceeded information is typically lost- Example: chat application</p><p>Asynchronous Communication: all parties are peers and can send messages at will. Does not require real-time acknowledgement of messages. Requester can continue with other processing once it sends the message (known as a non-blocking call)- Example: Email. Even though your e-mail client may not be running on your PC, people can still send multiple messages to you. - Example: internet-based purchase ring tone system -&gt; return feedback to browser, mobile phone turned off/no signal?</p></li><li><p> Using messaging for exchanging data provides for:EE557: Server-Side DevelopmentJava Message Service (JMS) Easy integration of incompatible systems</p><p> Asynchronous communications</p><p> One-to-many communications</p><p> Guaranteed messaging</p><p> Transactional messaging (all or none, commit/abort) JMS supports two message models known as Point-to-Point (PTP) and Publish/Subscribe (Pub/Sub)</p><p> Both models can deliver messages synchronously or asynchronously</p></li><li><p> Sends messages to a receiver on a one-to-one basis, such as in instant messaging, or sending an order to another system</p><p> Message delivered to a queue -&gt; processed on FIFO basis</p><p> Only one receiver can process each message (regardless of number of receivers)</p><p> Receiver can look through messages in a Queue (eg. To count them) but must process them FIFOEE557: Server-Side DevelopmentPoint-to-Point Model (PTP)</p></li><li><p>Publish/Subscribe Model Applications can publish messages on a one-to-many or many-to-many basis. Eg. Sending news stories to interested parties, stock prices to traders</p><p> Messages are published to a Topic -&gt; one or more publishers can publish messages to a Topic -&gt; clients must subscribe to receive messages -&gt; typically must be subscribed in advance If no clients subscribed, messages are typically destroyedEE557: Server-Side Development</p></li><li><p>JMS API Programming Model Firstly, we set up a QueueConnectionFactory or a TopicConnectionFactory for use in our JMS applications</p><p> We achieve this by using the Sun Application Server Admin Console (or whatever console is appropriate for the application server we are using). </p><p> The steps to add the ConnectionFactory are detailed in the notes At beginning of JMS application, we perform a JNDI API lookup of the connection factory. Eg.</p><p>Context ctx = new InitialContext();QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) ctx.lookup(myQueueConnectionFactory);EE557: Server-Side Development</p></li><li><p> We also need to define a destination, which will be either a Queue or a Topic. It defines the target of messages it produces and the source of messages it consumes</p><p> Again we create this resource using the Admin Console</p><p> In our Java application we perform a JNDI lookup for our destination:</p><p>Queue myQueue = (Queue) ctx.lookup(MyQueue);Topic myTopic = (Topic) ctx.lookup(MyTopic);</p><p> Obtain a QueueConnection/TopicConnection to the provider by using the QueueConnectionFactory or TopicConnectionFactory</p><p> Obtain a QueueSession/TopicSession with the provider by using the QueueConnection/TopicConnectionEE557: Server-Side DevelopmentJMS API Programming Model</p></li><li><p>JMS API Programming ModelEE557: Server-Side Development Create a QueueSender or QueueReceiver (TopicPublisher or TopicSubscriber) via the QueueSession (TopicSession) for the required Queue (Topic)</p><p> Send and/or receive messages (Publish and/or subscribe messages)</p><p> Close the QueueConnection (automatically closes QueueSender/Receiver, and the QueueSession). For Pub/Sub, close the TopicConnection, TopicPublisher/Subscriber and TopicSession</p></li><li><p>JMS API Programming ModelEE557: Server-Side Development</p></li><li><p>JMS Messages Typically formatted data (such as a request, event or status) passed between applications.</p><p> Message can contain simple or complex data types, including Serializable Java objects</p><p> JMS message is made up of 1 required component and 2 optional: - A header (required) used for identifying and routing messages, setting expiration,priority etc. many settable by clients - Properties (optional) extra header information- A body (optional) one of 5 different formats ByteMessage,ObjectMessage,TextMessage,StreamMessage and MapMessage (hashtable type)</p><p> message = queueSession.createTextMessage(); for (int i = 0; i &lt; NUM_MSGS; i++) { message.setText("This is message " + (i + 1)); System.out.println("Sending message: " + message.getText()); } EE557: Server-Side Development</p></li><li><p>Point-to-Point Example SimpleQueueReceiver.javaEE557: Server-Side DevelopmentPublish/Subscribe Example</p></li></ul>


View more >