    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005// http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.services.javascript;
    014
    015import org.apache.tapestry5.json.JSONObject;
    016
    017/**
    018 * Used to change the configuration object which will be used to
    019 * <a href="http://requirejs.org/docs/api.html#config">configure RequireJS</a>; callbacks can modify
    020 * and override the configuration after it was created
    021 * by the {@link ModuleManager} service based on contributed {@link JavaScriptModuleConfiguration}s.
    022 * This allows components, pages, mixins and services to configure Require.JS dynamically in a
    023 * per-request basis by using the
    024 * {@link JavaScriptSupport#addModuleConfigurationCallback(ModuleConfigurationCallback)} method.
    025 *
    026 * Note that RequireJS is only configured during a full page render; on Ajax requests, RequireJS
    027 * will already be loaded and configured.
    028 *
    029 *
    030 * @see JavaScriptSupport#addModuleConfigurationCallback(ModuleConfigurationCallback)
    031 * @since 5.4
    032 */
    033public interface ModuleConfigurationCallback
    034{
    035    /**
    036     * Receives the current configuration, which can be copied or returned, or (more typically) modified and returned.
    037     *
    038     * @param configuration
    039     *         a {@link JSONObject} containing the current configuration.
    040     * @return a {@link JSONObject} containing the changed configuration, most probably the same
    041     *         one received as a parameter.
    042     */
    043    JSONObject configure(JSONObject configuration);
    044}