ctkConfigurationPlugin.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 "ctkServiceReference.h"
  18. #include "ctkDictionary.h"
  19. /**
  20. * A service interface for processing configuration dictionary before the
  21. * update.
  22. *
  23. * <p>
  24. * A plugin registers a {@code ctkConfigurationPlugin} object in order to
  25. * process configuration updates before they reach the Managed Service or
  26. * Managed Service Factory. The Configuration Admin service will detect
  27. * registrations of Configuration Plugin services and must call these services
  28. * every time before it calls the {@code ctkManagedService} or
  29. * {@code ctkManagedServiceFactory}
  30. * {@code updated} method. The
  31. * Configuration Plugin service thus has the opportunity to view and modify the
  32. * properties before they are passed to the Managed Service or Managed Service
  33. * Factory.
  34. *
  35. * <p>
  36. * Configuration Plugin (plugin) services have full read/write access to all
  37. * configuration information. Therefore, plugins using this facility should be
  38. * trusted. Access to this facility should be limited with
  39. * {@code ctkServicePermission[ctkConfigurationPlugin,REGISTER]}.
  40. * Implementations of a Configuration Plugin service should assure that they
  41. * only act on appropriate configurations.
  42. *
  43. * <p>
  44. * The integer {@code service.cmRanking} registration
  45. * property may be specified. Not specifying this registration property, or
  46. * setting it to something other than an integer, is the same as
  47. * setting it to the integer zero. The
  48. * {@code service.cmRanking} property determines the order in which
  49. * plugins are invoked. Lower ranked plugins are called before higher ranked
  50. * ones. In the event of more than one plugin having the same value of
  51. * {@code service.cmRanking}, then the Configuration Admin service
  52. * arbitrarily chooses the order in which they are called.
  53. *
  54. * <p>
  55. * By convention, plugins with {@code service.cmRanking&lt; 0} or
  56. * {@code service.cmRanking &gt; 1000} should not make modifications to
  57. * the properties.
  58. *
  59. * <p>
  60. * The Configuration Admin service has the right to hide properties from
  61. * plugins, or to ignore some or all the changes that they make. This might be
  62. * done for security reasons. Any such behavior is entirely implementation
  63. * defined.
  64. *
  65. * <p>
  66. * A plugin may optionally specify a {@code cm.target} registration
  67. * property whose value is the PID of the Managed Service or Managed Service
  68. * Factory whose configuration updates the plugin is intended to intercept. The
  69. * plugin will then only be called with configuration updates that are targeted
  70. * at the Managed Service or Managed Service Factory with the specified PID.
  71. * Omitting the {@code cm.target} registration property means that the
  72. * plugin is called for all configuration updates.
  73. *
  74. */
  75. struct CTK_PLUGINFW_EXPORT ctkConfigurationPlugin
  76. {
  77. virtual ~ctkConfigurationPlugin() {};
  78. /**
  79. * A service property to limit the Managed Service or Managed Service
  80. * Factory configuration dictionaries a Configuration Plugin service
  81. * receives.
  82. *
  83. * This property contains a {@code QStringList} of PIDs. A Configuration
  84. * Admin service must call a Configuration Plugin service only when this
  85. * property is not set, or the target service's PID is listed in this
  86. * property.
  87. */
  88. static const QString CM_TARGET; // = "cm.target"
  89. /**
  90. * A service property to specify the order in which plugins are invoked.
  91. *
  92. * This property contains an integer ranking of the plugin.
  93. * Not specifying this registration property, or setting it to something
  94. * other than an integer, is the same as setting it to the
  95. * integer zero. This property determines the order in which
  96. * plugins are invoked. Lower ranked plugins are called before higher ranked
  97. * ones.
  98. */
  99. static const QString CM_RANKING; // = "service.cmRanking"
  100. /**
  101. * View and possibly modify a set of configuration properties before
  102. * they are sent to the Managed Service or the Managed Service Factory. The
  103. * Configuration Plugin services are called in increasing order of their
  104. * {@code service.cmRanking} property. If this property is undefined
  105. * or is a non-integer type, 0 is used.
  106. *
  107. * <p>
  108. * This method should not modify the properties unless the
  109. * {@code service.cmRanking} of this plugin is in the range
  110. * {@code 0 &lt;= service.cmRanking &lt;= 1000}.
  111. * <p>
  112. * If this method throws any exception, the Configuration
  113. * Admin service must catch it and should log it.
  114. *
  115. * @param reference reference to the Managed Service or Managed Service
  116. * Factory
  117. * @param properties The configuration properties. This argument must not
  118. * contain the "service.pluginLocation" property. The value of this
  119. * property may be obtained from the
  120. * {@code ctkConfiguration#getPluginLocation} method.
  121. */
  122. virtual void modifyConfiguration(const ctkServiceReference& reference,
  123. ctkDictionary& properties) = 0;
  124. };
  125. Q_DECLARE_INTERFACE(ctkConfigurationPlugin, "org.commontk.service.cm.ConfigurationPlugin")
  126. #endif // CTKCONFIGURATIONPLUGIN_H