blob: 804b4c11de008260f44e2a478d433e8957e4a50c [file] [log] [blame]
Marcel Offermansa962bc92009-11-21 17:59:33 +00001/*
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 */
Marcel Offermans8b93efa2010-07-02 18:27:21 +000019package org.apache.felix.dm;
Marcel Offermansa962bc92009-11-21 17:59:33 +000020
Marcel Offermans117aa2f2009-12-10 09:48:17 +000021import java.util.Dictionary;
22
Marcel Offermansa962bc92009-11-21 17:59:33 +000023/**
Marcel Offermansfaaed472010-09-08 10:07:32 +000024 * Generic dependency for a component. A dependency can be required or not.
25 * A dependency will be activated by the component it belongs to. The component
Marcel Offermansa962bc92009-11-21 17:59:33 +000026 * will call the <code>start(Service service)</code> and
27 * <code>stop(Service service)</code> methods.
28 *
29 * After it has been started, a dependency must callback
Marcel Offermansfaaed472010-09-08 10:07:32 +000030 * the associated component's <code>dependencyAvailable()</code> and
Marcel Offermansa962bc92009-11-21 17:59:33 +000031 * <code>dependencyUnavailable()</code>
32 * methods. State changes of the dependency itself may only be made as long as
Marcel Offermansfaaed472010-09-08 10:07:32 +000033 * the dependency is not 'active', meaning it is associated with a running component.
Marcel Offermansa962bc92009-11-21 17:59:33 +000034 *
35 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
36 */
37public interface Dependency {
38 /**
39 * Returns <code>true</code> if this a required dependency. Required dependencies
Marcel Offermansfaaed472010-09-08 10:07:32 +000040 * are dependencies that must be available before the component can be activated.
Marcel Offermansa962bc92009-11-21 17:59:33 +000041 *
42 * @return <code>true</code> if the dependency is required
43 */
44 public boolean isRequired();
45
46 /**
47 * Returns <code>true</code> if the dependency is available.
48 *
49 * @return <code>true</code> if the dependency is available
50 */
51 public boolean isAvailable();
52
53 /**
Marcel Offermanse14b3422009-11-25 23:04:32 +000054 * As soon as the instance is created, keep it around, even if this dependency
55 * goes away.
56 *
57 * @return <code>true</code> if the dependency is instance bound
58 */
59 public boolean isInstanceBound();
Marcel Offermans001db052009-12-08 08:58:40 +000060
61 /**
62 * Returns <code>true>code> if auto configuration is enabled for this dependency.
Marcel Offermansfaaed472010-09-08 10:07:32 +000063 * Auto configuration means that a dependency is injected in the component instance
Marcel Offermans001db052009-12-08 08:58:40 +000064 * when it's available, and if it's unavailable, a "null object" will be inserted
65 * instead.
66 *
Marcel Offermansfaaed472010-09-08 10:07:32 +000067 * @return <code>true</code> if auto configuration is enabled for this dependency
Marcel Offermans001db052009-12-08 08:58:40 +000068 */
69 public boolean isAutoConfig();
70
71 /**
72 * Returns the type of the instance that is injected.
73 *
74 * @return the type of the instance that is injected
75 */
76 public Class getAutoConfigType();
77
78 /**
79 * Returns the instance that is injected.
80 *
81 * @return the instance that is injected
82 */
83 public Object getAutoConfigInstance();
84
85 /**
Marcel Offermansfaaed472010-09-08 10:07:32 +000086 * Returns the name of the member in the class of the component instance
Marcel Offermans001db052009-12-08 08:58:40 +000087 * to inject into. If you specify this, not all members of the right
88 * type will be injected, only the member whose name matches.
89 *
90 * @return
91 */
92 public String getAutoConfigName();
93
94 /**
95 * Invoke the "added" callback on a required dependency.
96 *
97 * @param service
98 */
99 public void invokeAdded(DependencyService service);
100
101 /**
102 * Invoke the "removed" callback on a required dependency.
103 *
104 * @param service
105 */
106 public void invokeRemoved(DependencyService service);
Marcel Offermans117aa2f2009-12-10 09:48:17 +0000107
108 public boolean isPropagated();
109 public Dictionary getProperties();
Marcel Offermansb1959f42010-07-01 12:23:51 +0000110
111 /**
112 * Creates a copy of this dependency, cloning all declared state, but not the runtime state.
113 */
114 public Dependency createCopy();
Marcel Offermansa962bc92009-11-21 17:59:33 +0000115}