Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +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 | */ |
| 19 | package org.apache.felix.dm; |
| 20 | |
| 21 | /** |
| 22 | * Configuration dependency that can track the availability of a (valid) configuration. To use |
| 23 | * it, specify a PID for the configuration. The dependency is always required, because if it is |
| 24 | * not, it does not make sense to use the dependency manager. In that scenario, simply register |
| 25 | * your component as a <code>ManagedService(Factory)</code> and handle everything yourself. Also, |
| 26 | * only managed services are supported, not factories. There are a couple of things you need to |
| 27 | * be aware of when implementing the <code>updated(Dictionary)</code> method: |
| 28 | * <ul> |
| 29 | * <li>Make sure it throws a <code>ConfigurationException</code> when you get a configuration |
| 30 | * that is invalid. In this case, the dependency will not change: if it was not available, it |
| 31 | * will still not be. If it was available, it will remain available and implicitly assume you |
| 32 | * keep working with your old configuration.</li> |
| 33 | * <li>This method will be called before all required dependencies are available. Make sure you |
| 34 | * do not depend on these to parse your settings.</li> |
| 35 | * </ul> |
| 36 | * |
Pierre De Rop | c40d93f | 2015-05-04 20:25:57 +0000 | [diff] [blame^] | 37 | * The callback invoked when a configuration dependency is updated can supports the following signatures:<p> |
| 38 | * <ul><li> updated(Dictionary) |
| 39 | * <li> updated(Component, Dictionary) |
| 40 | * </ul> |
| 41 | * |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 42 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 43 | */ |
| 44 | public interface ConfigurationDependency extends Dependency, ComponentDependencyDeclaration { |
| 45 | /** |
| 46 | * Sets the name of the callback method that should be invoked when a configuration |
| 47 | * is available. The contract for this method is identical to that of |
| 48 | * <code>ManagedService.updated(Dictionary) throws ConfigurationException</code>. |
| 49 | * |
| 50 | * @param callback the name of the callback method |
| 51 | */ |
| 52 | ConfigurationDependency setCallback(String callback); |
| 53 | |
| 54 | /** |
| 55 | * Sets the name of the callback method that should be invoked when a configuration |
| 56 | * is available. The contract for this method is identical to that of |
| 57 | * <code>ManagedService.updated(Dictionary) throws ConfigurationException</code>. |
| 58 | * |
| 59 | * @param instance the instance to call the callbacks on |
| 60 | * @param callback the name of the callback method |
| 61 | */ |
| 62 | ConfigurationDependency setCallback(Object instance, String callback); |
| 63 | |
| 64 | /** |
| 65 | * Sets the <code>service.pid</code> of the configuration you are depending |
| 66 | * on. |
| 67 | */ |
| 68 | ConfigurationDependency setPid(String pid); |
| 69 | |
| 70 | /** |
| 71 | * Sets propagation of the configuration properties to the service |
| 72 | * properties. Any additional service properties specified directly are |
| 73 | * merged with these. |
| 74 | */ |
| 75 | ConfigurationDependency setPropagate(boolean propagate); |
| 76 | |
| 77 | /** |
| 78 | * The label used to display the tab name (or section) where the properties |
| 79 | * are displayed. Example: "Printer Service". |
| 80 | * |
| 81 | * @return The label used to display the tab name where the properties are |
| 82 | * displayed (may be localized) |
| 83 | */ |
| 84 | ConfigurationDependency setHeading(String heading); |
| 85 | |
| 86 | /** |
| 87 | * A human readable description of the PID this configuration is associated |
| 88 | * with. Example: "Configuration for the PrinterService bundle". |
| 89 | * |
| 90 | * @return A human readable description of the PID this configuration is |
| 91 | * associated with (may be localized) |
| 92 | */ |
| 93 | ConfigurationDependency setDescription(String description); |
| 94 | |
| 95 | /** |
| 96 | * Points to the basename of the Properties file that can localize the Meta |
| 97 | * Type informations. The default localization base name for the properties |
| 98 | * is OSGI-INF/l10n/bundle, but can be overridden by the manifest |
| 99 | * Bundle-Localization header (see core specification, in section |
| 100 | * Localization on page 68). You can specify a specific localization |
| 101 | * basename file using this method (e.g. |
| 102 | * <code>setLocalization("person")</code> will match person_du_NL.properties |
| 103 | * in the root bundle directory. |
| 104 | */ |
| 105 | ConfigurationDependency setLocalization(String path); |
| 106 | |
| 107 | /** |
| 108 | * Adds a MetaData regarding a given configuration property. |
| 109 | */ |
| 110 | ConfigurationDependency add(PropertyMetaData properties); |
| 111 | } |