001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.main;
029
030import java.io.IOException;
031import java.io.InputStream;
032
033import com.vaadin.server.Constants;
034import com.vaadin.server.DeploymentConfiguration;
035import com.vaadin.server.ServiceException;
036import com.vaadin.server.VaadinServlet;
037import com.vaadin.server.VaadinServletService;
038import com.vaadin.ui.UI;
039
040/**
041 * A custom servlet service implementation.<p>
042 */
043public class CmsVaadinServletService extends VaadinServletService {
044
045    /** Serial version id. */
046    private static final long serialVersionUID = 1L;
047
048    /**
049     * Creates a new instance.<p>
050     *
051     * @param servlet the servlet instance
052     * @param deploymentConfiguration the deployment configuration
053     *
054     * @throws ServiceException if something goes wrong
055     */
056    public CmsVaadinServletService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration)
057    throws ServiceException {
058        super(servlet, deploymentConfiguration);
059
060    }
061
062    /**
063     * @see com.vaadin.server.VaadinServletService#getThemeResourceAsStream(com.vaadin.ui.UI, java.lang.String, java.lang.String)
064     */
065    @Override
066    public InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) throws IOException {
067
068        String resourcePath = Constants.THEME_DIR_PATH + '/' + themeName + "/" + resource;
069        InputStream result = getClass().getClassLoader().getResourceAsStream(resourcePath);
070        if (result != null) {
071            return result;
072        } else {
073            return super.getThemeResourceAsStream(uI, themeName, resource);
074        }
075    }
076
077}