1 /*
2 * Copyright 2004-2008 the Seasar Foundation and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.seasar.uruma.renderer;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.seasar.uruma.component.UIComponent;
22 import org.seasar.uruma.context.PartContext;
23 import org.seasar.uruma.context.WidgetHandle;
24 import org.seasar.uruma.util.AssertionUtil;
25
26 /**
27 * 拡張レンダラを管理するためのクラスです。<br />
28 *
29 * @author y-komori
30 */
31 public class RendererExtender {
32 private static List<RendererExtension> extensions = new ArrayList<RendererExtension>();
33
34 /**
35 * 拡張レンダラを登録します。<br />
36 * Uruma のレンダリング処理を拡張したい場合、 {@link RendererExtension}
37 * インターフェースの実装クラスを作成し、本メソッド使って登録してください。<br />
38 *
39 * @param extension
40 * 拡張レンダラオブジェクト
41 */
42 public static void addRendererExtension(final RendererExtension extension) {
43 AssertionUtil.assertNotNull("extension", extension);
44
45 extensions.add(extension);
46 }
47
48 /**
49 * 登録された拡張レンダラをすべてクリアします。<br />
50 */
51 public static void clearRendererExtensions() {
52 extensions.clear();
53 }
54
55 /**
56 * 登録された拡張レンダラを順番に呼び出し、拡張レンダリングを実施します。<br />
57 * 拡張レンダラは {@link #addRendererExtension(RendererExtension)}
58 * メソッドで登録された順番に呼び出されます。<br />
59 * (本メソッドは Uruma のレンダリングエンジンから呼び出されるメソッドです)
60 *
61 * @param uiComponent
62 * レンダリング対象の情報を持つ {@link UIComponent} オブジェクト
63 * @param handle
64 * レンダリング対象のウィジットを保持する {@link WidgetHandle} オブジェクト
65 * @param context
66 * 画面情報を収めた {@link PartContext} オブジェクト
67 * @see RendererExtension#extRender(UIComponent, WidgetHandle, PartContext)
68 */
69 public static void doExtRender(final UIComponent uiComponent,
70 final WidgetHandle handle, final PartContext context) {
71 for (RendererExtension extension : extensions) {
72 extension.extRender(uiComponent, handle, context);
73 }
74 }
75 }