001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * dmetzler 018 */ 019package org.nuxeo.ecm.restapi.server.jaxrs; 020 021import java.util.LinkedHashSet; 022import java.util.Set; 023 024import org.nuxeo.ecm.automation.jaxrs.io.documents.BusinessAdapterListWriter; 025import org.nuxeo.ecm.automation.jaxrs.io.documents.JsonESDocumentWriter; 026import org.nuxeo.ecm.automation.jaxrs.io.operations.MultiPartFormRequestReader; 027import org.nuxeo.ecm.automation.jaxrs.io.operations.MultiPartRequestReader; 028import org.nuxeo.ecm.restapi.jaxrs.io.conversion.ConversionScheduledWriter; 029import org.nuxeo.ecm.restapi.jaxrs.io.conversion.ConversionStatusWithResultWriter; 030import org.nuxeo.ecm.restapi.jaxrs.io.types.DocumentTypesWriter; 031import org.nuxeo.ecm.restapi.jaxrs.io.types.FacetsWriter; 032import org.nuxeo.ecm.restapi.jaxrs.io.types.SchemasWriter; 033import org.nuxeo.ecm.webengine.app.WebEngineModule; 034import org.nuxeo.ecm.webengine.jaxrs.coreiodelegate.JsonCoreIODelegate; 035 036/** 037 * @since 5.8 038 */ 039public class APIModule extends WebEngineModule { 040 041 @Override 042 public Set<Class<?>> getClasses() { 043 Set<Class<?>> result = super.getClasses(); 044 // need to be stateless since it needs the request member to be 045 // injected 046 result.add(MultiPartRequestReader.class); 047 result.add(MultiPartFormRequestReader.class); 048 return result; 049 } 050 051 @Override 052 public Set<Object> getSingletons() { 053 Set<Object> result = new LinkedHashSet<Object>(); 054 055 // writers 056 result.add(new JsonESDocumentWriter()); 057 result.add(new BusinessAdapterListWriter()); 058 result.add(new SchemasWriter()); 059 result.add(new DocumentTypesWriter()); 060 result.add(new FacetsWriter()); 061 result.add(new ConversionScheduledWriter()); 062 result.add(new ConversionStatusWithResultWriter()); 063 064 // nuxeo-core-io MarshallerRegistry service reading and writing 065 result.add(new JsonCoreIODelegate()); 066 067 return result; 068 } 069}