Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +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; |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 20 | |
Marcel Offermans | a8c213f | 2010-07-02 17:27:20 +0000 | [diff] [blame] | 21 | import java.net.URL; |
| 22 | |
Marcel Offermans | 5be5f14 | 2011-04-26 10:47:12 +0000 | [diff] [blame] | 23 | /** |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 24 | * A resource dependency is a dependency on a resource. A resource in this context is an object that is |
| 25 | * identified by a URL. Resources should somehow be provided by an external component, the resource |
| 26 | * provider. These dependencies then react on them becoming available or not. Use cases for such dependencies |
| 27 | * are resources that are embedded in bundles, in a workspace or some remote or local repository, etc. |
| 28 | * |
Marcel Offermans | 5be5f14 | 2011-04-26 10:47:12 +0000 | [diff] [blame] | 29 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 30 | */ |
Marcel Offermans | faaed47 | 2010-09-08 10:07:32 +0000 | [diff] [blame] | 31 | public interface ResourceDependency extends Dependency, ComponentDependencyDeclaration, ResourceHandler { |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 32 | /** |
| 33 | * Sets the callbacks for this service. These callbacks can be used as hooks whenever a |
| 34 | * dependency is added or removed. When you specify callbacks, the auto configuration |
| 35 | * feature is automatically turned off, because we're assuming you don't need it in this |
| 36 | * case. |
| 37 | * |
| 38 | * @param added the method to call when a service was added |
| 39 | * @param removed the method to call when a service was removed |
| 40 | * @return this service dependency |
| 41 | */ |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 42 | public ResourceDependency setCallbacks(String added, String removed); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Sets the callbacks for this service. These callbacks can be used as hooks whenever a |
| 46 | * dependency is added, changed or removed. When you specify callbacks, the auto |
| 47 | * configuration feature is automatically turned off, because we're assuming you don't |
| 48 | * need it in this case. |
| 49 | * |
| 50 | * @param added the method to call when a service was added |
| 51 | * @param changed the method to call when a service was changed |
| 52 | * @param removed the method to call when a service was removed |
| 53 | * @return this service dependency |
| 54 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 55 | public ResourceDependency setCallbacks(String added, String changed, String removed); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Sets the callbacks for this service. These callbacks can be used as hooks whenever a |
| 59 | * dependency is added or removed. They are called on the instance you provide. When you |
| 60 | * specify callbacks, the auto configuration feature is automatically turned off, because |
| 61 | * we're assuming you don't need it in this case. |
| 62 | * |
| 63 | * @param instance the instance to call the callbacks on |
| 64 | * @param added the method to call when a service was added |
| 65 | * @param removed the method to call when a service was removed |
| 66 | * @return this service dependency |
| 67 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 68 | public ResourceDependency setCallbacks(Object instance, String added, String removed); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Sets the callbacks for this service. These callbacks can be used as hooks whenever a |
| 72 | * dependency is added, changed or removed. They are called on the instance you provide. When you |
| 73 | * specify callbacks, the auto configuration feature is automatically turned off, because |
| 74 | * we're assuming you don't need it in this case. |
| 75 | * |
| 76 | * @param instance the instance to call the callbacks on |
| 77 | * @param added the method to call when a service was added |
| 78 | * @param changed the method to call when a service was changed |
| 79 | * @param removed the method to call when a service was removed |
| 80 | * @return this service dependency |
| 81 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 82 | public ResourceDependency setCallbacks(Object instance, String added, String changed, String removed); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * Sets auto configuration for this service. Auto configuration allows the |
| 86 | * dependency to fill in any attributes in the service implementation that |
| 87 | * are of the same type as this dependency. Default is on. |
| 88 | * |
| 89 | * @param autoConfig the value of auto config |
| 90 | * @return this service dependency |
| 91 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 92 | public ResourceDependency setAutoConfig(boolean autoConfig); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * Sets auto configuration for this service. Auto configuration allows the |
| 96 | * dependency to fill in the attribute in the service implementation that |
| 97 | * has the same type and instance name. |
| 98 | * |
| 99 | * @param instanceName the name of attribute to auto config |
| 100 | * @return this service dependency |
| 101 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 102 | public ResourceDependency setAutoConfig(String instanceName); |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Sets the resource for this dependency. |
| 106 | * |
| 107 | * @param resource the URL of the resource |
| 108 | */ |
Marcel Offermans | a8c213f | 2010-07-02 17:27:20 +0000 | [diff] [blame] | 109 | public ResourceDependency setResource(URL resource); |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Determines if this is a required dependency or not. |
| 113 | * |
| 114 | * @param required <code>true</code> if the dependency is required |
| 115 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 116 | public ResourceDependency setRequired(boolean required); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 117 | |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 118 | /** |
| 119 | * Sets the filter condition for this resource dependency. |
| 120 | * |
| 121 | * @param resourceFilter the filter condition |
| 122 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 123 | public ResourceDependency setFilter(String resourceFilter); |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 124 | |
| 125 | /** @see ResourceDependency#setPropagate(Object, String) */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 126 | public ResourceDependency setPropagate(boolean propagate); |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * Sets an Object instance and a callback method used to propagate some properties to the provided service properties. |
| 130 | * The method will be invoked on the specified object instance and must have one of the following signatures:<p> |
| 131 | * <ul><li>Dictionary callback(ServiceReference, Object service) |
| 132 | * <li>Dictionary callback(ServiceReference) |
| 133 | * </ul> |
| 134 | * @param instance the Object instance which is used to retrieve propagated service properties |
| 135 | * @param method the method to invoke for retrieving the properties to be propagated to the service properties. |
| 136 | * @return this service dependency. |
| 137 | */ |
Marcel Offermans | 26081d3 | 2010-07-12 12:43:42 +0000 | [diff] [blame] | 138 | public ResourceDependency setPropagate(Object instance, String method); |
Marcel Offermans | cba269a | 2013-01-18 11:00:56 +0000 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * Sets this dependency to be instance bound or not. |
| 142 | * |
| 143 | * @param isInstanceBound <code>true</code> if this dependency should be instance bound |
| 144 | */ |
Marcel Offermans | a564b3a | 2010-03-20 20:19:15 +0000 | [diff] [blame] | 145 | public ResourceDependency setInstanceBound(boolean isInstanceBound); |
Pierre De Rop | ddce586 | 2009-12-04 22:16:48 +0000 | [diff] [blame] | 146 | } |