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