001// Copyright 2006, 2007, 2008, 2009, 2011 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; 016 017import org.apache.tapestry5.MarkupWriter; 018import org.apache.tapestry5.internal.structure.PageResetListener; 019import org.apache.tapestry5.plastic.MethodDescription; 020import org.apache.tapestry5.plastic.PlasticUtils; 021import org.apache.tapestry5.runtime.Component; 022import org.apache.tapestry5.runtime.ComponentEvent; 023import org.apache.tapestry5.runtime.Event; 024import org.apache.tapestry5.runtime.PageLifecycleListener; 025import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2; 026 027import java.lang.reflect.Modifier; 028 029/** 030 * Constants used by implementations {@link ComponentClassTransformWorker2}. 031 * <p/> 032 * Note: render phase methods on transformed components will not be invoked <em>unless</em> 033 * {@linkplain org.apache.tapestry5.model.MutableComponentModel#addRenderPhase(Class) the component model is updated to 034 * identify the use of the corresponding render phase}. This represents an optimization introduced in Tapestry 5.1. 035 */ 036public final class TransformConstants 037{ 038 // Shared parameters of a whole bunch of lifecycle methods, representing the different 039 // component render states. 040 private static final String[] RENDER_PHASE_METHOD_PARAMETERS = 041 {MarkupWriter.class.getName(), Event.class.getName()}; 042 043 044 /** 045 * Description for 046 * {@link org.apache.tapestry5.runtime.Component#dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent)} 047 * . 048 * 049 * @see org.apache.tapestry5.annotations.OnEvent 050 * @since 5.3 051 */ 052 public static final MethodDescription DISPATCH_COMPONENT_EVENT_DESCRIPTION = PlasticUtils.getMethodDescription( 053 Component.class, "dispatchComponentEvent", ComponentEvent.class); 054 055 056 /** 057 * Description for {@link org.apache.tapestry5.runtime.PageLifecycleListener#containingPageDidLoad()}. 058 * 059 * @since 5.3 060 */ 061 public static final MethodDescription CONTAINING_PAGE_DID_LOAD_DESCRIPTION = PlasticUtils.getMethodDescription( 062 PageLifecycleListener.class, "containingPageDidLoad"); 063 064 /** 065 * Description for {@link org.apache.tapestry5.internal.structure.PageResetListener#containingPageDidReset()}. Note that the {@link PageResetListener} 066 * interface is not automatically implemented by components. ] 067 * 068 * @see org.apache.tapestry5.annotations.PageReset 069 * @see org.apache.tapestry5.internal.transform.PageResetAnnotationWorker 070 * @since 5.3 071 */ 072 public static final MethodDescription CONTAINING_PAGE_DID_RESET_DESCRIPTION = PlasticUtils.getMethodDescription(PageResetListener.class, "containingPageDidReset"); 073 074 075 /** 076 * Description for {@link org.apache.tapestry5.runtime.Component#postRenderCleanup()}. 077 * 078 * @since 5.3 079 */ 080 public static final MethodDescription POST_RENDER_CLEANUP_DESCRIPTION = PlasticUtils.getMethodDescription(Component.class, "postRenderCleanup"); 081 082 083 /** 084 * Description for {@link org.apache.tapestry5.runtime.PageLifecycleListener#containingPageDidDetach()}. 085 * 086 * @since 5.3 087 */ 088 public static final MethodDescription CONTAINING_PAGE_DID_DETACH_DESCRIPTION = PlasticUtils.getMethodDescription(PageLifecycleListener.class, "containingPageDidDetach"); 089 090 091 /** 092 * Description for {@link org.apache.tapestry5.runtime.PageLifecycleListener#containingPageDidAttach()}. 093 * 094 * @since 5.3 095 */ 096 public static final MethodDescription CONTAINING_PAGE_DID_ATTACH_DESCRIPTION = PlasticUtils.getMethodDescription(PageLifecycleListener.class, "containingPageDidAttach"); 097 098 099 /** 100 * Description for {@link org.apache.tapestry5.runtime.Component#setupRender(MarkupWriter, Event)}. 101 * 102 * @see org.apache.tapestry5.annotations.SetupRender 103 * @since 5.3 104 */ 105 public static final MethodDescription SETUP_RENDER_DESCRIPTION = renderPhaseDescription("setupRender"); 106 107 108 /** 109 * Description for {@link org.apache.tapestry5.runtime.Component#beginRender(MarkupWriter, Event)}. 110 * 111 * @see org.apache.tapestry5.annotations.BeginRender 112 * @since 5.3 113 */ 114 public static final MethodDescription BEGIN_RENDER_DESCRIPTION = renderPhaseDescription("beginRender"); 115 116 117 /** 118 * Description for {@link org.apache.tapestry5.runtime.Component#beforeRenderTemplate(MarkupWriter, Event)}. 119 * 120 * @see org.apache.tapestry5.annotations.BeforeRenderTemplate 121 * @since 5.3 122 */ 123 public static final MethodDescription BEFORE_RENDER_TEMPLATE_DESCRIPTION = renderPhaseDescription("beforeRenderTemplate"); 124 125 126 /** 127 * Description for {@link org.apache.tapestry5.runtime.Component#afterRenderTemplate(MarkupWriter, Event)}. 128 * 129 * @see org.apache.tapestry5.annotations.BeforeRenderTemplate 130 * @since 5.3 131 */ 132 public static final MethodDescription AFTER_RENDER_TEMPLATE_DESCRIPTION = renderPhaseDescription("afterRenderTemplate"); 133 134 135 /** 136 * Description for {@link org.apache.tapestry5.runtime.Component#beforeRenderBody(MarkupWriter, Event)}. 137 * 138 * @see org.apache.tapestry5.annotations.BeforeRenderBody 139 * @since 5.3 140 */ 141 public static final MethodDescription BEFORE_RENDER_BODY_DESCRIPTION = renderPhaseDescription("beforeRenderBody"); 142 143 144 /** 145 * Description for {@link org.apache.tapestry5.runtime.Component#afterRenderBody(MarkupWriter, Event)}. 146 * 147 * @see org.apache.tapestry5.annotations.AfterRenderBody 148 * @since 5.3 149 */ 150 public static final MethodDescription AFTER_RENDER_BODY_DESCRIPTION = renderPhaseDescription("afterRenderBody"); 151 152 153 /** 154 * Description for {@link org.apache.tapestry5.runtime.Component#afterRender(MarkupWriter, Event)} 155 * 156 * @see org.apache.tapestry5.annotations.AfterRender 157 * @since 5.3 158 */ 159 public static final MethodDescription AFTER_RENDER_DESCRIPTION = renderPhaseDescription("afterRender"); 160 161 162 /** 163 * Description for {@link org.apache.tapestry5.runtime.Component#cleanupRender(MarkupWriter, Event)}. 164 * 165 * @see org.apache.tapestry5.annotations.CleanupRender 166 * @since 5.3 167 */ 168 public static final MethodDescription CLEANUP_RENDER_DESCRIPTION = renderPhaseDescription("cleanupRender"); 169 170 171 private static MethodDescription renderPhaseDescription(String name) 172 { 173 return new MethodDescription(Modifier.PUBLIC, "void", name, RENDER_PHASE_METHOD_PARAMETERS, null, null); 174 } 175 176}