01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry;
16:
17: import org.apache.tapestry.ioc.AnnotationProvider;
18:
19: /**
20: * A binding is a connection between a component and its container (another component), that allows
21: * the embedded component to gain access to <em>resources</em> defined by the container. Resources
22: * can represent any kind of value that can be obtained from the parent component, but is often a
23: * JavaBean property that can be read and updated. Different implementations of Binding as used to
24: * access different kinds of resources of the container.
25: * <p>
26: * A binding ultimately must provide access to the underlying annotations. In most cases, there are
27: * no annotations, but bindings that ultimate invoke methods or read and update fields must provide
28: * access to those annotations.
29: */
30: public interface Binding extends AnnotationProvider {
31: /**
32: * Reads the current value of the property (or other resource). When reading properties of
33: * objects that are primitive types, this will return an instance of the wrapper type. In some
34: * cases, a binding is read only and this method will throw a runtime exception.
35: */
36: Object get();
37:
38: /**
39: * Updates the current value. Most types of bindings are read-only, and this method will throw a
40: * runtime exception. It is the caller's responsibility to ensure that the value passed in is of
41: * the appropriate type.
42: *
43: * @param value
44: */
45: void set(Object value);
46:
47: /**
48: * Returns true if the value of the binding does not ever change. Components will often cache
49: * such values aggressively.
50: */
51: boolean isInvariant();
52:
53: /**
54: * Returns the type of the binding, either the type of resource exposed by the binding, or the
55: * type of the property bound.
56: */
57: Class getBindingType();
58: }
|