001/* 002 * Copyright 2016 Anyware Services 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 017package org.ametys.plugins.core.ui.minimize.js; 018 019import java.util.List; 020 021import org.apache.avalon.framework.service.ServiceException; 022import org.apache.avalon.framework.service.ServiceManager; 023 024import org.ametys.core.minimize.js.MinimizeJSManager; 025import org.ametys.plugins.core.ui.minimize.AbstractMinimizeReader; 026import org.ametys.plugins.core.ui.minimize.HashCache.UriData; 027 028/** 029 * This generator generates a single JS file to load all ui items js files. 030 * Can generates a list of imports of directly intergrates all js files. 031 */ 032public class MinimizeJSReader extends AbstractMinimizeReader 033{ 034 private MinimizeJSManager _jsMinimizeManager; 035 036 @Override 037 public void service(ServiceManager smanager) throws ServiceException 038 { 039 super.service(smanager); 040 _jsMinimizeManager = (MinimizeJSManager) manager.lookup(MinimizeJSManager.ROLE); 041 } 042 043 @Override 044 public String getMimeType() 045 { 046 return "text/javascript;charset=utf-8"; 047 } 048 049 @Override 050 protected String _handleFiles(List<UriData> files, boolean generateSourceMap) 051 { 052 return _jsMinimizeManager.minimizeAndAggregateURIs(files, source + ".js", generateSourceMap); 053 } 054}