001 // Copyright 2006 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.ioc.services;
016
017 /**
018 * A wrapper around the JavaBean Introspector that allows more manageable access to JavaBean properties of objects.
019 * <p/>
020 * <p/>
021 * Only provides access to <em>simple</em> properties. Indexed properties are ignored.
022 */
023 public interface PropertyAccess
024 {
025 /**
026 * Reads the value of a property.
027 *
028 * @throws UnsupportedOperationException if the property is write only
029 * @throws IllegalArgumentException if property does not exist
030 */
031 Object get(Object instance, String propertyName);
032
033 /**
034 * Updates the value of a property.
035 *
036 * @throws UnsupportedOperationException if the property is read only
037 * @throws IllegalArgumentException if property does not exist
038 */
039 void set(Object instance, String propertyName, Object value);
040
041 /**
042 * Returns the adapter for a particular object instance. A convienience over invoking {@link #getAdapter(Class)}.
043 */
044 ClassPropertyAdapter getAdapter(Object instance);
045
046 /**
047 * Returns the adapter used to access properties within the indicated class.
048 */
049 ClassPropertyAdapter getAdapter(Class forClass);
050
051 /**
052 * Discards all stored property access information, discarding all created class adapters.
053 */
054 void clearCache();
055 }