01: // Copyright 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.internal.services;
16:
17: import java.lang.annotation.Annotation;
18:
19: import org.apache.tapestry.Binding;
20: import org.apache.tapestry.ioc.BaseLocatable;
21: import org.apache.tapestry.ioc.Location;
22: import org.apache.tapestry.ioc.internal.util.TapestryException;
23:
24: /**
25: * Wraps another binding, adjusting the description of the binding and the location of the binding
26: * (as reported in any thrown exceptions).
27: */
28: public class InheritedBinding extends BaseLocatable implements Binding {
29: private final String _toString;
30:
31: private final Binding _binding;
32:
33: public InheritedBinding(String toString, Binding binding,
34: Location location) {
35: super (location);
36:
37: _toString = toString;
38: _binding = binding;
39: }
40:
41: @Override
42: public String toString() {
43: return _toString;
44: }
45:
46: public Object get() {
47: try {
48: return _binding.get();
49: } catch (Exception ex) {
50: throw new TapestryException(ex.getMessage(), this , ex);
51: }
52: }
53:
54: public Class getBindingType() {
55: try {
56: return _binding.getBindingType();
57: } catch (Exception ex) {
58: throw new TapestryException(ex.getMessage(), this , ex);
59: }
60: }
61:
62: public boolean isInvariant() {
63: try {
64: return _binding.isInvariant();
65: } catch (Exception ex) {
66: throw new TapestryException(ex.getMessage(), this , ex);
67: }
68: }
69:
70: public void set(Object value) {
71: try {
72: _binding.set(value);
73: } catch (Exception ex) {
74: throw new TapestryException(ex.getMessage(), this , ex);
75: }
76: }
77:
78: public <T extends Annotation> T getAnnotation(
79: Class<T> annotationClass) {
80: try {
81: return _binding.getAnnotation(annotationClass);
82: } catch (Exception ex) {
83: throw new TapestryException(ex.getMessage(), this, ex);
84: }
85: }
86:
87: }
|