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.restapi.jaxrs.io.conversion.ConversionScheduledWriter; 028import org.nuxeo.ecm.restapi.jaxrs.io.conversion.ConversionStatusWithResultWriter; 029import org.nuxeo.ecm.restapi.jaxrs.io.types.DocumentTypesWriter; 030import org.nuxeo.ecm.restapi.jaxrs.io.types.FacetsWriter; 031import org.nuxeo.ecm.restapi.jaxrs.io.types.SchemasWriter; 032import org.nuxeo.ecm.webengine.app.WebEngineModule; 033import org.nuxeo.ecm.webengine.jaxrs.coreiodelegate.JsonCoreIODelegate; 034 035/** 036 * @since 5.8 037 */ 038public class APIModule extends WebEngineModule { 039 040 @Override 041 public Set<Class<?>> getClasses() { 042 Set<Class<?>> result = super.getClasses(); 043 // need to be stateless since it needs the request member to be 044 // injected 045 result.add(MultiPartFormRequestReader.class); 046 return result; 047 } 048 049 @Override 050 public Set<Object> getSingletons() { 051 Set<Object> result = new LinkedHashSet<Object>(); 052 053 // writers 054 result.add(new JsonESDocumentWriter()); 055 result.add(new BusinessAdapterListWriter()); 056 result.add(new SchemasWriter()); 057 result.add(new DocumentTypesWriter()); 058 result.add(new FacetsWriter()); 059 result.add(new ConversionScheduledWriter()); 060 result.add(new ConversionStatusWithResultWriter()); 061 062 // nuxeo-core-io MarshallerRegistry service reading and writing 063 result.add(new JsonCoreIODelegate()); 064 065 return result; 066 } 067}