問題が発生しています。私はosgi構成のためにorg.osgi.service.cm.ManagedService
implクライアントを持っています。構成は、キーと値のペアの集合です。 の更新されたメソッド(ManagedService.updated
)にjava.util.Dictionary
オブジェクトとして渡されたこれらのプロパティのキーは、大文字と小文字が区別されないようです。つまり、configのキーが "Hello"であってもprops.get("HellO")
が機能します。Osgi Config ManagedServiceディクショナリキーで大文字と小文字を区別しない
辞書をHashmap
に変換すると、そのエントリを反復処理することで、マップのキーが大文字と小文字を区別します。 Dictionary
のキーで大文字と小文字を区別しないと予想されますか?
これはAEM 6.2インスタンスでテストされました。
ここは私のManagedService
implクラスです。
public class ConfigService implements ManagedService {
public void updated(final Dictionary props) throws ConfigurationException {
// props.get("HellO") returns value
if (props != null) {
String pid = (String) props.get(Constants.SERVICE_PID);
// convert to map
Map map = map(props);
// map.get("HellO") returns null
// map.get("Hello") returns value
}
}
private static Map map(Dictionary dict) {
Map map = new ConcurrentHashMap();
for (Enumeration keys = dict.keys(); keys.hasMoreElements();) {
Object key = keys.nextElement();
map.put(key, dict.get(key));
}
return map;
}
ManagedService
は、以下のコードを使用してサービスとして登録されています。
final Dictionary props = new Hashtable();
props.put(Constants.SERVICE_PID, "pid.of.the.osgi.configuration");
ServiceRegistration configSvc = context.registerService(ManagedService.class.getName(),
new ConfigService(), props);
キーは大文字小文字を区別していることの理由は、X.500の仕様が重要になるだろうし、のような時間(2000年)で、それが見えることです。 X.509証明書、SNMP、およびLDAPは、私が残したいくつかの事を推測しています。大文字と小文字が区別され、私たちは悪い決断をしていました。下位互換性を失う標準の欠点の1つ。 –