Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.felix.dependencymanager; |
| 20 | |
| 21 | /** |
| 22 | * Generic dependency for a service. A dependency can be required or not. |
| 23 | * A dependency will be activated by the service it belongs to. The service |
| 24 | * will call the <code>start(Service service)</code> and |
| 25 | * <code>stop(Service service)</code> methods. |
| 26 | * |
| 27 | * After it has been started, a dependency must callback |
| 28 | * the associated service's <code>dependencyAvailable()</code> and |
| 29 | * <code>dependencyUnavailable()</code> |
| 30 | * methods. State changes of the dependency itself may only be made as long as |
| 31 | * the dependency is not 'active', meaning it is associated with a running service. |
| 32 | * |
| 33 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 34 | */ |
| 35 | public interface Dependency { |
| 36 | /** |
| 37 | * Returns <code>true</code> if this a required dependency. Required dependencies |
| 38 | * are dependencies that must be available before the service can be activated. |
| 39 | * |
| 40 | * @return <code>true</code> if the dependency is required |
| 41 | */ |
| 42 | public boolean isRequired(); |
| 43 | |
| 44 | /** |
| 45 | * Returns <code>true</code> if the dependency is available. |
| 46 | * |
| 47 | * @return <code>true</code> if the dependency is available |
| 48 | */ |
| 49 | public boolean isAvailable(); |
| 50 | |
| 51 | /** |
| 52 | * Starts tracking the dependency. This activates some implementation |
| 53 | * specific mechanism to do the actual tracking. If the tracking discovers |
| 54 | * that the dependency becomes available, it should call |
| 55 | * <code>dependencyAvailable()</code> on the service. |
| 56 | * |
| 57 | * @param service the service that is associated with this dependency |
| 58 | */ |
| 59 | public void start(Service service); |
| 60 | |
| 61 | /** |
| 62 | * Stops tracking the dependency. This deactivates the tracking. If the |
| 63 | * dependency was available, the tracker should call |
| 64 | * <code>dependencyUnavaible()</code> before stopping itself to ensure |
| 65 | * that dependencies that aren't "active" are unavailable. |
| 66 | */ |
| 67 | public void stop(Service service); |
| 68 | } |