@XMLAccessorType, @XMLRootElement

2013. 1. 21. 11:39OpenSource/Spring

반응형
@XMLAccessorType, @XMLRootElement에 대해서 알아보자!^-^good~

아래를 읽기전에  JAXB?? 이거 모르시는 분은 아래 링크 꾹~~^-^good~!


@XMLAccessorType                    


getter setter 내용들이 나오는 것을 보아...VO에서 처리하는 것임을 알 수 있다!^^;

또한 PROPERTIES는 아래와 같다.

이처럼 그 종류는 아래의 그림과 같다. 조건에 맞게 잘~~쓰면 될 것 같다^-^
나머지는 .(dot) 눌러서 살펴보시면 됩니다~^-^good!



Usage

@XmlAccessorType annotation can be used with the following program elements:

  • package
  • a top level class

See "Package Specification" in javax.xml.bind.package javadoc for additional common information.

This annotation provides control over the default serialization of properties and fields in a class.

The annotation @XmlAccessorType on a package applies to all classes in the package. The following inheritance semantics apply:

  • If there is a @XmlAccessorType on a class, then it is used.
  • Otherwise, if a @XmlAccessorType exists on one of its super classes, then it is inherited.
  • Otherwise, the @XmlAccessorType on a package is inherited.

Defaulting Rules:

By default, if @XmlAccessorType on a package is absent, then the following package level annotation is assumed.

   @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
 

By default, if @XmlAccessorType on a class is absent, and none of its super classes is annotated with @XmlAccessorType, then the following default on the class is assumed:

   @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
 

This annotation can be used with the following annotations: XmlType, XmlRootElement, XmlAccessorOrder, XmlSchema, XmlSchemaType, XmlSchemaTypes, , XmlJavaTypeAdapter. It can also be used with the following annotations at the package level: XmlJavaTypeAdapter.

Since:
JAXB2.0
Version:
$Revision: 1.9 $
Author:
Sekhar Vajjhala, Sun Microsystems, Inc.
See Also:
XmlAccessType
_M#]

또 다른 녀석~!!
@XMLRootElement

정리 해보면
@XMLAccessorType는 bound to xml(JAXB기반 직렬화 object->xml)을 하는데 있어서 범위? 방식을 정하는 것이다. Field면 정적이지 않거나 임시적이지 않는 필드여야만 한다. 이러한 방식!

@XMLRootElement는 정보라고 보면 된다. object가 xml로 bound가 되어 질 때
아래와 같은 2가지 정보를 준다고 보면 된다.
  • a top level class
  • an enum type

정보를 주는 방식은 위에 보면 예제를 들어서 설명을 하고 있다.
특히 3번째 예제를 많이들 쓴다.
※ Example 3: Associate a global element with XML Schema type to which the class is mapped. 

추신..: 
xml 스키마 타입(클래스가 mapped된)을 가진 글로벌요소를 결부짓다???? 연합시키다??--;;
  Associate 는 뭐라고 해석해야하지..난감하다 ㅎㅎ느낌은 알꺼 같은데...;;

  -끝-
 
반응형

'OpenSource > Spring' 카테고리의 다른 글

Spring jmsTemplate 사용하기  (0) 2013.03.26
HornetQ, JMS Client using Springframework and Maven  (0) 2013.03.22
spring bean 등록 방법  (0) 2013.01.04
decompiler for eclipse  (0) 2012.11.14
어플리케이션 컨텍스트의 동작 원리  (0) 2012.11.05