blob: 64d241a2c2b9915815c1c37f4c5842520e35beba [file] [log] [blame]
Marcel Offermans516d38d2006-03-25 20:46:19 +00001/*
Marcel Offermans56db6d32007-06-06 09:11:21 +00002 * 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
Marcel Offermans516d38d2006-03-25 20:46:19 +00009 *
Marcel Offermans56db6d32007-06-06 09:11:21 +000010 * http://www.apache.org/licenses/LICENSE-2.0
Marcel Offermans516d38d2006-03-25 20:46:19 +000011 *
Marcel Offermans56db6d32007-06-06 09:11:21 +000012 * 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.
Marcel Offermans516d38d2006-03-25 20:46:19 +000018 */
19package 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 *
Marcel Offermans56db6d32007-06-06 09:11:21 +000033 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
Marcel Offermans516d38d2006-03-25 20:46:19 +000034 */
35public 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}