blob: c9a3a43325fec28ba4b70bb13d043d5dc4303843 [file] [log] [blame]
Pierre De Rop3a00a212015-03-01 09:27:46 +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 */
19package 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,
Pierre De Ropc8295c22015-06-04 10:15:35 +000026 * only managed services are supported, not factories. If you need support for factories, then
27 * you can use
28 * {@link DependencyManager#createFactoryConfigurationAdapterService(String, String, boolean)}.
29 * There are a couple of things you need to be aware of when implementing the
30 * <code>updated(Dictionary)</code> method:
Pierre De Rop3a00a212015-03-01 09:27:46 +000031 * <ul>
Pierre De Ropc8295c22015-06-04 10:15:35 +000032 * <li>Make sure it throws a <code>ConfigurationException</code> or any other exception when you
33 * get a configuration that is invalid. In this case, the dependency will not change:
34 * if it was not available, it will still not be. If it was available, it will remain available
35 * and implicitly assume you keep working with your old configuration.</li>
Pierre De Rop3a00a212015-03-01 09:27:46 +000036 * <li>This method will be called before all required dependencies are available. Make sure you
37 * do not depend on these to parse your settings.</li>
Pierre De Ropc8295c22015-06-04 10:15:35 +000038 * <li>unlike all other DM dependency callbacks, the update method is called from the CM configuration
39 * update thread, and is not serialized with the internal queue maintained by the DM component.
40 * So, take care to concurrent calls between updated callback and your other lifecycle callbacks.
41 * <li>When the configuration is lost, updated callback is invoked with a null dictionary parameter,
42 * and then the component stop lifecycle callback is invoked.
43 * <li>When the DM component is stopped, then updated(null) is not invoked.
Pierre De Rop3a00a212015-03-01 09:27:46 +000044 * </ul>
45 *
Pierre De Ropc40d93f2015-05-04 20:25:57 +000046 * The callback invoked when a configuration dependency is updated can supports the following signatures:<p>
47 * <ul><li> updated(Dictionary)
48 * <li> updated(Component, Dictionary)
49 * </ul>
50 *
Pierre De Rop3a00a212015-03-01 09:27:46 +000051 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
52 */
53public interface ConfigurationDependency extends Dependency, ComponentDependencyDeclaration {
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>.
Pierre De Ropc8295c22015-06-04 10:15:35 +000058 * By default, if this method is not called, the callback name is "updated".
Pierre De Rop3a00a212015-03-01 09:27:46 +000059 *
60 * @param callback the name of the callback method
61 */
62 ConfigurationDependency setCallback(String callback);
63
64 /**
65 * Sets the name of the callback method that should be invoked when a configuration
66 * is available. The contract for this method is identical to that of
67 * <code>ManagedService.updated(Dictionary) throws ConfigurationException</code>.
68 *
69 * @param instance the instance to call the callbacks on
70 * @param callback the name of the callback method
71 */
72 ConfigurationDependency setCallback(Object instance, String callback);
73
74 /**
75 * Sets the <code>service.pid</code> of the configuration you are depending
76 * on.
77 */
78 ConfigurationDependency setPid(String pid);
79
80 /**
81 * Sets propagation of the configuration properties to the service
82 * properties. Any additional service properties specified directly are
83 * merged with these.
84 */
85 ConfigurationDependency setPropagate(boolean propagate);
86
87 /**
88 * The label used to display the tab name (or section) where the properties
89 * are displayed. Example: "Printer Service".
90 *
91 * @return The label used to display the tab name where the properties are
92 * displayed (may be localized)
93 */
94 ConfigurationDependency setHeading(String heading);
95
96 /**
97 * A human readable description of the PID this configuration is associated
98 * with. Example: "Configuration for the PrinterService bundle".
99 *
100 * @return A human readable description of the PID this configuration is
101 * associated with (may be localized)
102 */
103 ConfigurationDependency setDescription(String description);
104
105 /**
106 * Points to the basename of the Properties file that can localize the Meta
107 * Type informations. The default localization base name for the properties
108 * is OSGI-INF/l10n/bundle, but can be overridden by the manifest
109 * Bundle-Localization header (see core specification, in section
110 * Localization on page 68). You can specify a specific localization
111 * basename file using this method (e.g.
112 * <code>setLocalization("person")</code> will match person_du_NL.properties
113 * in the root bundle directory.
114 */
115 ConfigurationDependency setLocalization(String path);
116
117 /**
118 * Adds a MetaData regarding a given configuration property.
119 */
120 ConfigurationDependency add(PropertyMetaData properties);
121}