001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * dmetzler 016 */ 017package org.nuxeo.ecm.restapi.server.jaxrs; 018 019import java.util.LinkedHashSet; 020import java.util.Set; 021 022import org.nuxeo.ecm.automation.jaxrs.io.documents.BusinessAdapterListWriter; 023import org.nuxeo.ecm.automation.jaxrs.io.documents.JsonESDocumentWriter; 024import org.nuxeo.ecm.automation.jaxrs.io.operations.MultiPartFormRequestReader; 025import org.nuxeo.ecm.automation.jaxrs.io.operations.MultiPartRequestReader; 026import org.nuxeo.ecm.restapi.jaxrs.io.conversion.ConversionScheduled; 027import org.nuxeo.ecm.restapi.jaxrs.io.conversion.ConversionScheduledWriter; 028import org.nuxeo.ecm.restapi.jaxrs.io.conversion.ConversionStatusWriter; 029import org.nuxeo.ecm.restapi.jaxrs.io.types.DocumentTypeWriter; 030import org.nuxeo.ecm.restapi.jaxrs.io.types.DocumentTypesWriter; 031import org.nuxeo.ecm.restapi.jaxrs.io.types.FacetWriter; 032import org.nuxeo.ecm.restapi.jaxrs.io.types.FacetsWriter; 033import org.nuxeo.ecm.restapi.jaxrs.io.types.SchemaWriter; 034import org.nuxeo.ecm.restapi.jaxrs.io.types.SchemasWriter; 035import org.nuxeo.ecm.webengine.app.WebEngineModule; 036import org.nuxeo.ecm.webengine.jaxrs.coreiodelegate.JsonCoreIODelegate; 037 038/** 039 * @since 5.8 040 */ 041public class APIModule extends WebEngineModule { 042 043 @Override 044 public Set<Class<?>> getClasses() { 045 Set<Class<?>> result = super.getClasses(); 046 // need to be stateless since it needs the request member to be 047 // injected 048 result.add(MultiPartRequestReader.class); 049 result.add(MultiPartFormRequestReader.class); 050 return result; 051 } 052 053 @Override 054 public Set<Object> getSingletons() { 055 Set<Object> result = new LinkedHashSet<Object>(); 056 057 // writers 058 result.add(new JsonESDocumentWriter()); 059 result.add(new BusinessAdapterListWriter()); 060 result.add(new SchemasWriter()); 061 result.add(new SchemaWriter()); 062 result.add(new DocumentTypeWriter()); 063 result.add(new DocumentTypesWriter()); 064 result.add(new FacetWriter()); 065 result.add(new FacetsWriter()); 066 result.add(new FacetsWriter()); 067 result.add(new ConversionScheduledWriter()); 068 result.add(new ConversionStatusWriter()); 069 070 // nuxeo-core-io MarshallerRegistry service reading and writing 071 result.add(new JsonCoreIODelegate()); 072 073 return result; 074 } 075}