Apache CXF API

org.apache.cxf.binding.http.strategy
Class ConventionStrategy

java.lang.Object
  extended by org.apache.cxf.binding.http.strategy.ConventionStrategy
All Implemented Interfaces:
ResourceStrategy

public class ConventionStrategy
extends Object
implements ResourceStrategy

Maps a BindingOperation to a URI/combination using the following rules:

GET Operations: If the operation name starts with "get" and it has no parameters, it is assumed it is a get for a collection of objects. The noun after the "get" is turned into the resource name. Example: "getCustomers" is turned into "/customers".

If the operation name starts with "get" and it takes parameters, it is taken to be a get for a singular noun. In this case the noun is pluralized, and the resource name is the pluralized noun and any additional parameters the operation takes. For the case of the operation which has a signature of "Customer getCustomer(String id)" the resource would become "/customers/{id}".

POST Operations: If the operation name starts with "add" or "create" it is turned into a POST operation. In this case noun after add/create is pluralized and turned into the resource name. Example: "addCustomer(Customer)" is truned into "/customers".

PUT Operations: If the operation name starts with "update" it is turned into a PUT operation. In this case the resource name is the pluralized noun after "update" and any additional XML schema primitive parameters the operation takes. Example: "updateCustomer(String id, Customer c)" becomes "/customers/{id}". The customer object does NOT become part of the resource name because it doesn't map to an XML schema primitive type such as xsd:int, xsd:string, etc.

DELETE Operations: Delete operations follow the same rules as PUT operations, except the operation name must start with either "delete" or "remove". Example: "deleteCustomer(String id,)" becomes "/customers/{id}".


Constructor Summary
ConventionStrategy()
           
 
Method Summary
 Inflector getInflector()
           
 boolean map(BindingOperationInfo bop, Method m, URIMapper mapper)
           
 void setInflector(Inflector inflector)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConventionStrategy

public ConventionStrategy()
Method Detail

map

public boolean map(BindingOperationInfo bop,
                   Method m,
                   URIMapper mapper)
Specified by:
map in interface ResourceStrategy

getInflector

public Inflector getInflector()

setInflector

public void setInflector(Inflector inflector)

Apache CXF API

Apache CXF