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     */
017    package org.apache.geronimo.system.plugin;
018    
019    import org.apache.geronimo.kernel.repository.Artifact;
020    import org.apache.geronimo.kernel.repository.MissingDependencyException;
021    
022    /**
023     * An interface for callers who want to monitor the progress of an installation.
024     * These are all callbacks sent by the server.
025     *
026     * @see PluginInstaller
027     *
028     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
029     */
030    public interface DownloadPoller {
031        /**
032         * Notes a configuration that was removed because it was obsoleted by a
033         * newly-installed configuration.
034         */
035        void addRemovedConfigID(Artifact obsolete);
036    
037        /**
038         * Notes that a configuration passed as an argument to the install
039         * operation was successfully installed.  This will only be called on
040         * the original arguments to the install command, not on anything
041         * installed because it was a dependency.
042         */
043        void addInstalledConfigID(Artifact target);
044    
045        /**
046         * Notes that a configuration was restarted as a result of the
047         * current operation.  This usually means that it depended on a
048         * configuration that was obsoleted (removed), so it shut down when
049         * the remove happened, and was started up again after the replacement
050         * was installed.
051         */
052        void addRestartedConfigID(Artifact target);
053    
054        /**
055         * Provides details on why a plugin was not installed.
056         * @param e MissingDependencyException containing info on 
057         */
058        void addSkippedConfigID(MissingDependencyException e);
059    
060        /**
061         * Notes that the current install operation found a dependency, and that
062         * dependency was satisfied by an artifact already available in the
063         * current server environment.
064         */
065        void addDependencyPresent(Artifact dep);
066    
067        /**
068         * Notes that the current install operation found a dependency, and that
069         * dependency was downloaded from a remote repository and installed into
070         * the local server environment.
071         */
072        void addDependencyInstalled(Artifact dep);
073    
074        /**
075         * Indicates which file the configuration installer is working on at the
076         * moment.  Mainly for purposes of user feedback during asynchronous
077         * requests.
078         */
079        void setCurrentFile(String currentFile);
080    
081        /**
082         * Describes the current operation status as a text message.  Mainly for
083         * purposes of user feedback during asynchronous requests.
084         */
085        void setCurrentMessage(String currentMessage);
086    
087        /**
088         * Gives the percent complete for a file currently being downloaded.
089         * Mainly for purposes of user feedback during asynchronous requests.
090         * This may be -1 if the download server does not supply the file size in
091         * advance.
092         */
093        void setCurrentFilePercent(int currentFileProgress);
094    
095        /**
096         * Called at the end of a file download with the number of bytes downloaded
097         * in the current operation.  This can be used to calculate a rough
098         * transfer rate (the time between setCurrentFile and setDownloadBytes) as
099         * well as if the caller wants to total the size of all downloads for the
100         * current installation.
101         */
102        void addDownloadBytes(long bytes);
103    
104        /**
105         * Indicates that a failure was encountered during the installation
106         * operation.  Any failure is currently treated as fatal -- the installer
107         * will not attempt to complete additional tasks after a failure.
108         */
109        void setFailure(Exception failure);
110    
111        /**
112         * Always called when the operation is complete, regardless of whether
113         * there was a failure or not.
114         */
115        void setFinished();
116    }