001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.resource;
018
019import org.apache.wicket.util.value.ValueMap;
020
021
022/**
023 * Implementations are responsible for {@link #load(Class, String) locating} {@link Properties}
024 * objects, which are a thin wrapper around {@link ValueMap} and is used to locate localized
025 * messages.
026 * <p>
027 * The {@link #clearCache()} method should remove any cached references to properties objects used
028 * by an implementation, so that {@link #load(Class, String)} gets the freshest instance possible.
029 * </p>
030 * <p>
031 * {@link IPropertiesChangeListener Listeners} are related to cached properties and should be used
032 * to inform observers when sets of properties are reloaded.
033 * </p>
034 * 
035 * @see org.apache.wicket.resource.Properties
036 * 
037 * @author Juergen Donnerstag
038 */
039public interface IPropertiesFactory
040{
041        /**
042         * Add a listener which will be called when a change to the underlying resource stream (e.g.
043         * properties file) has been detected
044         * 
045         * @param listener
046         */
047        void addListener(final IPropertiesChangeListener listener);
048
049        /**
050         * Remove all cached properties.
051         */
052        void clearCache();
053
054        /**
055         * Load the properties associated with the path
056         * 
057         * @param clazz
058         *            The class requesting the properties
059         * @param path
060         *            The path to identify the resource
061         * @return The properties
062         */
063        Properties load(final Class<?> clazz, final String path);
064}