Hi there,

If you have just two levels of nesting for your branches, I suggest that you
register additional attachments covering all cases.

If you have potentially unlimited nesting, you need to handle this in your
resource. In order to have your URI template match several URI path
segments, you need to customize the matching mode for the URI variable:

Route myRoute =
myRouter.attach("/branches/{branch_id}/branches/{branch_id}/leaves/{leaf_id}
/", MyLeafResoure.class);
myRoute.getTemplate().getVariables().put("branch_id",
Variable.TYPE_URI_PATH);

However, I'm not sure how to achieve something equivalent with Spring
configuration. Let us know if you have trouble.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com





-----Message d'origine-----
De : webp...@tigris.org [mailto:webp...@tigris.org] 
Envoyé : mercredi 24 juin 2009 19:57
À : discuss@restlet.tigris.org
Objet : Nested resource routing

I want to be able to nest arbitrarily deep items in a hierarchical format,
and route them based on URI patterns in Spring.  For example, I can have
objects nested like:

    /branches/{branch_id}/
    /branches/{branch_id}/leaves/{leaf_id}/
    /branches/{branch_id}/buds/{bud_id}/

However, the branches can alos be nested, like this:

    /branches/{branch_id}/
    /branches/{branch_id}/branches/{branch_id}/leaves/{leaf_id}/
 
/branches/{branch_id}//branches/{branch_id}/branches/{branch_id}/buds/{bud_i
d}/
etc.

I have my Spring application context set up like this to handle the root
instances of "branches":

<bean name="root" class="org.restlet.ext.spring.SpringRouter">
    <constructor-arg ref="application" />
    
    <property name="attachments">
        <map>
            <entry key="/branches/{branch_id}"
                value="com.example.api.resource.BranchResource"/>
            <entry key="/branches/{branch_id}/leaves/{leaf_id}/"
                value="com.example.api.resource.LeafResource"/>
            <entry key="/branches/{branch_id}/buds/{bud_id}/"
                value="com.example.api.resource.budResource"/>
        </map>
    </property>
</bean>

<!--  Spring Application -->
<bean id="application" class="org.restlet.Application">
        <property name="name" value="exampleAPI"></property>
</bean>

I would like to be able to build my URI patterns so that I can handle the
cases where the branches are nested.  Is this even possible?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=23650
46

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2368089

Reply via email to