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 * @deprecated Deprecated in 5.3, with {@link org.apache.tapestry5.annotations.PageDetached}. 088 */ 089 public static final MethodDescription CONTAINING_PAGE_DID_DETACH_DESCRIPTION = PlasticUtils.getMethodDescription(PageLifecycleListener.class, "containingPageDidDetach"); 090 091 092 /** 093 * Description for {@link org.apache.tapestry5.runtime.PageLifecycleListener#containingPageDidAttach()}. 094 * 095 * @since 5.3 096 * @deprecated Deprecated in 5.3, along with {@link org.apache.tapestry5.annotations.PageAttached}. 097 */ 098 public static final MethodDescription CONTAINING_PAGE_DID_ATTACH_DESCRIPTION = PlasticUtils.getMethodDescription(PageLifecycleListener.class, "containingPageDidAttach"); 099 100 101 /** 102 * Description for {@link org.apache.tapestry5.runtime.Component#setupRender(MarkupWriter, Event)}. 103 * 104 * @see org.apache.tapestry5.annotations.SetupRender 105 * @since 5.3 106 */ 107 public static final MethodDescription SETUP_RENDER_DESCRIPTION = renderPhaseDescription("setupRender"); 108 109 110 /** 111 * Description for {@link org.apache.tapestry5.runtime.Component#beginRender(MarkupWriter, Event)}. 112 * 113 * @see org.apache.tapestry5.annotations.BeginRender 114 * @since 5.3 115 */ 116 public static final MethodDescription BEGIN_RENDER_DESCRIPTION = renderPhaseDescription("beginRender"); 117 118 119 /** 120 * Description for {@link org.apache.tapestry5.runtime.Component#beforeRenderTemplate(MarkupWriter, Event)}. 121 * 122 * @see org.apache.tapestry5.annotations.BeforeRenderTemplate 123 * @since 5.3 124 */ 125 public static final MethodDescription BEFORE_RENDER_TEMPLATE_DESCRIPTION = renderPhaseDescription("beforeRenderTemplate"); 126 127 128 /** 129 * Description for {@link org.apache.tapestry5.runtime.Component#afterRenderTemplate(MarkupWriter, Event)}. 130 * 131 * @see org.apache.tapestry5.annotations.BeforeRenderTemplate 132 * @since 5.3 133 */ 134 public static final MethodDescription AFTER_RENDER_TEMPLATE_DESCRIPTION = renderPhaseDescription("afterRenderTemplate"); 135 136 137 /** 138 * Description for {@link org.apache.tapestry5.runtime.Component#beforeRenderBody(MarkupWriter, Event)}. 139 * 140 * @see org.apache.tapestry5.annotations.BeforeRenderBody 141 * @since 5.3 142 */ 143 public static final MethodDescription BEFORE_RENDER_BODY_DESCRIPTION = renderPhaseDescription("beforeRenderBody"); 144 145 146 /** 147 * Description for {@link org.apache.tapestry5.runtime.Component#afterRenderBody(MarkupWriter, Event)}. 148 * 149 * @see org.apache.tapestry5.annotations.AfterRenderBody 150 * @since 5.3 151 */ 152 public static final MethodDescription AFTER_RENDER_BODY_DESCRIPTION = renderPhaseDescription("afterRenderBody"); 153 154 155 /** 156 * Description for {@link org.apache.tapestry5.runtime.Component#afterRender(MarkupWriter, Event)} 157 * 158 * @see org.apache.tapestry5.annotations.AfterRender 159 * @since 5.3 160 */ 161 public static final MethodDescription AFTER_RENDER_DESCRIPTION = renderPhaseDescription("afterRender"); 162 163 164 /** 165 * Description for {@link org.apache.tapestry5.runtime.Component#cleanupRender(MarkupWriter, Event)}. 166 * 167 * @see org.apache.tapestry5.annotations.CleanupRender 168 * @since 5.3 169 */ 170 public static final MethodDescription CLEANUP_RENDER_DESCRIPTION = renderPhaseDescription("cleanupRender"); 171 172 173 private static MethodDescription renderPhaseDescription(String name) 174 { 175 return new MethodDescription(Modifier.PUBLIC, "void", name, RENDER_PHASE_METHOD_PARAMETERS, null, null); 176 } 177 178}