Java Reference
In-Depth Information
The file
sample-input.xml
in the top-level directory of the project contains an ex-
ample of an XML representation of a customer:
<?xml version="1.0" encoding="UTF-8"?>
<customer id="1">
<firstname>Duke</firstname>
<lastname>OfJava</lastname>
<address>
<number>1</number>
<street>Duke's Way</street>
<city>JavaTown</city>
<state>JA</state>
<zip>12345</zip>
<country>USA</country>
</address>
<email>duke@example.com</email>
<phone>123-456-7890</phone>
</customer>
The file
sample-input.json
contains an example of a JSON representation of a cus-
tomer:
{
"@id": "1",
"firstname": "Duke",
"lastname": "OfJava",
"address": {
"number": 1,
"street": "Duke's Way",
"city": "JavaTown",
"state": "JA",
"zip": "12345",
"country": "USA"
},
"email": "duke@example.com",
"phone": "123-456-7890"
}
The
CustomerService
Class
The
CustomerService
class has a
createCustomer
method that creates a custom-
er resource based on the
Customer
class and returns a URI for the new resource. The
persist
method emulates the behavior of the JPA entity manager. This example uses a
java.util.Properties
file to store data. If you are using the default configuration
of GlassFish Server, the properties file is at
domain-dir
/CustomerDATA.txt
.