public Collection<ManagedGroup> getChildren() { return group.getChildren(); }
public String getDescription() { return group.getDescription(); }
public Object traverse(Object node) throws JMException { assertTrue(node instanceof ManagedGroup); ManagedGroup mg = (ManagedGroup) node; for (ManagedGroup m : mg.getChildren()) { if (m.getName().equals("foo1")) { assertEquals("foodesc", m.getDescription()); assertEquals(1, m.getChildren().size()); assertEquals("foo2", m.getChildren().iterator().next().getName()); assertEquals("foodesc2", m.getChildren().iterator().next().getDescription()); wasCalled = true; } } return Void.TYPE; }
private void visitManagedGroup(ManagedGroup mg, String prefix, int level) throws JMException { ObjectName on = new ObjectName(prefix); if (mg.getObjects().size() > 0) { mg.register(server, on); } for (ManagedGroup group : mg.getChildren()) { String p = prefix + "," + levels[level + 1] + "=" + group.getName(); visitManagedGroup(group, p, level + 1); } }
public String getName() { return group.getName(); }
public ManagedGroup add(Object o) { group.add(o); return this; }
public ObjectName getObjectName() { return group.getObjectName(); }
public Collection<?> getObjects() { return group.getObjects(); }
public Object traverse(Object node) throws JMException { assertTrue(node instanceof ManagedGroup); ManagedGroup mg = (ManagedGroup) node; for (ManagedGroup m : mg.getChildren()) { if (m.getName().equals("foo1")) { assertEquals("foodesc", m.getDescription()); assertEquals(1, m.getChildren().size()); assertEquals("foo2", m.getChildren().iterator().next().getName()); assertEquals("foodesc2", m.getChildren().iterator().next().getDescription()); wasCalled = true; } } return Void.TYPE; }
/** {@inheritDoc} */ public void visitManagedGroup(ManagedGroup mg) throws JMException { String prefix = domain + ":" + levels[0] + "=" + mg.getName(); visitManagedGroup(mg, prefix, 0); }
public ManagedGroup addChild(String name, String description) { return group.addChild(name, description); }
private void depthFirstVisit(ManagedGroup group, Map<ManagedGroup, Exception> map) { for (ManagedGroup child : group.getChildren()) { depthFirstVisit(child, map); } try { visitManagedGroup(group); } catch (Exception e) { map.put(group, e); } }
@Test(expected = IllegalStateException.class) public void lateRegistering() throws Exception { final AtomicReference<ManagedGroup> ar = new AtomicReference<ManagedGroup>(); withConf(ManagementConfiguration.class).setEnabled(true); conf.addService(new Manageable() { public void manage(ManagedGroup parent) { ar.set(parent); } }); newContainer(); prestart(); ar.get().addChild("foo", "description");// already started }