001/* 002 * Copyright 2018 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.core.util.filereloader; 017 018import java.io.InputStream; 019 020import org.apache.excalibur.source.Source; 021 022/** 023 * Represents a class able to handle a reloadable configuration file 024 */ 025public interface FileReloader 026{ 027 /** 028 * Update the file, the sourceUrl is only there if you manage multiple files, the Configuration object is already present to read it 029 * @param sourceUrl the url of the file. 030 * @param source the source to read, can be null if no file was read 031 * @param is the input stream to read, can be null if no file was read 032 * @throws Exception something went wrong while reading the inputstream 033 */ 034 public void updateFile(String sourceUrl, Source source, InputStream is) throws Exception; 035 036 /** 037 * Get an unique ID for this File Reloader 038 * @param sourceUrl this is passed as an argument if your class read multiple files. 039 * If it reads only one file, the full class name can be a good enough ID 040 * @return an unique ID 041 */ 042 public String getId(String sourceUrl); 043 044}