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 | */ |
Marcel Offermans | 8b93efa | 2010-07-02 18:27:21 +0000 | [diff] [blame] | 19 | package org.apache.felix.dm; |
Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 20 | |
Marcel Offermans | 117aa2f | 2009-12-10 09:48:17 +0000 | [diff] [blame] | 21 | import java.util.Dictionary; |
| 22 | |
Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 23 | /** |
Marcel Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 24 | * 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 Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 26 | * 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 Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 30 | * the associated component's <code>dependencyAvailable()</code> and |
Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 31 | * <code>dependencyUnavailable()</code> |
| 32 | * methods. State changes of the dependency itself may only be made as long as |
Marcel Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 33 | * the dependency is not 'active', meaning it is associated with a running component. |
Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 34 | * |
| 35 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 36 | */ |
| 37 | public interface Dependency { |
| 38 | /** |
| 39 | * Returns <code>true</code> if this a required dependency. Required dependencies |
Marcel Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 40 | * are dependencies that must be available before the component can be activated. |
Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 41 | * |
| 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 Offermans | e14b342 | 2009-11-25 23:04:32 +0000 | [diff] [blame] | 54 | * 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 Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * Returns <code>true>code> if auto configuration is enabled for this dependency. |
Marcel Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 63 | * Auto configuration means that a dependency is injected in the component instance |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 64 | * when it's available, and if it's unavailable, a "null object" will be inserted |
| 65 | * instead. |
| 66 | * |
Marcel Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 67 | * @return <code>true</code> if auto configuration is enabled for this dependency |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 68 | */ |
| 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 Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 86 | * Returns the name of the member in the class of the component instance |
Marcel Offermans | 001db05 | 2009-12-08 08:58:40 +0000 | [diff] [blame] | 87 | * 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 Offermans | 117aa2f | 2009-12-10 09:48:17 +0000 | [diff] [blame] | 107 | |
| 108 | public boolean isPropagated(); |
| 109 | public Dictionary getProperties(); |
Marcel Offermans | b1959f4 | 2010-07-01 12:23:51 +0000 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Creates a copy of this dependency, cloning all declared state, but not the runtime state. |
| 113 | */ |
| 114 | public Dependency createCopy(); |
Marcel Offermans | a962bc9 | 2009-11-21 17:59:33 +0000 | [diff] [blame] | 115 | } |