Michael E. Rodriguez | 86f57b0 | 2006-03-29 21:05:08 +0000 | [diff] [blame] | 1 | /* |
Richard S. Hall | 33b07d1 | 2006-10-18 22:02:38 +0000 | [diff] [blame^] | 2 | * $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/LogReaderService.java,v 1.10 2006/06/16 16:31:49 hargrave Exp $ |
Michael E. Rodriguez | 86f57b0 | 2006-03-29 21:05:08 +0000 | [diff] [blame] | 3 | * |
Richard S. Hall | 33b07d1 | 2006-10-18 22:02:38 +0000 | [diff] [blame^] | 4 | * Copyright (c) OSGi Alliance (2000, 2006). All Rights Reserved. |
Michael E. Rodriguez | 86f57b0 | 2006-03-29 21:05:08 +0000 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | package org.osgi.service.log; |
| 19 | |
| 20 | import java.util.Enumeration; |
| 21 | |
| 22 | /** |
| 23 | * Provides methods to retrieve <code>LogEntry</code> objects from the log. |
| 24 | * <p> |
| 25 | * There are two ways to retrieve <code>LogEntry</code> objects: |
| 26 | * <ul> |
| 27 | * <li>The primary way to retrieve <code>LogEntry</code> objects is to register a |
| 28 | * <code>LogListener</code> object whose <code>LogListener.logged</code> method will |
| 29 | * be called for each entry added to the log. |
| 30 | * <li>To retrieve past <code>LogEntry</code> objects, the <code>getLog</code> |
| 31 | * method can be called which will return an <code>Enumeration</code> of all |
| 32 | * <code>LogEntry</code> objects in the log. |
| 33 | * |
Richard S. Hall | 33b07d1 | 2006-10-18 22:02:38 +0000 | [diff] [blame^] | 34 | * @version $Revision: 1.10 $ |
Michael E. Rodriguez | 86f57b0 | 2006-03-29 21:05:08 +0000 | [diff] [blame] | 35 | * @see LogEntry |
| 36 | * @see LogListener |
| 37 | * @see LogListener#logged(LogEntry) |
| 38 | */ |
| 39 | public interface LogReaderService { |
| 40 | /** |
| 41 | * Subscribes to <code>LogEntry</code> objects. |
| 42 | * |
| 43 | * <p> |
| 44 | * This method registers a <code>LogListener</code> object with the Log Reader |
| 45 | * Service. The <code>LogListener.logged(LogEntry)</code> method will be |
| 46 | * called for each <code>LogEntry</code> object placed into the log. |
| 47 | * |
| 48 | * <p> |
| 49 | * When a bundle which registers a <code>LogListener</code> object is stopped |
| 50 | * or otherwise releases the Log Reader Service, the Log Reader Service must |
| 51 | * remove all of the bundle's listeners. |
| 52 | * |
| 53 | * <p> |
| 54 | * If this Log Reader Service's list of listeners already contains a |
| 55 | * listener <code>l</code> such that <code>(l==listener)</code>, this method |
| 56 | * does nothing. |
| 57 | * |
| 58 | * @param listener A <code>LogListener</code> object to register; the |
| 59 | * <code>LogListener</code> object is used to receive <code>LogEntry</code> |
| 60 | * objects. |
| 61 | * @see LogListener |
| 62 | * @see LogEntry |
| 63 | * @see LogListener#logged(LogEntry) |
| 64 | */ |
| 65 | public void addLogListener(LogListener listener); |
| 66 | |
| 67 | /** |
| 68 | * Unsubscribes to <code>LogEntry</code> objects. |
| 69 | * |
| 70 | * <p> |
| 71 | * This method unregisters a <code>LogListener</code> object from the Log |
| 72 | * Reader Service. |
| 73 | * |
| 74 | * <p> |
| 75 | * If <code>listener</code> is not contained in this Log Reader Service's list |
| 76 | * of listeners, this method does nothing. |
| 77 | * |
| 78 | * @param listener A <code>LogListener</code> object to unregister. |
| 79 | * @see LogListener |
| 80 | */ |
| 81 | public void removeLogListener(LogListener listener); |
| 82 | |
| 83 | /** |
| 84 | * Returns an <code>Enumeration</code> of all <code>LogEntry</code> objects in |
| 85 | * the log. |
| 86 | * |
| 87 | * <p> |
| 88 | * Each element of the enumeration is a <code>LogEntry</code> object, ordered |
| 89 | * with the most recent entry first. Whether the enumeration is of all |
| 90 | * <code>LogEntry</code> objects since the Log Service was started or some |
| 91 | * recent past is implementation-specific. Also implementation-specific is |
| 92 | * whether informational and debug <code>LogEntry</code> objects are included |
| 93 | * in the enumeration. |
| 94 | * @return An <code>Enumeration</code> of all <code>LogEntry</code> objects in |
| 95 | * the log. |
| 96 | */ |
| 97 | public Enumeration getLog(); |
| 98 | } |