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

com.sun.faces.facelets.PrivateApiFaceletCacheAdapter Maven / Gradle / Ivy

There is a newer version: 4.1.1
Show newest version
/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package com.sun.faces.facelets;

import com.sun.faces.facelets.FaceletCache.InstanceFactory;
import java.io.IOException;
import java.net.URL;
import javax.faces.view.facelets.FaceletCache;
import javax.faces.view.facelets.FaceletCache.MemberFactory;

public class PrivateApiFaceletCacheAdapter extends FaceletCache {

    private com.sun.faces.facelets.FaceletCache privateApi;

    public PrivateApiFaceletCacheAdapter(com.sun.faces.facelets.FaceletCache privateApi) {
        this.privateApi = privateApi;
    }

    @Override
    public V getFacelet(URL url) throws IOException {
        return privateApi.getFacelet(url);
    }

    @Override
    public V getViewMetadataFacelet(URL url) throws IOException {
        return privateApi.getMetadataFacelet(url);
    }

    @Override
    public boolean isFaceletCached(URL url) {
        return privateApi.isFaceletCached(url);
    }

    @Override
    public boolean isViewMetadataFaceletCached(URL url) {
        return privateApi.isMetadataFaceletCached(url);
    }

    private MemberFactory memberFactory;
    private MemberFactory metadataMemberFactory;

    @Override
    public void setMemberFactories(final MemberFactory faceletFactory, 
            final MemberFactory viewMetadataFaceletFactory) {
        InstanceFactory instanceFactory = new InstanceFactory() {

            @Override
            public V newInstance(URL key) throws IOException {
                return faceletFactory.newInstance(key);
            }

        };
        InstanceFactory metadataInstanceFactory = new InstanceFactory() {

            @Override
            public V newInstance(URL key) throws IOException {
                return viewMetadataFaceletFactory.newInstance(key);
            }

        };

        privateApi.init(instanceFactory, metadataInstanceFactory);
    }

    @Override
    public MemberFactory getMemberFactory() {
        return memberFactory;
    }

    @Override
    public MemberFactory getMetadataMemberFactory() {
        return metadataMemberFactory;
    }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy