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 String getListenerName() { 044 return "bundle"; 045 } 046 047 @Override 048 protected WroManagerFactory newManagerFactory() { 049 return new NuxeoWroManagerFactory(); 050 } 051 052 @Override 053 protected WroConfiguration newConfiguration() { 054 WroConfiguration conf = new WroConfiguration(); 055 conf.setIgnoreMissingResources(false); 056 if (Framework.isDevModeSet()) { 057 if (log.isDebugEnabled()) { 058 log.debug("Set wro debug configuration"); 059 } 060 conf.setDebug(true); 061 conf.setMinimizeEnabled(false); 062 conf.setCacheUpdatePeriod(2); 063 conf.setModelUpdatePeriod(2); 064 } else { 065 conf.setDebug(false); 066 } 067 return conf; 068 } 069 070}