001 // Copyright 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
015 package org.apache.tapestry5.internal.transform;
016
017 import org.apache.tapestry5.Binding;
018 import org.apache.tapestry5.annotations.Parameter;
019 import org.apache.tapestry5.internal.InternalComponentResources;
020 import org.apache.tapestry5.ioc.services.TypeCoercer;
021 import org.apache.tapestry5.plastic.FieldConduit;
022
023 /**
024 * A facade around {@link Binding} and {@link InternalComponentResources} that is used to instrument
025 * fields with the {@link Parameter} annotation. Extends {@link FieldConduit} so that
026 * the get() method implicitly coerces the value to the field's type.
027 * <p/>
028 * {@link #get(Object, org.apache.tapestry5.plastic.InstanceContext)} will read from the underlying {@link Binding} and used the {@link TypeCoercer} coerce the value to the
029 * parameter field's type. get() also includes a null value check (as per {@link Parameter#allowNull()}.
030 * <p/>
031 * {@link #set(Object, org.apache.tapestry5.plastic.InstanceContext, Object)} pushes the value into the binding.
032 *
033 * @since 5.2.0
034 */
035 public interface ParameterConduit extends FieldConduit<Object>
036 {
037 /**
038 * Determines if the parameter is actually bound.
039 *
040 * @return true if bound
041 */
042 boolean isBound();
043
044 /**
045 * Resets the conduit, clearing any <em>temporarily</em> cached data (from a non-invariant {@link Binding}).
046 */
047 void reset();
048
049 /**
050 * Invoked from the component's {@link org.apache.tapestry5.runtime.PageLifecycleListener#containingPageDidLoad()} lifecycle method, to
051 * finishing initializing
052 * the conduit prior to real use.
053 */
054 void load();
055 }