blob: aa9400a16342ce02ceb4c7133a5ab01535231467 [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
Pierre De Ropddce5862009-12-04 22:16:48 +000021import org.osgi.framework.ServiceReference;
22
23/**
24 * Service dependency that can track an OSGi service.
25 *
26 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
27 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000028public interface ServiceDependency extends Dependency, ComponentDependencyDeclaration {
Pierre De Ropddce5862009-12-04 22:16:48 +000029 /**
30 * Sets the name of the service that should be tracked.
31 *
32 * @param serviceName the name of the service
33 * @return this service dependency
34 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +000035 public ServiceDependency setService(Class serviceName);
Pierre De Ropddce5862009-12-04 22:16:48 +000036
37 /**
38 * Sets the name of the service that should be tracked. You can either specify
39 * only the name, or the name and a filter. In the latter case, the filter is used
40 * to track the service and should only return services of the type that was specified
41 * in the name. To make sure of this, the filter is actually extended internally to
42 * filter on the correct name.
43 *
44 * @param serviceName the name of the service
45 * @param serviceFilter the filter condition
46 * @return this service dependency
47 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +000048 public ServiceDependency setService(Class serviceName, String serviceFilter);
Marcel Offermansa83c25a2009-12-22 13:38:38 +000049
50 /**
51 * Sets the filter for the services that should be tracked. Any service object
52 * matching the filter will be returned, without any additional filter on the
53 * class.
54 *
55 * @param serviceFilter the filter condition
56 * @return this service dependency
57 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +000058 public ServiceDependency setService(String serviceFilter);
Pierre De Ropddce5862009-12-04 22:16:48 +000059
60 /**
61 * Sets the name of the service that should be tracked. You can either specify
62 * only the name, or the name and a reference. In the latter case, the service reference
63 * is used to track the service and should only return services of the type that was
64 * specified in the name.
65 *
66 * @param serviceName the name of the service
67 * @param serviceReference the service reference to track
68 * @return this service dependency
69 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +000070 public ServiceDependency setService(Class serviceName, ServiceReference serviceReference);
Pierre De Ropddce5862009-12-04 22:16:48 +000071
72 /**
73 * Sets the default implementation for this service dependency. You can use this to supply
74 * your own implementation that will be used instead of a Null Object when the dependency is
75 * not available. This is also convenient if the service dependency is not an interface
76 * (which would cause the Null Object creation to fail) but a class.
77 *
78 * @param implementation the instance to use or the class to instantiate if you want to lazily
79 * instantiate this implementation
80 * @return this service dependency
81 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +000082 public ServiceDependency setDefaultImplementation(Object implementation);
Pierre De Ropddce5862009-12-04 22:16:48 +000083
84 /**
85 * Sets the required flag which determines if this service is required or not.
86 *
87 * @param required the required flag
88 * @return this service dependency
89 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +000090 public ServiceDependency setRequired(boolean required);
Pierre De Ropddce5862009-12-04 22:16:48 +000091
92 /**
93 * Sets auto configuration for this service. Auto configuration allows the
94 * dependency to fill in any attributes in the service implementation that
95 * are of the same type as this dependency. Default is on.
96 *
97 * @param autoConfig the value of auto config
98 * @return this service dependency
99 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000100 public ServiceDependency setAutoConfig(boolean autoConfig);
Pierre De Ropddce5862009-12-04 22:16:48 +0000101
102 /**
103 * Sets auto configuration for this service. Auto configuration allows the
104 * dependency to fill in the attribute in the service implementation that
105 * has the same type and instance name.
106 *
107 * @param instanceName the name of attribute to auto config
108 * @return this service dependency
109 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000110 public ServiceDependency setAutoConfig(String instanceName);
Pierre De Ropddce5862009-12-04 22:16:48 +0000111
112 /**
113 * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
114 * dependency is added or removed. When you specify callbacks, the auto configuration
115 * feature is automatically turned off, because we're assuming you don't need it in this
116 * case.
117 *
118 * @param added the method to call when a service was added
119 * @param removed the method to call when a service was removed
120 * @return this service dependency
121 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000122 public ServiceDependency setCallbacks(String added, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +0000123
124 /**
125 * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
126 * dependency is added, changed or removed. When you specify callbacks, the auto
127 * configuration feature is automatically turned off, because we're assuming you don't
128 * need it in this case.
129 *
130 * @param added the method to call when a service was added
131 * @param changed the method to call when a service was changed
132 * @param removed the method to call when a service was removed
133 * @return this service dependency
134 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000135 public ServiceDependency setCallbacks(String added, String changed, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +0000136
137 /**
138 * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
Marcel Offermans7f0cec02011-11-04 13:39:28 +0000139 * dependency is added, changed or removed. When you specify callbacks, the auto
140 * configuration feature is automatically turned off, because we're assuming you don't
141 * need it in this case.
142 * @param added the method to call when a service was added
143 * @param changed the method to call when a service was changed
144 * @param removed the method to call when a service was removed
145 * @param swapped the method to call when the service was swapped due to addition or
146 * removal of an aspect
147 * @return this service dependency
148 */
149 public ServiceDependency setCallbacks(String added, String changed, String removed, String swapped);
150
151 /**
152 * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
Pierre De Ropddce5862009-12-04 22:16:48 +0000153 * dependency is added or removed. They are called on the instance you provide. When you
154 * specify callbacks, the auto configuration feature is automatically turned off, because
155 * we're assuming you don't need it in this case.
156 *
157 * @param instance the instance to call the callbacks on
158 * @param added the method to call when a service was added
159 * @param removed the method to call when a service was removed
160 * @return this service dependency
161 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000162 public ServiceDependency setCallbacks(Object instance, String added, String removed);
Pierre De Ropddce5862009-12-04 22:16:48 +0000163
164 /**
165 * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
166 * dependency is added, changed or removed. They are called on the instance you provide. When you
167 * specify callbacks, the auto configuration feature is automatically turned off, because
168 * we're assuming you don't need it in this case.
169 *
170 * @param instance the instance to call the callbacks on
171 * @param added the method to call when a service was added
172 * @param changed the method to call when a service was changed
173 * @param removed the method to call when a service was removed
174 * @return this service dependency
175 */
Marcel Offermansa564b3a2010-03-20 20:19:15 +0000176 public ServiceDependency setCallbacks(Object instance, String added, String changed, String removed);
Marcel Offermansf9a6e4c2009-12-08 10:09:01 +0000177
Pierre De Rop23514f52010-08-29 20:44:25 +0000178 /**
Marcel Offermans7f0cec02011-11-04 13:39:28 +0000179 * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
180 * dependency is added, changed or removed. When you specify callbacks, the auto
181 * configuration feature is automatically turned off, because we're assuming you don't
182 * need it in this case.
183 * @param instance the instance to call the callbacks on
184 * @param added the method to call when a service was added
185 * @param changed the method to call when a service was changed
186 * @param removed the method to call when a service was removed
187 * @param swapped the method to call when the service was swapped due to addition or
188 * removal of an aspect
189 * @return this service dependency
190 */
191 public ServiceDependency setCallbacks(Object instance, String added, String changed, String removed, String swapped);
192
193 /**
Pierre De Rop23514f52010-08-29 20:44:25 +0000194 * Sets propagation of the service dependency properties to the provided service properties. Any additional
195 * service properties specified directly are merged with these.
196 */
197 public ServiceDependency setPropagate(boolean propagate);
198
199 /**
200 * Sets an Object instance and a callback method used to propagate some properties to the provided service properties.
201 * The method will be invoked on the specified object instance and must have one of the following signatures:<p>
202 * <ul><li>Dictionary callback(ServiceReference, Object service)
203 * <li>Dictionary callback(ServiceReference)
204 * </ul>
205 * @param instance the Object instance which is used to retrieve propagated service properties
206 * @param method the method to invoke for retrieving the properties to be propagated to the service properties.
207 * @return this service dependency.
208 */
209 public ServiceDependency setPropagate(Object instance, String method);
210
Marcel Offermanscba269a2013-01-18 11:00:56 +0000211 /**
212 * Sets this dependency to be instance bound or not.
213 *
214 * @param isInstanceBound <code>true</code> if this dependency should be instance bound
215 */
Pierre De Rop23514f52010-08-29 20:44:25 +0000216 public ServiceDependency setInstanceBound(boolean isInstanceBound);
Pierre De Ropddce5862009-12-04 22:16:48 +0000217}