| Apache Cayenne > Index > RESTful Cayenne XML Service |
The idea is to build a service that generates XML for persistent data based on some criteria, passed as a URL with parameters. The service would use Cayenne to run the queries and XML generation process would leverage DataMap information as much as possible. The service should allow arbitrary customization of the generated XML format. The service should allow to run user code at all points of the request lifecycle, e.g. to implement security, filter the results, customize XML, etc. At the same time, the service should be usable out of the box with no other configuration except for the "cayenne.xml" and friends..
The service is RESTful in that each request is uniquely identified by the URL parameters. E.g.:
http://localhost/myapp/cayennexml?q=myquery&p1=a&p2=b![]()
"q" is a reserved parameter corresponding to the mapped query name. Other parameters are treated as named parameters that should be passed to the query. (TODO: type conversion)
Default XML format will be auto-generated from Cayenne mapping and can be overridden by the user (e.g. certain tags can be renamed, excluded, etc.). Cayenne DataObject-to-XML generator will be used, and users would optionally specify a config file overriding the defaults for XML generation.
Service callers can not specify which relationships to include, as this would result in a security hole. Instead the default behavior is to look at the query prefetches to see what parts of object graph should be included in the output XML. (TODO: in the future we may allow specifying included relationships separately from the query prefetches).
The service would allow registering a chain of interceptors that would allow implementing custom processing logic at all points of the invocation lifecycle. E.g.:
public interface XMLServiceInterceptor { void onRequest(XMLServiceChain chain, XMLEncoder out, ObjectContext context, String queryName, Map<String, String> parameters); }