Java Reference
In-Depth Information
System . out . println ( match . getClass (). getName ());
}
...
}
}
The for loop in getCustomer() prints out the class names of the JAX-RS resource objects
that were used to process the request. If the request is GET http://example.com/custom-
ers/usa-db/333 , the output of the for loop would be:
com . acme . CustomerDatabaseResource
com . acme . CustomerResource
Again, I'm hard-pressed to find a use case for this method, but it's in the specification and
you should be aware of it.
Building Links and Link Headers
JAX-RS 2.0 added some support to help you build Link headers and to embed links in your
XML documents through the Link and Link.Builder classes:
package
package javax . ws . rs . core ;
public
public abstract
abstract class
class Link
Link {
public
public abstract
abstract URI getUri ();
public
public abstract
abstract UriBuilder getUriBuilder ();
public
public abstract
abstract String getRel ();
public
public abstract
abstract List < String > getRels ();
public
public abstract
abstract String getTitle ();
public
public abstract
abstract String getType ();
public
public abstract
abstract Map < String , String > getParams ();
public
public abstract
abstract String toString ();
}
Link is an abstract class that represents all the metadata contained in either a Link header or
Atom link. The getUri() method pertains to the href attribute of your Atom link. getRel()
pertains to the rel attribute, and so on. You can also reference any of these attributes as well
as any proprietary extension attributes through the getParams() method. The toString()
method will convert the Link instance into a Link header.
Link instances are built through a Link.Builder , which is created by one of these methods:
public
public abstract
abstract class
class Link
Link {
public
public static
static Builder fromUri ( URI uri )
public
public static
static Builder fromUri ( String uri )
Search WWH ::




Custom Search