001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.web.resources.wro.servlet; 018 019import org.apache.commons.logging.Log; 020import org.apache.commons.logging.LogFactory; 021import org.nuxeo.ecm.web.resources.wro.factory.NuxeoWroManagerFactory; 022import org.nuxeo.runtime.api.Framework; 023 024import ro.isdc.wro.config.jmx.WroConfiguration; 025import ro.isdc.wro.http.WroServletContextListener; 026import ro.isdc.wro.manager.factory.WroManagerFactory; 027 028/** 029 * Servlet context listener initiating wro debug mode on runtime dev mode, and hooking up the specific 030 * {@link NuxeoWroManagerFactory}. 031 * 032 * @since 7.3 033 */ 034public class NuxeoWroServletContextListener extends WroServletContextListener { 035 036 private static final Log log = LogFactory.getLog(NuxeoWroServletContextListener.class); 037 038 public NuxeoWroServletContextListener() { 039 super(); 040 } 041 042 @Override 043 protected WroManagerFactory newManagerFactory() { 044 return new NuxeoWroManagerFactory(); 045 } 046 047 @Override 048 protected WroConfiguration newConfiguration() { 049 WroConfiguration conf = new WroConfiguration(); 050 conf.setIgnoreMissingResources(false); 051 if (Framework.isDevModeSet()) { 052 if (log.isDebugEnabled()) { 053 log.debug("Set wro debug configuration"); 054 } 055 conf.setDebug(true); 056 conf.setMinimizeEnabled(false); 057 conf.setCacheUpdatePeriod(2); 058 conf.setModelUpdatePeriod(2); 059 } else { 060 conf.setDebug(false); 061 } 062 return conf; 063 } 064 065}