Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package javax.faces.view.facelets;
 
 import java.net.URL;



This API defines the facility by which the Facelets javax.faces.view.ViewDeclarationLanguage creates and caches instances of Facelets.

The cache handles two different kinds of Facelets: View Facelets and View Metadata Facelets. The former is the usual Facelet that provides for the construction of a UIComponent tree. This kind of Facelet is accessed via the getFacelet(java.net.URL) and isFaceletCached(java.net.URL) methods. The latter is a special kind of Facelet that corresponds to javax.faces.view.ViewDeclarationLanguage.getViewMetadata(javax.faces.context.FacesContext,java.lang.String). This kind of Facelet is accessed via the getViewMetadataFacelet(java.net.URL) and isViewMetadataFaceletCached(java.net.URL) methods.

Since:
2.1
 
 
 public abstract class FaceletCache<V> {

    

Factory interface for creating Facelet or View Metadata Facelet instances.

 
     public interface MemberFactory<V> {

Create a Facelet or View Metadata Facelet (depending on the type of factory this is) for the argument URL.

Parameters:
key the URL that will be used as the key for the instance being created.
Throws:
java.lang.NullPointerException if argument key is null.
 
         public V newInstance(final URL keythrows IOException;
     }


    

Returns a cached Facelet instance. If no instance is available, it will be created using the Facelet FaceletCache.MemberFactory and stored in the cache.

Parameters:
url URL for the Facelet being retrieved
Throws:
java.lang.NullPointerException if argument url is null.
 
    public abstract V getFacelet(URL urlthrows IOException;

    

Determines whether a cached Facelet instance exists for this URL. Returns true if a cached instance exists, false otherwise

Parameters:
url URL for the Facelet
Throws:
java.lang.NullPointerException if argument url is null.
    public abstract boolean isFaceletCached(URL url);

    

Returns a cached View Metadata Facelet instance. If no instance is available, it will be created using the View Metadata Facelet FaceletCache.MemberFactory and stored in the cache.

Parameters:
url URL for the View Metadata Facelet being retrieved
Throws:
java.lang.NullPointerException if argument url is null.
    public abstract V getViewMetadataFacelet(URL urlthrows IOException;

    

Determines whether a cached View Metadata Facelet instance exists for this URL. Returns true if a cached instance exists, false otherwise

Parameters:
url URL for the View Metadata Facelet
Throws:
java.lang.NullPointerException if argument url is null.
    public abstract boolean isViewMetadataFaceletCached(URL url);


    

This must be called by the runtime at startup time, before any requests are serviced, and allows for the FaceletCache implementation to provide the FaceletCache.MemberFactory instances that will be used to create instances of Facelets and View Metadata Facelets.

Parameters:
faceletFactory the FaceletCache.MemberFactory instance that will be used to create instances of Facelets.
viewMetadataFaceletFactory the FaceletCache.MemberFactory instance that will be used to create instances of metadata Facelets.
Throws:
java.lang.NullPointerException if either argument is null
    protected void setMemberFactories(MemberFactory<V> faceletFactory,
            MemberFactory<V> viewMetadataFaceletFactory) {
	if (null == faceletFactory || null == viewMetadataFaceletFactory) {
	    throw new NullPointerException("Neither faceletFactory no viewMetadataFaceletFactory may be null.");
	}
        this. = faceletFactory;
        this. = viewMetadataFaceletFactory;
    }
    private MemberFactory<V> memberFactory;
    private MemberFactory<V> viewMetadataMemberFactory;


    
    protected MemberFactory<V> getMemberFactory() {
        return ;
    }

    
    protected MemberFactory<V> getMetadataMemberFactory() {
        return ;
    }
New to GrepCode? Check out our FAQ X