62 | | The '''Spring framework''' is used to define '''beans''' for singleton service objects, which are injected into various components throughout the application. The [source:/VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/webapp/WEB-INF/applicationContext.xml applicationContext.xml] file bootstraps the bean definition, while most beans are discovered en constructed by means of 'component scanning'. For example, a singleton bean for ''!DataStore'' exists because it is annotated ''@Repository''. The instance is made available in the ''!VirtualCollectionRegistry'' and''Application'' (for the Wicket UI) instances because both are managed by Spring too (annotated with ''@Service'' and ''@Component'' respectively) and contain a ''!DataStore'' field annotated with ''@Autowired''. |
| 62 | The '''Spring framework''' is used to define '''beans''' for singleton service objects, which are injected into various components throughout the application. The [source:/VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/webapp/WEB-INF/applicationContext.xml applicationContext.xml] file bootstraps the bean definition, while most beans are discovered en constructed by means of 'component scanning'. For example, a singleton bean for ''!DataStore'' exists because it is annotated ''@Repository''. The instance is made available in the ''!VirtualCollectionRegistry'' and ''Application'' (for the Wicket UI) instances because both are managed by Spring too (annotated with ''@Service'' and ''@Component'' respectively) and contain a ''!DataStore'' field annotated with ''@Autowired''. |
| 63 | |
| 64 | A number of core services for marshalling, validation, etcetera can be found in ''eu.clarin.cmdi.virtualcollectionregistry.service'' package (generally interfaces with implementations in the .impl subpackage). |
| 65 | |
| 66 | {{{#!comment |
| 67 | Query language |
| 68 | }}} |
71 | | Jersey |
| 77 | The package ''eu.clarin.cmdi.virtualcollectionregistry.rest'' defines a RESTful web service by means of JAX-RS annotations. It uses Jersey as an implementation and depends on a number of Jersey extensions, primarily injection of beans. Four classes define the following (sub)resources: |
| 78 | * /virtualcollections (class ''!VirtualCollectionsResource'') allows listing (GET) of published collections and POSTing of new collections |
| 79 | * /virtualcollections/{id} (class ''!VirtualCollectionResource'') is a subresource that allows GETting, PUTting and DELETEing individual collections |
| 80 | * /my-virtualcollections (class ''!MyVirtualCollectionsResource'') only allows retrieval (GET) the list of private and published collections owned by the authenticated user |
| 81 | * / (class ''!BaseResource'') is a dummy resource that renders an informative HTML page (if content negotiation allows) about the service |
| 82 | |
| 83 | Two ''!BodyWriter'' classes are implemented and registered, taking care of the rendering of !VirtualCollection object as CMDI or XML/JSON respectively, by means of different methods of the (injected) ''!VirtualCollectionMarshaller'' service. This way, a single method in ''!VirtualCollectionResource'' can handle these various rendering options (depending on the HTTP Accept header in the client request). An additional method handles requests accepting HTML by returning a redirect ('see other') response pointing to the collection details page of the Wicket UI. |
| 84 | |
| 85 | More info: |
| 86 | * [https://jersey.java.net/documentation/latest/jaxrs-resources.html JAX-RS resources documentation from Jersey] |
| 87 | * [https://jersey.java.net/documentation/latest/message-body-workers.html information on custom body providers from Jersey] |