Package org.apache.tapestry5.ioc

Examples of org.apache.tapestry5.ioc.Resource


        assert path != null;
        int colonx = path.indexOf(':');

        if (colonx < 0)
        {
            Resource root = baseResource != null ? baseResource : prefixToRootResource.get(AssetConstants.CLASSPATH);

            return root.forFile(path);
        }

        String prefix = path.substring(0, colonx);

        Resource root = prefixToRootResource.get(prefix);

        if (root == null)
            throw new IllegalArgumentException(String.format("Unknown prefix for asset path '%s'.", path));

        return root.forFile(path.substring(colonx + 1));
    }
View Full Code Here


     *         locale to localize for, or null to not localize
     * @return resource, which may not exist
     */
    private Resource findLocalizedResource(Resource baseResource, String path, Locale locale)
    {
        Resource unlocalized = findResource(baseResource, path);

        if (locale == null || !unlocalized.exists())
        {
            return unlocalized;
        }

        return localize(unlocalized, locale);
View Full Code Here

        return localize(unlocalized, locale);
    }

    private Resource localize(Resource unlocalized, Locale locale)
    {
        Resource localized = unlocalized.forLocale(locale);

        return localized != null ? localized : unlocalized;
    }
View Full Code Here

        return localized != null ? localized : unlocalized;
    }

    private Asset getLocalizedAssetFromResource(Resource unlocalized, Locale locale)
    {
        Resource localized = locale == null ? unlocalized : unlocalized.forLocale(locale);

        if (localized == null || !localized.exists())
            throw new RuntimeException(String.format("Unable to locate asset '%s' (the file does not exist).", unlocalized));

        return getAssetForResource(localized);
    }
View Full Code Here

                {
                    return l.resource;
                }
            }

            Resource result = findLocalizedResource(locale);

            firstLocalization = new Localization(locale, result, firstLocalization);

            return result;
View Full Code Here

    private Resource findLocalizedResource(Locale locale)
    {
        for (String path : new LocalizedNameGenerator(this.path, locale))
        {
            Resource potential = createResource(path);

            if (potential.exists())
                return potential;
        }

        return null;
    }
View Full Code Here

                compress ? "compressed module" : "module",
                moduleName), new IOOperation<Boolean>()
        {
            public Boolean perform() throws IOException
            {
                Resource resource = moduleManager.findResourceForModule(moduleName);

                if (resource != null)
                {
                    // Slightly hacky way of informing the streamer whether to supply the
                    // compressed or default stream. May need to iterate the API on this a bit.
View Full Code Here

        return new JSONArray().putAll(input).toString(compactJSON);
    }

    public Resource findResourceForModule(String moduleName)
    {
        Resource resource = cache.get(moduleName);

        if (resource == null)
        {
            resource = resolveModuleNameToResource(moduleName);
            cache.put(moduleName, resource);
View Full Code Here

        return resource == classpathRoot ? null : resource;
    }

    private Resource resolveModuleNameToResource(String moduleName)
    {
        Resource resource = shimModuleNameToResource.get(moduleName);

        if (resource != null)
        {
            return resource;
        }

        // Tack on a fake extension; otherwise modules whose name includes a '.' get mangled
        // by Resource.withExtension().
        String baseName = String.format("/META-INF/modules/%s.EXT", moduleName);

        Resource baseResource = classpathRoot.forFile(baseName);

        for (String extension : extensions)
        {
            resource = baseResource.withExtension(extension);

            if (resource.exists())
            {
                return resource;
            }
View Full Code Here

    {
        Assembly assembly = new Assembly(String.format("'%s' JavaScript stack, for locale %s, resources=", parameters.stackName, localeName));

        for (Asset library : libraries)
        {
            Resource resource = library.getResource();

            assembly.add(resource, libraryReader);
        }

        for (String moduleName : moduleNames)
        {
            Resource resource = moduleManager.findResourceForModule(moduleName);

            if (resource == null)
            {
                throw new IllegalArgumentException(String.format("Could not identify a resource for module name '%s'.", moduleName));
            }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ioc.Resource

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.