E210 Message Bridge for Java - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

E210 Message Bridge for Java

Description:

In DOM terminology, the document element. Ancestor of all other elements in a document instance ... Martin, Birbeck, Kay, et al., Wrox Press (ISBN: 1861003110) Summary ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 35
Provided by: Kar9252
Category:
Tags: bridge | e210 | java | message | wrox

less

Transcript and Presenter's Notes

Title: E210 Message Bridge for Java


1
E210 Message Bridge for Java
  • Javier Cuerva
  • Technical Architect
  • eBusiness Division
  • cuerva_at_sybase.com

2
Agenda
  • Summarize Skills Prerequisites
  • Identify Business and Technical Contexts
  • Describe Message Bridge
  • Overview and Architecture
  • Features
  • Description and Usage

3
Skills Prerequisites
  • XML Concepts
  • Syntax (elements, attributes, structure)
  • Parsing SAX, DOM, validation
  • Namespaces
  • DTD vs. XML Schema
  • Java
  • Language concepts
  • Object-oriented programming

4
Definitions
  • Document Schema
  • Specifies structure and permissible values of
    documents
  • Syntaxes supported by Message Bridge
  • Document Type Definition
  • XML Schema
  • Root Element
  • In DOM terminology, the document element
  • Ancestor of all other elements in a document
    instance
  • Message Definition
  • Pairing of a root element and a schema

5
Definitions, cont
  • View
  • Subset of a message definition
  • Used to manipulate subset of overall document
  • Binding
  • XML document modelled via programming language
    (Java) constructs
  • DataBean
  • The Java binding produced by Message Bridge
  • An object encapsulating a specific XML document

6
Definitions, cont
  • Validation
  • Enforcement of document schema structure and
    constraints
  • Valuable and useful in many situations but not
    required
  • Serialization
  • Conversion of DataBean object instances into XML
    documents
  • Deserialization
  • Parsing (and optionally, validation) of XML
    documents
  • Reconstitution of DataBean object instances

7
Business and Technical Contexts
  • Message Bridge
  • Does not process messages
  • Not a broker, not a server
  • Not a runtime environment
  • Does not perform transformation or routing
  • Binds messages to objects
  • Focused on message content, not message
    processing
  • Lightweight
  • XML-focused solution
  • Oriented towards programmers

8
Product Overview
  • Purpose
  • Help Sybase customers build XML-oriented
    applications
  • Integrated Function
  • Binds specific XML documents to Java objects at
    runtime
  • Output incorporated into applications
  • Compiles XML document schemas into Java classes

9
Product Overview, cont
  • Comprised of the following
  • GUI for accessing design-time functionality
  • Document schema importers
  • Schema compilers to generate bindings
  • Runtime library infrastructure
  • Primary Audience
  • B2B and B2C integration applications

10
Architecture
  • DataBean Framework
  • Underlying functionality that supports the
    generated code
  • Must also be included with deployed application
  • Message Bridge GUI
  • Design-time tool
  • Document schemas are imported and displayed
  • Code generation attributes optionally modified
  • Generates Java code
  • Generated Code
  • Reflects concepts expressed in document schema
  • Hides the details associated with XML parsing

11
Architecture, cont
12
Framework Feature Description
  • Core Feature of Message Bridge
  • Runtime Support Infrastructure
  • All Required Components Are Bundled
  • Xerces XML Parser, JDOM Library
  • Message Definitions
  • Provides access to entire document
  • Views
  • Provides access to subset of document
  • Associated with a specific message definition

13
Framework Usage
  • API Documentation
  • located in ltinstallgt/docs/javadoc directory
  • Required Components
  • located in ltinstallgt/lib directory
  • DataBean.jar
  • Contains the DataBean Framework
  • jdom.jar
  • JDOM Library (0.7p1)
  • xerces.jar
  • Xerces XML parser (version 1.4.3)
  • Building Applications
  • Include above-mentioned jar files in CLASSPATH

14
Framework Usage, cont
  • Methods Common To All DataBeans
  • get() methods to access element data and
    attributes
  • set() methods to modify element data and
    attributes
  • Methods Provided By Root DataBean
  • Constructors to create a new DataBean object
    graph
  • get() and set() methods
  • Retrieve the main document
  • Access/modify root name
  • Access location of source schema

15
Framework Binding Example
  • lt!ELEMENT Recipe (IndexCard IngredientList
    StepList) gt
  • lt!ELEMENT IndexCard (Name, Description, Source)gt
  • lt!ELEMENT Name (PCDATA)gt
  • lt!ELEMENT Description (PCDATA)gt
  • lt!ELEMENT Source (PCDATA)gt
  • lt!ELEMENT IngredientList (Ingredient)gt
  • lt!ATTLIST IngredientList serves CDATA REQUIREDgt
  • lt!ELEMENT Ingredient (Food, Quantity)gt
  • lt!ELEMENT Food (PCDATA)gt
  • lt!ELEMENT Quantity (PCDATA)gt
  • lt!ELEMENT StepList (Step)gt
  • lt!ELEMENT Step (PCDATA)gt
  • lt!ELEMENT Comments (PCDATA)gt

16
Framework Binding Example, cont
  • Simple XML Element Containing Text
  • lt!ELEMENT Food (PCDATA)gt
  • Corresponding Java
  • Class Food
  • Methods
  • public String getData()
  • public void setData( String data )

17
Framework Binding Example, cont
  • XML Element Containing Children
  • lt!ELEMENT Ingredient (Food, Quantity)gt
  • Corresponding Java
  • Class Ingredient
  • Methods
  • public Food getFood()
  • public Food setFood()
  • public Quantity getQuantity()
  • public Quantity setQuantity()

