{
for (final SimpleManagedResource resource : children.values())
{
if (resource.pathElement.matches(path.toString()))
{
PathAddressIterator pai = new PathAddressIterator(iterator.currentAddress());
StringBuilder sb = new StringBuilder(path);
while (pai.hasNext())
{
String next = pai.next();
sb.append("/").append(next);
if (resource.pathElement.matches(sb.toString()))
{
AbstractManagedResource found = resource.findMatch(pai, new StringBuilder(next));
if (found == null)
{
path.append("/").append(next);
iterator.next();
}
else
{
break;
}
}
else
{
break;
}
}
iterator.originalAddress().addPathTemplateResolver(
new PathTemplateResolverImpl(resource.pathElement, path.toString()));
if (iterator.hasNext())
{
pai = new PathAddressIterator(iterator.currentAddress().copy());
AbstractManagedResource subResource = resource.getSubResource(pai);
if (subResource != null)
{
PathAddress address = pai.originalAddress();
for (PathTemplateResolver resolver : address.getPathTemplateResolvers())
{
iterator.originalAddress().addPathTemplateResolver(resolver);
}
while(iterator.hasNext()) iterator.next();