ctkConfigurationPlugin.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKCONFIGURATIONPLUGIN_H
  16. #define CTKCONFIGURATIONPLUGIN_H
  17. #include <ctkPluginFrameworkExport.h>
  18. #include "ctkServiceReference.h"
  19. #include "ctkPluginFramework_global.h"
  20. /**
  21. * A service interface for processing configuration dictionary before the
  22. * update.
  23. *
  24. * <p>
  25. * A plugin registers a {@code ctkConfigurationPlugin} object in order to
  26. * process configuration updates before they reach the Managed Service or
  27. * Managed Service Factory. The Configuration Admin service will detect
  28. * registrations of Configuration Plugin services and must call these services
  29. * every time before it calls the {@code ctkManagedService} or
  30. * {@code ctkManagedServiceFactory}
  31. * {@code updated} method. The
  32. * Configuration Plugin service thus has the opportunity to view and modify the
  33. * properties before they are passed to the Managed Service or Managed Service
  34. * Factory.
  35. *
  36. * <p>
  37. * Configuration Plugin (plugin) services have full read/write access to all
  38. * configuration information. Therefore, plugins using this facility should be
  39. * trusted. Access to this facility should be limited with
  40. * {@code ctkServicePermission[ctkConfigurationPlugin,REGISTER]}.
  41. * Implementations of a Configuration Plugin service should assure that they
  42. * only act on appropriate configurations.
  43. *
  44. * <p>
  45. * The integer {@code service.cmRanking} registration
  46. * property may be specified. Not specifying this registration property, or
  47. * setting it to something other than an integer, is the same as
  48. * setting it to the integer zero. The
  49. * {@code service.cmRanking} property determines the order in which
  50. * plugins are invoked. Lower ranked plugins are called before higher ranked
  51. * ones. In the event of more than one plugin having the same value of
  52. * {@code service.cmRanking}, then the Configuration Admin service
  53. * arbitrarily chooses the order in which they are called.
  54. *
  55. * <p>
  56. * By convention, plugins with {@code service.cmRanking&lt; 0} or
  57. * {@code service.cmRanking &gt; 1000} should not make modifications to
  58. * the properties.
  59. *
  60. * <p>
  61. * The Configuration Admin service has the right to hide properties from
  62. * plugins, or to ignore some or all the changes that they make. This might be
  63. * done for security reasons. Any such behavior is entirely implementation
  64. * defined.
  65. *
  66. * <p>
  67. * A plugin may optionally specify a {@code cm.target} registration
  68. * property whose value is the PID of the Managed Service or Managed Service
  69. * Factory whose configuration updates the plugin is intended to intercept. The
  70. * plugin will then only be called with configuration updates that are targeted
  71. * at the Managed Service or Managed Service Factory with the specified PID.
  72. * Omitting the {@code cm.target} registration property means that the
  73. * plugin is called for all configuration updates.
  74. *
  75. */
  76. struct CTK_PLUGINFW_EXPORT ctkConfigurationPlugin
  77. {
  78. virtual ~ctkConfigurationPlugin() {};
  79. /**
  80. * A service property to limit the Managed Service or Managed Service
  81. * Factory configuration dictionaries a Configuration Plugin service
  82. * receives.
  83. *
  84. * This property contains a {@code QStringList} of PIDs. A Configuration
  85. * Admin service must call a Configuration Plugin service only when this
  86. * property is not set, or the target service's PID is listed in this
  87. * property.
  88. */
  89. static const QString CM_TARGET; // = "cm.target"
  90. /**
  91. * A service property to specify the order in which plugins are invoked.
  92. *
  93. * This property contains an integer ranking of the plugin.
  94. * Not specifying this registration property, or setting it to something
  95. * other than an integer, is the same as setting it to the
  96. * integer zero. This property determines the order in which
  97. * plugins are invoked. Lower ranked plugins are called before higher ranked
  98. * ones.
  99. */
  100. static const QString CM_RANKING; // = "service.cmRanking"
  101. /**
  102. * View and possibly modify a set of configuration properties before
  103. * they are sent to the Managed Service or the Managed Service Factory. The
  104. * Configuration Plugin services are called in increasing order of their
  105. * {@code service.cmRanking} property. If this property is undefined
  106. * or is a non-integer type, 0 is used.
  107. *
  108. * <p>
  109. * This method should not modify the properties unless the
  110. * {@code service.cmRanking} of this plugin is in the range
  111. * {@code 0 &lt;= service.cmRanking &lt;= 1000}.
  112. * <p>
  113. * If this method throws any exception, the Configuration
  114. * Admin service must catch it and should log it.
  115. *
  116. * @param reference reference to the Managed Service or Managed Service
  117. * Factory
  118. * @param properties The configuration properties. This argument must not
  119. * contain the "service.pluginLocation" property. The value of this
  120. * property may be obtained from the
  121. * {@code ctkConfiguration#getPluginLocation} method.
  122. */
  123. virtual void modifyConfiguration(const ctkServiceReference& reference,
  124. ctkDictionary& properties) = 0;
  125. };
  126. Q_DECLARE_INTERFACE(ctkConfigurationPlugin, "org.commontk.service.cm.ConfigurationPlugin")
  127. #endif // CTKCONFIGURATIONPLUGIN_H