Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is JAXBContext.newInstance(String contextPath)?

I see the usage of the below method in my project

JAXBContext jc = JAXBContext.newInstance("org.test.customer");

where org.test.customer is the package name.

Does it mean we can marshal/unmarshal classes which lies under org.test.customer?

My understanding is based on http://docs.oracle.com/javaee/5/api/javax/xml/bind/JAXBContext.html#newInstance(java.lang.String)

like image 807
user3198603 Avatar asked Jun 04 '15 12:06

user3198603


1 Answers

The explanation is in JAXBContext class`s Javadoc

The JAXBContext instance is initialized from a list of colon separated Java package names. Each java package contains JAXB mapped classes, schema-derived classes and/or user annotated classes.

Example:

JAXBContext jc = JAXBContext.newInstance( "com.acme.foo:com.acme.bar" );
like image 189
Evgeniy Dorofeev Avatar answered Sep 22 '22 00:09

Evgeniy Dorofeev