001 // Copyright 2011 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry5.yuicompressor.services; 016 017 import org.apache.tapestry5.internal.yuicompressor.CSSResourceMinimizer; 018 import org.apache.tapestry5.internal.yuicompressor.JavaScriptResourceMinimizer; 019 import org.apache.tapestry5.ioc.MappedConfiguration; 020 import org.apache.tapestry5.ioc.annotations.Contribute; 021 import org.apache.tapestry5.ioc.annotations.Primary; 022 import org.apache.tapestry5.services.assets.ResourceMinimizer; 023 024 import com.yahoo.platform.yui.compressor.YUICompressor; 025 026 /** 027 * Sets up Tapestry to compress JavaScript assets using {@link YUICompressor}. 028 * 029 * @since 5.3 030 */ 031 public class YuiCompressorModule 032 { 033 /** 034 * Contibutes minimizers for <code>text/javascript</code> and <code>test/css</code>. 035 * 036 * @param configuration 037 */ 038 @Contribute(ResourceMinimizer.class) 039 @Primary 040 public static void contributeMinimizers(MappedConfiguration<String, ResourceMinimizer> configuration) 041 { 042 configuration.addInstance("text/javascript", JavaScriptResourceMinimizer.class); 043 configuration.addInstance("text/css", CSSResourceMinimizer.class); 044 } 045 }