All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.jsftemplating.util.CachedURLStreamHandler Maven / Gradle / Ivy

/*
 * The contents of this file are subject to the terms 
 * of the Common Development and Distribution License 
 * (the License).  You may not use this file except in
 * compliance with the License.
 * 
 * You can obtain a copy of the license at 
 * https://jsftemplating.dev.java.net/cddl1.html or
 * jsftemplating/cddl1.txt.
 * See the License for the specific language governing 
 * permissions and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL 
 * Header Notice in each file and include the License file 
 * at jsftemplating/cddl1.txt.  
 * If applicable, add the following below the CDDL Header, 
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information: 
 * "Portions Copyrighted [year] [name of copyright owner]"
 * 
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
 */
package com.sun.jsftemplating.util;

import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;

/**
 *  

This class enables a URLConnection to be returned when * openConnection(URL) is called which is capable of reading * from a T object.

*/ public class CachedURLStreamHandler extends URLStreamHandler { /** *

This constructor stores the given T object, which * will be used by the {@link CachedURLConnection} which is created * when openConnection is called. It stores this as a * WeakReference, so it will be garbage collected if no * other "strong" references refer to it!

*/ public CachedURLStreamHandler(T obj) { this.weakRef = new WeakReference(obj); } /** *

This method creates a new {@link CachedURLConnection} associated with * the T object given when the constructor was called.

*/ protected URLConnection openConnection(URL url) throws IOException { return new CachedURLConnection(url, weakRef); } private WeakReference weakRef = null; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy