Package org.apache.myfaces.shared.resource

Examples of org.apache.myfaces.shared.resource.ResourceMeta


    }
   
    protected ResourceMeta deriveViewResourceMeta(FacesContext context, ResourceLoader resourceLoader,
            String resourceName, String localePrefix)
    {
        ResourceMeta resourceMeta = null;
        String resourceVersion = null;

        //1. Try to locate resource in a localized path
        if (localePrefix != null)
        {
View Full Code Here


    }
   
    protected ResourceMeta deriveViewResourceMeta(FacesContext context, ContractResourceLoader resourceLoader,
            String resourceName, String localePrefix, String contractName)
    {
        ResourceMeta resourceMeta = null;
        String resourceVersion = null;

        //1. Try to locate resource in a localized path
        if (localePrefix != null)
        {
View Full Code Here

            boolean resolved = false;
            if (contractPreferred != null)
            {
                for (ContractResourceLoader loader : getResourceHandlerSupport().getContractResourceLoaders())
                {
                    ResourceMeta resourceMeta = deriveViewResourceMeta(
                        facesContext, loader, resourceName, localePrefix, contractPreferred);
                    if (resourceMeta != null)
                    {
                        resource = new ResourceImpl(resourceMeta, loader,
                            getResourceHandlerSupport(), contentType);

                        // cache it
                        getResourceLoaderCache().putViewResource(
                            resourceName, contentType, localePrefix, contractPreferred, resourceMeta, loader,
                            new ResourceCachedInfo(resource.getURL(), null));
                       
                        resolved = true;
                        break;
                    }
                }
            }
            if (!resolved && !contracts.isEmpty())
            {
                for (ContractResourceLoader loader :
                        getResourceHandlerSupport().getContractResourceLoaders())
                {
                    for (String contract : contracts)
                    {
                        ResourceMeta resourceMeta = deriveViewResourceMeta(
                            facesContext, loader, resourceName, localePrefix, contract);
                        if (resourceMeta != null)
                        {
                            resource = new ResourceImpl(resourceMeta, loader,
                                getResourceHandlerSupport(), contentType);

                            // cache it
                            getResourceLoaderCache().putViewResource(
                                resourceName, contentType, localePrefix, contract, resourceMeta, loader,
                                new ResourceCachedInfo(resource.getURL(), null));

                            resolved = true;
                            break;
                        }
                    }
                }
            }
            if (!resolved)
            {
                // "... Considering the web app root ..."
               
                // "... Considering faces flows (at the locations specified in the spec prose document section
                // Faces Flows in the Using JSF in Web Applications chapter) ..."
                for (ResourceLoader loader : getResourceHandlerSupport().getViewResourceLoaders())
                {
                    ResourceMeta resourceMeta = deriveViewResourceMeta(
                        facesContext, loader, resourceName, localePrefix);

                    if (resourceMeta != null)
                    {
                        resource = new ResourceImpl(resourceMeta, loader, getResourceHandlerSupport(), contentType);
View Full Code Here

        }
        else
        {
            for (ResourceLoader loader : getResourceHandlerSupport().getResourceLoaders())
            {
                ResourceMeta resourceMeta = deriveResourceMeta(loader, resourceName, libraryName, localePrefix);
   
                if (resourceMeta != null)
                {
                    resource = new ResourceImpl(resourceMeta, loader, getResourceHandlerSupport(), contentType);
View Full Code Here

    protected ResourceMeta deriveResourceMeta(ResourceLoader resourceLoader,
            String resourceName, String libraryName, String localePrefix)
    {
        String resourceVersion = null;
        String libraryVersion = null;
        ResourceMeta resourceId = null;
       
        //1. Try to locate resource in a localized path
        if (localePrefix != null)
        {
            if (null != libraryName)
View Full Code Here

                return true;
            }
        };
       
        application.setDefaultLocale(Locale.ENGLISH);
        ResourceMeta resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/1_0_2/myres.js/1_3.js");
        Assert.assertNotNull(resource);
        Assert.assertEquals("en", resource.getLocalePrefix());
        Assert.assertEquals("mylib", resource.getLibraryName());
        Assert.assertEquals("1_0_2", resource.getLibraryVersion());
        Assert.assertEquals("myres.js", resource.getResourceName());
        Assert.assertEquals("1_3", resource.getResourceVersion());
       
        resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/1_0_2/myres.js");
        Assert.assertNotNull(resource);
        Assert.assertEquals("en", resource.getLocalePrefix());
        Assert.assertEquals("mylib", resource.getLibraryName());
        Assert.assertEquals("1_0_2", resource.getLibraryVersion());
        Assert.assertEquals("myres.js", resource.getResourceName());
        Assert.assertNull(resource.getResourceVersion());       
       
        resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/myres.js/1_3.js");
        Assert.assertNotNull(resource);
        Assert.assertEquals("en", resource.getLocalePrefix());
        Assert.assertEquals("mylib", resource.getLibraryName());
        Assert.assertNull(resource.getLibraryVersion());
        Assert.assertEquals("myres.js", resource.getResourceName());
        Assert.assertEquals("1_3", resource.getResourceVersion());

        resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/mylib/myres.js");
        Assert.assertNotNull(resource);
        Assert.assertEquals("en", resource.getLocalePrefix());
        Assert.assertEquals("mylib", resource.getLibraryName());
        Assert.assertEquals("myres.js", resource.getResourceName());
        Assert.assertNull(resource.getLibraryVersion());
        Assert.assertNull(resource.getResourceVersion());

        resource = resourceHandler.deriveResourceMeta(facesContext, loader, "en/myres.js");
        Assert.assertNotNull(resource);
        Assert.assertNull(resource.getLibraryName());
        Assert.assertNull(resource.getLibraryVersion());
        Assert.assertNull(resource.getResourceVersion());
        Assert.assertEquals("en", resource.getLocalePrefix());
        Assert.assertEquals("myres.js", resource.getResourceName());
       
        resource = resourceHandler.deriveResourceMeta(facesContext, loader, "mylib/myres.js");
        Assert.assertNotNull(resource);
        Assert.assertNull(resource.getLocalePrefix());
        Assert.assertNull(resource.getLibraryVersion());
        Assert.assertNull(resource.getResourceVersion());
        Assert.assertEquals("mylib", resource.getLibraryName());
        Assert.assertEquals("myres.js", resource.getResourceName());
       
        resource = resourceHandler.deriveResourceMeta(facesContext, loader, "myres.js");
        Assert.assertNotNull(resource);
        Assert.assertNull(resource.getLocalePrefix());
        Assert.assertNull(resource.getLibraryName());
        Assert.assertNull(resource.getLibraryVersion());
        Assert.assertNull(resource.getResourceVersion());       
        Assert.assertEquals("myres.js", resource.getResourceName());
    }
View Full Code Here

            // Try preferred contract first
            if (contractPreferred != null)
            {
                for (ContractResourceLoader loader : getResourceHandlerSupport().getContractResourceLoaders())
                {
                    ResourceMeta resourceMeta = deriveResourceMeta(loader, resourceName, libraryName,
                        localePrefix, contractPreferred);
                    if (resourceMeta != null)
                    {
                        resource = new ResourceImpl(resourceMeta, loader,
                            getResourceHandlerSupport(), contentType);

                        // cache it
                        getResourceLoaderCache().putResource(resourceName, libraryName, contentType,
                                localePrefix, contractPreferred, resourceMeta, loader,
                                new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
                        resolved = true;
                        break;
                    }
                }
            }
            if (!resolved && !contracts.isEmpty())
            {
                for (ContractResourceLoader loader :
                    getResourceHandlerSupport().getContractResourceLoaders())
                {
                    for (String contract : contracts)
                    {
                        ResourceMeta resourceMeta = deriveResourceMeta(
                            loader, resourceName, libraryName,
                            localePrefix, contract);
                        if (resourceMeta != null)
                        {
                            resource = new ResourceImpl(resourceMeta, loader,
                                getResourceHandlerSupport(), contentType);

                            // cache it
                            getResourceLoaderCache().putResource(
                                    resourceName, libraryName, contentType,
                                    localePrefix, contract, resourceMeta, loader,
                                    new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
                            resolved = true;
                            break;
                        }
                    }
                }
            }
            if (!resolved)
            {
                for (ResourceLoader loader : getResourceHandlerSupport().getResourceLoaders())
                {
                    ResourceMeta resourceMeta = deriveResourceMeta(
                        loader, resourceName, libraryName, localePrefix);

                    if (resourceMeta != null)
                    {
                        resource = new ResourceImpl(
View Full Code Here

    protected ResourceMeta deriveResourceMeta(ContractResourceLoader resourceLoader,
            String resourceName, String libraryName, String localePrefix, String contractName)
    {
        String resourceVersion = null;
        String libraryVersion = null;
        ResourceMeta resourceId = null;
       
        //1. Try to locate resource in a localized path
        if (localePrefix != null)
        {
            if (null != libraryName)
View Full Code Here

    protected ResourceMeta deriveResourceMeta(ResourceLoader resourceLoader,
            String resourceName, String libraryName, String localePrefix)
    {
        String resourceVersion = null;
        String libraryVersion = null;
        ResourceMeta resourceId = null;
       
        //1. Try to locate resource in a localized path
        if (localePrefix != null)
        {
            if (null != libraryName)
View Full Code Here

            boolean resolved = false;
            if (contractPreferred != null)
            {
                for (ContractResourceLoader loader : getResourceHandlerSupport().getContractResourceLoaders())
                {
                    ResourceMeta resourceMeta = deriveResourceMeta(
                        facesContext, loader, resourceId, contractPreferred);
                    if (resourceMeta != null)
                    {
                        String contentType = facesContext.getExternalContext().getMimeType(
                            resourceMeta.getResourceName());
                       
                        resource = new ResourceImpl(resourceMeta, loader,
                            getResourceHandlerSupport(), contentType);

                        // cache it
                        getResourceLoaderCache().putResource(resourceId, resourceMeta, loader,
                            new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));
                       
                        resolved = true;
                        break;
                    }
                }
            }
            if (!resolved && !contracts.isEmpty())
            {
                for (ContractResourceLoader loader :
                        getResourceHandlerSupport().getContractResourceLoaders())
                {
                    for (String contract : contracts)
                    {
                        ResourceMeta resourceMeta = deriveResourceMeta(
                            facesContext, loader, resourceId, contract);
                        if (resourceMeta != null)
                        {
                            String contentType = facesContext.getExternalContext().getMimeType(
                                resourceMeta.getResourceName());

                            resource = new ResourceImpl(resourceMeta, loader,
                                getResourceHandlerSupport(), contentType);

                            // cache it
                            getResourceLoaderCache().putResource(resourceId, resourceMeta, loader,
                                new ResourceCachedInfo(resource.getURL(), resource.getRequestPath()));

                            resolved = true;
                            break;
                        }
                    }
                }
            }
            if (!resolved)
            {
                for (ResourceLoader loader : getResourceHandlerSupport().getResourceLoaders())
                {
                    ResourceMeta resourceMeta = deriveResourceMeta(facesContext, loader, resourceId);

                    if (resourceMeta != null)
                    {
                        String contentType = facesContext.getExternalContext().getMimeType(
                            resourceMeta.getResourceName());

                        resource = new ResourceImpl(resourceMeta, loader, getResourceHandlerSupport(), contentType);

                        // cache it
                        getResourceLoaderCache().putResource(resourceId, resourceMeta, loader,
View Full Code Here

TOP

Related Classes of org.apache.myfaces.shared.resource.ResourceMeta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.