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