Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +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 | */ |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 19 | package org.apache.felix.dm.lambda; |
| 20 | |
| 21 | import java.util.Dictionary; |
| 22 | import java.util.concurrent.CompletableFuture; |
| 23 | import java.util.function.Consumer; |
| 24 | import java.util.function.Function; |
| 25 | import java.util.function.Supplier; |
| 26 | import java.util.stream.Stream; |
| 27 | |
| 28 | import org.apache.felix.dm.Component; |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 29 | import org.apache.felix.dm.lambda.callbacks.Cb; |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 30 | import org.apache.felix.dm.lambda.callbacks.CbComponent; |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 31 | import org.apache.felix.dm.lambda.callbacks.InstanceCb; |
| 32 | import org.apache.felix.dm.lambda.callbacks.InstanceCbComponent; |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 33 | |
| 34 | /** |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 35 | * Builds a Dependency Manager Component. <p> Components are the main building blocks for OSGi applications. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 36 | * They can publish themselves as a service, and they can have dependencies. |
| 37 | * These dependencies will influence their life cycle as component will only be activated when all |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 38 | * required dependencies are available. This interface is also the base interface for extended components like |
| 39 | * aspects, adapters, etc ... |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 40 | * |
| 41 | * <p> Example of a component that depends on a ConfigurationAdmin service. The dependency is injected by reflection |
| 42 | * on a class field which type matches the ConfigurationAdmin interface: |
| 43 | * |
| 44 | * <pre>{@code |
| 45 | * public class Activator extends DependencyManagerActivator { |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 46 | * public void init(BundleContext ctx, DependencyManager dm) throws Exception { |
| 47 | * component(comp -> comp.impl(Configurator.class).withSvc(ConfigurationAdmin.class)); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 48 | * } |
| 49 | * } |
| 50 | * } </pre> |
| 51 | * |
| 52 | * @param <B> the type of a builder that may extends this builder interface (aspect/adapter). |
| 53 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 54 | */ |
| 55 | public interface ComponentBuilder<B extends ComponentBuilder<B>> { |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 56 | |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 57 | /** |
| 58 | * Configures the component implementation. Can be a class name, or a component implementation object. |
| 59 | * |
| 60 | * @param impl the component implementation (a class, or an Object). |
| 61 | * @return this builder |
| 62 | */ |
| 63 | B impl(Object impl); |
| 64 | |
| 65 | /** |
Pierre De Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame] | 66 | * Sets the factory to use when creating the implementation. You can specify both the factory class and method to invoke. The method should return the implementation, |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 67 | * and can use any method to create it. Actually, this can be used together with setComposition to create a composition of instances that work together to implement |
| 68 | * a component. The factory itself can also be instantiated lazily by not specifying an instance, but a Class. |
| 69 | * |
| 70 | * @param factory the factory instance, or the factory class. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 71 | * @param createMethod the create method called on the factory in order to instantiate the component. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 72 | * @return this builder |
| 73 | */ |
| 74 | B factory(Object factory, String createMethod); |
| 75 | |
| 76 | /** |
| 77 | * Configures a factory that can be used to create this component implementation. |
| 78 | * Example: |
| 79 | * |
| 80 | * <pre> {@code |
| 81 | * factory(ComponentImpl::new)", or "factory(() -> new ComponentImpl()) |
| 82 | * }</pre> |
| 83 | * |
| 84 | * @param create the factory used to create the component implementation. |
| 85 | * @return this builder |
| 86 | */ |
| 87 | B factory(Supplier<?> create); |
| 88 | |
| 89 | /** |
| 90 | * Configures a factory used to create this component implementation using a Factory object and a method in the Factory object. |
| 91 | * Example: |
| 92 | * |
| 93 | * <pre> {@code |
| 94 | * factory(Factory::new, Factory::create) |
| 95 | * }</pre> |
| 96 | * |
| 97 | * @param <U> the type of the factory returned by the supplier |
| 98 | * @param <V> the type of the object that is returned by the factory create method. |
| 99 | * @param factory the function used to create the Factory itself |
| 100 | * @param create the method reference on the Factory method that is used to create the Component implementation |
| 101 | * @return this builder |
| 102 | */ |
| 103 | <U, V> B factory(Supplier<U> factory, Function<U, V> create); |
| 104 | |
| 105 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 106 | * Configures a factory used to create this component implementation using a Factory object and a "getComposition" factory method. |
| 107 | * the Factory method may then return multiple objects that will be part of this component implementation, and |
Pierre De Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame] | 108 | * all of them will be searched when injecting any of the dependencies. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 109 | * |
| 110 | * Example: |
| 111 | * |
| 112 | * <pre> {@code |
| 113 | * CompositionManager mngr = new CompositionManager(); |
| 114 | * ... |
| 115 | * factory(mngr::create, mngr::getComposition) |
| 116 | * }</pre> |
| 117 | * |
| 118 | * @param factory the supplier used to return the main component implementation instance |
| 119 | * @param getComposition the supplier that returns the list of instances that are part of the component implementation classes. |
| 120 | * @return this builder |
| 121 | */ |
| 122 | B factory(Supplier<?> factory, Supplier<Object[]> getComposition); |
| 123 | |
| 124 | /** |
| 125 | * Configures a factory that also returns a composition of objects for this component implemenation. |
| 126 | * |
| 127 | * Example: |
| 128 | * |
| 129 | * <pre> {@code |
| 130 | * factory(CompositionManager::new, CompositionManager::create, CompositionManager::getComposition). |
| 131 | * }</pre> |
| 132 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 133 | * Here, the CompositionManager will act as a factory (the create method will return the component implementation object), the |
| 134 | * CompositionManager.getComposition() method will return all the objects that are also part of the component implementation, |
| 135 | * and all of them will be searched for injecting any of the dependencies. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 136 | * |
| 137 | * @param <U> the type of the object returned by the supplier factory |
| 138 | * @param factory the function used to create the Factory itself |
| 139 | * @param create the Factory method used to create the main component implementation object |
| 140 | * @param getComposition the Factory method used to return the list of objects that are also part of the component implementation. |
| 141 | * @return this builder |
| 142 | */ |
| 143 | <U> B factory(Supplier<U> factory, Function<U, ?> create, Function<U, Object[]> getComposition); |
| 144 | |
| 145 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 146 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 147 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 148 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 149 | * @return this builder |
| 150 | */ |
| 151 | B provides(Class<?> iface); |
| 152 | |
| 153 | /** |
| 154 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
| 155 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 156 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 157 | * @param name a property name for the provided service |
| 158 | * @param value a property value for the provided service |
| 159 | * @param rest the rest of property name/value pairs. |
| 160 | * @return this builder. |
| 161 | */ |
| 162 | B provides(Class<?> iface, String name, Object value, Object ... rest); |
| 163 | |
| 164 | /** |
| 165 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
| 166 | * Warning: you can only use this method if you compile your application using the "-parameters" javac option. |
| 167 | * |
| 168 | * code example: |
| 169 | * |
| 170 | * <pre> {@code |
| 171 | * provides(MyService.class, property1 -> "value1", property2 -> 123); |
| 172 | * }</pre> |
| 173 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 174 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 175 | * @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 176 | * {@link FluentProperty} interface that allows to define a property name using a lambda parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 177 | * @return this builder. |
| 178 | */ |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 179 | B provides(Class<?> iface, FluentProperty ... properties); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 183 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 184 | * @param properties the properties for the provided service |
| 185 | * @return this builder. |
| 186 | */ |
| 187 | B provides(Class<?> iface, Dictionary<?,?> properties); |
| 188 | |
| 189 | /** |
| 190 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
| 191 | * |
| 192 | * @param ifaces list of services provided by the component. |
| 193 | * @return this builder. |
| 194 | */ |
| 195 | B provides(Class<?>[] ifaces); |
| 196 | |
| 197 | /** |
| 198 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
| 199 | * |
| 200 | * @param ifaces the public interfaces to register in the OSGI service registry. |
| 201 | * @param name a property name for the provided service |
| 202 | * @param value a property value for the provided service |
| 203 | * @param rest the rest of property name/value pairs. |
| 204 | * @return this builder. |
| 205 | */ |
| 206 | B provides(Class<?>[] ifaces, String name, Object value, Object ... rest); |
| 207 | |
| 208 | /** |
| 209 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
| 210 | * Warning: you can only use this method if you compile your application using the "-parameters" javac option. |
| 211 | * code example: |
| 212 | * |
| 213 | * <pre> {@code |
| 214 | * provides(new Class[] { MyService.class, MyService2.class }, property1 -> "value1", property2 -> 123); |
| 215 | * }</pre> |
| 216 | * |
| 217 | * @param ifaces the public interfaces to register in the OSGI service registry. |
| 218 | * @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 219 | * {@link FluentProperty} interface that allows to define a property name using a lambda parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 220 | * @return this builder. |
| 221 | */ |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 222 | B provides(Class<?>[] ifaces, FluentProperty ... properties); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 223 | |
| 224 | /** |
| 225 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 226 | * |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 227 | * @param ifaces the public interfaces to register in the OSGI service registry. |
| 228 | * @param properties the properties for the provided service |
| 229 | * @return this builder. |
| 230 | */ |
| 231 | B provides(Class<?>[] ifaces, Dictionary<?,?> properties); |
| 232 | |
| 233 | /** |
| 234 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
| 235 | * |
| 236 | * @param iface the service provided by this component. |
| 237 | * @return this builder. |
| 238 | */ |
| 239 | B provides(String iface); |
| 240 | |
| 241 | /** |
| 242 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
| 243 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 244 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 245 | * @param name a property name for the provided service |
| 246 | * @param value a property value for the provided service |
| 247 | * @param rest the rest of property name/value pairs. |
| 248 | * @return this builder. |
| 249 | */ |
| 250 | B provides(String iface, String name, Object value, Object ... rest); |
| 251 | |
| 252 | /** |
| 253 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
| 254 | * Warning: you can only use this method if you compile your application using the "-parameters" javac option. |
| 255 | * code example: |
| 256 | * |
| 257 | * <pre> {@code |
| 258 | * provides(MyService.class, property1 -> "value1", property2 -> 123); |
| 259 | * }</pre> |
| 260 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 261 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 262 | * @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 263 | * {@link FluentProperty} interface that allows to define a property name using a lambda parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 264 | * @return this builder. |
| 265 | */ |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 266 | B provides(String iface, FluentProperty ... properties); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 267 | |
| 268 | /** |
| 269 | * Sets the public interface under which this component should be registered in the OSGi service registry. |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 270 | * @param iface the public interface to register in the OSGI service registry. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 271 | * @param properties the properties for the provided service |
| 272 | * @return this builder. |
| 273 | */ |
| 274 | B provides(String iface, Dictionary<?,?> properties); |
| 275 | |
| 276 | /** |
| 277 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
| 278 | * |
| 279 | * @param ifaces the list of services provided by the component. |
| 280 | * @return this builder. |
| 281 | */ |
| 282 | B provides(String[] ifaces); |
| 283 | |
| 284 | /** |
| 285 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
| 286 | * |
| 287 | * @param ifaces the public interfaces to register in the OSGI service registry. |
| 288 | * @param name a property name for the provided service |
| 289 | * @param value a property value for the provided service |
| 290 | * @param rest the rest of property name/value pairs. |
| 291 | * @return this builder. |
| 292 | */ |
| 293 | B provides(String[] ifaces, String name, Object value, Object ... rest); |
| 294 | |
| 295 | /** |
| 296 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
| 297 | * Warning: you can only use this method if you compile your application using the "-parameters" javac option. |
| 298 | * |
| 299 | * code example: |
| 300 | * <pre> {@code |
| 301 | * provides(new Class[] { MyService.class, MyService2.class }, property1 -> "value1", property2 -> 123); |
| 302 | * }</pre> |
| 303 | * |
| 304 | * @param ifaces the public interfaces to register in the OSGI service registry. |
| 305 | * @param properties a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 306 | * {@link FluentProperty} interface that allows to define a property name using a lambda parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 307 | * @return this builder. |
| 308 | */ |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 309 | B provides(String[] ifaces, FluentProperty ... properties); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 310 | |
| 311 | /** |
| 312 | * Sets the public interfaces under which this component should be registered in the OSGi service registry. |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 313 | * |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 314 | * @param ifaces the public interfaces to register in the OSGI service registry. |
| 315 | * @param properties the properties for the provided service |
| 316 | * @return this builder. |
| 317 | */ |
| 318 | B provides(String[] ifaces, Dictionary<?,?> properties); |
| 319 | |
| 320 | /** |
| 321 | * Sets the component's service properties |
| 322 | * @param properties the component's service properties |
| 323 | * @return this builder |
| 324 | */ |
| 325 | B properties(Dictionary<?,?> properties); |
| 326 | |
| 327 | /** |
| 328 | * Sets the components's service properties using varargs. The number of parameters must be even, representing a list of pair property key-value. |
| 329 | * |
| 330 | * <pre> {@code |
| 331 | * Example: properties("param1", "value1", "service.ranking", 3) |
| 332 | * }</pre> |
| 333 | * |
| 334 | * @param name the first property name |
| 335 | * @param value the first property value |
| 336 | * @param rest the rest of properties key/value pairs. |
| 337 | * @return this builder |
| 338 | */ |
| 339 | B properties(String name, Object value, Object ... rest); |
| 340 | |
| 341 | /** |
| 342 | * Sets the components's service properties using List of lamda properties. |
| 343 | * |
| 344 | * Example: |
| 345 | * |
| 346 | * <pre> {@code |
| 347 | * properties(param1 -> "value1, param2 -> 2); |
| 348 | * }</pre> |
| 349 | * |
| 350 | * When you use this method, you must compile your source code using the "-parameters" option, and the "arg0" parameter |
| 351 | * name is now allowed. |
| 352 | * |
| 353 | * @param properties the fluent properties |
| 354 | * @return this builder |
| 355 | */ |
Pierre De Rop | 0aac136 | 2016-02-02 19:46:08 +0000 | [diff] [blame] | 356 | B properties(FluentProperty ... properties); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 357 | |
| 358 | /** |
| 359 | * Adds a required/autoconfig service dependency. |
| 360 | * |
| 361 | * @param service the service dependency filter |
| 362 | * @param filter the service filter |
| 363 | * @return this builder |
| 364 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 365 | B withSvc(Class<?> service, String filter); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 366 | |
| 367 | /** |
| 368 | * Adds in one shot multiple required/autoconfig service dependencies. |
| 369 | * @param services the dependencies that are required and that will be injected in any field with the same dependency type. |
| 370 | * @return this builder |
| 371 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 372 | B withSvc(Class<?> ... services); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 373 | |
| 374 | /** |
| 375 | * Adds a service dependency built using a Consumer lambda that is provided with a ServiceDependencyBuilder. |
| 376 | * |
| 377 | * @param <U> the type of the dependency service |
| 378 | * @param service the service |
| 379 | * @param consumer the lambda for building the service dependency |
| 380 | * @return this builder. |
| 381 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 382 | <U> B withSvc(Class<U> service, Consumer<ServiceDependencyBuilder<U>> consumer); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 383 | |
| 384 | /** |
| 385 | * Adds a configuration dependency. |
| 386 | * @param consumer the lambda used to build the configuration dependency. |
| 387 | * @return this builder. |
| 388 | */ |
| 389 | B withCnf(Consumer<ConfigurationDependencyBuilder> consumer); |
| 390 | |
| 391 | /** |
| 392 | * Adds multiple configuration dependencies in one single call. All configurations are injected by default in the "updated" callback. |
| 393 | * @param pids list of configuration pids. |
| 394 | * @return this builder |
| 395 | */ |
| 396 | @SuppressWarnings("unchecked") |
| 397 | default B withCnf(String ... pids) { |
| 398 | Stream.of(pids).forEach(pid -> withCnf(cnf -> cnf.pid(pid))); |
| 399 | return (B) this; |
| 400 | } |
| 401 | |
| 402 | /** |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 403 | * Adds a bundle dependency. |
| 404 | * @param consumer the lambda used to build the bundle dependency. |
| 405 | * @return this builder. |
| 406 | */ |
| 407 | B withBundle(Consumer<BundleDependencyBuilder> consumer); |
| 408 | |
| 409 | /** |
| 410 | * Adds a CompletableFuture dependency. |
| 411 | * |
| 412 | * @param <U> the type of the result of the CompletableFuture. |
| 413 | * @param future a CompletableFuture on which the dependency will wait for |
| 414 | * @param consumer the builder used to build the dependency |
| 415 | * @return this builder. |
| 416 | */ |
| 417 | <U> B withFuture(CompletableFuture<U> future, Consumer<FutureDependencyBuilder<U>> consumer); |
| 418 | |
| 419 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 420 | * Sets the instance to invoke with the reflection based lifecycle callbacks. By default, reflection based |
| 421 | * lifecycle callbacks (init/start/stop/destroy) methods are invoked on the component implementation instance(s). |
| 422 | * But you can set a specific callback instance using this method. |
| 423 | * <p> |
| 424 | * Specifying an instance means you can create a manager |
| 425 | * that will be invoked whenever the life cycle of a component changes and this manager |
| 426 | * can then decide how to expose this life cycle to the actual component, offering an |
| 427 | * important indirection when developing your own component models. |
| 428 | * |
| 429 | * @see #init(String) |
| 430 | * @see #start(String) |
| 431 | * @see #stop(String) |
| 432 | * @see #destroy(String) |
| 433 | * @param lifecycleCallbackInstance the instance the lifecycle callback will be invoked on. |
| 434 | * @return this builder. |
| 435 | */ |
| 436 | B lifecycleCallbackInstance(Object lifecycleCallbackInstance); |
| 437 | |
| 438 | /** |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 439 | * Sets the name of the method used as the "init" callback. This method, when found, is |
| 440 | * invoked as part of the life cycle management of the component implementation. |
| 441 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 442 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 443 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
Pierre De Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame] | 444 | * <p>The dependency manager will look for a method of this name with the following signatures, |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 445 | * in this order: |
| 446 | * <ol> |
| 447 | * <li>method(Component component)</li> |
| 448 | * <li>method()</li> |
| 449 | * </ol> |
| 450 | * |
| 451 | * @param callback the callback name |
| 452 | * @return this builder. |
| 453 | */ |
| 454 | B init(String callback); |
| 455 | |
| 456 | /** |
| 457 | * Sets the name of the method used as the "start" callback. This method, when found, is |
Pierre De Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame] | 458 | * invoked as part of the life cycle management of the component implementation. <p>The |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 459 | * dependency manager will look for a method of this name with the following signatures, |
| 460 | * in this order: |
| 461 | * <ol> |
| 462 | * <li>method(Component component)</li> |
| 463 | * <li>method()</li> |
| 464 | * </ol> |
| 465 | * |
| 466 | * @param callback the callback name |
| 467 | * @return this builder. |
| 468 | */ |
| 469 | B start(String callback); |
| 470 | |
| 471 | /** |
| 472 | * Sets the name of the method used as the "stop" callback. This method, when found, is |
Pierre De Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame] | 473 | * invoked as part of the life cycle management of the component implementation. <p>The |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 474 | * dependency manager will look for a method of this name with the following signatures, |
| 475 | * in this order: |
| 476 | * <ol> |
| 477 | * <li>method(Component component)</li> |
| 478 | * <li>method()</li> |
| 479 | * </ol> |
| 480 | * |
| 481 | * @param callback the callback name |
| 482 | * @return this builder. |
| 483 | */ |
| 484 | B stop(String callback); |
| 485 | |
| 486 | /** |
| 487 | * Sets the name of the method used as the "destroy" callback. This method, when found, is |
Pierre De Rop | 57ffa3f | 2016-02-19 12:54:30 +0000 | [diff] [blame] | 488 | * invoked as part of the life cycle management of the component implementation. <p>The |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 489 | * dependency manager will look for a method of this name with the following signatures, |
| 490 | * in this order: |
| 491 | * <ol> |
| 492 | * <li>method(Component component)</li> |
| 493 | * <li>method()</li> |
| 494 | * </ol> |
| 495 | * |
| 496 | * @param callback the callback name |
| 497 | * @return this builder. |
| 498 | */ |
| 499 | B destroy(String callback); |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 500 | |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 501 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 502 | * Sets a reference to a component implementation class "init" callback method. |
| 503 | * This method does not take any arguments and is |
| 504 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 505 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 506 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 507 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 508 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 509 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 510 | * @param callback a method reference must point to method from the component implementation class(es). |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 511 | * @return this builder |
| 512 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 513 | <T> B init(Cb<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 514 | |
| 515 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 516 | * Sets a reference to a component implementation class "start" callback method. |
| 517 | * This method does not take any arguments and is |
| 518 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 519 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 520 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 521 | * @param callback a method reference must point to method from one of the component implementation classes. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 522 | * @return this builder. |
| 523 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 524 | <T> B start(Cb<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 525 | |
| 526 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 527 | * Sets a reference to a component implementation class "stop" callback method. |
| 528 | * This method does not take any arguments and is |
| 529 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 530 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 531 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 532 | * @param callback a method reference must point to method from one of the component implementation classes. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 533 | * @return this builder. |
| 534 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 535 | <T> B stop(Cb<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 536 | |
| 537 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 538 | * Sets a reference to a component implementation class "destroy" callback method. |
| 539 | * This method does not take any arguments and is |
| 540 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 541 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 542 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 543 | * @param callback a method reference must point to method from one of the component implementation classes. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 544 | * @return this builder. |
| 545 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 546 | <T> B destroy(Cb<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 547 | |
| 548 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 549 | * Sets a reference to a component implementation class "init" callback method. |
| 550 | * This method takes a Component argument and is |
| 551 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 552 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 553 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 554 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 555 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 556 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 557 | * @param callback a method reference must point to method from one of the component implementation classes. The method takes as argument a Component parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 558 | * @return this builder |
| 559 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 560 | <T> B init(CbComponent<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 561 | |
| 562 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 563 | * Sets a reference to a component implementation class "start" callback method. |
| 564 | * This method takes a Component argument and is |
| 565 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 566 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 567 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 568 | * @param callback a method reference must point to method from one of the component implementation classes. The method takes as argument a Component parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 569 | * @return this builder. |
| 570 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 571 | <T> B start(CbComponent<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 572 | |
| 573 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 574 | * Sets a reference to a component implementation class "stop" callback method. |
| 575 | * This method takes a Component argument and is |
| 576 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 577 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 578 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 579 | * @param callback a method reference must point to method from one of the component implementation classes. The method takes as argument a Component parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 580 | * @return this builder. |
| 581 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 582 | <T> B stop(CbComponent<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 583 | |
| 584 | /** |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 585 | * Sets a reference to a component implementation class "destroy" callback method. |
| 586 | * This method takes a Component argument and is |
| 587 | * invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 588 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 589 | * @param <T> the type of the component class on which the callback is invoked on. |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 590 | * @param callback a method reference must point to method from one of the component implementation classes. The method takes as argument a Component parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 591 | * @return this builder. |
| 592 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 593 | <T> B destroy(CbComponent<T> callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 594 | |
| 595 | /** |
| 596 | * Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component |
| 597 | * implementation. |
| 598 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 599 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 600 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
| 601 | * The method does not take any parameters. |
| 602 | * |
| 603 | * @param callback an Object instance method reference. The method does not take any parameters. |
| 604 | * @return this builder |
| 605 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 606 | B initInstance(InstanceCb callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 607 | |
| 608 | /** |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 609 | * Sets an Object instance method reference used as the "start" callback. |
| 610 | * This method is invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 611 | * The method does not take any parameters. |
| 612 | * |
| 613 | * @param callback an Object instance method reference. The method does not take any parameters. |
| 614 | * @return this builder. |
| 615 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 616 | B startInstance(InstanceCb callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 617 | |
| 618 | /** |
| 619 | * Sets an Object instance method reference used as the "stop" callback. It is invoked as part of the life cycle management of the component |
| 620 | * implementation. |
| 621 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 622 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 623 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
| 624 | * The method does not take any parameters. |
| 625 | * |
| 626 | * @param callback an Object instance method reference. The method does not take any parameters. |
| 627 | * @return this builder |
| 628 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 629 | B stopInstance(InstanceCb callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 630 | |
| 631 | /** |
| 632 | * Sets an Object instance method reference used as the "destroy" callback. It is invoked as part of the life cycle management of the component |
| 633 | * implementation. |
| 634 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 635 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 636 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
| 637 | * The method does not take any parameters. |
| 638 | * |
| 639 | * @param callback an Object instance method reference. The method does not take any parameters. |
| 640 | * @return this builder |
| 641 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 642 | B destroyInstance(InstanceCb callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 643 | |
| 644 | /** |
| 645 | * Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component |
| 646 | * implementation. |
| 647 | * This method is useful because when it is invoked, all required dependencies defines in the Activator |
| 648 | * are already injected, and you can then add more extra dependencies from the init() method. |
| 649 | * And once all extra dependencies will be available and injected, then the "start" callback will be invoked. |
| 650 | * The method takes as argument a Component parameter. |
| 651 | * |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 652 | * @param callback an Object instance method reference. The method takes as argument a Component parameter. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 653 | * @return this builder |
| 654 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 655 | B initInstance(InstanceCbComponent callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 656 | |
| 657 | /** |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 658 | * Sets an Object instance method reference used as the "start" callback. |
| 659 | * This method is invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 660 | * The method takes as argument a Component parameter. |
| 661 | * |
| 662 | * @param callback an Object instance method reference. The method takes as argument a Component parameter. |
| 663 | * @return this builder. |
| 664 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 665 | B startInstance(InstanceCbComponent callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 666 | |
| 667 | /** |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 668 | * Sets an Object instance method reference used as the "stop" callback. |
| 669 | * This method is invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 670 | * The method takes as argument a Component parameter. |
| 671 | * |
| 672 | * @param callback an Object instance method reference. The method takes as argument a Component parameter. |
| 673 | * @return this builder. |
| 674 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 675 | B stopInstance(InstanceCbComponent callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 676 | |
| 677 | /** |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 678 | * Sets an Object instance method reference used as the "destroy" callback. |
| 679 | * This method is invoked as part of the life cycle management of the component implementation. |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 680 | * The method takes as argument a Component parameter. |
| 681 | * |
| 682 | * @param callback an Object instance method reference. The method takes as argument a Component parameter. |
| 683 | * @return this builder. |
| 684 | */ |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 685 | B destroyInstance(InstanceCbComponent callback); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 686 | |
| 687 | /** |
| 688 | * Configures OSGi object (BundleContext, Component, etc ...) that will be injected in any field having the same OSGi object type. |
| 689 | * @param clazz the OSGi object type (BundleContext, Component, DependencyManager). |
| 690 | * @param autoConfig true if the OSGi object has to be injected, false if not |
| 691 | * @return this builder |
| 692 | */ |
| 693 | B autoConfig(Class<?> clazz, boolean autoConfig); |
| 694 | |
| 695 | /** |
| 696 | * Configures OSGi object (BundleContext, Component, etc ...) that will be injected in a given field. |
| 697 | * @param clazz the OSGi object type (BundleContext, Component, DependencyManager). |
| 698 | * @param field the field that will be injected with the OSGI object |
| 699 | * @return this builder |
| 700 | */ |
| 701 | B autoConfig(Class<?> clazz, String field); |
| 702 | |
| 703 | /** |
| 704 | * Activates debug mode |
| 705 | * @param label the debug label |
| 706 | * @return this builder |
| 707 | */ |
| 708 | B debug(String label); |
| 709 | |
| 710 | /** |
| 711 | * Automatically adds this component to its DependencyManager object. When a lambda builds a Component using this builder, by default |
| 712 | * the built component is auto added to its DependencyManager object, unless you invoke autoAdd(false). |
| 713 | * |
| 714 | * @param autoAdd true for automatically adding this component to the DependencyManager object, false if not |
| 715 | * @return this builder |
| 716 | */ |
| 717 | B autoAdd(boolean autoAdd); |
| 718 | |
| 719 | /** |
| 720 | * Sets the method to invoke on the service implementation to get back all |
| 721 | * instances that are part of a composition and need dependencies injected. |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 722 | * All of them will be searched to inject any of the dependencies. The method that |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 723 | * is invoked must return an <code>Object[]</code>. |
| 724 | * |
| 725 | * @param getCompositionMethod the method to invoke |
| 726 | * @return this builder |
| 727 | */ |
| 728 | B composition(String getCompositionMethod); |
| 729 | |
| 730 | /** |
| 731 | * Sets the instance and method to invoke to get back all instances that |
| 732 | * are part of a composition and need dependencies injected. All of them |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame] | 733 | * will be searched to inject any of the dependencies. The method that is |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 734 | * invoked must return an <code>Object[]</code>. |
| 735 | * |
| 736 | * @param instance the instance that has the method |
| 737 | * @param getCompositionMethod the method to invoke |
| 738 | * @return this builder |
| 739 | */ |
| 740 | B composition(Object instance, String getCompositionMethod); |
| 741 | |
| 742 | /** |
| 743 | * Sets a java8 method reference to a Supplier that returns all instances that are part of a composition and need dependencies injected. |
| 744 | * All of them will be searched for any of the dependencies. The method that |
| 745 | * is invoked must return an <code>Object[]</code>. |
| 746 | * |
| 747 | * @param getCompositionMethod the method to invoke |
| 748 | * @return this builder |
| 749 | */ |
| 750 | B composition(Supplier<Object[]> getCompositionMethod); |
Pierre De Rop | 6e8f921 | 2016-02-20 21:44:59 +0000 | [diff] [blame^] | 751 | |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 752 | /** |
| 753 | * Builds the real DependencyManager Component. |
| 754 | * @return the real DependencyManager Component. |
| 755 | */ |
| 756 | Component build(); |
| 757 | } |