com.kurento.kmf.content.internal.recorder.RecorderHandlerServlet.java Source code

Java tutorial

Introduction

Here is the source code for com.kurento.kmf.content.internal.recorder.RecorderHandlerServlet.java

Source

/*
 * (C) Copyright 2013 Kurento (http://kurento.org/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */
package com.kurento.kmf.content.internal.recorder;

import javax.servlet.AsyncContext;
import javax.servlet.ServletException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.kurento.kmf.content.HttpRecorderHandler;
import com.kurento.kmf.content.HttpRecorderService;
import com.kurento.kmf.content.internal.base.AbstractContentHandlerServlet;
import com.kurento.kmf.content.internal.base.AbstractContentSession;
import com.kurento.kmf.spring.KurentoApplicationContextUtils;

/**
 * 
 * Handler servlet for Recorder.
 * 
 * @author Luis Lpez (llopez@gsyc.es)
 * @version 1.0.0
 */
public class RecorderHandlerServlet extends AbstractContentHandlerServlet {

    /**
     * Default serial identifier.
     */
    private static final long serialVersionUID = 1L;

    /**
     * Logger.
     */
    private static final Logger log = LoggerFactory.getLogger(RecorderHandlerServlet.class);

    /**
     * Autowired Recorder Handler.
     */
    @Autowired
    private HttpRecorderHandler recorderHandler;

    /**
     * Look for {@link HttpRecorderService} annotation in the handler class and
     * check whether or not it is using JSON control protocol.
     * 
     * @return JSON Control Protocol strategy (true|false)
     */
    @Override
    protected boolean getUseJsonControlProtocol(Class<?> handlerClass) throws ServletException {
        return handlerClass.getAnnotation(HttpRecorderService.class).useControlProtocol();
    }

    /**
     * Create a content Request instance (as a Spring Bean).
     * 
     * @param asyncCtx
     *            Asynchronous context
     * @param contentId
     *            Content identifier
     * @return Content Request
     */
    @Override
    protected AbstractContentSession createContentSession(AsyncContext asyncCtx, String contentId) {
        return (HttpRecorderSessionImpl) KurentoApplicationContextUtils.getBean("httpRecordSessionImpl",
                recorderHandler, contentSessionManager, asyncCtx, contentId,
                handlerClass.getAnnotation(HttpRecorderService.class).redirect(), useControlProtocol);
    }

    /**
     * Logger accessor (getter).
     * 
     * @return Logger
     */
    @Override
    protected Logger getLogger() {
        return log;
    }

}