Web???? (?1?) - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Web???? (?1?)

Description:

... SOA( Service Oriented Architecture ) ... JAXB javax.xml.bind javax.xml.bind.annotation javax.xml.bind.annotation.adapters javax.xml.bind.attachment javax.xml ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 36
Provided by: Tatsuo
Category:
Tags: adapters | web

less

Transcript and Presenter's Notes

Title: Web???? (?1?)


1
Web???? (?1?)
  • 2007?9?26?

2
?Web????II????
  • ?2???Web????
  • Java SE 6 ???
  • ??????????
  • ??????????? Glassfish
  • EoD(Ease of Development)
  • ?????????3???????Java??????????(JAXB)

3
?????????
  • Web??????????
  • JAXB, JAX-WS 2.0?
  • Java SE 6 ??????
  • xjc, schemagen, wsgen,wsimport
  • Web????????????
  • EoD( Ease of Development )
  • SOA( Service Oriented Architecture )

4
???Web???????
  • JAX-WS 2.0 ? API
  • (JAX-RPC ????JAX-RPC 2.0 ???)
  • JAXB(Java Architecture for XML Binding ) ???????
  • ??????????
  • W3C XML Schema ? Java ??????

5
Java????????
  • JDK 1.4 ?? J2SDK 5.0?
  • ??????????
  • Generics, ??????gt??????????
  • J2SDK 5.0 ?? Java SE 6 ?
  • ?????????? EoD ??????
  • JAXB, JAX-WS ? Java SE 6 ????

6
???????
  • Java SE 6 ?XML????????(??)
  • JAXB???
  • ??? xjc
  • XML Schema ?? Java?????????
  • XML???? Java???????

7
J2SE 1.4???API
  • javax.xml.parsers
  • org.xml.sax
  • org.w3c.dom
  • javax.xml.transform
  • javax.xml.transform.stream
  • javax.xml.transform.sax
  • Javax.xml.transform.dom

8
J2SE 5.0 ????????
  • javax.xml
  • javax.xml.datatype
  • javax.xml.namespace
  • javax.xml.validation
  • javax.xml.xpath

9
Java SE 6 ???(1) -- JAXB
  • javax.xml.bind javax.xml.bind.annotation
    javax.xml.bind.annotation.adapters
    javax.xml.bind.attachment javax.xml.bind.helpers
    javax.xml.bind.util

10
Java SE 6 ???(2) ????
  • javax.xml.crypto
  • javax.xml.crypto.dom javax.xml.crypto.dsig
    javax.xml.crypto.dsig.dom javax.xml.crypto.dsig.ke
    yinfo javax.xml.crypto.dsig.spec

11
Java SE 6 ???(3) ???
  • javax.xml.soap
  • javax.xml.stream javax.xml.stream.events
    javax.xml.stream.util

12
Java SE 6 ???(4) Web????
  • javax.xml.ws
  • javax.xml.ws.handler javax.xml.ws.handler.soap
    javax.xml.ws.http
  • javax.xml.ws.soap
  • javax.xml.ws.spi
  • javax.jws
  • javax.jws.soap

13
????? Java SE 6???
  • 2F??? Linux ??? Windows ??
  • ?????????? Java SE 6 ???????

14
JAXB
  • JAXB(Java architecture for XML Binding)
  • Java ? XML ??????????
  • ??? Web????????????
  • ?????????????

15
Java ? XML(1)
  • Java ???????????
  • public class Name
  • String first
  • String last
  • --------------------------------------------------
    -
  • Name name new Name()
  • name.firstTatsuo name.lastUeda

16
Java ? XML(2)
  • XML???????
  • ltnamagt
  • ltfirstgtTatsuolt/fistgt
  • ltlastgtUedalt/lastgt
  • lt/namegt
  • ??ltnamegt -- ?????? name
  • ??ltfirstgt,ltlastgt -- ????????

17
Java ? XML(3)
  • ?????????? XML?????
  • ????????
  • XML????????????
  • DTD(Document Type Definition)
  • XML Schema
  • W3C XML Schema
  • RELAX NG
  • Schematron