18
Framework Binding Example, cont
  • XML Element Containing Repeating Child And
    Attribute
  • lt!ELEMENT IngredientList (Ingredient)gt
  • Corresponding Java
  • Class IngredientList
  • Methods
  • public Object get( int index )
  • public Ingredient getIngredient( int index)
  • public List getIngredients()
  • public Ingredient setIngredient( int index)
  • public void setIngredient( Ingredient instance,
    int index )

19
GUI Feature Description
  • Standalone Design-time Tool
  • DTD and XML Schema Import
  • View Creation
  • Code Generation
  • Online Help

20
GUI Usage
  • Step 1, Import DTD
  • Select a schema group (such as Default Group)
  • Select File New Message Definition from the
    menu
  • Brings up Add Message Schema dialog
  • Select DTD or XML Schema from drop-down list
  • Navigate to the directory containing DTD or XML
    Schema to be imported
  • User is prompted to select a root element
  • Message definition is added to project
  • Window opens to display diagram

21
GUI Usage, cont
  • Step 2 (Optional) Create View
  • Right-click on element in diagram window
  • Select New View from menu
  • Brings up View Name dialog
  • Type in a name for the view and click OK
  • Window opens to display diagram for view

22
GUI Usage, cont
  • Step 3 Generate Code
  • Select the newly-imported message definition
  • Select Tools Generate from the menu
  • Prompts for permission to save project
  • Brings up Generate dialog
  • Specify code generation parameters
  • Package name
  • Output Directory
  • Jar file name
  • Can optionally request documentation generation,
    too

23
Generated Code
  • Feature Description
  • Usage
  • Constructing Instances from an XML document
  • Getting elements
  • Populating a new DataBean
  • Creating an XML document
  • Identifying the DTD in an XML document

24
Generated Code Feature Description
  • Binding
  • Concepts expressed in specific document schema
    represented by Java classes and methods
  • Serialization / Deserialization
  • Parse XML documents and populate object hierarchy
  • Store data encapsulated by object hierarchy in
    XML format

25
Generated Code Usage
  • Constructing Instances From An XML Document
  • FileInputStream input
  • new FileInputStream( xml_filename )
  • // false in next method call means no validation
  • Recipe rcp new Recipe( input, false )
  • Or
  • FileInputStream input
  • new FileInputStream( xml_filename )
  • // again, false means no validation
  • Recipe rcp new Recipe()
  • Rcp.deserializeXML( input, false )

26
Generated Code Usage, cont
  • Getting Elements
  • // rcp is Recipe instance from previous slide
  • IngredientList ing_list rcp.getIngredientList()
  • // Get the first (0-based index) ingredient
    element
  • Ingredient ing ing_list.getIngredient( 0 )
  • // Determine whether there actually were any
  • // ingredients
  • if (!ing.hasValidElement())
  • // no ingredients to process
  • return

27
Generated Code Usage, cont
  • Populating A New DataBean
  • Recipe rcp new Recipe()
  • Ingredient ing
  • rcp.setIngredientList( 0 ).setIngredient( 0 )
  • ing.setFood().setData( Onions )
  • ing.setQuantity().setData( 2 )
  • // more code to populate recipe . . .

28
Generated Code Usage, cont
  • Creating An XML Document
  • FileOutputStream output
  • new FileOutputStream( xml_filename )
  • // rcp is Recipe object from previous slide
  • rcp.serializeXML( output )

29
Generated Code Usage, cont
  • Identifying DTD In An XML Document
  • FileInputStream input
  • FileInputStream( xml_filename )
  • DataBeanOpaque dbean
  • new DataBeanOpaque( input, false )
  • String dtd_name dbean.getDocTypeSystemID()
  • if (dtd_name.equals( recipe.dtd ))
  • Recipe rcp_v1 new Recipe( dbean, true )
  • // do something with version 1 recipe
  • else if (dtd_name.equals( recipe_v2.dtd ))
  • Recipe2 rcp_v2 new Recipe2( dbean, true )
  • // do something with version 2 recipe

30
Generated Code Enabling Validation
  • How To Enable Validation For DTDs
  • Pass true as the value of the validate parameter
    to the DataBean constructor
  • Call the validate() method
  • XML document must include a DOCTYPE statement

31
Generated Code Validation, cont
  • Runtime Location of DTDs
  • SYSTEM or PUBLIC keyword value
  • absolute path framework uses the path as is
  • relative path Xerces parsers default location
    (current working directory of the JVM) is
    prepended
  • otherwise, set Java system propertycom.sybase.Dat
    aBean.EntityResolver.dtdswith one or more
    directories to search in
  • entries separated by semicolons
  • safety net if document specifies incorrect path

32
Where to go for help
  • Technical Library Product Manuals Web site
  • http//www.sybase.com/support/manuals
  • W3C Web site
  • http//www.w3.org/XML/
  • Learning XML
  • Erik T. Ray, O'Reilly Associates (ISBN
    0596000464)
  • Professional XML
  • Martin, Birbeck, Kay, et al., Wrox Press (ISBN
    1861003110)

33
Summary
  • Binds Java classes and XML documents
  • Supports DTD and XML Schema syntaxes
  • Composed of three pieces
  • DataBean Framework
  • Runtime infrastructure library
  • GUI
  • Design-time tool
  • Generated Code
  • Document schema-specific runtime classes
  • No external dependencies
  • New product with minimal installed base
  • mainly early adopters

34
Questions ?
Write a Comment
User Comments (0)
About PowerShow.com