RBACDecorator implements RBACDecoratorMBean { static List<String> nameSegments(ObjectName objectName) { List<String> segments = new ArrayList<>(); segments.add(objectName.getDomain()); for (String s : objectName.getKeyPropertyListString().split(",")) { int index = s.indexOf('='); if (index < 0) { continue; } String key = objectName.getKeyProperty(s.substring(0, index)); if (s.substring(0, index).equals("type")) { segments.add(1, key); } else { segments.add(key); } } return segments; } RBACDecorator(BundleContext bundleContext); @Override @SuppressWarnings("unchecked") void decorate(Map<String, Object> result); @Override boolean getVerify(); @Override void setVerify(boolean verify); static Logger LOG; }
@Test public void objectNameSplitting() throws MalformedObjectNameException { assertThat(RBACDecorator.nameSegments(new ObjectName("a.b:type=a,name=b")).toArray(new String[3]), equalTo(new String[]{"a.b", "a", "b"})); assertThat(RBACDecorator.nameSegments(new ObjectName("a.b:name=b,type=a")).toArray(new String[3]), equalTo(new String[]{"a.b", "a", "b"})); }