blob: b837262a766e8ecf0aa489b6b932e0189b62dfd0 [file] [log] [blame]
Pierre De Ropddce5862009-12-04 22:16:48 +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;
Pierre De Ropddce5862009-12-04 22:16:48 +000020
Marcel Offermansa8c213f2010-07-02 17:27:20 +000021import java.net.URL;
22
Marcel Offermans5be5f142011-04-26 10:47:12 +000023/**
Marcel Offermanscba269a2013-01-18 11:00:56 +000024 * 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 Offermans5be5f142011-04-26 10:47:12 +000029 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
30 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000031public interface ResourceDependency extends Dependency, ComponentDependencyDeclaration, ResourceHandler {
Pierre De Ropddce5862009-12-04 22:16:48 +000032 /**
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 Offermanscba269a2013-01-18 11:00:56 +000042 public ResourceDependency setCallbacks(String added, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +000043
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 Offermansa564b3a2010-03-20 20:19:15 +000055 public ResourceDependency setCallbacks(String added, String changed, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +000056
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 Offermansa564b3a2010-03-20 20:19:15 +000068 public ResourceDependency setCallbacks(Object instance, String added, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +000069
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 Offermansa564b3a2010-03-20 20:19:15 +000082 public ResourceDependency setCallbacks(Object instance, String added, String changed, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +000083
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 Offermansa564b3a2010-03-20 20:19:15 +000092 public ResourceDependency setAutoConfig(boolean autoConfig);
Pierre De Ropddce5862009-12-04 22:16:48 +000093
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 Offermansa564b3a2010-03-20 20:19:15 +0000102 public ResourceDependency setAutoConfig(String instanceName);
Marcel Offermanscba269a2013-01-18 11:00:56 +0000103
104 /**
105 * Sets the resource for this dependency.
106 *
107 * @param resource the URL of the resource
108 */
Marcel Offermansa8c213f2010-07-02 17:27:20 +0000109 public ResourceDependency setResource(URL resource);
Marcel Offermanscba269a2013-01-18 11:00:56 +0000110
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 Offermansa564b3a2010-03-20 20:19:15 +0000116 public ResourceDependency setRequired(boolean required);
Pierre De Ropddce5862009-12-04 22:16:48 +0000117
Marcel Offermanscba269a2013-01-18 11:00:56 +0000118 /**
119 * Sets the filter condition for this resource dependency.
120 *
121 * @param resourceFilter the filter condition
122 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000123 public ResourceDependency setFilter(String resourceFilter);
Marcel Offermanscba269a2013-01-18 11:00:56 +0000124
125 /** @see ResourceDependency#setPropagate(Object, String) */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000126 public ResourceDependency setPropagate(boolean propagate);
Marcel Offermanscba269a2013-01-18 11:00:56 +0000127
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 Offermans26081d32010-07-12 12:43:42 +0000138 public ResourceDependency setPropagate(Object instance, String method);
Marcel Offermanscba269a2013-01-18 11:00:56 +0000139
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 Offermansa564b3a2010-03-20 20:19:15 +0000145 public ResourceDependency setInstanceBound(boolean isInstanceBound);
Pierre De Ropddce5862009-12-04 22:16:48 +0000146}