001// Copyright 2008, 2009, 2010, 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.EventContext; 018import org.apache.tapestry5.TapestryConstants; 019import org.apache.tapestry5.internal.TapestryInternalUtils; 020import org.apache.tapestry5.internal.structure.PageResetListener; 021 022/** 023 * Used with {@link org.apache.tapestry5.services.PageRenderRequestHandler} and 024 * {@link org.apache.tapestry5.services.PageRenderRequestFilter} to define the logical page name and 025 * activation context for the request. 026 */ 027public class PageRenderRequestParameters 028{ 029 private final String logicalPageName; 030 031 private final EventContext activationContext; 032 033 /** 034 * @since 5.2.0 035 */ 036 private final boolean loopback; 037 038 /** 039 * @deprecated Use {@link #PageRenderRequestParameters(String, EventContext, boolean)}. 040 */ 041 public PageRenderRequestParameters(String logicalPageName, EventContext activationContext) 042 { 043 this(logicalPageName, activationContext, false); 044 } 045 046 /** 047 * @since 5.2.0 048 */ 049 public PageRenderRequestParameters(String logicalPageName, EventContext activationContext, boolean loopback) 050 { 051 assert logicalPageName != null; 052 assert activationContext != null; 053 this.logicalPageName = logicalPageName; 054 this.activationContext = activationContext; 055 this.loopback = loopback; 056 } 057 058 /** 059 * Returns a {@linkplain ComponentClassResolver#canonicalizePageName(String) canonicalized} version of the page 060 * name. 061 */ 062 public String getLogicalPageName() 063 { 064 return logicalPageName; 065 } 066 067 public EventContext getActivationContext() 068 { 069 return activationContext; 070 } 071 072 @Override 073 public boolean equals(Object obj) 074 { 075 if (this == obj) 076 return true; 077 078 if (obj == null || getClass() != obj.getClass()) 079 return false; 080 081 PageRenderRequestParameters other = (PageRenderRequestParameters) obj; 082 083 return loopback == other.loopback && logicalPageName.equals(other.logicalPageName) 084 && TapestryInternalUtils.isEqual(activationContext, other.activationContext); 085 } 086 087 /** 088 * Is this request a loopback (a request for the same page that rendered it in the first place)? 089 * 090 * @see TapestryConstants#PAGE_LOOPBACK_PARAMETER_NAME 091 * @see PageResetListener 092 * @since 5.2.0 093 */ 094 public boolean isLoopback() 095 { 096 return loopback; 097 } 098 099 @Override 100 public String toString() 101 { 102 return String.format("PageRenderRequestParameters[%s]", logicalPageName); 103 } 104}