@Test public void testChildNames() { SimpleManagedResource root = createRootResource(); SimpleManagedResource a = (SimpleManagedResource) root.registerSubResource("a", A_DESC); SimpleManagedResource a_1 = (SimpleManagedResource) a.registerSubResource("a-1", A_1_DESC); SimpleManagedResource a_1_1 = (SimpleManagedResource) a_1.registerSubResource("a-1-1", A_1_1_DESC); SimpleManagedResource a_2 = (SimpleManagedResource) a.registerSubResource("a-2", A_2_DESC); SimpleManagedResource b = (SimpleManagedResource) root.registerSubResource("b", B_DESC); SimpleManagedResource c = (SimpleManagedResource) root.registerSubResource("c", C_DESC); SimpleManagedResource c_1 = (SimpleManagedResource) c.registerSubResource("c-1", C_1_DESC); assertChildNames(root, asSet("a-1", "a-2"), "a"); assertChildNames(root, asSet("a-1-1"), "a", "a-1"); assertChildNames(root, asSet(), "a", "a-1", "a-1-1"); assertChildNames(root, asSet(), "a", "a-2"); assertChildNames(root, asSet(), "b"); assertChildNames(root, asSet("c-1"), "c"); assertChildNames(root, asSet(), "c", "c-1"); }
@Override public Registration registerSubResource(String name, ManagedDescription description) { if (name == null) throw new IllegalArgumentException("name is null"); if (description == null) throw new IllegalArgumentException("description is null"); if (name.charAt(0) == '/') name = name.substring(1, name.length()); PathElement element; try { element = PathElement.pathElement(name); } catch (PatternSyntaxException e) { throw new ManagementException("Could not parse path template " + name, e); } SimpleManagedResource resource = new SimpleManagedResource(element, this, description); if (children.putIfAbsent(element.getValue(), resource) != null) { throw new IllegalArgumentException("Resource " + name + " already exists for path " + getPath()); } return resource; }
SimpleManagedResource extends AbstractManagedResource { @Override public Registration registerSubResource(String name, ManagedDescription description) { if (name == null) throw new IllegalArgumentException("name is null"); if (description == null) throw new IllegalArgumentException("description is null"); if (name.charAt(0) == '/') name = name.substring(1, name.length()); PathElement element; try { element = PathElement.pathElement(name); } catch (PatternSyntaxException e) { throw new ManagementException("Could not parse path template " + name, e); } SimpleManagedResource resource = new SimpleManagedResource(element, this, description); if (children.putIfAbsent(element.getValue(), resource) != null) { throw new IllegalArgumentException("Resource " + name + " already exists for path " + getPath()); } return resource; } }
SimpleManagedResource extends AbstractManagedResource { @Override public Registration registerSubResource(String name, ManagedDescription description) { if (name == null) throw new IllegalArgumentException("name is null"); if (description == null) throw new IllegalArgumentException("description is null"); if (name.charAt(0) == '/') name = name.substring(1, name.length()); PathElement element; try { element = PathElement.pathElement(name); } catch (PatternSyntaxException e) { throw new ManagementException("Could not parse path template " + name, e); } SimpleManagedResource resource = new SimpleManagedResource(element, this, description); if (children.putIfAbsent(element.getValue(), resource) != null) { throw new IllegalArgumentException("Resource " + name + " already exists for path " + getPath()); } return resource; } SimpleManagedResource(PathElement pathElement, AbstractManagedResource parent, ManagedDescription description); }
SimpleManagedResource extends AbstractManagedResource { @Override public Registration registerSubResource(String name, ManagedDescription description) { if (name == null) throw new IllegalArgumentException("name is null"); if (description == null) throw new IllegalArgumentException("description is null"); if (name.charAt(0) == '/') name = name.substring(1, name.length()); PathElement element; try { element = PathElement.pathElement(name); } catch (PatternSyntaxException e) { throw new ManagementException("Could not parse path template " + name, e); } SimpleManagedResource resource = new SimpleManagedResource(element, this, description); if (children.putIfAbsent(element.getValue(), resource) != null) { throw new IllegalArgumentException("Resource " + name + " already exists for path " + getPath()); } return resource; } SimpleManagedResource(PathElement pathElement, AbstractManagedResource parent, ManagedDescription description); @Override Registration registerSubResource(String name, ManagedDescription description); @Override void registerOperationHandler(String operationName, OperationHandler operationHandler, ManagedDescription description); @Override void registerOperationHandler(String operationName, OperationHandler operationHandler, ManagedDescription description, boolean inherited); @Override ManagedResource getSubResource(String childName); }
SimpleManagedResource extends AbstractManagedResource { @Override public Registration registerSubResource(String name, ManagedDescription description) { if (name == null) throw new IllegalArgumentException("name is null"); if (description == null) throw new IllegalArgumentException("description is null"); if (name.charAt(0) == '/') name = name.substring(1, name.length()); PathElement element; try { element = PathElement.pathElement(name); } catch (PatternSyntaxException e) { throw new ManagementException("Could not parse path template " + name, e); } SimpleManagedResource resource = new SimpleManagedResource(element, this, description); if (children.putIfAbsent(element.getValue(), resource) != null) { throw new IllegalArgumentException("Resource " + name + " already exists for path " + getPath()); } return resource; } SimpleManagedResource(PathElement pathElement, AbstractManagedResource parent, ManagedDescription description); @Override Registration registerSubResource(String name, ManagedDescription description); @Override void registerOperationHandler(String operationName, OperationHandler operationHandler, ManagedDescription description); @Override void registerOperationHandler(String operationName, OperationHandler operationHandler, ManagedDescription description, boolean inherited); @Override ManagedResource getSubResource(String childName);  }