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