Package org.apache.tapestry5.services.javascript

Examples of org.apache.tapestry5.services.javascript.JavaScriptStack


        this.configuration = configuration;
    }

    public JavaScriptStack getStack(String name)
    {
        JavaScriptStack stack = findStack(name);

        if (stack == null)
        {
            throw new UnknownValueException(String.format("No JavaScriptStack with name '%s'.", name),
                    new AvailableValues("Configured JavaScript stacks", configuration));
View Full Code Here


        this.combineScripts = combineScripts;
    }

    public List<String> constructPathsForJavaScriptStack(String stackName)
    {
        JavaScriptStack stack = javascriptStackSource.getStack(stackName);

        List<Asset> assets = stack.getJavaScriptLibraries();

        // When combine scripts is true, we want to build the virtual aggregated JavaScript ... but only
        // if there is more than one library asset, or any modules.
        if (combineScripts && stack.getJavaScriptAggregationStrategy().enablesCombine())
        {
            boolean needsVirtual = (assets.size() > 1) || (!stack.getModules().isEmpty());

            if (needsVirtual)
            {
                return combinedStackURL(stackName, stack);
            }
View Full Code Here


    @Override
    public StreamableResource getStreamableResource(Resource baseResource, StreamableResourceProcessing processing, ResourceDependencies dependencies) throws IOException
    {
        JavaScriptStack stack = javaScriptStackSource.findStackForJavaScriptLibrary(baseResource);

        if (stack != null && !stack.getJavaScriptAggregationStrategy().enablesMinimize())
        {
            request.setAttribute(TapestryConstants.DISABLE_JAVASCRIPT_MINIMIZATION, true);
        }

        try
View Full Code Here

        if (compressed)
        {
            checksum = checksum.substring(1);
        }

        final JavaScriptStack stack = stackSource.findStack(stackName);

        if (stack == null)
        {
            logger.warn(String.format("JavaScript stack '%s' not found.", stackName));
            return false;
        }


        // Yes, I have a big regret that the JavaScript stack stuff relies on this global, rather than
        // having it passed around properly.

        localizationSetter.setNonPersistentLocaleFromLocaleName(localeName);

        StreamableResource resource =
                tracker.perform(String.format("Assembling JavaScript asset stack '%s' (%s)",
                                stackName, localeName),
                        new IOOperation<StreamableResource>()
                        {
                            public StreamableResource perform() throws IOException
                            {

                                return javaScriptStackAssembler.assembleJavaScriptResourceForStack(stackName, compressed,
                                        stack.getJavaScriptAggregationStrategy());

                            }
                        });

View Full Code Here

            StreamableResource uncompressed = assembleJavascriptResourceForStack(parameters.disableCompress());

            return new CompressedStreamableResource(uncompressed, checksumGenerator);
        }

        JavaScriptStack stack = stackSource.getStack(parameters.stackName);

        return assembleStreamableForStack(parameters.locale.toString(), parameters, stack.getJavaScriptLibraries(), stack.getModules());
    }
View Full Code Here

    private StreamableResource assembleStackContent(String localeName, String stackName) throws IOException
    {
        localizationSetter.setNonPeristentLocaleFromLocaleName(localeName);

        JavaScriptStack stack = javascriptStackSource.getStack(stackName);
        List<Asset> libraries = stack.getJavaScriptLibraries();

        StreamableResource stackContent = assembleStackContent(libraries);

        return minificationEnabled ? resourceMinimizer.minimize(stackContent) : stackContent;
    }
View Full Code Here

    }

    private void trainForEmptyCoreStack(DocumentLinker linker, JavaScriptStackSource stackSource,
            JavaScriptStackPathConstructor pathConstructor)
    {
        JavaScriptStack stack = mockJavaScriptStack();

        expect(stackSource.getStack(InternalConstants.CORE_STACK_NAME)).andReturn(stack);
        expect(pathConstructor.constructPathsForJavaScriptStack(InternalConstants.CORE_STACK_NAME)).andReturn(
                Collections.<String> emptyList());
        expect(stack.getStylesheets()).andReturn(Collections.<StylesheetLink> emptyList());

        expect(stack.getInitialization()).andReturn(null);

        expect(stack.getStacks()).andReturn(Collections.<String> emptyList());
    }
View Full Code Here

    }

    private void trainForCoreStack(DocumentLinker linker, JavaScriptStackSource stackSource,
            JavaScriptStackPathConstructor pathConstructor)
    {
        JavaScriptStack stack = mockJavaScriptStack();

        StylesheetLink stylesheetLink = new StylesheetLink("style.css");

        expect(stackSource.getStack(InternalConstants.CORE_STACK_NAME)).andReturn(stack);
        expect(pathConstructor.constructPathsForJavaScriptStack(InternalConstants.CORE_STACK_NAME)).andReturn(
                CollectionFactory.newList("stack1.js", "stack2.js"));
        expect(stack.getStylesheets()).andReturn(CollectionFactory.newList(stylesheetLink));

        expect(stack.getInitialization()).andReturn("stackInit();");

        expect(stack.getStacks()).andReturn(Collections.<String> emptyList());

        linker.addScriptLink("stack1.js");
        linker.addScriptLink("stack2.js");
        linker.addStylesheetLink(stylesheetLink);
    }
View Full Code Here

        trainForEmptyCoreStack(linker, stackSource, pathConstructor);

        Asset library1 = mockAsset("mylib1.js");
        Asset library2 = mockAsset("mylib2.js");

        JavaScriptStack mystack = mockJavaScriptStack();

        expect(stackSource.getStackNames()).andReturn(Arrays.asList("mystack"));
        expect(stackSource.getStack("mystack")).andReturn(mystack).atLeastOnce();

        expect(mystack.getStacks()).andReturn(Collections.<String> emptyList());
        expect(mystack.getJavaScriptLibraries()).andReturn(Arrays.asList(library1, library2));

        expect(pathConstructor.constructPathsForJavaScriptStack("mystack")).andReturn(
                Arrays.asList("stacks/mystack.js"));
        expect(mystack.getStylesheets()).andReturn(Collections.<StylesheetLink> emptyList());

        expect(mystack.getInitialization()).andReturn(null);

        linker.addScriptLink("stacks/mystack.js");

        replay();
View Full Code Here

        JavaScriptStackSource stackSource = mockJavaScriptStackSource();
        JavaScriptStackPathConstructor pathConstructor = mockJavaScriptStackPathConstructor();

        trainForCoreStack(linker, stackSource, pathConstructor);

        JavaScriptStack stack = mockJavaScriptStack();

        StylesheetLink stylesheetLink = new StylesheetLink("stack.css");

        expect(stackSource.getStack("custom")).andReturn(stack);
        expect(pathConstructor.constructPathsForJavaScriptStack("custom")).andReturn(
                CollectionFactory.newList("stack.js"));
        expect(stack.getStylesheets()).andReturn(CollectionFactory.newList(stylesheetLink));

        expect(stack.getInitialization()).andReturn("customInit();");

        List<String> stacks = Collections.emptyList();
        expect(stack.getStacks()).andReturn(stacks);

        linker.addScriptLink("stack.js");
        linker.addStylesheetLink(stylesheetLink);

        linker.addScript(InitializationPriority.IMMEDIATE, "stackInit();");
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.javascript.JavaScriptStack

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.