18
W3C XML Schema ???
  • ??????
  • ?????
  • ???????
  • ???????
  • ?????XML???!
  • ????????

19
XML Schema ??(1)
  • ltxsdschema xmlnsxsd
  • "http//www.w3.org/2001/XMLSchema"gt
  • ltxsdelement name"name" type"nameType"/gt
  • ltxsdcomplexType name"nameType"gt
  • ltxsdsequencegt
  • ltxsdelement name"first"
    type"xsdstring"/gt
  • ltxsdelement name"last" type"xsdstring"/gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • lt/xsdschemagt

20
Java ????(1)
  • String first
  • public String getFirst() returen first
  • public void setFirst( String s ) first s
  • ltxsdelement name"first"
  • type"xsdstring"/gt

21
Java ????(2)
  • public class name
  • ltxsdelement
  • name"name type"nameType"/gt
  • ltxsdcomplexType name"nameType"gt
  • String first String last
  • ltxsdsequencegt
  • ltxsdelement name"first"
    type"xsdstring"/gt
  • ltxsdelement name"last" type"xsdstring"/gt
  • lt/xsdsequencegt

22
XML Schema ??(2)
  • ltxsdcomplexType name"peopleType"gt
  • ltxsdsequencegt
  • ltxsdelement name"name"
  • type"nameType" minOccurs"1"
  • maxOccurs"unbounded"/gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt

23
??????
  • Java?? lt -- gt W3C XML Schema
  • Java ???? lt -- gt ??????????
  • Java ??????? lt -- gt XML??
  • Java ?????? lt -- gt XML???

24
??? ??? xjc (1)
  • xjc ( XML to Java compiler )
  • W3C XML Schema ???????
  • Java ???????
  • xjc name.xsd

25
??????????
  • ltxsdschema
  • xmlnsxsd"http//www.w3.org/2001/XMLSchema"gt
  • ltxsdelement name"name" type"Name"/gt
  • ltxsdcomplexType name"Name"gt
  • ltxsdsequencegt
  • ltxsdelement name"first"
    type"xsdstring"/gt
  • ltxsdelement name"last"
    type"xsdstring"/gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • lt/xsdschemagt

26
??????? Name.java(1)
  • package generated
  • import javax.xml.bind.annotation.XmlAccessType
  • import javax.xml.bind.annotation.XmlAccessorType
  • import javax.xml.bind.annotation.XmlElement
  • import javax.xml.bind.annotation.XmlType

27
??????? Name.java(2)
  • _at_XmlAccessorType(XmlAccessType.FIELD)
  • _at_XmlType( name "Name",
  • propOrder "first", "last"
    )
  • public class Name

28
??????? Name.java(3)
  • ?????????????
  • _at_XmlElement(required true)
  • protected String first
  • _at_XmlElement(required true)
  • protected String last

29
??????? Name.java(4)
  • getter ? setter ???
  • public String getFirst()
  • return first
  • public void setFirst( String value)
  • this.first value

30
XML???? Java??????
  • ltnamegt
  • ltfirstgtTatsuolt/firstgt
  • ltlastgtUedalt/lastgt
  • lt/namegt

31
XML???? Java??????
  • import javax.xml.bind.
  • import generated.
  • JAXBContext jc
  • JAXBContext.newInstance( "generated" )

32
XML???? Java??????
  • Unmarshaller u
  • jc.createUnmarshaller() JAXBElement
  • element
  • (JAXBElement)u.unmarshal(
  • new FileInputStream( "name.xml" ) )
  • Name name
  • (Name)element.getValue()

33
XML???? Java??????
  • String first name.getFirst()
  • String last name.getLast()
  • System.out.println( first " " last )

34
Java????????XML??
  • Name name new Name()
  • String first "Fujio"
  • String last "Maruyama"
  • name.setFirst( first )
  • name.setLast( last )

35
Java????????XML??
  • JAXBElement element new JAXBElement(
  • new QName( "name" ),
  • Name.class, name )
  • Marshaller m jc.createMarshaller()
  • m.setProperty(
  • Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE
    )
Write a Comment
User Comments (0)
About PowerShow.com