1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or14 * implied.15 * 16 * See the License for the specific language governing permissions and17 * limitations under the License.18 */19 20 package org.apache.excalibur.instrument.manager.http;21 22 import com.sun.image.codec.jpeg.JPEGCodec;23 import com.sun.image.codec.jpeg.JPEGEncodeParam;24 import com.sun.image.codec.jpeg.JPEGImageEncoder;25 26 import java.awt.Graphics ;27 import java.awt.image.BufferedImage ;28 import java.io.BufferedInputStream ;29 import java.io.IOException ;30 import java.io.OutputStream ;31 import java.io.UnsupportedEncodingException ;32 import java.util.Map ;33 34 import org.apache.excalibur.instrument.manager.http.server.AbstractHTTPURLHandler;35 import org.apache.excalibur.instrument.manager.http.server.HTTPRedirect;36 import org.apache.excalibur.instrument.manager.http.server.URLCoder;37 import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;38 import org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor;39 import org.apache.excalibur.instrument.manager.InstrumentSampleSnapshot;40 import org.apache.excalibur.instrument.manager.NoSuchInstrumentSampleException;41 42 /**43 * Serves up a favicon.ico file.44 *45 * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>46 * @version CVS $Revision: 1.9 $ $Date: 2004/03/06 14:01:28 $47 * @since 4.148 */49 public class FavIconHandler50 extends AbstractHTTPURLHandler51 {52 /*---------------------------------------------------------------53 * Constructors54 *-------------------------------------------------------------*/55 /**56 * Creates a new FavIconHandler.57 */58 public FavIconHandler()59 {60 super( "/favicon.ico", CONTENT_TYPE_IMAGE_X_ICON,61 InstrumentManagerHTTPConnector.ENCODING );62 }63 64 /*---------------------------------------------------------------65 * AbstractHandler Methods66 *-------------------------------------------------------------*/67 /**68 * Handles the specified request.69 *70 * @param The full path being handled.71 * @param parameters A Map of the parameters in the request.72 * @param os The OutputStream to write the result to.73 */74 public void doGet( String path, Map parameters, OutputStream os )75 throws IOException 76 {77 String imageResource = "favicon.ico";78 BufferedInputStream is =79 new BufferedInputStream ( getClass().getResourceAsStream( imageResource ) );80 byte[] favIcon;81 try {82 favIcon = new byte[is.available()];83 is.read( favIcon, 0, favIcon.length );84 } finally {85 is.close();86 }87 // Now write the image out to the client.88 os.write( favIcon );89 }90 }91 92