org.fusesource.examples.cxf.jaxrs.security
Class Order

java.lang.Object
  extended by org.fusesource.examples.cxf.jaxrs.security.Order

public class Order
extends java.lang.Object

The Order class is not only a plain old java object, with a few properties and getters and setters, but it also defines a sub-resource for the Order returned by CustomerService. By adding the @XmlRootElement annotation, we make it possible for JAXB to unmarshal this object into a XML document and to marshal it back from the same XML document. The XML representation of an Order will look like this: 223 Order 223


Constructor Summary
Order()
           
 
Method Summary
 java.lang.String getDescription()
           
 long getId()
           
 Product getProduct(int productId)
          This method is mapped to an HTTP GET of 'products/{productId}', relative to the URL that point to this Order resource itself.
 Order getThisOrder()
          This method is mapped to an HTTP GET of '/', relative to the URL that point to this Order resource itself.
 void setDescription(java.lang.String d)
           
 void setId(long id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Order

public Order()
Method Detail

getId

public long getId()

setId

public void setId(long id)

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String d)

getThisOrder

public Order getThisOrder()
This method is mapped to an HTTP GET of '/', relative to the URL that point to this Order resource itself. The method returns the Order object itself - for creating the HTTP response, this object is marshaled into XML using JAXB. For example: if surfing to 'http://localhost:8181/cxf/crm/customerservice/orders/223' will show you the information of order 223 in XML format (as defined in CustomerService's getOrder() method), you can access product 323 in that order by accessing 'http://localhost:8181/cxf/crm/customerservice/orders/223/products/323'


getProduct

public Product getProduct(int productId)
This method is mapped to an HTTP GET of 'products/{productId}', relative to the URL that point to this Order resource itself. The value for {productId} will be passed to this message as a parameter, using the @PathParam annotation. The method returns an Product object - for creating the HTTP response, this object is marshaled into XML using JAXB. For example: accessing 'http://localhost:8181/cxf/crm/customerservice/orders/223/products/323' will first trigger the CustomerService's getOrder() method to return the Order instance for order 223 and afterwards, it will use the remaining part of the URI ('products/323') to map to this method and return the product details for product 323 in this order.



Copyright © 2012 FuseSource. All Rights Reserved.